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

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

Introduction

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

Prototype

public static String substringAfter(String str, String separator) 

Source Link

Document

Gets the substring after the first occurrence of a separator.

Usage

From source file:com.dianping.lion.util.UrlUtils.java

public static List<String> getParameterNames(String url) {
    if (url == null) {
        throw new NullPointerException("Param[url] cannot be null.");
    }//from ww  w. j  a  v a  2 s .  co m
    List<String> parameterNames = new ArrayList<String>();
    String queryString = StringUtils.substringAfter(url, "?");
    if (queryString != null) {
        String[] segments = StringUtils.split(queryString, "&");
        for (String segment : segments) {
            String param = StringUtils.substringBefore(segment, "=");
            if (!parameterNames.contains(param)) {
                parameterNames.add(param);
            }
        }
    }
    return parameterNames;
}

From source file:it.openutils.mgnlaws.magnolia.init.ClasspathBindableRepository.java

@Override
protected JackrabbitRepository createRepository() throws RepositoryException {
    Reference reference = this.getReference();
    String configFilePath = reference.get(CONFIGFILEPATH_ADDRTYPE).getContent().toString();
    if (StringUtils.startsWith(configFilePath, ClasspathPropertiesInitializer.CLASSPATH_PREFIX)) {
        InputStream resource = getClass().getResourceAsStream(
                StringUtils.substringAfter(configFilePath, ClasspathPropertiesInitializer.CLASSPATH_PREFIX));
        if (resource != null) {
            RepositoryConfig config = RepositoryConfig.create(resource,
                    reference.get(REPHOMEDIR_ADDRTYPE).getContent().toString());
            return RepositoryImpl.create(config);
        }// w w  w  .ja  va  2 s  .  co  m
    }
    return super.createRepository();
}

From source file:info.magnolia.objectfactory.ComponentConfigurationPath.java

public ComponentConfigurationPath(String value) {
    if (value.indexOf(':') >= 0) {
        this.repository = StringUtils.substringBefore(value, ":");
        this.path = StringUtils.substringAfter(value, ":");
    } else {//from  w w  w  .  j  a  va  2 s .  c o  m
        this.repository = RepositoryConstants.CONFIG;
        this.path = value;
    }
}

From source file:edu.jhu.pha.vospace.node.VospaceId.java

public VospaceId(String idStr) throws URISyntaxException {
    URI voURI = new URI(idStr);

    if (!validId(voURI)) {
        throw new URISyntaxException(idStr, "InvalidURI");
    }/*  w  w w  .  j a  v  a 2  s .c o  m*/

    if (!StringUtils.contains(idStr, "vospace")) {
        throw new URISyntaxException(idStr, "InvalidURI");
    }

    this.uri = StringUtils.substringBetween(idStr, "vos://", "!vospace");

    if (this.uri == null)
        throw new URISyntaxException(idStr, "InvalidURI");

    try {
        String pathStr = URLDecoder.decode(StringUtils.substringAfter(idStr, "!vospace"), "UTF-8");
        this.nodePath = new NodePath(pathStr);
    } catch (UnsupportedEncodingException e) {
        // should not happen
        logger.error(e.getMessage());
    }

}

From source file:info.joseluismartin.gtc.Tile.java

public String getFileExension() {
    return StringUtils.substringAfter(mimeType, "/");
}

From source file:com.cognifide.aet.executor.SuiteStatusServlet.java

/**
 * Returns JSON with suite status defined by {@link SuiteStatusResult} for a given correlation ID.
 *
 * @param request//from w ww .ja va  2 s . c  o  m
 * @param response
 * @throws ServletException
 * @throws IOException
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String correlationId = StringUtils.substringAfter(request.getRequestURI(), SERVLET_PATH).replace("/", "");
    SuiteStatusResult suiteStatusResult = suiteExecutor.getExecutionStatus(correlationId);

    if (suiteStatusResult != null) {
        Gson gson = new Gson();
        String responseBody = gson.toJson(suiteStatusResult);

        response.setStatus(200);
        response.setContentType("application/json");
        response.setCharacterEncoding("UTF-8");
        response.getWriter().write(responseBody);
    } else {
        response.sendError(404, "Suite status not found");
    }
}

From source file:eionet.cr.util.FolderUtil.java

/**
 * Detects if the given URI starts with a CR user home.
 *
 * @param uri The given URI./*w w  w .  j  a  v a 2s  .c  om*/
 * @return See description above..
 */
