List of usage examples for org.springframework.util StringUtils collectionToCommaDelimitedString
public static String collectionToCommaDelimitedString(@Nullable Collection<?> coll)
From source file:org.cloudfoundry.identity.uaa.api.common.impl.UaaConnectionHelper.java
/** * Because variable substitution used by {@link org.springframework.web.client.RestTemplate} escapes things in a way * that makes SCIM filtering difficult, manually include the parameters in the uri * /*from ww w.j a v a 2 s . c o m*/ * @param baseUrl the url relative to the base URL (i.e. /Users, /oauth/clients, etc) * @param request the Filter Request to populate the URL * @return the URL */ public String buildScimFilterUrl(String baseUrl, FilterRequest request) { StringBuilder uriBuilder = new StringBuilder(baseUrl); boolean hasParams = false; if (request.getAttributes() != null && !request.getAttributes().isEmpty()) { uriBuilder.append("?attributes=") .append(StringUtils.collectionToCommaDelimitedString(request.getAttributes())); hasParams = true; } if (StringUtils.hasText(request.getFilter())) { if (hasParams) { uriBuilder.append("&"); } else { uriBuilder.append("?"); } uriBuilder.append("filter=").append(request.getFilter()); hasParams = true; } if (request.getStart() > 0) { if (hasParams) { uriBuilder.append("&"); } else { uriBuilder.append("?"); } uriBuilder.append("startIndex=").append(request.getStart()); hasParams = true; } if (request.getCount() > 0) { if (hasParams) { uriBuilder.append("&"); } else { uriBuilder.append("?"); } uriBuilder.append("count=").append(request.getCount()); hasParams = true; } return uriBuilder.toString(); }
From source file:eu.trentorise.smartcampus.permissionprovider.manager.ResourceAdapter.java
/** * Try to remove the resource parameter and its children. Operation is recursive. * If one of the derived resources is already in use, an exception is thrown. * @param resourceId//from www . j ava 2 s .c o m * @param value * @param clientId */ public void removeResourceParameter(String resourceId, String value, String clientId) { ResourceParameterKey pk = new ResourceParameterKey(); pk.resourceId = resourceId; pk.value = value; // main parameter ResourceParameter rpdb = resourceParameterRepository.findOne(pk); if (rpdb != null && !rpdb.getClientId().equals(clientId)) { throw new IllegalArgumentException("Can delete only own resource parameters"); } if (rpdb != null) { Set<String> ids = new HashSet<String>(); Set<String> scopes = new HashSet<String>(); // aggregate all derived resource uris Collection<String> uris = findResourceURIs(rpdb).keySet(); for (String uri : uris) { Resource r = resourceRepository.findByResourceUri(uri); if (r != null) { ids.add(r.getResourceId().toString()); scopes.add(r.getResourceUri()); } } ClientDetailsEntity owner = null; // check the resource uri usages for (ClientDetailsEntity cd : clientDetailsRepository.findAll()) { if (cd.getClientId().equals(clientId)) { owner = cd; continue; } if (!Collections.disjoint(cd.getResourceIds(), ids)) { throw new IllegalArgumentException("Resource is in use by other client app."); } } // delete main and its children for (String id : ids) { resourceRepository.delete(Long.parseLong(id)); } if (owner != null) { Set<String> oldScopes = new HashSet<String>(owner.getScope()); oldScopes.removeAll(scopes); owner.setScope(StringUtils.collectionToCommaDelimitedString(oldScopes)); Set<String> oldIds = new HashSet<String>(owner.getResourceIds()); oldIds.removeAll(ids); owner.setResourceIds(StringUtils.collectionToCommaDelimitedString(oldIds)); clientDetailsRepository.save(owner); } resourceParameterRepository.delete(rpdb); } }
From source file:eu.trentorise.smartcampus.permissionprovider.manager.ResourceManager.java
/** * Try to remove the resource parameter and its children. Operation is recursive. * If one of the derived resources is already in use, an exception is thrown. * @param rpId//from www . j a v a 2 s .com */ public void removeResourceParameter(Long rpId) { // main parameter ResourceParameter rpdb = resourceParameterRepository.findOne(rpId); if (rpdb != null) { String clientId = rpdb.getClientId(); Set<String> ids = new HashSet<String>(); Set<String> scopes = new HashSet<String>(); // aggregate all derived resource uris Collection<String> uris = findResourceURIs(rpdb).keySet(); for (String uri : uris) { Resource r = resourceRepository.findByResourceUri(uri); if (r != null) { ids.add(r.getResourceId().toString()); scopes.add(r.getResourceUri()); } } ClientDetailsEntity owner = null; // check the resource uri usages for (ClientDetailsEntity cd : clientDetailsRepository.findAll()) { if (cd.getClientId().equals(clientId)) { owner = cd; continue; } if (!Collections.disjoint(cd.getResourceIds(), ids)) { throw new IllegalArgumentException("Resource is in use by other client app."); } } // delete main and its children for (String id : ids) { resourceRepository.delete(Long.parseLong(id)); } if (owner != null) { Set<String> oldScopes = new HashSet<String>(owner.getScope()); oldScopes.removeAll(scopes); owner.setScope(StringUtils.collectionToCommaDelimitedString(oldScopes)); Set<String> oldIds = new HashSet<String>(owner.getResourceIds()); oldIds.removeAll(ids); owner.setResourceIds(StringUtils.collectionToCommaDelimitedString(oldIds)); clientDetailsRepository.save(owner); } resourceParameterRepository.delete(rpdb); } }
From source file:com.devnexus.ting.web.controller.admin.AdminController.java
@RequestMapping({ "/s/admin/reset-spring-cache" }) public String resetSpringCache(ModelMap model) { Collection<String> cacheNames = cacheManager.getCacheNames(); LOGGER.warn("Clearing caches: {}", StringUtils.collectionToCommaDelimitedString(cacheNames)); for (String cacheName : cacheNames) { cacheManager.getCache(cacheName).clear(); }//from w w w . j a va2 s. c om return "redirect:/s/admin/index"; }
From source file:com.baidu.rigel.biplatform.tesseract.isservice.search.service.impl.CallbackSearchServiceImpl.java
private SearchIndexResultSet packageResultRecords(QueryRequest query, SqlQuery sqlQuery, Map<CallbackExecutor, CallbackResponse> response) { List<String> groupby = new ArrayList<String>(query.getGroupBy().getGroups()); // Confirm meta sequence List<Entry<CallbackExecutor, CallbackResponse>> fieldValuesHolderList = new ArrayList<Entry<CallbackExecutor, CallbackResponse>>( response.size());/*from w ww.j a v a 2s.c o m*/ for (Entry<CallbackExecutor, CallbackResponse> e : response.entrySet()) { groupby.addAll(e.getKey().getCallbackMeasures()); fieldValuesHolderList.add(e); } Meta meta = new Meta(groupby.toArray(new String[0])); // default result size 500 SearchIndexResultSet result = new SearchIndexResultSet(meta, 500); // Use first response as base SEQ. Weak implementation. FIXME: WANGYUXUE. List<String> fieldValues = null; for (int index = 0; index < fieldValuesHolderList.get(0).getValue().getData().size(); index++) { fieldValues = new ArrayList<String>(groupby.size()); CallbackMeasureVaue mv = (CallbackMeasureVaue) fieldValuesHolderList.get(0).getValue().getData() .get(index); String key = mv.keySet().iterator().next(); fieldValues.addAll(Arrays.asList(StringUtils.delimitedListToStringArray(key, RESPONSE_VALUE_SPLIT))); fieldValues.addAll(mv.get(key)); for (int i = 1; i < fieldValuesHolderList.size(); i++) { CallbackMeasureVaue callbackMeasureValue = (CallbackMeasureVaue) fieldValuesHolderList.get(i) .getValue().getData().get(index); if (key.equals(callbackMeasureValue.keySet().iterator().next())) { fieldValues.addAll(callbackMeasureValue.get(key)); } else { LOGGER.error("Wrong SEQ of callback response of {} : {}", fieldValuesHolderList.get(i).getKey().group.getKey(), callbackMeasureValue); } } SearchIndexResultRecord record = new SearchIndexResultRecord(fieldValues.toArray(new Serializable[0]), StringUtils.collectionToCommaDelimitedString(fieldValues)); result.addRecord(record); } return result; }
From source file:org.mule.modules.salesforce.SalesforceModule.java
/** * Retrieves one or more records based on the specified IDs. * <p/>/*from w ww. j a v a 2s .co m*/ * {@sample.xml ../../../doc/mule-module-sfdc.xml.sample sfdc:retrieve} * * @param type Object type. The sp ecified value must be a valid object for your organization. * @param ids The ids of the objects to retrieve * @param fields The fields to return for the matching objects * @return An array of {@link SObject}s * @throws Exception */ @Processor @InvalidateConnectionOn(exception = SoapConnection.SessionTimedOutException.class) public List<Map<String, Object>> retrieve( @Placement(group = "Information", order = 1) @FriendlyName("sObject Type") String type, @Placement(group = "Ids to Retrieve") List<String> ids, @Placement(group = "Fields to Retrieve") List<String> fields) throws Exception { String fiedsCommaDelimited = StringUtils.collectionToCommaDelimitedString(fields); SObject[] sObjects = connection.retrieve(fiedsCommaDelimited, type, ids.toArray(new String[ids.size()])); List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); if (sObjects != null) { for (SObject sObject : sObjects) { result.add(sObject.toMap()); } } return result; }
From source file:org.web4thejob.web.panel.DefaultListViewPanel.java
private String getDroppableTypes() { List<String> types = new ArrayList<String>(); RenderScheme renderScheme = (RenderScheme) listbox.getAttribute(ListboxRenderer.ATTRIB_RENDER_SCHEME); if (renderScheme != null) { for (RenderElement renderElement : renderScheme.getElements()) { if (!renderElement.getPropertyPath().isMultiStep() && renderElement.getPropertyPath().getLastStep().isAssociationType()) { Class<? extends Entity> entityType = renderElement.getPropertyPath().getLastStep() .getAssociatedEntityMetadata().getEntityType(); if (isMasterDetail()) { if (!entityType.equals(getMasterType())) { types.add(entityType.getCanonicalName()); }/* w w w . j av a2 s. c o m*/ } else { types.add(entityType.getCanonicalName()); } } } } if (!types.isEmpty()) { return StringUtils.collectionToCommaDelimitedString(types); } else { return null; } }
From source file:org.web4thejob.web.panel.DefaultEntityHierarchyPanel.java
private Treeitem getNewTreeitem(EntityHierarchyItem item) { Treeitem newItem = new Treeitem(); new Treerow().setParent(newItem); Treecell cell = new Treecell(); cell.setParent(newItem.getTreerow()); cell.setStyle("white-space:nowrap;"); cell.setImage("img/" + (item instanceof EntityHierarchyParent ? "FOLDER" : "FILE") + ".png"); Html html = new Html(item.toString()); html.setStyle("margin-left: 5px;"); html.setParent(cell);/*from w w w .j a v a 2 s . c o m*/ newItem.setAttribute(ATTRIB_ITEM, item); newItem.addEventListener(Events.ON_DOUBLE_CLICK, this); newItem.addEventListener(ON_DOUBLE_CLICK_ECHO, this); if (!readOnly) { if (item instanceof EntityHierarchyParent) { Set<String> subs = CoreUtil.getSubClasses(HIERARCHY_INSTANCE.getParentType()); subs.addAll(CoreUtil.getSubClasses(HIERARCHY_INSTANCE.getChildType())); newItem.setDroppable(StringUtils.collectionToCommaDelimitedString(subs)); newItem.addEventListener(Events.ON_DROP, DefaultEntityHierarchyPanel.this); } newItem.setDraggable(item.getEntityType().getCanonicalName()); } return newItem; }
From source file:org.zenoss.zep.dao.impl.EventSummaryDaoImpl.java
@Override @TransactionalRollbackAllExceptions// ww w .j a v a 2 s . c om @Timed public int archive(List<String> uuids) throws ZepException { if (uuids.isEmpty()) { return 0; } if (this.archiveColumnNames == null) { try { this.archiveColumnNames = DaoUtils.getColumnNames(this.dataSource, TABLE_EVENT_ARCHIVE); } catch (MetaDataAccessException e) { throw new ZepException(e.getLocalizedMessage(), e); } } TypeConverter<Long> timestampConverter = databaseCompatibility.getTimestampConverter(); Map<String, Object> fields = new HashMap<String, Object>(); fields.put(COLUMN_UPDATE_TIME, timestampConverter.toDatabaseType(System.currentTimeMillis())); fields.put("_uuids", TypeConverterUtils.batchToDatabaseType(uuidConverter, uuids)); StringBuilder selectColumns = new StringBuilder(); for (Iterator<String> it = this.archiveColumnNames.iterator(); it.hasNext();) { String columnName = it.next(); if (fields.containsKey(columnName)) { selectColumns.append(':').append(columnName); } else { selectColumns.append(columnName); } if (it.hasNext()) { selectColumns.append(','); } } final long updateTime = System.currentTimeMillis(); /* signal event_summary table rows to get indexed */ this.template.update("INSERT INTO event_summary_index_queue (uuid, update_time) " + "SELECT uuid, " + String.valueOf(updateTime) + " " + "FROM event_summary" + " WHERE uuid IN (:_uuids) AND closed_status = TRUE", fields); String insertSql = String.format("INSERT INTO event_archive (%s) SELECT %s FROM event_summary" + " WHERE uuid IN (:_uuids) AND closed_status = TRUE ON DUPLICATE KEY UPDATE summary=event_summary.summary", StringUtils.collectionToCommaDelimitedString(this.archiveColumnNames), selectColumns); this.template.update(insertSql, fields); final int updated = this.template .update("DELETE FROM event_summary WHERE uuid IN (:_uuids) AND closed_status = TRUE", fields); TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { @Override public void afterCommit() { counters.addToArchivedEventCount(updated); } }); return updated; }