List of usage examples for org.apache.commons.lang3 StringUtils substringAfter
public static String substringAfter(final String str, final String separator)
Gets the substring after the first occurrence of a separator.
From source file:io.wcm.devops.conga.tooling.maven.plugin.validation.TemplateValidator.java
@Override public void validate(Resource resource, String pathForLog) throws MojoFailureException { if (StringUtils.equalsIgnoreCase(resource.getFileExtension(), FILE_EXTENSION)) { String templatePath = StringUtils.substringAfter(PathUtil.unifySlashes(resource.getCanonicalPath()), PathUtil.unifySlashes(templateDir.getCanonicalPath()) + "/"); Handlebars handlebars = handlebarsManager.get(NoneEscapingStrategy.NAME, CharEncoding.UTF_8); try {//from w w w . jav a 2 s . c om handlebars.compile(templatePath); } catch (Throwable ex) { throw new MojoFailureException("Template " + pathForLog + " is invalid:\n" + ex.getMessage()); } } }
From source file:info.magnolia.security.app.util.UsersWorkspaceUtil.java
private static void updateAclEntries(Node parentNode, String previousPath, Node aclNode) throws RepositoryException { for (Node entryNode : NodeUtil.getNodes(aclNode)) { Property path = entryNode.getProperty("path"); String aclPath = path.getString(); if (aclPath.startsWith(previousPath + "/")) { path.setValue(parentNode.getPath() + "/" + StringUtils.substringAfter(aclPath, previousPath + "/")); }// ww w.j ava 2 s .c o m if (aclPath.equals(previousPath)) { path.setValue(parentNode.getPath()); } } }
From source file:com.sketchy.server.JsonServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); String pathInfo = request.getPathInfo(); if (pathInfo.startsWith("/")) pathInfo = StringUtils.substringAfter(pathInfo, "/"); String action = ACTION_PACKAGE + pathInfo; JSONServletResult jsonServletResult = null; try {//from w w w . j a va 2 s. c o m ServletAction servletAction = ServletAction.getInstance(action); jsonServletResult = servletAction.execute(request); } catch (ClassNotFoundException e) { jsonServletResult = new JSONServletResult(Status.ERROR, "ServletAction '" + pathInfo + "' not found! " + e.getMessage()); } catch (Exception e) { jsonServletResult = new JSONServletResult(Status.ERROR, "Unexpected Exception from ServletAction '" + pathInfo + "'! " + e.getMessage()); } response.setStatus(HttpServletResponse.SC_OK); response.getWriter().println(jsonServletResult.toJSONString()); }
From source file:de.blizzy.documentr.markdown.DocumentrLinkRenderer.java
@Override public Rendering render(WikiLinkNode node) { String text = node.getText(); String uri;/*from ww w . j av a2 s . co m*/ boolean noFollow = false; if (text.startsWith("#")) { //$NON-NLS-1$ text = text.substring(1).trim(); uri = "#" + Util.simplifyForUrl(text); //$NON-NLS-1$ } else { uri = StringUtils.substringBefore(text, " ").trim(); //$NON-NLS-1$ text = StringUtils.substringAfter(text, " "); //$NON-NLS-1$ String params = StringUtils.substringAfter(text, "|").trim(); //$NON-NLS-1$ text = StringUtils.substringBefore(text, "|"); //$NON-NLS-1$ if (uri.startsWith("=")) { //$NON-NLS-1$ if (StringUtils.isBlank(text)) { text = uri.substring(1); } uri = context.getAttachmentUri(uri.substring(1)); } else { if (StringUtils.isBlank(text)) { text = uri; } } text = text.trim(); if (params.equalsIgnoreCase("nofollow")) { //$NON-NLS-1$ noFollow = true; } } Rendering rendering = new Rendering(uri, text); if (noFollow) { rendering.withAttribute(Attribute.NO_FOLLOW); } return rendering; }
From source file:com.thinkbiganalytics.servicemonitor.support.ServiceMonitorCheckUtil.java
/** * get a map of the Service and any components that should be checked within that service. */// w w w . j av a2s. c om public static Map<String, List<String>> getMapOfServiceAndComponents(String services) { Map<String, List<String>> map = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER); if (StringUtils.isNotBlank(services)) { String finalServiceString = services; if (services.contains("/")) { int i = 1; String serviceName = null; for (String servicePart : StringUtils.split(services, "/")) { //service name is the first string before the / if (serviceName == null) { if (servicePart.contains(",")) { serviceName = StringUtils.substringAfterLast(servicePart, ","); } else { serviceName = servicePart; } } else { String components = ""; String origComponents = ""; if (servicePart.contains("]")) { components = StringUtils.substringBeforeLast(servicePart, "]"); components = StringUtils.substringAfter(components, "["); origComponents = "[" + components + "]"; } else { components = StringUtils.substringBefore(servicePart, ","); origComponents = components; } String[] componentsArr = StringUtils.split(components, ","); map.put(serviceName, Arrays.asList(componentsArr)); //now remove these from the finalServiceString finalServiceString = StringUtils.replace(finalServiceString, serviceName + "/" + origComponents, ""); //reset serviceName serviceName = StringUtils.substringAfterLast(servicePart, ","); } i++; } } for (String service : StringUtils.split(finalServiceString, ",")) { String serviceName = service; map.put(serviceName, Arrays.asList(new String[] { ALL_COMPONENTS })); } } return map; }
From source file:com.nestof.paraweather.utils.LocationConverter.java
/** * Returns the Decimal Degrees that corresponds to the DMS values entered. * Requires values in Degrees, Minutes, Seconds, and Direction * * @return String// w ww . j a va 2 s. co m */ public String toDecimalDegrees(String location) { degrees = StringUtils.substringBefore(location, "").trim(); minutes = StringUtils.substringBetween(location, "", "'").trim(); seconds = StringUtils.substringBetween(location, "'", "\"").trim(); direction = StringUtils.substringAfter(location, "\"").trim(); String returnString = null; Double dblDegree; Double dblMinutes; Double dblSeconds; Double decDegrees; String CompassDirection; dblDegree = Double.parseDouble(getDegrees()); dblMinutes = Double.parseDouble(getMinutes()); dblSeconds = Double.parseDouble(getSeconds()); CompassDirection = getDirection(); decDegrees = dblDegree + (dblMinutes / 60) + (dblSeconds / 3600); if (CompassDirection.equalsIgnoreCase("S")) decDegrees = decDegrees * -1; if (CompassDirection.equalsIgnoreCase("W")) decDegrees = decDegrees * -1; returnString = decDegrees.toString() + direction; return returnString; }
From source file:cc.recommenders.names.VmFieldName.java
@Override public ITypeName getFieldType() { final String fieldType = StringUtils.substringAfter(identifier, ";"); return VmTypeName.get(fieldType); }
From source file:com.thinkbiganalytics.alerts.rest.AlertsModel.java
public String alertTypeDisplayName(String type) { String part = type;//from ww w .j a v a2 s .com if (part.startsWith(AlertConstants.KYLO_ALERT_TYPE_PREFIX + "/alert")) { part = StringUtils.substringAfter(part, AlertConstants.KYLO_ALERT_TYPE_PREFIX + "/alert"); } else if (part.startsWith(AlertConstants.KYLO_ALERT_TYPE_PREFIX)) { part = StringUtils.substringAfter(part, AlertConstants.KYLO_ALERT_TYPE_PREFIX); } else { int idx = StringUtils.lastOrdinalIndexOf(part, "/", 2); part = StringUtils.substring(part, idx); } String[] parts = part.split("/"); return Arrays.asList(parts).stream().map(s -> StringUtils.capitalize(s)).collect(Collectors.joining(" ")); }
From source file:com.neatresults.mgnltweaks.ui.field.TemplateIdConverter.java
@Override public String convertToModel(String path, Class<? extends String> targetType, Locale locale) throws ConversionException { // Null is required for the property to be removed if path is empty String res = null;/* w w w . j a v a2 s . c o m*/ if (StringUtils.isBlank(path)) { return res; } String id = StringUtils.substringBefore(StringUtils.removeStart(path, "/modules/"), "/"); String template = StringUtils.substringAfter(path, "/templates/"); res = id + ":" + template; return res; }
From source file:cc.recommenders.names.CoReFieldName.java
@Override public ICoReTypeName getFieldType() { final String fieldType = StringUtils.substringAfter(identifier, ";"); return CoReTypeName.get(fieldType); }