public static boolean startsWithUserHome(String uri) {

    if (StringUtils.isBlank(uri)) {
        return false;
    }

    String appHomeUrl = GeneralConfig.getRequiredProperty(GeneralConfig.APPLICATION_HOME_URL);
    if (!uri.startsWith(appHomeUrl) || uri.equals(appHomeUrl)) {
        return false;
    }

    String afterAppHomeUrl = StringUtils.substringAfter(uri, appHomeUrl);
    String homeString = "/home/";
    return afterAppHomeUrl.startsWith(homeString) && afterAppHomeUrl.length() > homeString.length();
}

From source file:ddf.mime.mapper.MockMimeTypeResolver.java

public void setCustomMimeTypes(String[] customMimeTypes) {
    //        this.customMimeTypes = customMimeTypes.clone();
    this.customFileExtensionsToMimeTypesMap = new HashMap<String, String>();
    this.customMimeTypesToFileExtensionsMap = new HashMap<String, List<String>>();

    for (String mimeTypeMapping : customMimeTypes) {

        // mimeTypeMapping is of the form <file extension>=<mime type>
        // Examples:
        // nitf=image/nitf

        String fileExtension = StringUtils.substringBefore(mimeTypeMapping, "=");
        String mimeType = StringUtils.substringAfter(mimeTypeMapping, "=");

        customFileExtensionsToMimeTypesMap.put(fileExtension, mimeType);
        List<String> fileExtensions = (List<String>) customMimeTypesToFileExtensionsMap.get(mimeType);
        if (fileExtensions == null) {
            fileExtensions = new ArrayList<String>();
        }/*from w w  w.  j  av  a  2 s  .  c  o m*/
        fileExtensions.add(fileExtension);
        customMimeTypesToFileExtensionsMap.put(mimeType, fileExtensions);
    }
}

From source file:info.magnolia.module.delta.BootstrapConditionally.java

private static String determinePath(String filename) {
    String withoutExtensionAndRepository = StringUtils.substringAfter(cleanupFilename(filename), ".");
    String path = StringUtils.replace(withoutExtensionAndRepository, ".", "/");
    return (StringUtils.isEmpty(path) ? "/" : "/" + path);
}

From source file:com.opengamma.bbg.referencedata.MockReferenceDataProvider.java

@Override
protected ReferenceDataProviderGetResult doBulkGet(ReferenceDataProviderGetRequest request) {
    if (_expectedFields.size() > 0) {
        for (String field : _expectedFields) {
            assertTrue(request.getFields().contains(field));
        }/*from w ww.j ava  2 s. c o m*/
    }
    ReferenceDataProviderGetResult result = new ReferenceDataProviderGetResult();
    for (String identifier : request.getIdentifiers()) {
        if (_mockDataMap.containsKey(identifier)) {
            // known security
            ReferenceData refData = new ReferenceData(identifier);
            MutableFudgeMsg msg = OpenGammaFudgeContext.getInstance().newMessage();

            Multimap<String, String> fieldMap = _mockDataMap.get(identifier);
            if (fieldMap != null) {
                // security actually has data
                for (String field : request.getFields()) {
                    Collection<String> values = fieldMap.get(field);
                    assertTrue("Field not found: " + field + " in " + fieldMap.keySet(), values.size() > 0);
                    assertNotNull(values);
                    for (String value : values) {
                        if (value != null) {
                            if (value.contains("=")) {
                                MutableFudgeMsg submsg = OpenGammaFudgeContext.getInstance().newMessage();
                                submsg.add(StringUtils.substringBefore(value, "="),
                                        StringUtils.substringAfter(value, "="));
                                msg.add(field, submsg);
                            } else {
                                msg.add(field, value);
                            }
                        }
                    }
                }
            }
            refData.setFieldValues(msg);
            result.addReferenceData(refData);

        } else {
            // security wasn't marked as known
            fail("Security not found: " + identifier + " in " + _mockDataMap.keySet());
        }
    }
    return result;
}