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:at.pagu.soldockr.core.query.Criteria.java

private String processCriteriaEntry(String key, Object value) {
    if (value == null) {
        return null;
    }/*from   ww  w.j a va  2 s. c o  m*/

    // do not filter espressions
    if (StringUtils.equals(OperationKey.EXPRESSION.getKey(), key)) {
        return value.toString();
    }

    if (StringUtils.equals(OperationKey.BETWEEN.getKey(), key)) {
        Object[] args = (Object[]) value;
        String rangeFragment = "[";
        rangeFragment += args[0] != null ? filterCriteriaValue(args[0]) : WILDCARD;
        rangeFragment += RANGE_OPERATOR;
        rangeFragment += args[1] != null ? filterCriteriaValue(args[1]) : WILDCARD;
        rangeFragment += "]";
        return rangeFragment;
    }

    Object filteredValue = filterCriteriaValue(value);
    if (StringUtils.equals(OperationKey.CONTAINS.getKey(), key)) {
        return WILDCARD + filteredValue + WILDCARD;
    }
    if (StringUtils.equals(OperationKey.STARTS_WITH.getKey(), key)) {
        return filteredValue + WILDCARD;
    }
    if (StringUtils.equals(OperationKey.ENDS_WITH.getKey(), key)) {
        return WILDCARD + filteredValue;
    }
    if (StringUtils.equals(OperationKey.IS_NOT.getKey(), key)) {
        return "-" + filteredValue;
    }

    if (StringUtils.startsWith(key, "$fuzzy")) {
        String sDistance = StringUtils.substringAfter(key, "$fuzzy#");
        float distance = Float.NaN;
        if (StringUtils.isNotBlank(sDistance)) {
            distance = Float.parseFloat(sDistance);
        }
        return filteredValue + "~" + (Float.isNaN(distance) ? "" : sDistance);
    }

    return filteredValue.toString();
}

From source file:ch.cyberduck.core.ftp.FTPPath.java

protected Map<String, Map<String, String>> parseFacts(String line) {
    final Pattern p = Pattern.compile("\\s?(\\S+\\=\\S+;)*\\s(.*)");
    final Matcher result = p.matcher(line);
    Map<String, Map<String, String>> file = new HashMap<String, Map<String, String>>();
    if (result.matches()) {
        final String filename = result.group(2);
        final Map<String, String> facts = new HashMap<String, String>();
        for (String fact : result.group(1).split(";")) {
            String key = StringUtils.substringBefore(fact, "=");
            if (StringUtils.isBlank(key)) {
                continue;
            }//ww w. j  a  v a2s  .  c om
            String value = StringUtils.substringAfter(fact, "=");
            if (StringUtils.isBlank(value)) {
                continue;
            }
            facts.put(key.toLowerCase(java.util.Locale.ENGLISH), value);
        }
        file.put(filename, facts);
        return file;
    }
    log.warn("No match for " + line);
    return null;
}

From source file:com.steeleforge.aem.ironsites.wcm.WCMUtil.java

/**
 * For protocol specific fully qualified URLs, ensure protocol relativity
 * /*from   w w  w.  j  a  v a  2s. c  o  m*/
 * @param fullyQualifiedURL
 * @return
 */
public static String getProtocolRelativeURL(String fullyQualifiedURL) {
    if (!StringUtils.startsWith(fullyQualifiedURL, WCMConstants.PROTOCOL_RELATIVE)) {
        return WCMConstants.PROTOCOL_RELATIVE
                + StringUtils.substringAfter(fullyQualifiedURL, WCMConstants.PROTOCOL_RELATIVE);
    }
    return fullyQualifiedURL;
}

From source file:info.magnolia.cms.security.SecurityUtil.java

public static String stripPasswordFromUrl(String url) {
    if (StringUtils.isBlank(url)) {
        return null;
    }// w ww . ja  v a  2 s . c  o m
    String value = null;
    value = StringUtils.substringBefore(url, "mgnlUserPSWD");
    value = value + StringUtils.substringAfter(StringUtils.substringAfter(url, "mgnlUserPSWD"), "&");
    return StringUtils.removeEnd(value, "&");
}

From source file:info.magnolia.cms.security.SecurityUtil.java

