Example usage for org.apache.commons.lang3 StringUtils substringAfter

List of usage examples for org.apache.commons.lang3 StringUtils substringAfter

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils substringAfter.

Prototype

public static String substringAfter(final String str, final String separator) 

Source Link

Document

Gets the substring after the first occurrence of a separator.

Usage

From source file:com.adobe.cq.wcm.core.components.internal.models.v1.SearchImpl.java

@PostConstruct
private void initModel() {
    resultsSize = currentStyle.get(PN_RESULTS_SIZE, PROP_RESULTS_SIZE_DEFAULT);
    searchTermMinimumLength = currentStyle.get(PN_SEARCH_TERM_MINIMUM_LENGTH,
            PROP_SEARCH_TERM_MINIMUM_LENGTH_DEFAULT);
    PageManager pageManager = currentPage.getPageManager();
    Resource currentResource = request.getResource();
    if (pageManager != null) {
        Page containingPage = pageManager.getContainingPage(currentResource);
        if (containingPage != null) {
            relativePath = StringUtils.substringAfter(currentResource.getPath(), containingPage.getPath());
        }/*from   www .  j  ava 2s.  co m*/
    }
}

From source file:alfio.controller.api.admin.UsersApiController.java

/**
 * This endpoint is intended only for external use. If a user is registered as "sponsor", then the answer will be "SPONSOR", otherwise "OPERATOR".
 * @return "SPONSOR" or "OPERATOR", depending on current user's privileges.
 *//*from   w w w  .  j av a  2 s.  c  o  m*/
@RequestMapping(value = "/user-type", method = GET)
public String getLoggedUserType() {
    return SecurityContextHolder.getContext().getAuthentication().getAuthorities().stream()
            .map(GrantedAuthority::getAuthority).map(s -> StringUtils.substringAfter(s, "ROLE_"))
            .filter(WebSecurityConfig.SPONSOR::equals).findFirst().orElse(WebSecurityConfig.OPERATOR);
}

From source file:com.cognifide.qa.bb.aem.touch.pageobjects.touchui.Parsys.java

/**
 * @return data path of parsys/*from  w w w.j av  a2s  .com*/
 */
public String getDataPath() {
    String rawValue = currentScope.getAttribute(HtmlTags.Attributes.DATA_PATH);
    return StringUtils.substringAfter(rawValue, JCR_CONTENT);
}

From source file:com.handpay.ibenefit.framework.util.PropertyFilter.java

/**
 *  /*  w w w  . j  ava2  s. co m*/
 * @param defalutObjectName default object name
 * @param filterName property name
 * @param value the value of the property
 */
public PropertyFilter(final String defalutObjectName, final String filterName, final String value) {
    String matchTypeStr = StringUtils.substringBefore(filterName, "_");
    String matchTypeCode = StringUtils.substring(matchTypeStr, 0, matchTypeStr.length() - 1);
    String propertyTypeCode = StringUtils.substring(matchTypeStr, matchTypeStr.length() - 1,
            matchTypeStr.length());
    this.filterName = filterName;
    matchType = Enum.valueOf(MatchType.class, matchTypeCode);
    propertyType = Enum.valueOf(PropertyType.class, propertyTypeCode).getValue();
    propertyName = StringUtils.substringAfter(filterName, "_");
    if (propertyName.indexOf(".") != -1) {
        String[] array = propertyName.split("\\.");
        objectName = array[0];
        propertyName = array[1];
    } else {
        objectName = defalutObjectName;
    }
    propertyValueString = value;
    try {
        this.propertyValue = ReflectUtils.convertStringToObject(value, propertyType);
        //Handle Date type
        if (propertyTypeCode.equals("D")) {
            //Set to the begin of the date or end of the date
            if (matchType == MatchType.GE || matchType == MatchType.GT) {
                this.propertyValue = DateUtils.getBeginOfTheDate((Date) this.propertyValue);
            } else if (matchType == MatchType.LE || matchType == MatchType.LT) {
                this.propertyValue = DateUtils.getEndOfTheDate((Date) this.propertyValue);
            }
        }
        if (matchType == PropertyFilter.MatchType.IC || matchType == PropertyFilter.MatchType.NC) {
            String[] values = value.split(",");
            propertyValues = new ArrayList(values.length);
            for (String v : values) {
                propertyValues.add(ReflectUtils.convertStringToObject(v, propertyType));
            }
        }
    } catch (Exception e) {
    }
}

