List of usage examples for java.lang String join
public static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements)
From source file:com.streamsets.pipeline.stage.origin.jdbc.cdc.oracle.TestOracleCDCSource.java
@Test public void testGetListOfSchemasAndTablesBig() { List<String> listOfTables = new ArrayList<>(1010); List<SchemaAndTable> schemaAndTables = new ArrayList<>(1010); for (int i = 0; i < 1010; i++) { String tableName = RandomStringUtils.randomAlphanumeric(5); listOfTables.add(Utils.format("'{}'", tableName)); schemaAndTables.add(new SchemaAndTable("SYS", tableName)); }//ww w .ja v a2 s . c o m OracleCDCConfigBean configBean = new OracleCDCConfigBean(); configBean.dictionary = DictionaryValues.DICT_FROM_ONLINE_CATALOG; OracleCDCSource source = new OracleCDCSource(null, configBean); String actual = source.getListOfSchemasAndTables(schemaAndTables); String expected = Utils.format("( (SEG_OWNER='SYS' AND (TABLE_NAME IN ({}) OR TABLE_NAME IN ({}))) )", String.join(",", listOfTables.subList(0, 1000)), String.join(",", listOfTables.subList(1000, 1010))); Assert.assertEquals(expected, actual); }
From source file:io.bosh.client.jobs.SpringJobs.java
@Override public Observable<InputStream> fetchLogs(FetchLogsRequest request) { return getEntity(Void.class, builder -> builder.pathSegment("deployments", request.getDeploymentName()) .pathSegment("jobs", request.getJobName(), String.valueOf(request.getJobIndex())) .pathSegment("logs").queryParam("type", request.getLogType().getType()) .queryParam("filters", String.join(",", request.getFilters()))) .flatMap(response -> tasks.trackToCompletion(getTaskId(response))) .flatMap(task -> getGzip( builder -> builder.pathSegment("resources", task.getResult()))) .map(file -> createInputStream(file)); }
From source file:io.klerch.alexa.tellask.model.wrapper.AlexaSpeechletServlet.java
/** * When this servlet is created it obtains supported application ids from overridden getter * or AlexaApplication-annotation and joins this set of ids with supported application ids * configured in system property 'com.amazon.speech.speechlet.servlet.supportedApplicationIds' */// w w w. ja va2s. co m public AlexaSpeechletServlet() { super(); final Set<String> customSupportedApplicationIds = getSupportedApplicationIds(); if (!customSupportedApplicationIds.isEmpty()) { // add supported application ids to system variable final String systemSupportedApplicationIds = System .getProperty(Sdk.SUPPORTED_APPLICATION_IDS_SYSTEM_PROPERTY); if (systemSupportedApplicationIds != null) { customSupportedApplicationIds.addAll(Arrays.asList(systemSupportedApplicationIds.split(","))); } // update system property with appended application ids provided by this servlet System.setProperty(Sdk.SUPPORTED_APPLICATION_IDS_SYSTEM_PROPERTY, String.join(",", customSupportedApplicationIds)); } }
From source file:com.opopov.cloud.image.service.Validator.java
public void validateConfig(ImageStitchingConfiguration config) throws InvalidImageConfigException { if (config.getUrlList().size() != config.getRowCount() * config.getColumnCount()) { throw new InvalidImageConfigException( String.format("The list of the URLs must contain %d elements, but it contains %d elements", config.getRowCount() * config.getColumnCount(), config.getUrlList().size())); }//from w ww. j ava 2 s .co m if (config.getOutputFormat() == null || !supportedImageWriteFormats.contains(config.getOutputFormat())) { throw new InvalidImageConfigException("The specified format " + config.getOutputFormat() + " is invalid" + " please, specify one of the supported formats - " + String.join(", ", supportedImageWriteFormats)); } }
From source file:com.orange.clara.cloud.servicedbdumper.dbdumper.core.AbstractCoreDbAction.java
private ProcessBuilder generateProcessBuilder(String[] commandLine) { if (this.showCommandLine) { logger.info("Running command line: " + String.join(" ", commandLine)); }//from ww w . j a va2 s . co m ProcessBuilder pb = new ProcessBuilder(commandLine); return pb; }
From source file:com.netflix.spinnaker.igor.docker.DockerRegistryKeyFactory.java
DockerRegistryV1Key parseV1Key(String keyStr, boolean includeRepository) throws DockerRegistryKeyFormatException { List<String> splits = SPLITTER.splitToList(keyStr); try {/*from w ww .j av a 2s . c om*/ String prefix = splits.get(0); verify(prefix.equals(prefix()), "Expected prefix '%s', found '%s'", prefix(), prefix); String id = splits.get(1); verify(ID.equals(id), "Expected ID '%s', found '%s'", ID, id); String account = splits.get(2); verify(!account.isEmpty(), "Empty account string"); String registry = splits.get(3); verify(!registry.isEmpty(), "Empty registry string"); // the repository URL (typically without "http://" // it may contain ':' (e.g. port number), so it may be split across multiple tokens String repository = null; if (includeRepository) { List<String> repoSplits = splits.subList(4, splits.size() - 1); repository = String.join(":", repoSplits); } String tag = splits.get(splits.size() - 1); verify(!tag.isEmpty(), "Empty registry string"); return new DockerRegistryV1Key(prefix, id, account, registry, repository, tag); } catch (IndexOutOfBoundsException | VerifyException e) { throw new DockerRegistryKeyFormatException(String.format("Could not parse '%s' as a v1 key", keyStr), e); } }
From source file:com.thoughtworks.go.helper.SvnRemoteRepository.java
public void addUser(String username, String password) throws Exception { enableAuthentication();// w ww .j a v a2 s. com File passwdFile = new File(repo.projectRepositoryRoot(), "conf/passwd"); String passwd = String.join(FileUtil.lineSeparator(), Files.readAllLines(passwdFile.toPath())); if (!(passwd.contains("\n[users]\n"))) { passwd = passwd + "\n[users]\n"; } passwd = passwd + String.format("\n%s = %s\n", username, password); FileUtils.writeStringToFile(passwdFile, passwd, UTF_8); }
From source file:org.jboss.as.test.manualmode.mgmt.elytron.HttpMgmtInterfaceElytronAuthenticationTestCase.java
public static void prepareServerConfiguration() throws Exception { tempFolder = File.createTempFile( "ely-" + HttpMgmtInterfaceElytronAuthenticationTestCase.class.getSimpleName(), "", null); if (tempFolder.exists()) { tempFolder.delete();/*from w w w . j av a2 s .c om*/ tempFolder.mkdir(); } String fsRealmPath = tempFolder.getAbsolutePath() + File.separator + "fs-realm-users"; try (CLIWrapper cli = new CLIWrapper(true)) { final String levelStr = ""; final List<String> roles = new ArrayList<>(); cli.sendLine(String.format("/subsystem=elytron/filesystem-realm=%s:add(path=\"%s\", %s)", MANAGEMENT_FILESYSTEM_NAME, escapePath(fsRealmPath), levelStr)); cli.sendLine(String.format("/subsystem=elytron/filesystem-realm=%s:add-identity(identity=%s)", MANAGEMENT_FILESYSTEM_NAME, USER)); cli.sendLine(String.format( "/subsystem=elytron/filesystem-realm=%s:set-password(identity=%s, clear={password=\"%s\"})", MANAGEMENT_FILESYSTEM_NAME, USER, CORRECT_PASSWORD)); if (!roles.isEmpty()) { cli.sendLine(String.format( "/subsystem=elytron/filesystem-realm=%s:add-identity-attribute=%s:add-attribute(name=groups, value=[%s])", MANAGEMENT_FILESYSTEM_NAME, USER, String.join(",", roles))); } cli.sendLine(String.format( "/subsystem=elytron/security-domain=%1$s:add(realms=[{realm=%1$s,role-decoder=groups-to-roles},{realm=local,role-mapper=super-user-mapper}],default-realm=%1$s,permission-mapper=default-permission-mapper)", MANAGEMENT_FILESYSTEM_NAME)); cli.sendLine(String.format( "/subsystem=elytron/http-authentication-factory=%1$s:add(http-server-mechanism-factory=%2$s,security-domain=%1$s," + "mechanism-configurations=[{mechanism-name=BASIC,mechanism-realm-configurations=[{realm-name=\"%1$s\"}]}])", MANAGEMENT_FILESYSTEM_NAME, PREDEFINED_HTTP_SERVER_MECHANISM_FACTORY)); cli.sendLine(String.format( "/core-service=management/management-interface=http-interface:write-attribute(name=http-authentication-factory,value=%s)", MANAGEMENT_FILESYSTEM_NAME)); cli.sendLine("reload"); } }
From source file:net.sf.jabref.external.RegExpFileSearch.java
/** * Method for searching for files using regexp. A list of extensions and directories can be * given.//w ww. ja v a 2s. com * @param entry The entry to search for. * @param extensions The extensions that are acceptable. * @param directories The root directories to search. * @param regularExpression The expression deciding which names are acceptable. * @return A list of files paths matching the given criteria. */ private static List<File> findFiles(BibEntry entry, Collection<String> extensions, Collection<File> directories, String regularExpression) { String extensionRegExp = '(' + String.join("|", extensions) + ')'; return findFile(entry, directories, regularExpression, extensionRegExp); }
From source file:mtsar.api.csv.TaskCSV.java
public static void write(Collection<Task> tasks, OutputStream output) throws IOException { try (final Writer writer = new OutputStreamWriter(output, StandardCharsets.UTF_8)) { final Iterable<String[]> iterable = () -> tasks.stream().sorted(ORDER) .map(task -> new String[] { Integer.toString(task.getId()), // id task.getStage(), // stage Long.toString(task.getDateTime().toInstant().getEpochSecond()), // datetime String.join("|", task.getTags()), // tags task.getType(), // type task.getDescription(), // description String.join("|", task.getAnswers()), // answers }).iterator();//from w ww. j a v a 2 s. c o m FORMAT.withHeader(HEADER).print(writer).printRecords(iterable); } }