public static String stripParameterFromCacheLog(String log, String parameter) {
    if (StringUtils.isBlank(log)) {
        return null;
    } else if (!StringUtils.contains(log, parameter)) {
        return log;
    }//  w  ww .j a  va 2 s. c  o  m
    String value = null;
    value = StringUtils.substringBefore(log, parameter);
    String afterString = StringUtils.substringAfter(log, parameter);
    if (StringUtils.indexOf(afterString, " ") < StringUtils.indexOf(afterString, "}")) {
        value = value + StringUtils.substringAfter(afterString, " ");
    } else {
        value = value + "}" + StringUtils.substringAfter(afterString, "}");
    }
    return value;
}

From source file:ch.cyberduck.core.DownloadTransfer.java

@Override
protected void transfer(final Path file) {
    log.debug("transfer:" + file);
    final Local local = file.getLocal();
    if (file.attributes().isSymbolicLink() && this.isSymlinkSupported(file)) {
        // Make relative symbolic link
        final String target = StringUtils.substringAfter(file.getSymlinkTarget().getAbsolute(),
                file.getParent().getAbsolute() + Path.DELIMITER);
        if (log.isDebugEnabled()) {
            log.debug("Symlink " + file.getLocal() + ":" + target);
        }//from  w w w  .  j a  v a2 s.  c  om
        file.getLocal().symlink(target);
        file.status().setComplete(true);
    } else if (file.attributes().isFile()) {
        file.download(bandwidth, new AbstractStreamListener() {
            @Override
            public void bytesReceived(long bytes) {
                transferred += bytes;
            }
        });
    } else if (file.attributes().isDirectory()) {
        local.mkdir(true);
    }
    if (!file.status().isCanceled() && file.status().isComplete()) {
        if (Preferences.instance().getBoolean("queue.download.changePermissions")) {
            Permission permission = Permission.EMPTY;
            if (Preferences.instance().getBoolean("queue.download.permissions.useDefault")) {
                if (file.attributes().isFile()) {
                    permission = new Permission(
                            Preferences.instance().getInteger("queue.download.permissions.file.default"));
                }
                if (file.attributes().isDirectory()) {
                    permission = new Permission(
                            Preferences.instance().getInteger("queue.download.permissions.folder.default"));
                }
            } else {
                permission = file.attributes().getPermission();
            }
            if (!Permission.EMPTY.equals(permission)) {
                if (file.attributes().isDirectory()) {
                    // Make sure we can read & write files to directory created.
                    permission.getOwnerPermissions()[Permission.READ] = true;
                    permission.getOwnerPermissions()[Permission.WRITE] = true;
                    permission.getOwnerPermissions()[Permission.EXECUTE] = true;
                }
                if (file.attributes().isFile()) {
                    // Make sure the owner can always read and write.
                    permission.getOwnerPermissions()[Permission.READ] = true;
                    permission.getOwnerPermissions()[Permission.WRITE] = true;
                }
                if (log.isInfoEnabled()) {
                    log.info("Updating permissions:" + local + "," + permission);
                }
                local.writeUnixPermission(permission, false);
            }
        }
        if (Preferences.instance().getBoolean("queue.download.preserveDate")) {
            if (file.attributes().getModificationDate() != -1) {
                long timestamp = file.attributes().getModificationDate();
                if (log.isInfoEnabled()) {
                    log.info("Updating timestamp:" + local + "," + timestamp);
                }
                local.writeTimestamp(-1, timestamp, -1);
            }
        }
    }
}

From source file:eionet.cr.web.util.JstlFunctions.java

/**
 * Extract folder//w  w  w  . j  a  va 2s  .co  m
 *
 * @param uri
 * @return String
 */
public static String extractFolder(String uri) {
    if (uri == null) {
        return "";
    }
    String appHome = GeneralConfig.getProperty(GeneralConfig.APPLICATION_HOME_URL);
    return StringUtils.substringAfter(uri, appHome);
}

From source file:com.hcc.cms.util.PageUtils.java

/**
 * This method is used to get the current locale of the page which would be
 * used in setting the path for driver profile page based on the current
 * locale.//from  w w  w  .jav  a 2  s .c  o m
 *
 * @param pagePath
 *            - path of the page whose locale is to be figured out
 * @return currentLocale - of the current page.
 */
