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

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

Introduction

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

Prototype

public static String removeStart(final String str, final String remove) 

Source Link

Document

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

A null source string will return null .

Usage

From source file:org.codice.ddf.catalog.plugin.metacard.backup.storage.s3storage.MetacardS3StorageRoute.java

public void setObjectTemplate(String objectTemplate) {
    this.objectTemplate = StringUtils.removeStart(objectTemplate, "/");
}

From source file:org.codice.ddf.test.common.UrlBuilder.java

private String cleanContextPath(String contextPath) {
    String cleanContextPath = StringUtils.removeEnd(contextPath, "/");
    return StringUtils.removeStart(cleanContextPath, "/");
}

From source file:org.craftercms.core.url.impl.RemovePrefixAndSuffixUrlTransformer.java

@Override
public String transformUrl(Context context, CachingOptions cachingOptions, String url)
        throws UrlTransformationException {
    if (StringUtils.isNotEmpty(prefix)) {
        url = StringUtils.removeStart(url, prefix);
    }//from ww w .  j a v a  2 s  .  com
    if (StringUtils.isNotEmpty(suffix)) {
        url = StringUtils.removeEnd(url, suffix);
    }

    return url;
}

From source file:org.cryptomator.filesystem.crypto.CryptoFolder.java

private String removeDirPrefix(String encryptedFolderName) {
    return StringUtils.removeStart(encryptedFolderName, DIR_PREFIX);
}

From source file:org.cryptomator.filesystem.jackrabbit.FileSystemResourceLocatorFactory.java

@Override
public FileSystemResourceLocator createResourceLocator(String prefix, String href) {
    final String fullPrefix = StringUtils.removeEnd(prefix, "/");
    final String remainingHref = StringUtils.removeStart(href, fullPrefix);
    final String unencodedRemaingingHref = EncodeUtil.unescape(remainingHref);
    return createResourceLocator(unencodedRemaingingHref);
}

From source file:org.cryptomator.frontend.webdav.mount.MacOsXAppleScriptWebDavMounter.java

@Override
public WebDavMount mount(URI uri, Map<MountParam, Optional<String>> mountParams) throws CommandFailedException {
    try {/*ww  w . ja v a 2  s . c  om*/
        String mountAppleScript = String.format("mount volume \"%s\"", uri.toString());
        ProcessBuilder mount = new ProcessBuilder("/usr/bin/osascript", "-e", mountAppleScript);
        Process mountProcess = mount.start();
        String stdout = IOUtils.toString(mountProcess.getInputStream(), StandardCharsets.UTF_8);
        waitForProcessAndCheckSuccess(mountProcess, 1, TimeUnit.SECONDS);
        String volumeIdentifier = StringUtils.trim(StringUtils.removeStart(stdout, "file "));
        String waitAppleScript1 = String
                .format("tell application \"Finder\" to repeat while not (\"%s\" exists)", volumeIdentifier);
        String waitAppleScript2 = "delay 0.1";
        String waitAppleScript3 = "end repeat";
        ProcessBuilder wait = new ProcessBuilder("/usr/bin/osascript", "-e", waitAppleScript1, "-e",
                waitAppleScript2, "-e", waitAppleScript3);
        Process waitProcess = wait.start();
        waitForProcessAndCheckSuccess(waitProcess, 5, TimeUnit.SECONDS);
        return new MacWebDavMount(volumeIdentifier);
    } catch (IOException e) {
        throw new CommandFailedException(e);
    }
}

From source file:org.cryptomator.frontend.webdav.servlet.DavLocatorFactoryImpl.java

@Override
public DavLocatorImpl createResourceLocator(String prefix, String href) {
    final String canonicalPrefix = StringUtils.appendIfMissing(prefix, "/");
    final String hrefWithoutPrefix = StringUtils.removeStart(StringUtils.removeStart(href, "/"),
            canonicalPrefix);/* w w  w  . j a va2 s. c om*/
    final String resourcePath = EncodeUtil.unescape(hrefWithoutPrefix);
    return createResourceLocator(canonicalPrefix, null, resourcePath);
}

From source file:org.cryptomator.webdav.jackrabbit.DavLocatorFactoryImpl.java

@Override
public DavResourceLocator createResourceLocator(String prefix, String href) {
    final String fullPrefix = prefix.endsWith("/") ? prefix : prefix + "/";
    final String relativeHref = StringUtils.removeStart(href, fullPrefix);

    final String resourcePath = EncodeUtil.unescape(StringUtils.removeStart(relativeHref, "/"));
    return new DavResourceLocatorImpl(fullPrefix, resourcePath);
}

From source file:org.eclipse.ebr.maven.EclipseIpLogUtil.java

private String getProjectLocation(final Model recipePom, final Xpp3Dom existingIpLog) {
    final String existingValue = getProjectInfo(existingIpLog, "location");
    if (existingValue != null)
        return existingValue;

    final Scm scm = recipePom.getScm();
    if (scm != null) {
        final String url = getScmUrl(scm);

        // by definition, we return everything after to the last ".git"
        if (url != null) {
            final int lastIndexOf = StringUtils.lastIndexOf(url, ".git");
            if (lastIndexOf >= 0)
                return StringUtils.removeStart(url.substring(lastIndexOf + 4), "/");
            return url;
        }//www  .  ja  v a  2  s .c om
    }

    return null;
}

From source file:org.eclipse.ebr.maven.LicenseProcessingUtility.java

protected String removeWebProtocols(final String url) {
    return StringUtils.removeStart(StringUtils.removeStart(url, HTTPS_PREFIX), HTTP_PREFIX);
}