List of usage examples for org.eclipse.jgit.util StringUtils join
public static String join(Collection<String> parts, String separator)
From source file:com.mangosolutions.rcloud.rawgist.repository.security.CollaborationGrantedAuthority.java
@Override public String getAuthority() { return COLLABORATOR_ROLE + ":" + StringUtils.join(collaborations, ","); }
From source file:gov.osti.services.MetadataTest.java
/** * Test that PUBLISHED VALIDATIONS work. *///w ww.j av a 2 s.c om @Test public void testValidatePublished() { DOECodeMetadata m = new DOECodeMetadata(); // empty metadata should have numerous errors List<String> reasons = Metadata.validateSubmit(m); assertFalse("Validation passed?", reasons.isEmpty()); String[] validations = { "Missing Source Accessibility.", "Software title is required.", "Description is required.", "A License is required.", "At least one developer is required.", "A valid Landing Page URL is required for non-open source submissions." }; for (String message : validations) { assertTrue("Missing: " + message, reasons.contains(message)); } // fix some of these and test them m.setSoftwareTitle("A Testing Software Title"); m.setAccessibility(DOECodeMetadata.Accessibility.OS); // removes software title validation, adds OS one reasons = Metadata.validateSubmit(m); assertFalse("Still requiring title?", reasons.contains("Software title is required.")); assertFalse("Still requiring accessibility", reasons.contains("Missing Source Accessibility.")); assertTrue("Missing OS validation", reasons.contains("Repository URL is required for open source submissions.")); // test developer issues Developer d = new Developer(); List<Developer> developers = new ArrayList<>(); developers.add(d); // empty developer m.setDevelopers(developers); reasons = Metadata.validateSubmit(m); assertFalse("Developer reason still there", reasons.contains("At least one developer is required.")); assertTrue("Missing validation on name", reasons.contains("Developer missing first name.")); assertTrue("Missing validation on name", reasons.contains("Developer missing last name.")); // fix developer names, invalid email d.setFirstName("Test"); d.setLastName("Guy"); d.setEmail("testguy"); developers.clear(); developers.add(d); m.setDevelopers(developers); reasons = Metadata.validateSubmit(m); assertFalse("still missing name", reasons.contains("Developer missing first name.")); assertFalse("still missing last name", reasons.contains("Developer missing last name.")); assertTrue("Missing email validation error", reasons.contains("Developer email \"testguy\" is not valid.")); m.setRepositoryLink("nothing"); reasons = Metadata.validateSubmit(m); assertFalse("Still requiring repository link", reasons.contains("Repository URL is required for open source submissions.")); assertTrue("Repository link should be invalid", reasons.contains("Repository URL is not a valid repository.")); // test the "Other" requirement List<String> licenses = Arrays.asList(new String[] { "Other" }); m.setLicenses(licenses); reasons = Metadata.validateSubmit(m); assertTrue("Should require a proprietary URL", reasons.contains("Proprietary License URL is required.")); // create something that will pass validations m.setAccessibility(DOECodeMetadata.Accessibility.CS); m.setRepositoryLink(""); m.setLandingPage("http://code.google.com/"); d.setEmail("testguy@testing.com"); developers.clear(); developers.add(d); m.setDevelopers(developers); m.setProprietaryUrl("http://mylicense.com/terms.html"); m.setDescription("This is a testing description."); reasons = Metadata.validateSubmit(m); assertTrue("Should be no more errors: " + StringUtils.join(reasons, ", "), reasons.isEmpty()); }
From source file:org.apache.oozie.command.PurgeXCommand.java
License:Apache License
/** * Purge the workflows in REVERSE order in batches of size 'limit' (this must be done in reverse order so that children are * purged before their parents)/* w w w. j ava 2s . c o m*/ * * @param wfs List of workflows to purge * @throws JPAExecutorException If a JPA executor has a problem */ private void purgeWorkflows(List<String> wfs) throws JPAExecutorException { wfDel += wfs.size(); //To delete sub-workflows before deleting parent workflows Collections.reverse(wfs); for (int startIndex = 0; startIndex < wfs.size();) { int endIndex = (startIndex + limit < wfs.size()) ? (startIndex + limit) : wfs.size(); List<String> wfsForDelete = wfs.subList(startIndex, endIndex); LOG.debug("Deleting workflows: " + StringUtils.join(wfsForDelete, ",")); jpaService.execute(new WorkflowJobsDeleteJPAExecutor(wfsForDelete)); startIndex = endIndex; } }
From source file:org.apache.oozie.command.PurgeXCommand.java
License:Apache License
/** * Purge coordActions of long running coordinators and purge them * * @param coordActions List of coordActions to purge * @throws JPAExecutorException If a JPA executor has a problem *//*from w ww . j a va 2 s . co m*/ private void purgeCoordActions(List<String> coordActions) throws JPAExecutorException { coordActionDel = coordActions.size(); for (int startIndex = 0; startIndex < coordActions.size();) { int endIndex = (startIndex + limit < coordActions.size()) ? (startIndex + limit) : coordActions.size(); List<String> coordActionsForDelete = coordActions.subList(startIndex, endIndex); LOG.debug("Deleting coordinator actions: " + StringUtils.join(coordActionsForDelete, ",")); jpaService.execute(new CoordActionsDeleteJPAExecutor(coordActionsForDelete)); startIndex = endIndex; } }
From source file:org.apache.oozie.command.PurgeXCommand.java
License:Apache License
/** * Purge the coordinators in SOME order in batches of size 'limit' (its in reverse order only for convenience) * * @param coords List of coordinators to purge * @throws JPAExecutorException If a JPA executor has a problem */// ww w.j a va 2 s . c o m private void purgeCoordinators(List<String> coords) throws JPAExecutorException { coordDel += coords.size(); for (int startIndex = 0; startIndex < coords.size();) { int endIndex = (startIndex + limit < coords.size()) ? (startIndex + limit) : coords.size(); List<String> coordsForDelete = coords.subList(startIndex, endIndex); LOG.debug("Deleting coordinators: " + StringUtils.join(coordsForDelete, ",")); jpaService.execute(new CoordJobsDeleteJPAExecutor(coordsForDelete)); startIndex = endIndex; } }
From source file:org.apache.oozie.command.PurgeXCommand.java
License:Apache License
/** * Purge the bundles in SOME order in batches of size 'limit' (its in reverse order only for convenience) * * @param bundles List of bundles to purge * @throws JPAExecutorException If a JPA executor has a problem *//* w ww . j a v a 2 s . co m*/ private void purgeBundles(List<String> bundles) throws JPAExecutorException { bundleDel += bundles.size(); for (int startIndex = 0; startIndex < bundles.size();) { int endIndex = (startIndex + limit < bundles.size()) ? (startIndex + limit) : bundles.size(); Collection<String> bundlesForDelete = bundles.subList(startIndex, endIndex); LOG.debug("Deleting bundles: " + StringUtils.join(bundlesForDelete, ",")); jpaService.execute(new BundleJobsDeleteJPAExecutor(bundlesForDelete)); startIndex = endIndex; } }
From source file:org.eclipse.egit.ui.view.synchronize.AbstractSynchronizeViewTest.java
License:Open Source License
private SWTBotTreeItem getTreeItemContainingText(SWTBotTreeItem[] items, String text) { List<String> existingItems = new ArrayList<String>(); for (SWTBotTreeItem item : items) { if (item.getText().contains(text)) return item; existingItems.add(item.getText()); }/*from w ww .ja v a2 s .c o m*/ throw new WidgetNotFoundException("Tree item element containing text \"" + text + "\" was not found. Existing tree items:\n" + StringUtils.join(existingItems, "\n")); }
From source file:uk.ac.cam.cl.dtg.segue.comm.EmailManager.java
License:Apache License
/** * helper function to map a value to an email friendly string * * @param o - object to map/*from ww w .ja va 2 s.com*/ * @return more sensible string representation or null */ private String emailTokenValueMapper(final Object o) { String valueToStore; if (o == null) { valueToStore = ""; } else if (o instanceof String) { valueToStore = (String) o; } else if (o instanceof Date) { valueToStore = FULL_DATE_FORMAT.format((Date) o); } else if (o instanceof Number || o instanceof Boolean) { valueToStore = o.toString(); } else if (o instanceof Enum) { valueToStore = ((Enum) o).name(); } else if (o instanceof ExternalReference) { ExternalReference er = (ExternalReference) o; valueToStore = String.format("<a href='%s'>%s</a>", er.getUrl(), er.getTitle()) + "\n"; } else if (o instanceof Collection) { List<String> sl = Lists.newArrayList(); for (Object i : (Collection) o) { String s = this.emailTokenValueMapper(i); if (s != null) { sl.add(s); } } valueToStore = StringUtils.join(sl, ","); } else { return null; } return valueToStore; }