List of usage examples for org.apache.commons.lang3 StringUtils substringAfterLast
public static String substringAfterLast(final String str, final String separator)
Gets the substring after the last occurrence of a separator.
From source file:org.apereo.openlrs.model.event.EventConversionService.java
private Map<String, String> parseObjectXApi(Statement xapi) { Map<String, String> objectIdandType = null; XApiObject xApiObject = xapi.getObject(); if (xApiObject != null) { objectIdandType = new HashMap<String, String>(); XApiObjectDefinition xApiObjectDefinition = xApiObject.getDefinition(); if (xApiObjectDefinition != null) { String type = xApiObjectDefinition.getType(); if (StringUtils.isNotBlank(type)) { objectIdandType.put("TYPE", StringUtils.substringAfterLast(type, "/")); }// w w w .j a v a 2 s . co m } String id = xApiObject.getId(); if (StringUtils.isNotBlank(id)) { objectIdandType.put("ID", StringUtils.substringAfterLast(id, "/")); } } return objectIdandType; }
From source file:org.apereo.openlrs.repositories.statements.ElasticSearchStatementRepository.java
private StatementMetadata extractMetadata(Statement statement) { StatementMetadata statementMetadata = new StatementMetadata(); statementMetadata.setId(UUID.randomUUID().toString()); statementMetadata.setStatementId(statement.getId()); XApiContext xApiContext = statement.getContext(); if (xApiContext != null) { XApiContextActivities xApiContextActivities = xApiContext.getContextActivities(); if (xApiContextActivities != null) { List<XApiObject> parentContext = xApiContextActivities.getParent(); if (parentContext != null && !parentContext.isEmpty()) { for (XApiObject object : parentContext) { String id = object.getId(); if (StringUtils.contains(id, "portal/site/")) { statementMetadata.setContext(StringUtils.substringAfterLast(id, "/")); }//from w ww . j ava 2s .c o m } } } } XApiActor xApiActor = statement.getActor(); if (xApiActor != null) { String mbox = xApiActor.getMbox(); if (StringUtils.isNotBlank(mbox)) { statementMetadata.setUser(StringUtils.substringBetween(mbox, "mailto:", "@")); } } return statementMetadata; }
From source file:org.awesomeagile.webapp.AwesomeAgileFunctionalTest.java
@Test public void testCreateDefinitionOfReady() throws Exception { assertEquals(2, fakeHackpadServer.getHackpads().size()); LandingPage landingPage = PageFactory.initElements(driver, LandingPage.class); landingPage.loginWithGoogle(getEndpoint()); assertThat(driver.getWindowHandles(), hasSize(1)); String firstWindow = driver.getWindowHandle(); landingPage.createDefinitionOfReady(); assertThat(driver.getWindowHandles(), hasSize(2)); assertEquals(3, fakeHackpadServer.getHackpads().size()); String newWindow = Iterables/*from www. j ava2s . c om*/ .getFirst(Sets.difference(driver.getWindowHandles(), ImmutableSet.of(firstWindow)), null); driver.switchTo().window(newWindow); HackpadPage hackpadPage = PageFactory.initElements(driver, HackpadPage.class); assertEquals(DEFINITION_OF_READY_CONTENTS, hackpadPage.getContent()); String newHackpadUrl = driver.getCurrentUrl(); String newHackpadId = StringUtils.substringAfterLast(newHackpadUrl, "/"); assertNotEquals(DEFINITION_OF_READY_TEMPLATE_ID, newHackpadId); String newHackpad = fakeHackpadServer.getHackpad(new PadIdentity(newHackpadId)); assertEquals(DEFINITION_OF_READY_CONTENTS, newHackpad); }
From source file:org.awesomeagile.webapp.AwesomeAgileFunctionalTest.java
@Test public void testCreateDefinitionOfDone() throws Exception { assertEquals(2, fakeHackpadServer.getHackpads().size()); LandingPage landingPage = PageFactory.initElements(driver, LandingPage.class); landingPage.loginWithGoogle(getEndpoint()); assertThat(driver.getWindowHandles(), hasSize(1)); String firstWindow = driver.getWindowHandle(); landingPage.createDefinitionOfDone(); assertThat(driver.getWindowHandles(), hasSize(2)); assertEquals(3, fakeHackpadServer.getHackpads().size()); String newWindow = Iterables/*from www . ja va 2 s . co m*/ .getFirst(Sets.difference(driver.getWindowHandles(), ImmutableSet.of(firstWindow)), null); driver.switchTo().window(newWindow); HackpadPage hackpadPage = PageFactory.initElements(driver, HackpadPage.class); assertEquals(DEFINITION_OF_DONE_CONTENTS, hackpadPage.getContent()); String newHackpadUrl = driver.getCurrentUrl(); String newHackpadId = StringUtils.substringAfterLast(newHackpadUrl, "/"); assertNotEquals(DEFINITION_OF_DONE_TEMPLATE_ID, newHackpadId); String newHackpad = fakeHackpadServer.getHackpad(new PadIdentity(newHackpadId)); assertEquals(DEFINITION_OF_DONE_CONTENTS, newHackpad); }
From source file:org.awesomeagile.webapp.AwesomeAgileFunctionalTest.java
/** * Tests the fact that dashboard view can retrieve links * to the previously created Hackpad documents with the following steps: * 1. Log in.//from w w w. j a v a 2 s .c o m * 2. Click on create definition of ready button and wait until the view button is visible. * 3. Refresh Awesome Agile window. * 4. Verify that the view button is visible, and create button is invisible. * 5. Click on the view button and verify the contents. * @throws Exception */ @Test public void testDashboard() throws Exception { LandingPage landingPage = PageFactory.initElements(driver, LandingPage.class); landingPage.loginWithGoogle(getEndpoint()); assertThat(driver.getWindowHandles(), hasSize(1)); String firstWindow = driver.getWindowHandle(); landingPage.createDefinitionOfReady(); closeWindowsExceptFor(driver, firstWindow); assertEquals(1, driver.getWindowHandles().size()); driver.switchTo().window(firstWindow); driver.navigate().refresh(); landingPage.waitForDefinitionOfReady(); assertTrue(landingPage.isDefinitionOfReadyViewable()); landingPage.viewDefinitionOfReady(); String newWindow = Iterables .getFirst(Sets.difference(driver.getWindowHandles(), ImmutableSet.of(firstWindow)), null); driver.switchTo().window(newWindow); HackpadPage hackpadPage = PageFactory.initElements(driver, HackpadPage.class); assertEquals(DEFINITION_OF_READY_CONTENTS, hackpadPage.getContent()); String newHackpadUrl = driver.getCurrentUrl(); String newHackpadId = StringUtils.substringAfterLast(newHackpadUrl, "/"); assertNotEquals(DEFINITION_OF_READY_TEMPLATE_ID, newHackpadId); }
From source file:org.ballerinalang.composer.service.ballerina.launcher.service.LaunchManager.java
private String getPort(String line) { String hostPort = StringUtils .substringAfterLast(line, LauncherConstants.SERVER_CONNECTOR_STARTED_AT_HTTP_LOCAL).trim(); return StringUtils.substringAfterLast(hostPort, ":"); }
From source file:org.blockartistry.mod.Restructured.util.ItemStackHelper.java
public static ItemStack getItemStack(final String name, final int quantity) { ItemStack result = null;/*from w ww . ja v a 2s.c om*/ // Parse out the possible subtype from the end of the string String workingName = name; int subType = -1; if (StringUtils.countMatches(name, ":") == 2) { workingName = StringUtils.substringBeforeLast(name, ":"); final String num = StringUtils.substringAfterLast(name, ":"); if (num != null && !num.isEmpty()) { if ("*".compareTo(num) == 0) subType = OreDictionary.WILDCARD_VALUE; else { try { subType = Integer.parseInt(num); } catch (Exception e) { // It appears malformed - assume the incoming name // is // the real name and continue. ; } } } } // Check the OreDictionary first for any alias matches. Otherwise // go to the game registry to find a match. final List<ItemStack> ores = OreDictionary.getOres(workingName); if (!ores.isEmpty()) { result = ores.get(0).copy(); result.stackSize = quantity; } else { final Item i = GameData.getItemRegistry().getObject(new ResourceLocation(workingName)); if (i != null) { result = new ItemStack(i, quantity); } } // If we did have a hit on a base item, set the subtype // as needed. if (result != null && subType != -1) { result.setItemDamage(subType); } return result; }
From source file:org.blockartistry.mod.ThermalRecycling.util.ItemStackHelper.java
public static ItemStack getItemStack(final String name, final int quantity) { if (name == null || name.isEmpty()) return null; // Check our preferred list first. If we have a hit, use it. ItemStack result = preferred.get(name); if (result != null) { result = result.copy();/* ww w . j a va2s.c om*/ result.stackSize = quantity; } else { // Parse out the possible subtype from the end of the string String workingName = name; int subType = -1; if (StringUtils.countMatches(name, ":") == 2) { workingName = StringUtils.substringBeforeLast(name, ":"); final String num = StringUtils.substringAfterLast(name, ":"); if (num != null && !num.isEmpty()) { if ("*".compareTo(num) == 0) subType = OreDictionary.WILDCARD_VALUE; else { try { subType = Integer.parseInt(num); } catch (Exception e) { // It appears malformed - assume the incoming name // is // the real name and continue. ; } } } } // Check the OreDictionary first for any alias matches. Otherwise // go to the game registry to find a match. final ArrayList<ItemStack> ores = OreDictionary.getOres(workingName); if (!ores.isEmpty()) { result = ores.get(0).copy(); result.stackSize = quantity; } else { final Item i = GameData.getItemRegistry().getObject(workingName); if (i != null) { result = new ItemStack(i, quantity); } } // If we did have a hit on a base item, set the sub-type // as needed. if (result != null && subType != -1) { if (subType == OreDictionary.WILDCARD_VALUE && !result.getHasSubtypes()) { ModLog.warn("[%s] GENERIC requested but Item does not support sub-types", name); } else { result.setItemDamage(subType); } } } return result; }
From source file:org.brekka.paveway.web.servlet.UploadServlet.java
@Override protected void doDelete(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { UploadingFilesContext filesContext = getFilesContext(req); String requestUri = req.getRequestURI(); String fileName = StringUtils.substringAfterLast(requestUri, "/"); fileName = URLDecoder.decode(fileName, "UTF-8"); if (!filesContext.discard(fileName)) { resp.setStatus(HttpServletResponse.SC_NOT_FOUND); return;//from w ww.j a v a 2 s . c o m } resp.setStatus(HttpServletResponse.SC_NO_CONTENT); }
From source file:org.brekka.pegasus.core.services.impl.EMailAddressServiceImpl.java
@Override @Transactional(propagation = Propagation.REQUIRED) public EMailAddress createEMail(String email, Member owner, boolean requiresVerification) { email = email.toLowerCase();/*from w w w.j a v a2 s . c o m*/ String domain = StringUtils.substringAfterLast(email, "@"); DomainName domainName = toDomainName(domain); EMailAddress eMailAddress = new EMailAddress(); eMailAddress.setHash(hash(email)); eMailAddress.setDomainName(domainName); eMailAddress.setAddress(email); eMailAddress.setOwner(owner); if (!requiresVerification) { eMailAddress.setActive(Boolean.TRUE); eMailAddress.setVerified(new Date()); } else { // TODO // eMailAddress.setVerificationCode(""); } eMailAddressDAO.create(eMailAddress); // TODO add to profile return eMailAddress; }