List of usage examples for org.apache.commons.lang StringUtils join
public static String join(Collection<?> collection, String separator)
Joins the elements of the provided Collection
into a single String containing the provided elements.
From source file:com.netflix.explorers.jersey.ViewableResource.java
public Response redirect(String resource) { try {/* www . ja v a 2s . c o m*/ String redirect = StringUtils.join(Arrays.asList(uriInfo.getRequestUri().toString(), resource), "/"); return Response.temporaryRedirect(new URI(redirect)).build(); } catch (URISyntaxException e) { return Response.serverError().build(); } }
From source file:com.cognifide.cq.cqsm.foundation.actions.removeuser.RemoveUser.java
private ActionResult process(final Context context, boolean execute) { ActionResult actionResult = new ActionResult(); List<String> errors = new ArrayList<>(); LOGGER.info(String.format("Removing users with ids = %s", StringUtils.join(ids, ", "))); for (String id : ids) { try {//from w w w .j av a2s . co m User user = AuthorizablesUtils.getUserIfExists(context, id); if (user != null) { AuthorizablesUtils.markAuthorizableAsRemoved(context, user); if (execute) { AuthorizablesUtils.removeUser(context, user); } actionResult.logMessage("User with id: " + id + " removed"); } } catch (RepositoryException | ActionExecutionException e) { errors.add(MessagingUtils.createMessage(e)); } } if (!errors.isEmpty()) { for (String error : errors) { actionResult.logError(error); } actionResult.logError("Execution interrupted"); } return actionResult; }
From source file:ezbake.data.common.TokenUtils.java
/** * Extracts authorizations from passed in token. * * @param userToken passed in token./*from w w w. j a v a 2 s. co m*/ * @return comma-delimited string of authorizations. */ public static String getAuths(EzSecurityToken userToken) { return userToken.isSetAuthorizations() ? StringUtils.join(userToken.getAuthorizations().getFormalAuthorizations(), ",") : "N/A - No auths set"; }
From source file:com.hp.alm.ali.idea.filter.MultipleItemsChooser.java
@Override public void show() { ArrayList<Object> selected = new ArrayList<Object>(); if (value != null) { Collections.addAll(selected, value.split(";")); }/*from w ww. ja va 2 s .com*/ MultipleItemsDialog<Object, ComboItem> chooser = new MultipleItemsDialog<Object, ComboItem>(project, "Select " + title, new MultipleItemsDialogModel<Object, ComboItem>(title, multiple, items, selected, translator)); chooser.setVisible(true); if (chooser.isOk()) { value = StringUtils.join(selected.toArray(), ";"); } }
From source file:de.tudarmstadt.ukp.dkpro.argumentation.sequence.feature.lexical.LemmaNGramUtils.java
public static FrequencyDistribution<String> getAnnotationNGrams(JCas jcas, Annotation focusAnnotation, boolean lowerCaseNGrams, boolean filterPartialMatches, int minN, int maxN, Set<String> stopwords) { FrequencyDistribution<String> result = new FrequencyDistribution<>(); // If the focusAnnotation contains sentence annotations, extract the n-grams sentence-wise // if not, extract them from all tokens in the focusAnnotation if (JCasUtil.selectCovered(jcas, Sentence.class, focusAnnotation).size() > 0) { for (Sentence s : selectCovered(jcas, Sentence.class, focusAnnotation)) { for (List<String> nGram : new NGramStringListIterable(toText(selectCovered(tokenClass, s)), minN, maxN)) {/*from w w w .j a v a2 s .c o m*/ if (lowerCaseNGrams) { nGram = lower(nGram); } if (passesNgramFilter(nGram, stopwords, filterPartialMatches)) { String nGramString = StringUtils.join(nGram, N_GRAM_GLUE); result.inc(nGramString); } } } } // FIXME the focus annotation branch doesn't make much sense else { for (List<String> nGram : new NGramStringListIterable( toText(selectCovered(tokenClass, focusAnnotation)), minN, maxN)) { if (lowerCaseNGrams) { nGram = lower(nGram); } if (passesNgramFilter(nGram, stopwords, filterPartialMatches)) { String nGramString = StringUtils.join(nGram, N_GRAM_GLUE); result.inc(nGramString); } } } return result; }
From source file:jenkins.slaves.DeprecatedAgentProtocolMonitor.java
@CheckForNull public static String getDeprecatedProtocolsString() { final List<String> deprecatedProtocols = new ArrayList<>(); final Set<String> agentProtocols = Jenkins.getInstance().getAgentProtocols(); for (String name : agentProtocols) { AgentProtocol pr = AgentProtocol.of(name); if (pr != null && pr.isDeprecated()) { deprecatedProtocols.add(name); }//from w w w . j a v a2 s.c o m } if (deprecatedProtocols.isEmpty()) { return null; } return StringUtils.join(deprecatedProtocols, ','); }
From source file:com.cognifide.cq.cqsm.foundation.actions.removegroup.RemoveGroup.java
private ActionResult process(final Context context, boolean execute) { List<String> errors = new ArrayList<>(); ActionResult actionResult = new ActionResult(); LOGGER.info(String.format("Removing groups with ids = %s", StringUtils.join(ids, ", "))); for (String id : ids) { try {//from w w w . ja v a 2 s.c o m Group group = AuthorizablesUtils.getGroupIfExists(context, id); if (group != null) { AuthorizablesUtils.markAuthorizableAsRemoved(context, group); if (execute) { AuthorizablesUtils.removeGroup(context, group); } actionResult.logMessage("Group with id: " + id + " removed"); } } catch (RepositoryException | ActionExecutionException e) { errors.add(MessagingUtils.createMessage(e)); } } if (!errors.isEmpty()) { for (String error : errors) { actionResult.logError(error); } actionResult.logError("Execution interrupted"); } return actionResult; }
From source file:com.collective.celos.ci.mode.test.CelosSchedulerWorker.java
private void startScheduler(TestCase testCase, Set<WorkflowID> workflowList, ScheduledTime actualTime, ScheduledTime endTime) throws Exception { System.out/* w w w. j a v a2s . co m*/ .println(testCase.getName() + ": Starting scheduler for: " + StringUtils.join(workflowList, ", ")); client.iterateScheduler(actualTime, testCase.getTargetWorkflows()); while (!actualTime.getDateTime().isAfter(endTime.getDateTime())) { String workflowStatuses = StringUtils.join(getWorkflowStatusesInfo(workflowList, actualTime), " "); if (!workflowStatuses.trim().isEmpty()) { System.out.println(testCase.getName() + ": Workflow statuses: " + workflowStatuses); } if (!isThereAnyRunningWorkflows(workflowList, actualTime)) { actualTime = new ScheduledTime(actualTime.getDateTime().plusHours(1)); } else { Thread.sleep(2000); } client.iterateScheduler(actualTime, testCase.getTargetWorkflows()); } }
From source file:de.tudarmstadt.ukp.dkpro.keyphrases.core.wrapper.CooccurrenceGraphExtractorTest.java
@Ignore @Test//from w w w . ja v a 2 s.c o m public void cooccurrenceGraphExtractorTest() throws Exception { String testDoc = FileUtils.readFileToString(new File("src/test/resources/keyphrase/extractor/test.txt")); KeyphraseExtractor textRank = CooccurrenceGraphExtractor.createTextRankExtractor(); System.out.println(textRank.getConfigurationDetails()); for (Keyphrase keyphrase : getTopRankedUniqueKeyphrases(textRank.extract(testDoc), 5)) { System.out.println(keyphrase.getKeyphrase()); } String textrankKeyphrases = StringUtils .join(keyphraseList2StringList(getTopRankedUniqueKeyphrases(textRank.extract(testDoc), 5)), ","); assertEquals("variable temporal rates,temporal rates,different temporal rates," + "video object-based rate allocation,multiple video objects", textrankKeyphrases); CooccurrenceGraphExtractor cooccExtractor = new CooccurrenceGraphExtractor(); cooccExtractor.setMinKeyphraseLength(2); cooccExtractor.setCandidate(new Candidate(CandidateType.Token, PosType.N)); List<Keyphrase> keyphrases = cooccExtractor.extract(testDoc); assertEquals(28, keyphrases.size()); List<Keyphrase> top5Keyphrases = getTopRankedUniqueKeyphrases(keyphrases, 5); assertEquals(5, top5Keyphrases.size()); String cooccKeyphrases = StringUtils.join(keyphraseList2StringList(top5Keyphrases), ","); for (Keyphrase keyphrase : top5Keyphrases) { System.out.println(keyphrase); } System.out.println(cooccKeyphrases); assertEquals("rate allocation,target bit rate,algorithm deals,bit allocation,object level", cooccKeyphrases); }
From source file:com.titankingdoms.dev.titanchat.command.defaults.WhitelistCommand.java
@Override public void execute(CommandSender sender, Channel channel, String[] args) { if (channel == null) { sendMessage(sender, "&4Channel not defined"); return;//from ww w . ja v a 2 s. c o m } if (!channel.getConfig().getBoolean("whitelist", false)) { sendMessage(sender, "&4Whitelist is not enabled for the channel"); return; } if (args[0].equalsIgnoreCase("list")) { String list = StringUtils.join(channel.getWhitelist(), ", "); sendMessage(sender, "&6" + channel.getName() + " Whitelist: " + list); return; } else { if (args.length < 2) { sendMessage(sender, "&4Invalid argument length"); String usage = "/titanchat [@<channel>] whitelist " + getUsage(); sendMessage(sender, "&6" + usage); return; } } Participant participant = plugin.getParticipantManager().getParticipant(args[1]); if (args[0].equalsIgnoreCase("add")) { if (channel.getWhitelist().contains(participant.getName())) { sendMessage(sender, participant.getDisplayName() + " &4is already on the whitelist"); return; } channel.getWhitelist().add(participant.getName()); participant.notice("&6You have been added to the whitelist of " + channel.getName()); if (args.length > 2) { String reason = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ").trim(); participant.notice("&6Reason: " + reason); } if (!channel.isLinked(plugin.getParticipantManager().getParticipant(sender))) sendMessage(sender, participant.getDisplayName() + " &6has been added to the whitelist"); channel.notice(participant.getDisplayName() + " &6has been added to the whitelist"); } else if (args[0].equalsIgnoreCase("remove")) { if (!channel.getWhitelist().contains(participant.getName())) { sendMessage(sender, participant.getDisplayName() + " &4is not on the whitelist"); return; } channel.getWhitelist().remove(participant.getName()); participant.notice("&4You have been removed from the whitelisted of " + channel.getName()); if (args.length > 2) { String reason = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ").trim(); participant.notice("&4Reason: " + reason); } if (!channel.isLinked(plugin.getParticipantManager().getParticipant(sender))) sendMessage(sender, participant.getDisplayName() + " &6has been removed from the whitelist"); channel.notice(participant.getDisplayName() + " &6has been removed from the whitelist"); } else { sendMessage(sender, "&4Incorrect usage: /titanchat [@<channel>] whitelist " + getUsage()); } }