List of usage examples for java.util Set contains
boolean contains(Object o);
From source file:org.switchyard.quickstarts.demo.policy.security.wss.signencrypt.WorkServiceMain.java
public static void main(String... args) throws Exception { Set<String> policies = new HashSet<String>(); for (String arg : args) { arg = Strings.trimToNull(arg);/*w ww . jav a2 s . c o m*/ if (arg != null) { if (arg.equals(CONFIDENTIALITY) || arg.equals(SIGNENCRYPT) || arg.equals(HELP)) { policies.add(arg); } else { LOGGER.error(MAVEN_USAGE); throw new Exception(MAVEN_USAGE); } } } if (policies.contains(HELP)) { LOGGER.info(MAVEN_USAGE); } else { final String scheme; final int port; if (policies.contains(CONFIDENTIALITY)) { scheme = "https"; port = getPort(8443); SSLContext sslcontext = SSLContext.getInstance("TLS"); sslcontext.init(null, null, null); SSLSocketFactory sf = new SSLSocketFactory(sslcontext, SSLSocketFactory.STRICT_HOSTNAME_VERIFIER); Scheme https = new Scheme(scheme, port, sf); SchemeRegistry sr = new SchemeRegistry(); sr.register(https); } else { scheme = "http"; port = getPort(8080); } boolean signencrypt = policies.contains(SIGNENCRYPT); invokeWorkService(scheme, port, getContext(), signencrypt); } }
From source file:org.switchyard.quickstarts.demo.policy.security.basic.propagate.WorkServiceMain.java
public static void main(String... args) throws Exception { Set<String> policies = new HashSet<String>(); for (String arg : args) { arg = Strings.trimToNull(arg);/*from w w w . j av a 2 s . c o m*/ if (arg != null) { if (arg.equals(CONFIDENTIALITY) || arg.equals(CLIENT_AUTHENTICATION) || arg.equals(HELP)) { policies.add(arg); } else { LOGGER.error(MAVEN_USAGE); throw new Exception(MAVEN_USAGE); } } } if (policies.contains(HELP)) { LOGGER.info(MAVEN_USAGE); } else { final String scheme; final int port; if (policies.contains(CONFIDENTIALITY)) { scheme = "https"; port = 8443; SSLContext sslcontext = SSLContext.getInstance("TLS"); sslcontext.init(null, null, null); SSLSocketFactory sf = new SSLSocketFactory(sslcontext, SSLSocketFactory.STRICT_HOSTNAME_VERIFIER); Scheme https = new Scheme(scheme, port, sf); SchemeRegistry sr = new SchemeRegistry(); sr.register(https); } else { scheme = "http"; port = 8080; } String[] userPass = policies.contains(CLIENT_AUTHENTICATION) ? new String[] { "kermit", "the-frog-1" } : null; invokeWorkService(scheme, port, userPass); } }
From source file:org.switchyard.quickstarts.demo.security.propagation.jms.WorkServiceMain.java
public static void main(String... args) throws Exception { Set<String> policies = new HashSet<String>(); for (String arg : args) { arg = Strings.trimToNull(arg);/*from ww w .ja va2 s. c o m*/ if (arg != null) { if (arg.equals(CONFIDENTIALITY) || arg.equals(CLIENT_AUTHENTICATION) || arg.equals(HELP)) { policies.add(arg); } else { LOGGER.error(MAVEN_USAGE); throw new Exception(MAVEN_USAGE); } } } if (policies.contains(HELP)) { LOGGER.info(MAVEN_USAGE); } else { final String scheme; final int port; if (policies.contains(CONFIDENTIALITY)) { scheme = "https"; port = getPort(8443); SSLContext sslcontext = SSLContext.getInstance("TLS"); sslcontext.init(null, null, null); SSLSocketFactory sf = new SSLSocketFactory(sslcontext, SSLSocketFactory.STRICT_HOSTNAME_VERIFIER); Scheme https = new Scheme(scheme, port, sf); SchemeRegistry sr = new SchemeRegistry(); sr.register(https); } else { scheme = "http"; port = getPort(8080); } String[] userPass = policies.contains(CLIENT_AUTHENTICATION) ? new String[] { "kermit", "the-frog-1" } : null; invokeWorkService(scheme, port, getContext(), userPass); } }
From source file:org.acme.insurance.policyquote.test.WorkServiceMain.java
public static void main(String... args) throws Exception { serverHostname = System.getProperty("serverHostname", serverHostname); Set<String> policies = new HashSet<String>(); for (String arg : args) { arg = Strings.trimToNull(arg);/*from w w w. j a v a 2s .com*/ if (arg != null) { if (arg.equals(CONFIDENTIALITY) || arg.equals(CLIENT_AUTHENTICATION) || arg.equals(HELP)) { policies.add(arg); } else { LOGGER.error(MAVEN_USAGE); throw new Exception(MAVEN_USAGE); } } } if (policies.contains(HELP)) { LOGGER.info(MAVEN_USAGE); } else { final String scheme; final int port; if (policies.contains(CONFIDENTIALITY)) { LOGGER.info("Invoking service via SSL..."); scheme = "https"; port = 443; SSLContext sslcontext = SSLContext.getInstance("TLS"); sslcontext.init(null, null, null); SSLSocketFactory sf = new SSLSocketFactory(sslcontext, SSLSocketFactory.STRICT_HOSTNAME_VERIFIER); Scheme https = new Scheme(scheme, port, sf); SchemeRegistry sr = new SchemeRegistry(); sr.register(https); } else { scheme = "http"; port = 8080; } Element assertion = policies.contains(CLIENT_AUTHENTICATION) ? getAssertion() : null; invokeWorkService(scheme, port, assertion); } }
From source file:de.jetwick.snacktory.HtmlFetcher.java
public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new FileReader("urls.txt")); String line = null;// w w w. j av a2 s. c om Set<String> existing = new LinkedHashSet<String>(); while ((line = reader.readLine()) != null) { int index1 = line.indexOf("\""); int index2 = line.indexOf("\"", index1 + 1); String url = line.substring(index1 + 1, index2); String domainStr = SHelper.extractDomain(url, true); String counterStr = ""; // TODO more similarities if (existing.contains(domainStr)) counterStr = "2"; else existing.add(domainStr); String html = new HtmlFetcher().fetchAsString(url, 20000); String outFile = domainStr + counterStr + ".html"; BufferedWriter writer = new BufferedWriter(new FileWriter(outFile)); writer.write(html); writer.close(); } reader.close(); }
From source file:com.me.jvmi.Main.java
public static void main(String[] args) throws IOException { final Path localProductImagesPath = Paths.get("/Volumes/jvmpubfs/WEB/images/products/"); final Path uploadCSVFile = Paths.get("/Users/jbabic/Documents/products/upload.csv"); final Config config = new Config(Paths.get("../config.properties")); LuminateOnlineClient luminateClient2 = new LuminateOnlineClient("https://secure2.convio.net/jvmi/admin/", 3);/* w ww. j ava2s. c o m*/ luminateClient2.login(config.luminateUser(), config.luminatePassword()); Set<String> completed = new HashSet<>( IOUtils.readLines(Files.newBufferedReader(Paths.get("completed.txt")))); try (InputStream is = Files.newInputStream(Paths.get("donforms.csv")); PrintWriter pw = new PrintWriter(new FileOutputStream(new File("completed.txt"), true))) { for (String line : IOUtils.readLines(is)) { if (completed.contains(line)) { System.out.println("completed: " + line); continue; } try { luminateClient2.editDonationForm(line, "-1"); pw.println(line); System.out.println("done: " + line); pw.flush(); } catch (Exception e) { System.out.println("skipping: " + line); e.printStackTrace(); } } } // luminateClient2.editDonationForm("8840", "-1"); // Collection<String> ids = luminateClient2.donFormSearch("", true); // // CSVFormat csvFileFormat = CSVFormat.DEFAULT.withRecordSeparator("\n"); // try (FileWriter fileWriter = new FileWriter(new File("donforms.csv")); // CSVPrinter csvFilePrinter = new CSVPrinter(fileWriter, csvFileFormat);) { // // for (String id : ids) { // csvFilePrinter.printRecord(id); // } // } // if (true) { return; } Collection<InputRecord> records = parseInput(uploadCSVFile); LuminateFTPClient ftp = new LuminateFTPClient("customerftp.convio.net"); ftp.login(config.ftpUser(), config.ftpPassword()); ProductImages images = new ProductImages(localProductImagesPath, ftp); validateImages(records, images); Map<String, DPCSClient> dpcsClients = new HashMap<>(); dpcsClients.put("us", new DPCSClient("https://donor.dpconsulting.com/NewDDI/Logon.asp?client=jvm")); dpcsClients.put("ca", new DPCSClient("https://donor.dpconsulting.com/NewDDI/Logon.asp?client=jvcn")); dpcsClients.put("uk", new DPCSClient("https://donor.dpconsulting.com/NewDDI/Logon.asp?client=jvuk")); for (DPCSClient client : dpcsClients.values()) { client.login(config.dpcsUser(), config.dpcsPassword()); } Map<String, LuminateOnlineClient> luminateClients = new HashMap<>(); luminateClients.put("us", new LuminateOnlineClient("https://secure2.convio.net/jvmi/admin/", 10)); luminateClients.put("ca", new LuminateOnlineClient("https://secure3.convio.net/jvmica/admin/", 10)); luminateClients.put("uk", new LuminateOnlineClient("https://secure3.convio.net/jvmiuk/admin/", 10)); Map<String, EcommerceProductFactory> ecommFactories = new HashMap<>(); ecommFactories.put("us", new EcommerceProductFactory(dpcsClients.get("us"), images, Categories.us)); ecommFactories.put("ca", new EcommerceProductFactory(dpcsClients.get("ca"), images, Categories.ca)); ecommFactories.put("uk", new EcommerceProductFactory(dpcsClients.get("uk"), images, Categories.uk)); List<String> countries = Arrays.asList("us", "ca", "uk"); boolean error = false; for (InputRecord record : records) { for (String country : countries) { if (record.ignore(country)) { System.out.println("IGNORE: " + country + " " + record); continue; } try { EcommerceProductFactory ecommFactory = ecommFactories.get(country); LuminateOnlineClient luminateClient = luminateClients.get(country); luminateClient.login(config.luminateUser(), config.luminatePassword()); ECommerceProduct product = ecommFactory.createECommerceProduct(record); luminateClient.createOrUpdateProduct(product); } catch (Exception e) { System.out.println("ERROR: " + country + " " + record); //System.out.println(e.getMessage()); error = true; e.printStackTrace(); } } } if (!error) { for (String country : countries) { LuminateOnlineClient luminateClient = luminateClients.get(country); DPCSClient dpcsClient = dpcsClients.get(country); luminateClient.close(); dpcsClient.close(); } } }
From source file:de.uni_rostock.goodod.checker.CheckerApp.java
public static void main(String[] args) throws OWLOntologyCreationException { config = Configuration.getConfiguration(args); String bioTopVariantA = "biotoplite_group_A_TEST.owl"; String bioTopVariantB = "biotoplite_group_B_TEST.owl"; String repoRoot = config.getString("repositoryRoot"); File commonBioTopF = new File(repoRoot + File.separator + config.getString("bioTopLiteSource")); String groupAFile = repoRoot + File.separator + "Results" + File.separator + "GruppeA" + File.separator + bioTopVariantA;//from w w w. jav a 2 s .c o m String groupBFile = repoRoot + File.separator + "Results" + File.separator + "GruppeB" + File.separator + bioTopVariantB; String testFile = config.getString("testDescription"); IRI bioTopIRI = IRI.create("http://purl.org/biotop/biotoplite.owl"); SimpleIRIMapper bioTopLiteMapper = new SimpleIRIMapper(bioTopIRI, IRI.create(commonBioTopF)); SimpleIRIMapper variantMapperA = new SimpleIRIMapper( IRI.create("http://purl.org/biotop/biotoplite_group_A_TEST.owl"), IRI.create(new File(groupAFile))); SimpleIRIMapper variantMapperB = new SimpleIRIMapper( IRI.create("http://purl.org/biotop/biotoplite_group_B_TEST.owl"), IRI.create(new File(groupBFile))); //logger.info("Loading ontology " + testFile + "."); OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); manager.addIRIMapper(variantMapperA); manager.addIRIMapper(variantMapperB); manager.addIRIMapper(bioTopLiteMapper); FileDocumentSource source = new FileDocumentSource(new File(testFile)); OWLOntology ontology = null; try { ontology = manager.loadOntologyFromOntologyDocument(source); } catch (Throwable e) { logger.fatal("Loading failed", e); System.exit(1); } org.semanticweb.HermiT.Configuration reasonerConfig = new org.semanticweb.HermiT.Configuration(); reasonerConfig.throwInconsistentOntologyException = false; //ReasonerProgressMonitor monitor = new ConsoleProgressMonitor(); reasonerConfig.existentialStrategyType = ExistentialStrategyType.INDIVIDUAL_REUSE; //reasonerConfig.reasonerProgressMonitor = monitor; reasonerConfig.tableauMonitorType = TableauMonitorType.NONE; //reasonerConfig.individualTaskTimeout = 10000; Reasoner reasoner = new Reasoner(reasonerConfig, ontology); reasoner.classifyClasses(); Set<OWLClass> before = reasoner.getUnsatisfiableClasses() .getEntitiesMinus(manager.getOWLDataFactory().getOWLNothing()); //logger.info("Found " + before.size() + " inconsistent classes before import change."); logger.debug(before); reasoner.dispose(); reasoner = null; manager.removeOntology(ontology); ontology = null; Map<IRI, IRI> importMap = new HashMap<IRI, IRI>(); OWLOntologyLoaderConfiguration interimConfig = new OWLOntologyLoaderConfiguration(); for (String str : config.getStringArray("ignoredImports")) { IRI ignoredIRI = IRI.create(str); importMap.put(ignoredIRI, bioTopIRI); interimConfig = interimConfig.addIgnoredImport(ignoredIRI); } interimConfig = interimConfig.setMissingImportHandlingStrategy(MissingImportHandlingStrategy.SILENT); try { ontology = manager.loadOntologyFromOntologyDocument(source, interimConfig); } catch (Throwable e) { logger.fatal("Loading failed", e); System.exit(1); } BasicImportingNormalizerFactory n = new BasicImportingNormalizerFactory(importMap, interimConfig); n.normalize(ontology); reasoner = new Reasoner(reasonerConfig, ontology); reasoner.classifyClasses(); Set<OWLClass> after = reasoner.getUnsatisfiableClasses() .getEntitiesMinus(manager.getOWLDataFactory().getOWLNothing()); //logger.info("Found " + after.size() + " inconsistent classes after import change."); logger.debug(after); /* * We need some tidying afterwards. The after set can contain * inconsistent classes that are inconsistent only because in the new * import, they are subclasses of a class that was already inconsistent before. * Hence we remove them from the after set. */ for (OWLClass c : before) { Set<OWLClass> subclasses = SubClassCollector.collect(c, manager.getImportsClosure(ontology)); for (OWLClass subC : subclasses) { if ((true == after.contains(subC)) && (false == before.contains(subC))) { after.remove(subC); } } } int difference = before.size() - after.size(); if (0 == difference) { logger.info(testFile + ": OK"); } else { logger.warn(testFile + ": Import change is not neutral to inconsistencies (" + before.size() + '/' + after.size() + ")"); } }
From source file:com.utdallas.s3lab.smvhunter.monkey.MonkeyMe.java
/** * @param args//w ww . j av a 2s . c o m */ public static void main(String[] args) throws Exception { logger.info("start time ==== " + System.currentTimeMillis()); try { //load the adb location from the props file Properties props = new Properties(); props.load(new FileInputStream(new File("adb.props"))); //set the adb location WindowUpdate.adbLocation = props.getProperty("adb_location"); adbLocation = props.getProperty("adb_location"); //set root dir ROOT_DIRECTORY = props.getProperty("root_dir"); //completed txt completedFile = new File(ROOT_DIRECTORY + "tested.txt"); //db location for static analysis dbLocation = props.getProperty("db_location"); //location for smart input generation output smartInputLocation = props.getProperty("smart_input_location"); //udp dump location udpDumpLocation = props.getProperty("udp_dump_location"); //logcat dump location logCatLocation = props.getProperty("log_cat_location"); //strace output location straceOutputLocation = props.getProperty("strace_output_location"); //strace dump location straceDumpLocation = props.getProperty("strace_output_location"); //set x and y coords UIEnumerator.screenX = props.getProperty("x"); UIEnumerator.screenY = props.getProperty("y"); DeviceOfflineMonitor.START_EMULATOR = props.getProperty("restart"); //read output of static analysis readFromStaticAnalysisText(); logger.info("Read static analysis output"); readFromSmartInputText(); logger.info("Read smart input generation output"); //populate the queue with apps which are only present in the static analysis @SuppressWarnings("unchecked") final Set<? extends String> sslApps = new HashSet<String>( CollectionUtils.collect(FileUtils.readLines(new File(dbLocation)), new Transformer() { @Override public Object transform(Object input) { //get app file name String temp = StringUtils.substringBefore(input.toString(), " "); return StringUtils.substringAfterLast(temp, "/"); } })); Collection<File> fileList = FileUtils.listFiles(new File(ROOT_DIRECTORY), new String[] { "apk" }, false); CollectionUtils.filter(fileList, new Predicate() { @Override public boolean evaluate(Object object) { return sslApps.contains(StringUtils.substringAfterLast(object.toString(), "/")); } }); apkQueue = new LinkedBlockingDeque<File>(fileList); logger.info("finished listing files from the root directory"); try { //populate the tested apk list completedApps.addAll(FileUtils.readLines(completedFile)); } catch (Exception e) { //pass except logger.info("No tested.txt file found"); //create new file if (completedFile.createNewFile()) { logger.info("tested.txt created in root directory"); } else { logger.info("tested.txt file could not be created"); } } //get the executors for managing the emulators executors = Executors.newCachedThreadPool(); //set the devicemonitor exec DeviceOfflineMonitor.exec = executors; final List<Future<?>> futureList = new ArrayList<Future<?>>(); //start the offline device monitor (emulator management thread) logger.info("Starting Device Offline Monitor Thread"); executors.submit(new DeviceOfflineMonitor()); //get ADB backend object for device change listener AdbBackend adb = new AdbBackend(); //register for device change and wait for events //once event is received, start the MonkeyMe thread MonkeyDeviceChangeListener deviceChangeListener = new MonkeyDeviceChangeListener(executors, futureList); AndroidDebugBridge.addDeviceChangeListener(deviceChangeListener); logger.info("Listening to changes in devices (emulators)"); //wait for the latch to come down //this means that all the apks have been processed cdl.await(); logger.info("Finished testing all apps waiting for threads to join"); //now wait for every thread to finish for (Future<?> future : futureList) { future.get(); } logger.info("All threads terminated"); //stop listening for device update AndroidDebugBridge.removeDeviceChangeListener(deviceChangeListener); //stop the debug bridge AndroidDebugBridge.terminate(); //stop offline device monitor DeviceOfflineMonitor.stop = true; logger.info("adb and listeners terminated"); } finally { logger.info("Executing this finally"); executors.shutdownNow(); } logger.info("THE END!!"); }
From source file:com.termmed.sampling.ConceptsWithMoreThanThreeRoleGroups.java
/** * The main method.//from w w w . j av a2 s.c om * * @param args the arguments * @throws Exception the exception */ public static void main(String[] args) throws Exception { System.out.println("Starting..."); Map<String, Set<String>> groupsMap = new HashMap<String, Set<String>>(); File relsFile = new File( "/Users/alo/Downloads/SnomedCT_RF2Release_INT_20160131-1/Snapshot/Terminology/sct2_Relationship_Snapshot_INT_20160131.txt"); BufferedReader br2 = new BufferedReader(new FileReader(relsFile)); String line2; int count2 = 0; while ((line2 = br2.readLine()) != null) { // process the line. count2++; if (count2 % 10000 == 0) { //System.out.println(count2); } List<String> columns = Arrays.asList(line2.split("\t", -1)); if (columns.size() >= 6) { if (columns.get(2).equals("1") && !columns.get(6).equals("0")) { if (!groupsMap.containsKey(columns.get(4))) { groupsMap.put(columns.get(4), new HashSet<String>()); } groupsMap.get(columns.get(4)).add(columns.get(6)); } } } System.out.println("Relationship groups loaded"); Gson gson = new Gson(); System.out.println("Reading JSON 1"); File crossoverFile1 = new File("/Users/alo/Downloads/crossover_role_to_group.json"); String contents = FileUtils.readFileToString(crossoverFile1, "utf-8"); Type collectionType = new TypeToken<Collection<ControlResultLine>>() { }.getType(); List<ControlResultLine> lineObject = gson.fromJson(contents, collectionType); Set<String> crossovers1 = new HashSet<String>(); for (ControlResultLine loopResult : lineObject) { crossovers1.add(loopResult.conceptId); } System.out.println("Crossovers 1 loaded, " + lineObject.size() + " Objects"); System.out.println("Reading JSON 2"); File crossoverFile2 = new File("/Users/alo/Downloads/crossover_group_to_group.json"); String contents2 = FileUtils.readFileToString(crossoverFile2, "utf-8"); List<ControlResultLine> lineObject2 = gson.fromJson(contents2, collectionType); Set<String> crossovers2 = new HashSet<String>(); for (ControlResultLine loopResult : lineObject2) { crossovers2.add(loopResult.conceptId); } System.out.println("Crossovers 2 loaded, " + lineObject2.size() + " Objects"); Set<String> foundConcepts = new HashSet<String>(); int count3 = 0; BufferedWriter writer = new BufferedWriter( new FileWriter(new File("ConceptsWithMoreThanThreeRoleGroups.csv"))); ; for (String loopConcept : groupsMap.keySet()) { if (groupsMap.get(loopConcept).size() > 3) { writer.write(loopConcept); writer.newLine(); foundConcepts.add(loopConcept); count3++; } } writer.close(); System.out.println("Found " + foundConcepts.size() + " concepts"); int countCrossover1 = 0; for (String loopConcept : foundConcepts) { if (crossovers1.contains(loopConcept)) { countCrossover1++; } } System.out.println(countCrossover1 + " are present in crossover_role_to_group"); int countCrossover2 = 0; for (String loopConcept : foundConcepts) { if (crossovers2.contains(loopConcept)) { countCrossover2++; } } System.out.println(countCrossover2 + " are present in crossover_group_to_group"); System.out.println("Done"); }
From source file:edu.wpi.margrave.MCommunicator.java
public static void main(String[] args) { ArrayList<String> foo = new ArrayList<String>(); Set<String> argsSet = new HashSet<String>(); for (int ii = 0; ii < args.length; ii++) { argsSet.add(args[ii].toLowerCase()); }// w ww . ja va2 s. c om if (argsSet.contains("-log")) { // parser is in racket now. instead, require -log switch for logging //MEnvironment.debugParser = true; bDoLogging = true; } if (argsSet.contains("-min")) { bMinimalModels = true; } // Re-direct all System.err input to our custom buffer // Uses Apache Commons IO for WriterOutputStream. System.setErr(new PrintStream(new WriterOutputStream(MEnvironment.errorWriter), true)); // Re-direct all System.out input to our custom buffer. // (We have already saved System.out.) // This is useful in case we start getting GC messages from SAT4j. System.setOut(new PrintStream(new WriterOutputStream(MEnvironment.outWriter), true)); initializeLog(); writeToLog("\n\n"); // Inform the caller that we are ready to receive commands sendReadyReply(); while (true) { // Block until a command is received, handle it, and then return the result. handleXMLCommand(in); } // outLog will be closed as it goes out of scope }