List of usage examples for java.util Set toString
public String toString()
From source file:ddf.catalog.resource.impl.URLResourceReader.java
/** * Sets the directories that the {@link URLResourceReader} has permission to access when attempting to * download a resource linked by a file URL. * * @param rootResourceDirectoryPaths//w ww .j a v a 2 s . co m * a set of absolute paths specifying which directories the {@link URLResourceReader} has * permission to access when attempting to download resources linked by a file URL. A * null or empty input clears all root resource directory paths from the * {@link URLResourceReader} (this effectively blocks all resource downloads linked by file * URLs). */ public void setRootResourceDirectories(Set<String> rootResourceDirectoryPaths) { this.rootResourceDirectories.clear(); if (rootResourceDirectoryPaths != null) { LOGGER.debug("Attempting to set Root Resource Directories to {} for {}", rootResourceDirectoryPaths.toString(), URLResourceReader.class.getSimpleName()); for (String rootResourceDirectoryPath : rootResourceDirectoryPaths) { String path = null; try { path = Paths.get(rootResourceDirectoryPath).toAbsolutePath().normalize().toString(); this.rootResourceDirectories.add(path); LOGGER.debug("Added [{}] to the list of Root Resource Directories for {}", path, URLResourceReader.class.getSimpleName()); } catch (InvalidPathException e) { LOGGER.error("{} is an invalid path.", rootResourceDirectoryPath, e); } } } LOGGER.debug("Root Resource Directories for {} are {}", URLResourceReader.class.getSimpleName(), this.rootResourceDirectories.toString()); }
From source file:org.apache.ctakes.ytex.kernel.IntrinsicInfoContentEvaluatorImpl.java
/** * add/update icInfoMap entry for concept with the concept's subsumer count * //from ww w . java2 s .c o m * @param concept * @param icInfoMap * @param subsumerMap * @param w * @throws IOException */ private void computeSubsumerCount(ConcRel concept, Map<String, IntrinsicICInfo> icInfoMap, Map<String, Set<String>> subsumerMap, short[] depthArray, BufferedWriter w) throws IOException { // see if we already computed this IntrinsicICInfo icInfo = icInfoMap.get(concept.getConceptID()); if (icInfo != null && icInfo.getSubsumerCount() > 0) { return; } // if not, figure it out if (icInfo == null) { icInfo = new IntrinsicICInfo(concept); icInfoMap.put(concept.getConceptID(), icInfo); } Set<String> subsumers = this.getSubsumers(concept, subsumerMap, depthArray); if (w != null) { w.write(concept.getConceptID()); w.write("\t"); w.write(Integer.toString(subsumers.size())); w.write("\t"); w.write(subsumers.toString()); w.newLine(); } icInfo.setSubsumerCount(subsumers.size()); // recursively compute the children's subsumer counts for (ConcRel child : concept.getChildren()) { computeSubsumerCount(child, icInfoMap, subsumerMap, depthArray, w); } }
From source file:com.datafibers.kafka.connect.SchemaedFileSourceTask.java
private Schema ConvertMappingSchema(Set<?> columns) { SchemaBuilder builder = SchemaBuilder.struct().name(topic); Schema coreSchema;// w w w . j a v a2s.c om Iterator colIter = columns.iterator(); log.trace("Converting columns {} to Connect Schema", columns.toString()); while (colIter.hasNext()) { String column = colIter.next().toString(); builder.field(column, Schema.STRING_SCHEMA); } coreSchema = builder.build(); return coreSchema; }
From source file:org.slc.sli.api.security.context.ContextValidator.java
/** * Validates entities, based upon entity definition and entity ids to validate. * * @param def - Definition of entities to validate * @param ids - Collection of ids of entities to validate * @param isTransitive - Determines whether validation is through another entity type * * @throws APIAccessDeniedException - When entities cannot be accessed *//*from ww w. j av a 2 s .c om*/ public void validateContextToEntities(EntityDefinition def, Collection<String> ids, boolean isTransitive) throws APIAccessDeniedException { LOG.debug(">>>ContextValidator.validateContextToEntities()"); LOG.debug(" def: " + ToStringBuilder.reflectionToString(def, ToStringStyle.DEFAULT_STYLE)); LOG.debug(" ids: {}", (ids == null) ? "null" : ids.toArray().toString()); LOG.debug(" isTransitive" + isTransitive); IContextValidator validator = findValidator(def.getType(), isTransitive); LOG.debug(" loaded validator: " + ToStringBuilder.reflectionToString(validator, ToStringStyle.DEFAULT_STYLE)); if (validator != null) { NeutralQuery getIdsQuery = new NeutralQuery( new NeutralCriteria("_id", "in", new ArrayList<String>(ids))); LOG.debug(" getIdsQuery: " + getIdsQuery.toString()); Collection<Entity> entities = (Collection<Entity>) repo.findAll(def.getStoredCollectionName(), getIdsQuery); LOG.debug(" entities: " + ToStringBuilder.reflectionToString(entities, ToStringStyle.DEFAULT_STYLE)); Set<String> idsToValidate = getEntityIdsToValidate(def, entities, isTransitive, ids); LOG.debug(" idsToValidate: " + idsToValidate.toString()); Set<String> validatedIds = getValidatedIds(def, idsToValidate, validator); LOG.debug(" validatedIds: " + validatedIds.toString()); if (!validatedIds.containsAll(idsToValidate)) { LOG.debug(" ...APIAccessDeniedException"); throw new APIAccessDeniedException("Cannot access entities", def.getType(), idsToValidate); } } else { throw new APIAccessDeniedException("No validator for " + def.getType() + ", transitive=" + isTransitive, def.getType(), ids); } }
From source file:cs.ox.ac.uk.sors.PreferencesTestA.java
public void testMerge() throws Exception { // Configuration. final DecompositionStrategy decomposition = DecompositionStrategy.DECOMPOSE; final RewritingLanguage rewLang = RewritingLanguage.UCQ; final SubCheckStrategy subchkStrategy = SubCheckStrategy.INTRADEC; final NCCheck ncCheckStrategy = NCCheck.NONE; LOGGER.info("Decomposition: " + decomposition.name()); LOGGER.info("Rewriting Language: " + rewLang.name()); LOGGER.info("Subsumption Check Strategy: " + subchkStrategy.name()); LOGGER.info("Negative Constraints Check Strategy " + ncCheckStrategy.name()); final String creationDate = dateFormat.format(new Date()); // Parse the program final Parser parser = new Parser(); parser.parse(getStringFile(_DEFAULT_INPUT_PATH + "prefDB-ontology.dtg")); // Get the rules final List<IRule> rules = parser.getRules(); // Get the queries final List<IQuery> queryHeads = parser.getQueries(); final Map<IPredicate, IRelation> conf = parser.getDirectives(); if (!conf.isEmpty()) { StorageManager.getInstance();//w w w .java 2 s. c o m StorageManager.configure(conf); } // Get the TGDs from the set of rules final List<IRule> tgds = RewritingUtils.getTGDs(rules, queryHeads); final List<IRule> mSBox = RewritingUtils.getSBoxRules(rules, queryHeads); final IRuleSafetyProcessor ruleProc = new StandardRuleSafetyProcessor(); ruleProc.process(mSBox); final IQueryRewriter ndmRewriter = new NDMRewriter(mSBox); // Convert the query bodies in rules final List<IRule> bodies = new LinkedList<IRule>(rules); bodies.removeAll(tgds); final IRule query = RewritingUtils.getQueries(bodies, queryHeads).get(0); // get the constraints from the set of rules final Set<IRule> constraints = RewritingUtils.getConstraints(rules, queryHeads); final Set<Expressivity> exprs = RewritingUtils.getExpressivity(tgds); LOGGER.info("Expressivity: " + exprs.toString()); if (!exprs.contains(Expressivity.LINEAR) && !exprs.contains(Expressivity.STICKY)) { extracted(); } // compute the dependency graph LOGGER.debug("Computing position dependencies."); long posDepTime = System.currentTimeMillis(); Map<Pair<IPosition, IPosition>, Set<List<IRule>>> deps = DepGraphUtils.computePositionDependencyGraph(tgds); posDepTime = System.currentTimeMillis() - posDepTime; CacheManager.setupCaching(); // if linear TGDs, compute the atom coverage graph. LOGGER.debug("Computing atom coverage graph."); long atomCoverGraphTime = System.currentTimeMillis(); if (exprs.contains(Expressivity.LINEAR)) { deps = DepGraphUtils.computeAtomCoverageGraph(deps); } atomCoverGraphTime = System.currentTimeMillis() - atomCoverGraphTime; final ParallelRewriter cnsRewriter = new ParallelRewriter(DecompositionStrategy.MONOLITIC, RewritingLanguage.UCQ, SubCheckStrategy.NONE, NCCheck.NONE); long ncRewTime = System.currentTimeMillis(); final Set<IRule> rewrittenConstraints = Sets.newHashSet(); if (!ncCheckStrategy.equals(NCCheck.NONE)) { for (final IRule c : constraints) { rewrittenConstraints.addAll(cnsRewriter.getRewriting(c, tgds, new HashSet<IRule>(), deps, exprs)); } } ncRewTime = System.currentTimeMillis() - ncRewTime; LOGGER.debug("Finished rewriting constraints."); Map<String, Double> probModel = ProbabilisticModel.get(_DEFAULT_INPUT_PATH + "reviews.txt"); // Compute the Rewriting final ParallelRewriter rewriter = new ParallelRewriter(decomposition, rewLang, subchkStrategy, ncCheckStrategy); // List<Integer> ks = new ArrayList<Integer>(); // ks.add(5); List<MergingStrategy> str = new ArrayList<MergingStrategy>(); //str.add(PreferenceStrategy.PREFS_GEN); str.add(MergingStrategy.PREFS_PT); str.add(MergingStrategy.PREFS_RANK); str.add(MergingStrategy.PREFS_SORT); LOGGER.trace("start the things."); final String summaryPrefix = StringUtils.join(creationDate, "-"); final File sizeSummaryFile = FileUtils.getFile(_WORKING_DIR, FilenameUtils.separatorsToSystem(_DEFAULT_OUTPUT_PATH + "/"), FilenameUtils.separatorsToSystem(_DEFAULT_SUMMARY_DIR), StringUtils.join(summaryPrefix, "-", "size-summary.csv")); final CSVWriter sizeSummaryWriter = new CSVWriter(new FileWriter(sizeSummaryFile), ','); final File timeSummaryFile = FileUtils.getFile(_WORKING_DIR, FilenameUtils.separatorsToSystem(_DEFAULT_OUTPUT_PATH + "/"), FilenameUtils.separatorsToSystem(_DEFAULT_SUMMARY_DIR), StringUtils.join(summaryPrefix, "-", "time-summary.csv")); final CSVWriter timeSummaryWriter = new CSVWriter(new FileWriter(timeSummaryFile), ','); sizeSummaryWriter.writeNext(UReportingUtils.getSummaryRewritingSizeReportHeader()); timeSummaryWriter.writeNext(UReportingUtils.getSummaryRewritingTimeReportHeader()); // for (int nbNodes = 500; nbNodes < 1000; nbNodes += 500) { // for (int nbNodes = 10; nbNodes < 20; nbNodes += 10) { for (int nbNodes = 1000; nbNodes < 13000; nbNodes += 1000) { double sparisity = 0.15; //double sparsity = 0.15 and experirement no gen and no transitve closure, expeirment 1000> 13.0000 // for (Integer k : ks) { for (int con = 0; con < 10; con++) { PrefParameters parameters = new PrefParameters(nbNodes, sparisity); IRule q = query; CacheManager.setupCaching(); final String queryPredicate = q.getHead().iterator().next().getAtom().getPredicate() .getPredicateSymbol(); // Setup reporting final JoDSReporter rep = JoDSReporter.getInstance(true); JoDSReporter.setupReporting(); JoDSReporter.setQuery(queryPredicate); JoDSReporter.setTest("test" + con); rep.setValue(URewMetric.DEPGRAPH_TIME, posDepTime); LOGGER.info("Processing query: ".concat(q.toString())); final long overallTime = System.currentTimeMillis(); final Set<IRule> rewriting = rewriter.getRewriting(q, tgds, rewrittenConstraints, deps, exprs); rep.setValue(URewMetric.REW_TIME, System.currentTimeMillis() - overallTime); rep.setValue(URewMetric.REW_SIZE, (long) rewriting.size()); rep.setValue(URewMetric.REW_CNS_TIME, ncRewTime); IRelation result = getRelation(rewriting, parameters, ndmRewriter); // CONSTRUCT graph long constPrefGraphTime = System.currentTimeMillis(); final PreferencesGraph prefGraph = PreferenceGenerator .generatePreferenceGraph(parameters.getSparsity(), result); System.out.println("Gen" + prefGraph.getEdgesSize()); rep.setValue(URewMetric.PREFGRAPH_CONST_SIZE_V, (long) prefGraph.getVertexesSize()); rep.setValue(URewMetric.PREFGRAPH_CONST_SIZE_E, (long) prefGraph.getEdgesSize()); constPrefGraphTime = System.currentTimeMillis() - constPrefGraphTime; rep.setValue(URewMetric.PREFGRAPH_CONST_TIME, constPrefGraphTime); // TRANSITIVE graph long transitiveClosureTime = System.currentTimeMillis(); //TransitiveClosure c = TransitiveClosure.INSTANCE; //c.closeSimpleDirectedGraph(prefGraph.g); transitiveClosureTime = System.currentTimeMillis() - transitiveClosureTime; rep.setValue(URewMetric.TRANSITIVE_CLOSURE_TIME, transitiveClosureTime); rep.setValue(URewMetric.PREFGRAPH_TRA_SIZE_V, (long) prefGraph.getVertexesSize()); rep.setValue(URewMetric.PREFGRAPH_TRA_SIZE_E, (long) prefGraph.getEdgesSize()); System.out.println("Trans" + prefGraph.getEdgesSize() + "-" + transitiveClosureTime); PreferencesGraph prefMerged = null; Map<ITuple, Integer> ranks = null; // Merge Graph graph for (MergingStrategy strategyQA : str) { JoDSReporter.setStrategy(strategyQA); long mergeOperatorTime = System.currentTimeMillis(); if (strategyQA == MergingStrategy.PREFS_GEN) { double t = 0.3;//randInt(509, 761)/100.0; mergeOperatorTime = System.currentTimeMillis(); prefMerged = CombinationAlgorithms.combPrefsGen(prefGraph, probModel, t); mergeOperatorTime = System.currentTimeMillis() - mergeOperatorTime; } else { if (strategyQA == MergingStrategy.PREFS_PT) { mergeOperatorTime = System.currentTimeMillis(); double p = 0.5;//randInt(383, 887)/100.0; prefMerged = CombinationAlgorithms.combPrefsPT(prefGraph, probModel, p); mergeOperatorTime = System.currentTimeMillis() - mergeOperatorTime; } else { if (strategyQA == MergingStrategy.PREFS_RANK) { mergeOperatorTime = System.currentTimeMillis(); ranks = CombinationAlgorithms.combPrefsRank(prefGraph, probModel, Function.Max); mergeOperatorTime = System.currentTimeMillis() - mergeOperatorTime; } else { if (strategyQA == MergingStrategy.PREFS_SORT) { mergeOperatorTime = System.currentTimeMillis(); prefMerged = CombinationAlgorithms.combPrefsSort(prefGraph, probModel); mergeOperatorTime = System.currentTimeMillis() - mergeOperatorTime; } } } } if (prefMerged != null) { rep.setValue(URewMetric.PREFGRAPH_TOPK_SIZE_V, (long) prefMerged.getVertexesSize()); rep.setValue(URewMetric.PREFGRAPH_TOPK_SIZE_E, (long) prefMerged.getEdgesSize()); } else { rep.setValue(URewMetric.PREFGRAPH_TOPK_SIZE_V, (long) 0); rep.setValue(URewMetric.PREFGRAPH_TOPK_SIZE_E, (long) 0); } System.out.print("test" + con + strategyQA + "\n"); for (int k = 5; k < 10; k = k + 5) { JoDSReporter.setK(k); rep.setValue(URewMetric.PREFGRAPH_MERGE_TIME, (long) mergeOperatorTime); long topKTime = System.currentTimeMillis(); List<ITuple> topk = null; if (strategyQA == MergingStrategy.PREFS_RANK) { topk = TopKAlgorithms.topkPrefsRank(ranks, k); } else { topk = TopKAlgorithms.getTopK(prefMerged, k); } topKTime = System.currentTimeMillis() - topKTime; rep.setValue(URewMetric.PREFGRAPH_TOPK_TIME, topKTime); int sizeAnswer = (topk != null) ? topk.size() : 0; rep.setValue(URewMetric.ANSWER_SIZE, (long) sizeAnswer); sizeSummaryWriter.writeNext(rep.getSummarySizeMetrics()); timeSummaryWriter.writeNext(rep.getSummaryTimeMetrics()); sizeSummaryWriter.flush(); timeSummaryWriter.flush(); } } } } sizeSummaryWriter.close(); timeSummaryWriter.close(); }
From source file:com.siddique.androidwear.today.GeofenceTransitionsIntentService.java
private void notifyTodoItems(NotificationManagerCompat notificationManager, String todoItemType, int notificationId, int background) { Set<String> todoItems = TodoItems.readItems(this, todoItemType); Intent viewIntent = new Intent(this, TodoMobileActivity.class); PendingIntent viewPendingIntent = PendingIntent.getActivity(this, 0, viewIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_today_notification) .setLargeIcon(BitmapFactory.decodeResource(getResources(), background)) .setContentTitle(todoItems.size() + " " + todoItemType + " todo items found!") .setContentText(todoItems.toString()).setContentIntent(viewPendingIntent); // ? , ? ?/*from ww w .j a v a 2s . c o m*/ notificationManager.notify(notificationId, notificationBuilder.build()); }
From source file:org.devproof.portal.core.module.modulemgmt.service.ModuleServiceImpl.java
private String getLocations(ModuleConfiguration config) { Set<String> locations = new HashSet<String>(); for (BoxConfiguration c : config.getBoxes()) { locations.add(getLocation(c.getBoxClass())); }/*from w ww . j a v a 2 s .c om*/ for (Class<?> c : config.getEntities()) { locations.add(getLocation(c)); } for (PageConfiguration c : config.getPages()) { locations.add(getLocation(c.getPageClass())); } if (locations.isEmpty()) { locations.add("unknown"); } return StringUtils.replaceChars(locations.toString(), "[]", ""); }
From source file:de.rrze.idmone.utils.jpwgen.PwGenerator.java
/** * This method parses the command line options, initializes the needed * objects and generates the required number of passwords by calling * <em>generatePassword()</em>. When not used as a stand-alone program this * method is to be preferred instead of the main(String[]). * /*ww w . j av a 2 s .c o m*/ * @param args * the arguments used to initialize the generation process * @return a list of passwords or <em>null</em> if no suitable passwords * could be generated. */ public static synchronized List<String> process(String[] args) { int passwordFlags = initDefaultFlags(); // The length of the password to be generated int passwordLength = DEFAULT_PASSWORD_LENGTH; int numberOfPasswords = DEFAULT_NUMBER_OF_PASSWORDS; int maxAttempts = DEFAULT_MAX_ATTEMPTS; log(Messages.getString("PwGenerator.PASSWORD_GENERATOR"), //$NON-NLS-1$ false); ArrayList<String> passwords = new ArrayList<String>(); BasicParser parser = new BasicParser(); try { CommandLine commandLine = parser.parse(options, args); parser.parse(options, args); if (commandLine.hasOption(CL_HELP)) { printUsage(); log(Messages.getString("PwGenerator.SEPARATOR"), //$NON-NLS-1$ false); return passwords; } parser.parse(options, args); if (commandLine.hasOption(CL_SR_PROVIDERS)) { Set<String> serviceProviders = RandomFactory.getInstance() .getServiceProviderFor(IRandomFactory.TYPE_SECURE_RANDOM); log(Messages.getString("PwGenerator.SERVICES_PROVIDERS_FOR") //$NON-NLS-1$ + IRandomFactory.TYPE_SECURE_RANDOM + Messages.getString("PwGenerator.NEW_LINE"), false); //$NON-NLS-1$ for (Iterator<String> iter = serviceProviders.iterator(); iter.hasNext();) { String element = (String) iter.next(); log(Messages.getString("PwGenerator.SERVICE_PROVIDERS") + element //$NON-NLS-1$ + Messages.getString("PwGenerator.NEW_LINE"), false); //$NON-NLS-1$ log(Messages.getString("PwGenerator.SEPARATOR"), //$NON-NLS-1$ false); return passwords; } } parser.parse(options, args); if (commandLine.hasOption(CL_PROVIDERS)) { log(Messages.getString("PwGenerator.ALL_SEC_PROVIDERS") //$NON-NLS-1$ + IRandomFactory.TYPE_SECURE_RANDOM + Messages.getString("PwGenerator.NEW_LINE"), false); //$NON-NLS-1$ Provider[] serviceProviders = RandomFactory.getInstance().getProviders(); for (int i = 0; i < serviceProviders.length; i++) { log(Messages.getString("PwGenerator.SEPARATOR"), //$NON-NLS-1$ false); log(Messages.getString("PwGenerator.PROVIDER") + serviceProviders[i].getName() //$NON-NLS-1$ + Messages.getString("PwGenerator.NEW_LINE"), //$NON-NLS-1$ false); Set<Provider.Service> services = serviceProviders[i].getServices(); log(Messages.getString("PwGenerator.SERVICES") + Messages.getString("PwGenerator.NEW_LINE"), //$NON-NLS-1$//$NON-NLS-2$ false); log(services.toString(), false); log(Messages.getString("PwGenerator.SEPARATOR"), //$NON-NLS-1$ false); } log(Messages.getString("PwGenerator.SEPARATOR"), //$NON-NLS-1$ false); return passwords; } if (commandLine.hasOption(CL_NUMBER_PASSWORD)) { String sNumberOfPasswords = commandLine.getOptionValue(CL_NUMBER_PASSWORD); if (sNumberOfPasswords != null) numberOfPasswords = Integer.parseInt(sNumberOfPasswords); log(Messages.getString("PwGenerator.NUM_PASSWORDS") + numberOfPasswords, false); //$NON-NLS-1$ } commandLine = parser.parse(options, args); if (commandLine.hasOption(CL_PASSWORD_LENGTH)) { String sPasswordLength = commandLine.getOptionValue(CL_PASSWORD_LENGTH); if (sPasswordLength != null) passwordLength = Integer.parseInt(sPasswordLength); log(Messages.getString("PwGenerator.PASSWORD_LENGTH") + passwordLength, false); //$NON-NLS-1$ } parser.parse(options, args); if (commandLine.hasOption(CL_COLUMN)) { doColumns = true; log(Messages.getString("PwGenerator.COLUMNS_ENABLED"), false); //$NON-NLS-1$ } parser.parse(options, args); if (commandLine.hasOption(CL_TERM_WIDTH)) { String sTermWidth = commandLine.getOptionValue(CL_TERM_WIDTH); if (sTermWidth != null) termWidth = Integer.parseInt(sTermWidth); log(Messages.getString("PwGenerator.TERMINAL_LENGTH") + termWidth, false); //$NON-NLS-1$ } Random random = null; parser.parse(options, args); if (commandLine.hasOption(CL_RANDOM)) { random = RandomFactory.getInstance().getRandom(); log(Messages.getString("PwGenerator.NORMAL_RANDOM"), false); //$NON-NLS-1$ } else { try { random = RandomFactory.getInstance().getSecureRandom(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); random = RandomFactory.getInstance().getRandom(); } catch (NoSuchProviderException e) { e.printStackTrace(); random = RandomFactory.getInstance().getRandom(); } } parser.parse(options, args); if (commandLine.hasOption(CL_SR_ALGORITHM)) { String[] data = commandLine.getOptionValues(CL_SR_ALGORITHM); if (data.length == 2) { try { random = RandomFactory.getInstance().getSecureRandom(data[0], data[1]); log(Messages.getString("PwGenerator.SEC_ALG") + data[0] //$NON-NLS-1$ + Messages.getString("PwGenerator.PROV") + data[1] //$NON-NLS-1$ + Messages.getString("PwGenerator.DOR"), false); //$NON-NLS-1$ } catch (NoSuchAlgorithmException e) { log(Messages.getString("PwGenerator.ERROR") + e.getMessage() //$NON-NLS-1$ + Messages.getString("PwGenerator.NEW_LINE"), true); //$NON-NLS-1$ log(Messages.getString("PwGenerator.DEFAUL_RANDOM"), true); //$NON-NLS-1$ } catch (NoSuchProviderException e) { log(Messages.getString("PwGenerator.ERROR") + e.getMessage() //$NON-NLS-1$ + Messages.getString("PwGenerator.NEW_LINE"), true); //$NON-NLS-1$ log(Messages.getString("PwGenerator.DEFAUL_RANDOM"), true); //$NON-NLS-1$ } } } if (commandLine.hasOption(CL_NUMERALS)) { passwordFlags |= PW_DIGITS; log(Messages.getString("PwGenerator.DIGITS_ON"), false); //$NON-NLS-1$ } if (commandLine.hasOption(CL_NO_NUMERALS)) { passwordFlags &= ~PW_DIGITS; log(Messages.getString("PwGenerator.DIGITS_OFF"), false); //$NON-NLS-1$ } if (commandLine.hasOption(CL_CAPITALIZE)) { passwordFlags |= PW_UPPERS; log(Messages.getString("PwGenerator.UPPERCASE_ON"), false); //$NON-NLS-1$ } if (commandLine.hasOption(CL_NO_CAPITALIZE)) { passwordFlags &= ~PW_UPPERS; log(Messages.getString("PwGenerator.UPPERCASE_OFF"), false); //$NON-NLS-1$ } if (commandLine.hasOption(CL_AMBIGOUS)) { passwordFlags |= PW_AMBIGUOUS; log(Messages.getString("PwGenerator.AMBIGOUS_ON"), false); //$NON-NLS-1$ } if (commandLine.hasOption(CL_NO_AMBIGOUS)) { passwordFlags &= ~PW_AMBIGUOUS; log(Messages.getString("PwGenerator.AMBIGOUS_OFF"), false); //$NON-NLS-1$ } if (commandLine.hasOption(CL_SYMBOLS)) { passwordFlags |= PW_SYMBOLS; log(Messages.getString("PwGenerator.SYMBOLS_ON"), false); //$NON-NLS-1$ } if (commandLine.hasOption(CL_SYMBOLS_REDUCED)) { passwordFlags |= PW_SYMBOLS_REDUCED; log(Messages.getString("PwGenerator.SYMBOLS_REDUCED_ON"), false); //$NON-NLS-1$ } if (commandLine.hasOption(CL_NO_SYMBOLS)) { passwordFlags &= ~PW_SYMBOLS; passwordFlags &= ~PW_SYMBOLS_REDUCED; log(Messages.getString("PwGenerator.SYMBOLS_OFF"), false); //$NON-NLS-1$ } if (commandLine.hasOption(CL_MAX_ATTEMPTS)) { String sMaxAttempts = commandLine.getOptionValue(CL_MAX_ATTEMPTS); if (sMaxAttempts != null) maxAttempts = Integer.parseInt(sMaxAttempts); log(Messages.getString("PwGenerator.MAX_ATTEMPTS") + maxAttempts, false); //$NON-NLS-1$ } if (commandLine.hasOption(CL_REGEX_STARTS_NO_SMALL_LETTER)) passwordFlags |= REGEX_STARTS_NO_SMALL_LETTER_FLAG; if (commandLine.hasOption(CL_REGEX_ENDS_NO_SMALL_LETTER)) passwordFlags |= REGEX_STARTS_NO_SMALL_LETTER_FLAG; if (commandLine.hasOption(CL_REGEX_STARTS_NO_UPPER_LETTER)) passwordFlags |= REGEX_STARTS_NO_UPPER_LETTER_FLAG; if (commandLine.hasOption(CL_REGEX_ENDS_NO_UPPER_LETTER)) passwordFlags |= REGEX_ENDS_NO_UPPER_LETTER_FLAG; if (commandLine.hasOption(CL_REGEX_ENDS_NO_DIGIT)) passwordFlags |= REGEX_ENDS_NO_DIGIT_FLAG; if (commandLine.hasOption(CL_REGEX_STARTS_NO_DIGIT)) passwordFlags |= REGEX_STARTS_NO_DIGIT_FLAG; if (commandLine.hasOption(CL_REGEX_STARTS_NO_SYMBOL)) passwordFlags |= REGEX_STARTS_NO_SYMBOL_FLAG; if (commandLine.hasOption(CL_REGEX_ENDS_NO_SYMBOL)) passwordFlags |= REGEX_ENDS_NO_SYMBOL_FLAG; if (commandLine.hasOption(CL_REGEX_ONLY_1_CAPITAL)) passwordFlags |= REGEX_ONLY_1_CAPITAL_FLAG; if (commandLine.hasOption(CL_REGEX_ONLY_1_SYMBOL)) passwordFlags |= REGEX_ONLY_1_SYMBOL_FLAG; if (commandLine.hasOption(CL_REGEX_AT_LEAST_2_SYMBOLS)) passwordFlags |= REGEX_AT_LEAST_2_SYMBOLS_FLAG; if (commandLine.hasOption(CL_REGEX_ONLY_1_DIGIT)) passwordFlags |= REGEX_ONLY_1_DIGIT_FLAG; if (commandLine.hasOption(CL_REGEX_AT_LEAST_2_DIGITS)) passwordFlags |= REGEX_AT_LEAST_2_DIGITS_FLAG; // ------------------------------------------------------------------- log(Messages.getString("PwGenerator.GENRIC_FLAGS"), //$NON-NLS-1$ false); int res = passwordFlags & PW_DIGITS; log(Messages.getString("PwGenerator.DIGITS") + (res != 0), false); //$NON-NLS-1$ res = passwordFlags & PW_AMBIGUOUS; log(Messages.getString("PwGenerator.AMBIGOUS") + (res != 0), false); //$NON-NLS-1$ res = passwordFlags & PW_SYMBOLS; log(Messages.getString("PwGenerator.SYMBOLS") + (res != 0), false); //$NON-NLS-1$ res = passwordFlags & PW_SYMBOLS_REDUCED; log(Messages.getString("PwGenerator.SYMBOLS_REDUCED") + (res != 0), false); //$NON-NLS-1$ res = passwordFlags & PW_UPPERS; log(Messages.getString("PwGenerator.UPPERS") + (res != 0), false); //$NON-NLS-1$ log(Messages.getString("PwGenerator.SEPARATOR"), //$NON-NLS-1$ false); log(Messages.getString("PwGenerator.GENERATING") + numberOfPasswords //$NON-NLS-1$ + Messages.getString("PwGenerator.PW_LENGTH") //$NON-NLS-1$ + passwordLength, false); log(Messages.getString("PwGenerator.PW"), //$NON-NLS-1$ false); int i; for (i = 0; i < numberOfPasswords; i++) { String password = generatePassword(passwordLength, passwordFlags, maxAttempts, random); if (password != null) passwords.add(password); } } catch (ParseException e) { log(Messages.getString("PwGenerator.PARAM_ERROR") + e.getLocalizedMessage(), true); //$NON-NLS-1$ printUsage(); } catch (NumberFormatException e) { log(Messages.getString("PwGenerator.NUM_FORM_ERROR") + e.getLocalizedMessage(), true); //$NON-NLS-1$ printUsage(); } return passwords; }
From source file:info.pancancer.arch3.reporting.Arch3ReportImpl.java
@Override public Map<String, Map<String, String>> getVMInfo(ProvisionState... states) { Map<String, AbstractInstanceListing.InstanceDescriptor> youxiaInstances = this.getYouxiaInstances(); Set<String> activeIPAddresses = new HashSet<>(); // curate set of ip addresses for active instances for (Entry<String, AbstractInstanceListing.InstanceDescriptor> entry : youxiaInstances.entrySet()) { activeIPAddresses.add(entry.getValue().getIpAddress()); activeIPAddresses.add(entry.getValue().getPrivateIpAddress()); }//from w ww . j a va 2s . c o m System.out.println("Set of active addresses: " + activeIPAddresses.toString()); // this map is provision_uuid -> keys -> values Map<String, Map<String, String>> map = new TreeMap<>(); for (ProvisionState state : states) { List<Provision> provisions = db.getProvisions(state); Date now = new Date(); Timestamp currentTimestamp = new java.sql.Timestamp(now.getTime()); long time = currentTimestamp.getTime(); DecimalFormat df = new DecimalFormat("#.00"); for (Provision provision : provisions) { System.out.println("Checking " + provision.getIpAddress()); if (!activeIPAddresses.contains(provision.getIpAddress())) { System.out.println("Excluding " + provision.getIpAddress() + " due to youxia filter"); continue; } Map<String, String> jobMap = new TreeMap<>(); jobMap.put("ip_address", provision.getIpAddress()); jobMap.put("status", provision.getState().toString()); long lastSeen = provision.getUpdateTimestamp().getTime(); double secondsAgo = (time - lastSeen) / MILLISECONDS_IN_SECOND; jobMap.put("last seen with live heartbeat (seconds)", df.format(secondsAgo)); long firstSeen = provision.getCreateTimestamp().getTime(); double hoursAgo = (time - firstSeen) / (MILLISECONDS_IN_SECOND * SECONDS_IN_MINUTE * MINUTES_IN_HOUR); jobMap.put("first seen in submission queue (hours)", df.format(hoursAgo)); map.put(provision.getProvisionUUID(), jobMap); } } return map; }
From source file:org.red5.net.websocket.WebSocketTransport.java
/** * Creates the i/o handler and nio acceptor; ports and addresses are bound. * /* w w w . j a v a 2s . c om*/ * @throws IOException */ @Override public void afterPropertiesSet() throws Exception { // create the nio acceptor //acceptor = new NioSocketAcceptor(Executors.newFixedThreadPool(connectionThreads), new NioProcessor(Executors.newFixedThreadPool(ioThreads))); acceptor = new NioSocketAcceptor(ioThreads); // instance the websocket handler if (ioHandler == null) { ioHandler = new WebSocketHandler(); } log.trace("I/O handler: {}", ioHandler); DefaultIoFilterChainBuilder chain = acceptor.getFilterChain(); // if handling wss init the config if (secureConfig != null) { SslFilter sslFilter = secureConfig.getSslFilter(); chain.addFirst("sslFilter", sslFilter); } if (log.isTraceEnabled()) { chain.addLast("logger", new LoggingFilter()); } // add the websocket codec factory chain.addLast("protocol", new ProtocolCodecFilter(new WebSocketCodecFactory())); // close sessions when the acceptor is stopped acceptor.setCloseOnDeactivation(true); acceptor.setHandler(ioHandler); // requested maximum length of the queue of incoming connections acceptor.setBacklog(64); SocketSessionConfig sessionConf = acceptor.getSessionConfig(); sessionConf.setReuseAddress(true); sessionConf.setTcpNoDelay(true); sessionConf.setReceiveBufferSize(receiveBufferSize); sessionConf.setSendBufferSize(sendBufferSize); acceptor.setReuseAddress(true); if (addresses.isEmpty()) { acceptor.bind(new InetSocketAddress(port)); } else { try { // loop through the addresses and bind Set<InetSocketAddress> socketAddresses = new HashSet<InetSocketAddress>(); for (String addr : addresses) { if (addr.indexOf(':') != -1) { String[] parts = addr.split(":"); socketAddresses.add(new InetSocketAddress(parts[0], Integer.valueOf(parts[1]))); } else { socketAddresses.add(new InetSocketAddress(addr, port)); } } log.debug("Binding to {}", socketAddresses.toString()); acceptor.bind(socketAddresses); } catch (Exception e) { log.error("Exception occurred during resolve / bind", e); } } log.info("started {} websocket transport", (isSecure() ? "secure" : "")); }