public static String getLocale(String pagePath) {

    for (int i = 0; i <= 2; i++) {
        pagePath = StringUtils.substringAfter(pagePath, SEPARATOR);
    }

    return StringUtils.substringBefore(pagePath, SEPARATOR);
}

From source file:com.amalto.core.storage.SystemStorageWrapper.java

@Override
public String getDocumentAsString(String clusterName, String uniqueID, String encoding)
        throws XmlServerException {
    if (encoding == null) {
        encoding = "UTF-8"; //$NON-NLS-1$
    }/*from   w w  w  .jav  a2  s . c o  m*/
    Storage storage = getStorage(clusterName);
    ComplexTypeMetadata type = getType(clusterName, storage, uniqueID);
    if (type == null) {
        return null; // TODO
    }
    UserQueryBuilder qb;
    boolean isUserFormat = false;
    String documentUniqueID;
    if (DROPPED_ITEM_TYPE.equals(type.getName())) {
        // head.Product.Product.0- (but DM1.Bird.bid3)
        if (uniqueID.endsWith("-")) { //$NON-NLS-1$
            uniqueID = uniqueID.substring(0, uniqueID.length() - 1);
        }
        // TODO Code may not correctly handle composite id (but no system objects use this)
        documentUniqueID = uniqueID;
        if (StringUtils.countMatches(uniqueID, ".") >= 3) { //$NON-NLS-1$
            documentUniqueID = StringUtils.substringAfter(uniqueID, "."); //$NON-NLS-1$
        }
    } else if (COMPLETED_ROUTING_ORDER.equals(type.getName()) || FAILED_ROUTING_ORDER.equals(type.getName())) {
        documentUniqueID = uniqueID;
    } else {
        // TMDM-5513 custom form layout pk contains double dot .. to split, but it's a system definition object
        // like this Product..Product..product_layout
        isUserFormat = !uniqueID.contains("..") && uniqueID.indexOf('.') > 0; //$NON-NLS-1$
        documentUniqueID = uniqueID;
        if (uniqueID.startsWith(PROVISIONING_PREFIX_INFO)) {
            documentUniqueID = StringUtils.substringAfter(uniqueID, PROVISIONING_PREFIX_INFO);
        } else if (uniqueID.startsWith(BROWSEITEM_PREFIX_INFO)) {
            documentUniqueID = StringUtils.substringAfter(uniqueID, BROWSEITEM_PREFIX_INFO); //$NON-NLS-1$
        } else if (isUserFormat) {
            documentUniqueID = StringUtils.substringAfterLast(uniqueID, "."); //$NON-NLS-1$
        }
    }
    qb = from(type).where(eq(type.getKeyFields().iterator().next(), documentUniqueID));
    StorageResults results = null;
    try {
        storage.begin();
        results = storage.fetch(qb.getSelect());
        String xmlString = getXmlString(clusterName, type, results.iterator(), uniqueID, encoding,
                isUserFormat);
        storage.commit();
        return xmlString;
    } catch (IOException e) {
        storage.rollback();
        throw new XmlServerException(e);
    } finally {
        if (results != null) {
            results.close();
        }
    }
}

From source file:com.prowidesoftware.swift.io.parser.MxParser.java

/**
 * Distinguished Name structure: cn=name,ou=payment,o=bank,o=swift
 * <br />//  w w  w.j a v  a  2 s  .  c  o  m
 * Example: o=spxainjj,o=swift
 * 
 * @param dn the DN element content
 * @return returns capitalized "bank", in the example SPXAINJJ
 */
public static String getBICFromDN(final String dn) {
    for (String s : StringUtils.split(dn, ",")) {
        if (StringUtils.startsWith(s, "o=") && !StringUtils.equals(s, "o=swift")) {
            return StringUtils.upperCase(StringUtils.substringAfter(s, "o="));
        }
        /*
        else if (StringUtils.startsWith(s, "ou=") && !StringUtils.equals(s, "ou=swift")) {
           return StringUtils.upperCase(StringUtils.substringAfter(s, "ou="));
        }
        */
    }
    return null;
}