From source file:io.wcm.devops.conga.tooling.maven.plugin.DefinitionValidateMojo.java

private static String getPathForLog(ResourceCollection rootSourceDir, Resource file) {
    String path = PathUtil.unifySlashes(file.getCanonicalPath());
    String rootPath = PathUtil.unifySlashes(rootSourceDir.getCanonicalPath()) + "/";
    return StringUtils.substringAfter(path, rootPath);
}

From source file:de.vandermeer.skb.datatool.backend.BackendLatexAcrLog.java

/**
 * Loads and processes the the LaTeX, creates list of found acronyms.
 * @throws IOException if there is a problem with the file read
 *//*from www  . j a va 2  s. c  om*/
public void loadLatexLog() throws IOException {
    Validate.validState(this.file != null);
    BufferedReader br = new BufferedReader(new FileReader(this.file));
    String line;
    while ((line = br.readLine()) != null) {
        if (StringUtils.contains(line, "Package acronym ")) {
            if (StringUtils.contains(line, "Info: ")) {
                String acro = StringUtils.substringAfter(line, "acro:");
                acro = StringUtils.substringBefore(acro, "'");
                this.acronymsLog.add(acro);
                this.acronymsUsed++;
            } else if (StringUtils.contains(line, "Warning: ")) {
                String acro = StringUtils.substringAfter(line, "`");
                acro = StringUtils.substringBefore(acro, "'");
                this.acronymsLog.add(acro);
                this.acronymsUsed++;
            } else {
                System.err.println("##########");
            }
        }
    }
    br.close();
}

From source file:io.wcm.config.core.override.impl.SystemPropertyOverrideProvider.java

@Activate
void activate(final ComponentContext ctx) {
    Dictionary config = ctx.getProperties();
    final boolean enabled = PropertiesUtil.toBoolean(config.get(PROPERTY_ENABLED), DEFAULT_ENABLED);

    Map<String, String> map = new HashMap<>();
    if (enabled) {
        Properties properties = System.getProperties();
        Enumeration<Object> keys = properties.keys();
        while (keys.hasMoreElements()) {
            Object keyObject = keys.nextElement();
            if (keyObject instanceof String) {
                String key = (String) keyObject;
                if (StringUtils.startsWith(key, SYSTEM_PROPERTY_PREFIX)) {
                    map.put(StringUtils.substringAfter(key, SYSTEM_PROPERTY_PREFIX), System.getProperty(key));
                }//w ww  .  j a  va  2  s .co m
            }
        }
    }
    this.overrideMap = ImmutableMap.copyOf(map);
}

From source file:com.cognifide.aet.rest.ConfigsServlet.java

