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

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

Introduction

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

Prototype

public static String removeStart(String str, String remove) 

Source Link

Document

Removes a substring only if it is at the begining of a source string, otherwise returns the source string.

Usage

From source file:info.magnolia.module.admininterface.DialogHandlerManager.java

/**
 * Check if this dialog is used by a paragraph. If so register it under the paragraphs name.
 * @param dialog//from   www .ja v  a2 s  . c  o m
 */
private void registerAsParagraphDialog(String basePath, Content dialog) {

    String dialogPath = StringUtils.removeStart(dialog.getHandle(), basePath + "/");
    String dialogName = dialog.getNodeData(ND_NAME).getString();
    if (StringUtils.isEmpty(dialogName)) {
        dialogName = dialog.getName();
    }

    Map paragraphs = ParagraphManager.getInstance().getParagraphs();
    for (Iterator iter = paragraphs.entrySet().iterator(); iter.hasNext();) {
        Paragraph paragraph = (Paragraph) ((Entry) iter.next()).getValue();
        String paragraphDialogPath = paragraph.getDialogPath();
        String paragraphDialogName = paragraph.getDialog();

        if (StringUtils.equals(paragraphDialogPath, dialogPath)
                || StringUtils.equals(paragraphDialogName, dialogName)) {
            Class handler = ParagraphEditDialog.class;

            String className = dialog.getNodeData(CLASS).getString(); //$NON-NLS-1$
            if (StringUtils.isNotEmpty(className)) {
                try {
                    handler = Class.forName(className);
                } catch (ClassNotFoundException e) {
                    log.error("Registering paragraph: class [" + className + "] not found", e); //$NON-NLS-1$ //$NON-NLS-2$
                }
            }

            registerDialogHandler(paragraph.getName(), handler, dialog);
        }
    }

}

From source file:hudson.plugins.clearcase.ucm.model.ActivitiesDelta.java

private static Activity parseLeftLine(String line) {
    String activityLine = StringUtils.removeStart(line, LEFT_PREFIX);
    return buildActivity(activityLine);
}

From source file:com.dp2345.plugin.oss.OssPlugin.java

