List of usage examples for org.springframework.util StringUtils collectionToCommaDelimitedString
public static String collectionToCommaDelimitedString(@Nullable Collection<?> coll)
From source file:com.phoenixnap.oss.ramlapisync.data.ApiActionMetadata.java
public String toString() { return "Method " + getName() + " Verb [" + actionType + "] Url [" + getUrl() + "] \nConsumes [" + getConsumes() + "] Produces [" + getProduces() + "] with Schema [" + null + "] \nPath Vars [" + StringUtils.collectionToCommaDelimitedString(getPathVariables()) + "] \nRequest Params [" + StringUtils.collectionToCommaDelimitedString(getRequestParameters()) + "] \nRequest Headers [" + StringUtils.collectionToCommaDelimitedString(getRequestHeaders()) + "] \n"; }
From source file:de.dlopes.stocks.facilitator.services.YahooFinanceComIndexHTMLExtractorTest.java
@Test public void testGetYahooSymbols() { List<String> isins = _classUnderTest.getFinanceData(URL); assertEquals("unexpected number of stocks", DAX_TEST_YSYM.size(), isins.size()); String strArr = "[" + StringUtils.collectionToCommaDelimitedString(isins) + "]"; for (String isin : DAX_TEST_YSYM) { // assert all expected values are found in the result assertTrue("ISIN " + isin + " is not included in " + strArr, CollectionUtils.contains(isins.iterator(), isin)); }/*from w w w .jav a 2 s.c om*/ }
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:de.dlopes.stocks.facilitator.services.FinanzenNetIndexHTMLExtractorTest.java
@Test public void testGetISINs() { List<String> isins = _classUnderTest.getFinanceData(URL); assertEquals("unexpected number of stocks", DAX_TEST_ISINS.size(), isins.size()); String strArr = "[" + StringUtils.collectionToCommaDelimitedString(isins) + "]"; for (String isin : DAX_TEST_ISINS) { // assert all expected values are found in the result assertTrue("ISIN " + isin + " is not included in " + strArr, CollectionUtils.contains(isins.iterator(), isin)); }//from www.j a va 2 s . c o m }
From source file:org.esco.portlet.changeetab.mvc.controller.ChangeEtablissementController.java
@ActionMapping("changeEtab") public void changeEtab(@ModelAttribute("command") final ChangeEtabCommand changeEtabCommand, final ActionRequest request, final ActionResponse response) throws Exception { final String selectedEtabCode = changeEtabCommand.getSelectedEtabCode(); Assert.hasText(selectedEtabCode, "No Etablissement code selected !"); ChangeEtablissementController.LOG.debug("Selected Etab code to change: [{}]", selectedEtabCode); final Collection<String> changeableEtabCodes = this.userInfoService.getChangeableEtabCodes(request); if (!changeableEtabCodes.contains(selectedEtabCode)) { // If selected Id is not an allowed Id ChangeEtablissementController.LOG .warn("Attempt to switch to a not allowed Etablissement with code: [{}] !", selectedEtabCode); ChangeEtablissementController.LOG.debug("Allowed Etablissements are: [{}]", StringUtils.collectionToCommaDelimitedString(changeableEtabCodes)); } else {//from w ww .j a v a 2s. c o m // Process the etablissement swap. final String userId = this.userInfoService.getUserId(request); if (StringUtils.hasText(userId)) { final Etablissement selectedEtab = this.etablissementService .retrieveEtablissementsByCode(selectedEtabCode); this.userService.changeCurrentEtablissement(userId, selectedEtab); if (this.redirectAfterChange) { request.getPortalContext(); response.sendRedirect(this.logoutUrlRedirect); } } else { ChangeEtablissementController.LOG .warn("No user Id found in request ! Cannot process the etablishment swapping !"); } } changeEtabCommand.reset(); }
From source file:com.vivastream.security.oauth2.provider.DynamoDBClientDetailsService.java
public void saveOrUpdateClient(ClientDetails clientDetails) { Map<String, AttributeValueUpdate> updates = new HashMap<String, AttributeValueUpdate>(); DynamoDBUtils.nullSafeUpdateS(updates, schema.getColumnResourceIds(), StringUtils.collectionToCommaDelimitedString(clientDetails.getResourceIds())); DynamoDBUtils.nullSafeUpdateS(updates, schema.getColumnScopes(), StringUtils.collectionToCommaDelimitedString(clientDetails.getScope())); DynamoDBUtils.nullSafeUpdateS(updates, schema.getColumnAuthorizedGrantTypes(), StringUtils.collectionToCommaDelimitedString(clientDetails.getAuthorizedGrantTypes())); DynamoDBUtils.nullSafeUpdateS(updates, schema.getColumnAuthorities(), StringUtils.collectionToCommaDelimitedString( AuthorityUtils.authorityListToSet(clientDetails.getAuthorities()))); DynamoDBUtils.nullSafeUpdateS(updates, schema.getColumnRegisteredRedirectUris(), StringUtils.collectionToCommaDelimitedString(clientDetails.getRegisteredRedirectUri())); DynamoDBUtils.nullSafeUpdateS(updates, schema.getColumnClientSecret(), clientDetails.getClientSecret()); enrichUpdates(updates, clientDetails); client.updateItem(schema.getTableName(), Collections.singletonMap(schema.getColumnClientId(), new AttributeValue(clientDetails.getClientId())), updates); }
From source file:com.googlecode.janrain4j.api.engage.EngagePartnerServiceImpl.java
public void setProviderPermissions(String apiKey, String providerName, Collection<String> providerPermissions) throws EngageFailureException, ErrorResponeException { Map<String, String> params = new HashMap<String, String>(); params.put(API_KEY_PARAM, apiKey);/*from w ww . java 2s.com*/ params.put(PROVIDER_PARAM, providerName); params.put(PERMISSIONS_PARAM, StringUtils.collectionToCommaDelimitedString(providerPermissions)); apiCall(SET_PROVIDER_PERMISSIONS_METHOD, params); }
From source file:com.googlecode.flyway.core.validation.DbValidator.java
/** * Validate the checksum of all existing sql migration in the metadata table with the checksum of the sql migrations * in the classpath//w w w . j a va 2s . c om * * @param resolvedMigrations All migrations available on the classpath, sorted by version, newest first. * @return description of validation error or NULL if no validation error was found */ public String validate(List<Migration> resolvedMigrations) { if (ValidationMode.NONE.equals(validationMode)) { return null; } LOG.debug(String.format("Validating (mode %s) migrations ...", validationMode)); StopWatch stopWatch = new StopWatch(); stopWatch.start(); final List<MetaDataTableRow> appliedMigrations = new ArrayList<MetaDataTableRow>( metaDataTable.allAppliedMigrations()); if (appliedMigrations.isEmpty()) { LOG.info("No migrations applied yet. No validation necessary."); return null; } List<Migration> migrations = new ArrayList<Migration>(resolvedMigrations); // migrations now with newest last Collections.reverse(migrations); final MetaDataTableRow firstAppliedMigration = appliedMigrations.get(0); if (MigrationType.INIT.equals(firstAppliedMigration.getMigrationType())) { // if first migration is INIT, just check checksum of following migrations final SchemaVersion initVersion = firstAppliedMigration.getVersion(); appliedMigrations.remove(firstAppliedMigration); Iterator<Migration> iterator = migrations.iterator(); while (iterator.hasNext()) { Migration migration = iterator.next(); if (migration.getVersion().compareTo(initVersion) <= 0) { iterator.remove(); } } } if (appliedMigrations.size() > migrations.size()) { List<SchemaVersion> schemaVersions = new ArrayList<SchemaVersion>(); for (MetaDataTableRow metaDataTableRow : appliedMigrations) { schemaVersions.add(metaDataTableRow.getVersion()); } for (Migration migration : migrations) { schemaVersions.remove(migration.getVersion()); } String diff = StringUtils.collectionToCommaDelimitedString(schemaVersions); return String.format( "More applied migrations than classpath migrations: DB=%s, Classpath=%s, Missing migrations=(%s)", appliedMigrations.size(), migrations.size(), diff); } for (int i = 0; i < appliedMigrations.size(); i++) { MetaDataTableRow appliedMigration = appliedMigrations.get(i); //Migrations are sorted in the opposite order: newest first. Migration classpathMigration = migrations.get(i); if (!appliedMigration.getVersion().equals(classpathMigration.getVersion())) { return String.format("Version mismatch for migration %s: DB=%s, Classpath=%s", appliedMigration.getScript(), appliedMigration.getVersion(), classpathMigration.getVersion()); } if (!appliedMigration.getMigrationType().equals(classpathMigration.getMigrationType())) { return String.format("Migration Type mismatch for migration %s: DB=%s, Classpath=%s", appliedMigration.getScript(), appliedMigration.getMigrationType(), classpathMigration.getMigrationType()); } final Integer appliedChecksum = appliedMigration.getChecksum(); final Integer classpathChecksum = classpathMigration.getChecksum(); if (!ObjectUtils.nullSafeEquals(appliedChecksum, classpathChecksum)) { return String.format("Checksum mismatch for migration %s: DB=%s, Classpath=%s", appliedMigration.getScript(), appliedChecksum, classpathMigration.getChecksum()); } } stopWatch.stop(); if (appliedMigrations.size() == 1) { LOG.info(String.format("Validated 1 migration (mode: %s) (execution time %s)", validationMode, TimeFormat.format(stopWatch.getTotalTimeMillis()))); } else { LOG.info(String.format("Validated %d migrations (mode: %s) (execution time %s)", appliedMigrations.size(), validationMode, TimeFormat.format(stopWatch.getTotalTimeMillis()))); } return null; }
From source file:com.vivastream.security.oauth2.provider.DynamoDBUserDetailsManager.java
@Override public void updateUser(UserDetails user) { Map<String, AttributeValueUpdate> updates = new HashMap<String, AttributeValueUpdate>(); DynamoDBUtils.nullSafeUpdateS(updates, schema.getColumnPassword(), getPasswordToPersist(user.getPassword(), user)); DynamoDBUtils.nullSafeUpdateS(updates, schema.getColumnAuthorities(), StringUtils .collectionToCommaDelimitedString(AuthorityUtils.authorityListToSet(user.getAuthorities()))); enrichUpdates(updates, user);/*from w ww . j av a 2 s . c o m*/ client.updateItem(schema.getTableName(), Collections.singletonMap(schema.getColumnUsername(), new AttributeValue(user.getUsername())), updates); }