/***
 * Returns JSON representation of Suite based on correlationId or suite name.
 * If suite name is provided, then newest version of JSON is returned.
 *
 * @param req// w  ww. j  a v  a2 s.c  o  m
 * @param resp
 */
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
    LOGGER.debug("GET, req: '{}'", req);
    PrintWriter responseWriter = retrieveResponseWriter(req, resp);
    if (responseWriter != null) {
        resp.setContentType("application/json");
        String configType = StringUtils.substringAfter(req.getRequestURI(), Helper.getConfigsPath())
                .replace(Helper.PATH_SEPARATOR, "");
        String reportDomain = reportConfigurationManager.getReportDomain();

        if (COMMUNICATION_SETTINGS_PARAM.equals(configType)) {
            JmsEndpointConfig jmsEndpointConfig = jmsConnection.getEndpointConfig();
            CommunicationSettings communicationSettings = new CommunicationSettings(jmsEndpointConfig,
                    reportDomain);
            responseWriter.write(new Gson().toJson(communicationSettings));
        } else if (LIST_PARAM.equals(configType)) {
            resp.setContentType("text/html; charset=utf-8");
            resp.setHeader("User-Agent",
                    "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36");
            responseWriter.write(new SuitesListProvider(metadataDAO, reportDomain).listSuites());
        } else if (LOCKS_PARAM.equals(configType)) {
            responseWriter.write(getLocks());
        } else {
            resp.setStatus(HttpURLConnection.HTTP_BAD_REQUEST);
            responseWriter.write("Unable to get given config.");
        }
    } else {
        resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
    flushResponseBuffer(req, resp);
}

From source file:base.compilations.PascalCompilation.java

private CompilationError processLineFor(String errorType, String line) {
    CompilationError error = new CompilationError();
    String beforeLineNumberStr = fileExtention + "(";
    int lineNumberStart = line.indexOf(beforeLineNumberStr) + beforeLineNumberStr.length();
    int lineNumberEnd = line.indexOf(",", lineNumberStart);
    String lineNumberAsStr = line.substring(lineNumberStart, lineNumberEnd);
    error.setLine(Integer.parseInt(lineNumberAsStr));
    error.setErrorText(StringUtils.substringAfter(line, errorType));
    return error;
}

From source file:common.util.PropertyFilter.java

/**
 * @param filterName/*  ww w . j a  v a2  s .c  o  m*/
 * @param value
 */
public PropertyFilter(final String filterName, final String value) {

    String matchTypeStr;
    String matchPattenCode = LikeMatchPatten.ALL.toString();
    String matchTypeCode;
    String propertyTypeCode;

    if (filterName.contains("LIKE") && filterName.charAt(0) != 'L') {
        matchTypeStr = StringUtils.substringBefore(filterName, PARAM_PREFIX);
        matchPattenCode = StringUtils.substring(matchTypeStr, 0, 1);
        matchTypeCode = StringUtils.substring(matchTypeStr, 1, matchTypeStr.length() - 1);
        propertyTypeCode = StringUtils.substring(matchTypeStr, matchTypeStr.length() - 1,
                matchTypeStr.length());
    } else {
        matchTypeStr = StringUtils.substringBefore(filterName, PARAM_PREFIX);
        matchTypeCode = StringUtils.substring(matchTypeStr, 0, matchTypeStr.length() - 1);
        propertyTypeCode = StringUtils.substring(matchTypeStr, matchTypeStr.length() - 1,
                matchTypeStr.length());
    }

    try {
        matchType = Enum.valueOf(MatchType.class, matchTypeCode);
        likeMatchPatten = Enum.valueOf(LikeMatchPatten.class, matchPattenCode);
    } catch (RuntimeException e) {
        throw new IllegalArgumentException("filter name: " + filterName
                + "Not prepared in accordance with rules, not get more types of property.", e);
    }

    try {
        propertyType = Enum.valueOf(PropertyType.class, propertyTypeCode).getValue();
    } catch (RuntimeException e) {
        throw new IllegalArgumentException("filter name: " + filterName
                + "Not prepared in accordance with the rules, attribute value types can not be.", e);
    }

    String propertyNameStr = StringUtils.substringAfter(filterName, PARAM_PREFIX);
    propertyNames = StringUtils.split(propertyNameStr, PropertyFilter.OR_SEPARATOR);

    Validate.isTrue(propertyNames.length > 0, "filter name: " + filterName
            + "Not prepared in accordance with the rules, property names can not be.");

    this.propertyValue = ConvertUtils.convert(value, propertyType);
}