List of usage examples for org.springframework.util StringUtils collectionToDelimitedString
public static String collectionToDelimitedString(@Nullable Collection<?> coll, String delim)
From source file:fr.openwide.talendalfresco.alfresco.XmlContentImporterResultHandler.java
/** * //www .j a v a 2 s. co m * @param namePath * @param context null if container case * @param t */ public void nodeError(ImportNode nodeContext, Throwable t) { String typeInfo = null; // node case : take info from context TypeDefinition typeDef = nodeContext.getTypeDefinition(); if (typeDef != null) { String nodeAspects = StringUtils.collectionToDelimitedString(nodeContext.getNodeAspects(), " "); typeInfo = typeDef.getName() + ";" + nodeAspects; } String nodeName = (String) nodeContext.getProperties().get(ContentModel.PROP_NAME); // NB. parent noderef exists since we've being there and created it already NodeRef parentNodeRef = nodeContext.getParentContext().getParentRef(); this.nodeError(nodeName, parentNodeRef, typeInfo, t); }
From source file:org.jasig.portlet.contacts.control.SearchEventController.java
@EventMapping(SearchConstants.SEARCH_REQUEST_QNAME_STRING) public void handleSearchEvents(EventRequest request, EventResponse response) { log.debug("Responding to Search Event"); final Event event = request.getEvent(); final SearchRequest searchQuery = (SearchRequest) event.getValue(); final String searchTerms = searchQuery.getSearchTerms(); final SearchResults searchResults = new SearchResults(); searchResults.setQueryId(searchQuery.getQueryId()); searchResults.setWindowId(request.getWindowID()); for (ContactDomain domain : contactDomains) { if (domain.getHasSearch()) { ContactSet contacts = domain.search(searchTerms); for (Contact contact : contacts) { //Build the result object for the match final SearchResult searchResult = new SearchResult(); String title = contact.getSurname().toUpperCase() + ", " + contact.getTitle() + " " + contact.getFirstname(); if (contact.getPosition() != null && !contact.getPosition().equals("")) title += " (" + contact.getPosition() + ")"; List<String> summary = new ArrayList<String>(); ;//from w w w . jav a 2 s. c om if (contact.getPrimaryEmailAddress() != null) summary.add("E:" + contact.getPrimaryEmailAddress().getEmailAddress()); if (contact.getPrimaryPhoneNumber() != null) summary.add("T:" + contact.getPrimaryPhoneNumber().getPhoneNumber()); String summaryText = StringUtils.collectionToDelimitedString(summary, " -- "); searchResult.setTitle(title); searchResult.setSummary(summaryText); /* * Portlet URL to be added when / if portlet support for * deep linking added. */ PortletUrl url = new PortletUrl(); url.setPortletMode("VIEW"); url.setWindowState(WindowState.MAXIMIZED.toString()); PortletUrlParameter domainParam = new PortletUrlParameter(); domainParam.setName("domain"); domainParam.getValue().add(domain.getId()); url.getParam().add(domainParam); PortletUrlParameter urnParam = new PortletUrlParameter(); urnParam.setName("urn"); urnParam.getValue().add(contact.getURN()); url.getParam().add(urnParam); searchResult.setPortletUrl(url); searchResult.getType().add("contact"); //Add the result to the results and send the event searchResults.getSearchResult().add(searchResult); } } } response.setEvent(SearchConstants.SEARCH_RESULTS_QNAME, searchResults); log.debug("Finished response -- " + searchResults.getSearchResult().size() + " -- results returned"); }
From source file:io.s4.message.SinglePERequest.java
public List<CompoundKeyInfo> partition(Hasher h, String delim, int partCount) { List<String> valueList = this.getTarget(); if (valueList == null) return null; // First, build the key KeyInfo keyInfo = new KeyInfo(); // special kay name to denote request keyInfo.addElementToPath("#req"); // for value, concatenate list of values from Request's target field. String stringValue = StringUtils.collectionToDelimitedString(valueList, delim); keyInfo.setValue(stringValue);// w w w . j a va 2s . co m // partition id is derived form string value, as usual int partitionId = (int) (h.hash(stringValue) % partCount); CompoundKeyInfo partitionInfo = new CompoundKeyInfo(); partitionInfo.addKeyInfo(keyInfo); partitionInfo.setCompoundValue(stringValue); partitionInfo.setPartitionId(partitionId); List<CompoundKeyInfo> partitionInfoList = new ArrayList<CompoundKeyInfo>(); partitionInfoList.add(partitionInfo); return partitionInfoList; }
From source file:org.cloudfoundry.identity.uaa.scim.DefaultPasswordValidator.java
@Override public void validate(String password, ScimUser user) throws InvalidPasswordException { List<Rule> rules;// w w w.j a v a 2 s . co m PasswordData passwordData = new PasswordData(new Password(password)); passwordData.setUsername(user.getUserName()); // Build dictionary rule based on Scim data rules = new ArrayList<Rule>(defaultRules); if (password.length() < 20) { // Check sequences only in "short" passwords (see CFID-221) rules.addAll(shortRules); } String[] userWords = user.wordList().toArray(new String[user.wordList().size()]); Arrays.sort(userWords, WordLists.CASE_INSENSITIVE_COMPARATOR); rules.add(new DictionarySubstringRule(new WordListDictionary(new ArrayWordList(userWords, false)))); edu.vt.middleware.password.PasswordValidator validator = new edu.vt.middleware.password.PasswordValidator( rules); RuleResult result = validator.validate(passwordData); if (!result.isValid()) { String errors = StringUtils.collectionToDelimitedString(validator.getMessages(result), ","); throw new InvalidPasswordException(errors); } }
From source file:com.ethlo.kfka.mysql.MysqlKfkaMapStore.java
private String getInsertSql(KfkaMessage value) { final Collection<String> extraProps = value.getQueryableProperties(); final String extraColsStr = (extraProps.isEmpty() ? "" : (", " + StringUtils.collectionToCommaDelimitedString(extraProps))); final String extraColPlaceholdersStr = (extraProps.isEmpty() ? "" : (", :" + StringUtils.collectionToDelimitedString(extraProps, ", :"))); return "INSERT INTO kfka (id, topic, type, timestamp, payload" + extraColsStr + ")" + " VALUES(:id, :topic, :type, :timestamp, :payload" + extraColPlaceholdersStr + ")"; }
From source file:com.kixeye.chassis.support.logging.FlumeLoggerLoader.java
@PostConstruct public void initialize() { multicaster.addApplicationListener(loggingListener); ConcurrentHashMap<String, String> flumeConfig = new ConcurrentHashMap<>(); List<String> sinks = new ArrayList<>(); for (String server : servers) { String sinkName = server.replace(":", "-").replace(".", "_"); String[] servers = server.split(":", 2); if (servers.length == 2) { flumeConfig.put(sinkName + ".type", "avro"); flumeConfig.put(sinkName + ".channels", "channel-" + name); flumeConfig.put(sinkName + ".hostname", servers[0]); flumeConfig.put(sinkName + ".port", servers[1]); } else {/*from w w w. ja v a 2 s . c o m*/ logger.error("Invalid server format [{}], should be [hostname:port]", server); } sinks.add(sinkName); } // force some properties flumeConfig.put("channel.type", "file"); flumeConfig.put("sinks", StringUtils.collectionToDelimitedString(sinks, " ")); flumeConfig.putIfAbsent("processor.type", serversUsage); flumeConfig.put("channel.checkpointDir", SystemPropertyUtils.resolvePlaceholders("${user.dir}/flume-data/checkpoint")); flumeConfig.put("channel.dataDirs", SystemPropertyUtils.resolvePlaceholders("${user.dir}/flume-data/data")); agent = new EmbeddedAgent(name); agent.configure(flumeConfig); agent.start(); appender = new FlumeLogAppender(agent, serviceName); installFlumeAppender(); }
From source file:com.stormpath.spring.security.authz.permission.DomainPermission.java
protected void setParts(String domain, Set<String> actions, Set<String> targets) { String actionsString = StringUtils.collectionToDelimitedString(actions, SUBPART_DIVIDER_TOKEN); String targetsString = StringUtils.collectionToDelimitedString(targets, SUBPART_DIVIDER_TOKEN); encodeParts(domain, actionsString, targetsString); this.domain = domain; this.actions = actions; this.targets = targets; }
From source file:org.openmrs.module.simplelabentry.web.dwr.LabPatientListItem.java
public LabPatientListItem(Patient patient) { super(patient); if (patient != null) { // Handle patient identifiers PatientIdentifierType pit = (PatientIdentifierType) SimpleLabEntryUtil.getPatientIdentifierType(); setIdentifier(""); Set<String> otherIds = new HashSet<String>(); for (PatientIdentifier pi : patient.getIdentifiers()) { if (pi.getIdentifierType().getPatientIdentifierTypeId().equals(pit.getPatientIdentifierTypeId())) { if (pi.isPreferred()) { setIdentifier(pi.getIdentifier()); } else { if ("".equals(getIdentifier())) { setIdentifier(pi.getIdentifier()); }//from ww w . java2 s . c o m otherIds.add(pi.getIdentifier()); } } } // show one of the extra patient id search type IDs, this is purely for display if (getIdentifier().equals("")) { boolean matched = false; for (PatientIdentifierType pitExtra : SimpleLabEntryUtil.getPatientIdentifierTypesToSearch()) { if (!pitExtra.getPatientIdentifierTypeId().equals(pit.getPatientIdentifierTypeId())) { for (PatientIdentifier pi : patient.getIdentifiers()) { if (pi.getIdentifierType().getPatientIdentifierTypeId() .equals(pitExtra.getPatientIdentifierTypeId())) { matched = true; setIdentifier(pi.getIdentifier()); break; } } if (matched) break; } } } otherIds.remove(getIdentifier()); setOtherIdentifiers(StringUtils.collectionToDelimitedString(otherIds, ", ")); // Handle PatientProgram Current WorkFlow State ProgramWorkflow workflow = null; Program program = SimpleLabEntryUtil.getProgram(); ProgramWorkflow progWorkflowToDisplay = SimpleLabEntryUtil.getWorkflow(); if (program != null) { for (ProgramWorkflow wf : program.getAllWorkflows()) { if (wf.getProgramWorkflowId().toString().equals(progWorkflowToDisplay.getName())) { workflow = wf; } else { for (ConceptName n : wf.getConcept().getNames()) { if (n.getName().equals(progWorkflowToDisplay.getName())) { workflow = wf; } } } } } if (workflow != null) { List<PatientProgram> patientPrograms = Context.getProgramWorkflowService() .getPatientPrograms(patient, program, null, null, null, null, false); if (!patientPrograms.isEmpty()) { PatientProgram prog = patientPrograms.get(0); if (prog != null) { PatientState state = prog.getCurrentState(workflow); if (state != null && state.getState() != null) { programState = state.getState().getConcept().getName().getName(); } } } } // Handle Last Obs Concept obsConcept = null; String obsConceptProp = SimpleLabEntryUtil.getObsConceptIdToDisplay(); try { obsConcept = Context.getConceptService().getConceptByUuid(obsConceptProp); if (obsConcept == null) obsConcept = Context.getConceptService().getConcept(Integer.valueOf(obsConceptProp)); } catch (Exception e) { } if (obsConcept != null) { List<Obs> obs = Context.getObsService().getObservationsByPersonAndConcept(patient, obsConcept); Obs latestObs = null; for (Obs o : obs) { if (latestObs == null || latestObs.getObsDatetime() == null || latestObs.getObsDatetime().before(o.getObsDatetime())) { latestObs = o; } } if (latestObs != null) { lastObs = latestObs.getValueAsString(Context.getLocale()); } } // Handle patient address fields PersonAddress address = patient.getPersonAddress(); if (address != null) { setAddress1(address.getAddress1()); setAddress2(address.getAddress2()); setCountyDistrict(address.getCountyDistrict()); setCityVillage(address.getCityVillage()); setNeighborhoodCell(address.getNeighborhoodCell()); } labOrderIdsForPatient = SimpleLabEntryUtil.getLabOrderIDsByPatient(patient, 6); } }
From source file:io.pivotal.poc.gemfire.gtx.jndi.SimpleNamingContext.java
/** * Look up the object with the given name. * <p>Note: Not intended for direct use by applications. * Will be used by any standard InitialContext JNDI lookups. * @throws javax.naming.NameNotFoundException if the object could not be found *//*from www . j a va 2s . c om*/ @Override public Object lookup(String lookupName) throws NameNotFoundException { String name = this.root + lookupName; if (logger.isDebugEnabled()) { logger.debug("Static JNDI lookup: [" + name + "]"); } if ("".equals(name)) { return new SimpleNamingContext(this.root, this.boundObjects, this.environment); } Object found = this.boundObjects.get(name); if (found == null) { if (!name.endsWith("/")) { name = name + "/"; } for (String boundName : this.boundObjects.keySet()) { if (boundName.startsWith(name)) { return new SimpleNamingContext(name, this.boundObjects, this.environment); } } throw new NameNotFoundException( "Name [" + this.root + lookupName + "] not bound; " + this.boundObjects.size() + " bindings: [" + StringUtils.collectionToDelimitedString(this.boundObjects.keySet(), ",") + "]"); } return found; }
From source file:com.agileapes.couteau.maven.sample.task.CompileCodeTask.java
/** * This method will determine the classpath argument passed to the JavaC compiler used by this * implementation//from w ww . j ava 2 s. co m * @return the classpath * @throws org.apache.maven.artifact.DependencyResolutionRequiredException if the resolution of classpath requires a prior * resolution of dependencies for the target project */ private String getClassPath(SampleExecutor executor) throws DependencyResolutionRequiredException { //Adding compile time dependencies for the project final List elements = executor.getProject().getCompileClasspathElements(); final Set<File> classPathElements = new HashSet<File>(); //noinspection unchecked classPathElements.addAll(elements); //Adding runtime dependencies available to the target project final ClassLoader loader = executor.getProjectClassLoader(); URL[] urls = new URL[0]; if (loader instanceof URLClassLoader) { urls = ((URLClassLoader) loader).getURLs(); } else if (loader instanceof ConfigurableClassLoader) { urls = ((ConfigurableClassLoader) loader).getUrls(); } for (URL url : urls) { try { final File file = new File(url.toURI()); if (file.exists()) { classPathElements.add(file); } } catch (Throwable ignored) { } } //Adding dependency artifacts for the target project for (Object dependencyArtifact : executor.getProject().getDependencyArtifacts()) { if (!(dependencyArtifact instanceof DefaultArtifact)) { continue; } DefaultArtifact artifact = (DefaultArtifact) dependencyArtifact; if (artifact.getFile() != null) { classPathElements.add(artifact.getFile()); } } return StringUtils.collectionToDelimitedString(classPathElements, File.pathSeparator); }