@Override
public List<FileInfo> browser(String path) {
    List<FileInfo> fileInfos = new ArrayList<FileInfo>();
    PluginConfig pluginConfig = getPluginConfig();
    if (pluginConfig != null) {
        String accessId = pluginConfig.getAttribute("accessId");
        String accessKey = pluginConfig.getAttribute("accessKey");
        String bucketName = pluginConfig.getAttribute("bucketName");
        String urlPrefix = pluginConfig.getAttribute("urlPrefix");
        try {//from  w ww.  j  a  v  a  2  s . c  o m
            OSSClient ossClient = new OSSClient(accessId, accessKey);
            ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucketName);
            listObjectsRequest.setPrefix(StringUtils.removeStart(path, "/"));
            listObjectsRequest.setDelimiter("/");
            ObjectListing objectListing = ossClient.listObjects(listObjectsRequest);
            for (String commonPrefix : objectListing.getCommonPrefixes()) {
                FileInfo fileInfo = new FileInfo();
                fileInfo.setName(StringUtils.substringAfterLast(StringUtils.removeEnd(commonPrefix, "/"), "/"));
                fileInfo.setUrl(urlPrefix + "/" + commonPrefix);
                fileInfo.setIsDirectory(true);
                fileInfo.setSize(0L);
                fileInfos.add(fileInfo);
            }
            for (OSSObjectSummary ossObjectSummary : objectListing.getObjectSummaries()) {
                if (ossObjectSummary.getKey().endsWith("/")) {
                    continue;
                }
                FileInfo fileInfo = new FileInfo();
                fileInfo.setName(StringUtils.substringAfterLast(ossObjectSummary.getKey(), "/"));
                fileInfo.setUrl(urlPrefix + "/" + ossObjectSummary.getKey());
                fileInfo.setIsDirectory(false);
                fileInfo.setSize(ossObjectSummary.getSize());
                fileInfo.setLastModified(ossObjectSummary.getLastModified());
                fileInfos.add(fileInfo);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return fileInfos;
}

From source file:com.cognifide.actions.msg.push.passive.PushServlet.java

public void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
        throws ServletException, IOException {
    if (!authenticate(request, response)) {
        return;//from  w  w w  .  j  a  va 2  s .  c om
    }

    final String msgId = StringUtils.removeStart(request.getRequestPathInfo().getSuffix(), "/");
    if (StringUtils.isBlank(msgId)) {
        throw new ServletException("No suffix found");
    }
    if (!sentMessages.contains(msgId)) {
        throw new ServletException("No one is waiting for confirmation for " + msgId);
    } else {
        receivedConfirmations.add(msgId);
        synchronized (receivedConfirmations) {
            receivedConfirmations.notifyAll();
        }
        response.getWriter().append("Message " + msgId + " confirmed");
        LOG.debug("Message " + msgId + " confirmed");
    }
}

From source file:com.predic8.membrane.core.interceptor.IndexInterceptor.java

private ServiceInfo getServiceInfo(Exchange exc, AbstractServiceProxy sp) {
    if (sp.getInterceptors().size() == 1 && sp.getInterceptors().get(0) instanceof IndexInterceptor)
        return null;

    ServiceProxyKey k = (ServiceProxyKey) sp.getKey();

    ServiceInfo ri = new ServiceInfo();

    ri.method = k.getMethod();//from  w ww .  j  a  va 2 s  .  c  o  m

    ri.ssl = sp.getSslInboundContext() != null;// NOTE: when running as servlet, we have no idea what the protocol was
    String protocol = ri.ssl ? "https" : "http";

    String host = k.isHostWildcard() ? new HostColonPort(ri.ssl, exc.getRequest().getHeader().getHost()).host
            : fullfillRegexp(ServiceProxyKey.createHostPattern(k.getHost()));
    if (host == null || host.length() == 0)
        host = exc.getHandler().getLocalAddress().getHostAddress().toString();

    int port = k.getPort();
    if (port == -1 || !exc.getHandler().isMatchLocalPort())
        port = exc.getHandler().getLocalPort();

    String path;
    if (!k.isUsePathPattern()) {
        path = "/";
    } else if (k.isPathRegExp()) {
        path = fullfillRegexp(k.getPath());
    } else {
        path = "/" + StringUtils.removeStart(k.getPath(), "/");
    }

    if (!"".equals(exc.getHandler().getContextPath(exc))) {
        path = StringUtils.removeEnd(exc.getHandler().getContextPath(exc), "/") + "/"
                + StringUtils.removeStart(path, "/");
    }

    ri.name = sp.getName();
    if (path != null)
        ri.url = protocol + "://" + host + ":" + port + path;
    ri.host = k.isHostWildcard() ? "" : StringEscapeUtils.escapeHtml(k.getHost());
    ri.port = k.getPort() == -1 ? "" : "" + k.getPort();
    ri.path = k.isUsePathPattern()
            ? "<tt>" + StringEscapeUtils.escapeHtml(k.getPath()) + "</tt>"
                    + (k.isPathRegExp() ? " (regex)" : "")
            : "";
    return ri;
}

From source file:com.ewcms.publication.uri.UriRule.java

/**
 * ??//from  ww w  .ja va2 s . c o  m
 * 
 * @param variable ????
 * @param parameters ??
 * @return ??
 * @throws PublishException
 */
Object getVariableValue(String variable, Map<String, Object> parameters) throws PublishException {
    logger.debug("Variable is {}", variable);
    String p = StringUtils.splitPreserveAllTokens(variable, ".")[0];
    logger.debug("Parameter name is {}", p);

    String parameter = ALIAS_PARAMETERS.get(p);
    if (parameter == null) {
        logger.warn("\"{}\" parameter is not exist", p);
        parameter = p;
    }
    Object object = parameters.get(parameter);
    if (object == null) {
        logger.error("\"{}\" parameter is not exist", parameter);
        throw new PublishException(variable + " is not exist");
    }
    try {
        if (!p.equals(variable)) {
            String property = StringUtils.removeStart(variable, p + ".");
            logger.debug("Property name is {}", property);
            return PropertyUtils.getProperty(object, property);
        } else {
            return object;
        }
    } catch (Exception e) {
        logger.error("Get variable value is error:{}", e.toString());
        throw new PublishException(e);
    }
}

From source file:com.sonicle.webtop.vfs.sfs.StoreFileSystem.java

public String relativizePath(String path) {
    return PathUtils.ensureBeginningSeparator(StringUtils.removeStart(path, uri.getPath()));
}

From source file:com.yhd.spark.oozie.OozieAuditLogParser.java

private void applyValueTo(OozieAuditLogObject oozieAuditLogObject, Matcher matcher) throws ParseException {
    oozieAuditLogObject.timestamp = DateTimeUtil.humanDateToMilliseconds(matcher.group(1));
    oozieAuditLogObject.level = matcher.group(2);
    oozieAuditLogObject.ip = StringUtils.removeEnd(StringUtils.removeStart(matcher.group(6), "["), "]");
    oozieAuditLogObject.user = StringUtils.removeEnd(StringUtils.removeStart(matcher.group(9), "["), "]");
    oozieAuditLogObject.group = StringUtils.removeEnd(StringUtils.removeStart(matcher.group(12), "["), "]");
    oozieAuditLogObject.app = StringUtils.removeEnd(StringUtils.removeStart(matcher.group(15), "["), "]");
    oozieAuditLogObject.jobId = StringUtils.removeEnd(StringUtils.removeStart(matcher.group(18), "["), "]");
    oozieAuditLogObject.operation = StringUtils.removeEnd(StringUtils.removeStart(matcher.group(21), "["), "]");
    oozieAuditLogObject.parameter = StringUtils.removeEnd(StringUtils.removeStart(matcher.group(24), "["), "]");
    oozieAuditLogObject.status = StringUtils.removeEnd(StringUtils.removeStart(matcher.group(27), "["), "]");
    oozieAuditLogObject.httpcode = StringUtils.removeEnd(StringUtils.removeStart(matcher.group(30), "["), "]");
    oozieAuditLogObject.errorcode = StringUtils.removeEnd(StringUtils.removeStart(matcher.group(33), "["), "]");
    oozieAuditLogObject.errormessage = StringUtils.removeEnd(StringUtils.removeStart(matcher.group(36), "["),
            "]");
}

From source file:mitm.common.util.DomainUtils.java

/**
 * Removes the wildcard part of a domain. If domain does not have a wildcard part the complete domain
 * is returned. The returned domain is canonicalized. 
 *///from ww w  .  j ava2 s . co m
public static String removeWildcard(String domain) {
    String validated = canonicalizeAndValidate(domain, DomainType.WILD_CARD);

    return StringUtils.removeStart(validated, "*.");
}

From source file:com.netflix.paas.config.base.ConfigurationProxyUtils.java

static String getPropertyName(Method method, Configuration c) {
    String name = c.value();//from  www. j av  a 2s .  c om
    if (name.isEmpty()) {
        name = method.getName();
        name = StringUtils.removeStart(name, "is");
        name = StringUtils.removeStart(name, "get");
        name = name.toLowerCase();
    }
    return name;
}