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

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

Introduction

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

Prototype

public static String stripEnd(String str, String stripChars) 

Source Link

Document

Strips any of a set of characters from the end of a String.

Usage

From source file:org.apereo.lap.services.input.csv.BaseCSVInputHandler.java

@Override
public SampleCSVInputHandlerService.InputCollection getHandledCollection() {
    // convert the CSV filename into a standard collection name
    return BaseInputHandlerService.InputCollection.fromString(StringUtils.stripEnd(getFileName(), ".csv"));
}

From source file:org.candlepin.util.X509Util.java

/**
 * Creates a Content URL from the prefix and the path
 * @param contentPrefix to prepend to the path
 * @param pc the product content/*from   w w  w . j av a 2  s. c  o  m*/
 * @return the complete content path
 */
public String createFullContentPath(String contentPrefix, ProductContent pc) {
    String prefix = "/";
    String contentPath = pc.getContent().getContentUrl();

    // Allow for the case where the content URL is a true URL.
    // If that is true, then return it as is.
    if (contentPath != null && (contentPath.startsWith("http://") || contentPath.startsWith("file://")
            || contentPath.startsWith("https://") || contentPath.startsWith("ftp://"))) {

        return contentPath;
    }

    if (!StringUtils.isEmpty(contentPrefix)) {
        // Ensure there is no double // in the URL. See BZ952735
        // remove them all except one.
        prefix = StringUtils.stripEnd(contentPrefix, "/") + prefix;
    }

    contentPath = StringUtils.stripStart(contentPath, "/");
    return prefix + contentPath;
}

From source file:org.codehaus.mojo.mrm.impl.maven.ArtifactStoreFileSystem.java

/**
 * {@inheritDoc}//from   w  w w  .  j a v  a  2 s  . c  o m
 */
protected Entry get(DirectoryEntry parent, String name) {

    String path = parent.toPath() + "/" + name;

    if ("favicon.ico".equals(name)) {
        return null;
    }
    if (METADATA.matcher(path).matches()) {
        MetadataFileEntry entry = new MetadataFileEntry(this, parent, parent.toPath(), store);
        try {
            entry.getLastModified();
            return entry;
        } catch (IOException e) {
            return null;
        }
    } else {
        Matcher snapshotArtifact = SNAPSHOT_ARTIFACT.matcher(path);
        if (snapshotArtifact.matches()) {
            String groupId = StringUtils.stripEnd(snapshotArtifact.group(1), "/").replace('/', '.');
            String artifactId = snapshotArtifact.group(2);
            String version = snapshotArtifact.group(3) + "-SNAPSHOT";
            Pattern rule = Pattern.compile("\\Q" + artifactId + "\\E-(?:\\Q"
                    + StringUtils.removeEnd(version, "-SNAPSHOT")
                    + "\\E-(SNAPSHOT|(\\d{4})(\\d{2})(\\d{2})\\.(\\d{2})(\\d{2})(\\d{2})-(\\d+)))(?:-([^.]+))?\\.([^/]*)");
            Matcher matcher = rule.matcher(name);
            if (!matcher.matches()) {
                String classifier = snapshotArtifact.group(5);
                String type = snapshotArtifact.group(6);
                if (classifier != null) {
                    classifier = classifier.substring(1);
                }
                if (StringUtils.isEmpty(classifier)) {
                    classifier = null;
                }
                return new ArtifactFileEntry(this, parent,
                        new Artifact(groupId, artifactId, version, classifier, type), store);
            }
            if (matcher.group(1).equals("SNAPSHOT")) {
                Artifact artifact = new Artifact(groupId, artifactId, version, matcher.group(9),
                        matcher.group(10));
                try {
                    store.get(artifact);
                    return new ArtifactFileEntry(this, parent, artifact, store);
                } catch (IOException e) {
                    return null;
                } catch (ArtifactNotFoundException e) {
                    return null;
                }
            }
            try {
                Calendar cal = new GregorianCalendar();
                cal.setTimeZone(TimeZone.getTimeZone("GMT"));
                cal.set(Calendar.YEAR, Integer.parseInt(matcher.group(2)));
                cal.set(Calendar.MONTH, Integer.parseInt(matcher.group(3)) - 1);
                cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(matcher.group(4)));
                cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(matcher.group(5)));
                cal.set(Calendar.MINUTE, Integer.parseInt(matcher.group(6)));
                cal.set(Calendar.SECOND, Integer.parseInt(matcher.group(7)));
                long timestamp = cal.getTimeInMillis();
                int buildNumber = Integer.parseInt(matcher.group(8));

                Artifact artifact = new Artifact(groupId, artifactId, version, matcher.group(9),
                        matcher.group(10), timestamp, buildNumber);
                try {
                    store.get(artifact);
                    return new ArtifactFileEntry(this, parent, artifact, store);
                } catch (IOException e) {
                    return null;
                } catch (ArtifactNotFoundException e) {
                    return null;
                }
            } catch (NullPointerException e) {
                return new DefaultDirectoryEntry(this, parent, name);
            }
        } else {
            Matcher matcher = ARTIFACT.matcher(path);
            if (matcher.matches()) {
                String groupId = StringUtils.stripEnd(matcher.group(1), "/").replace('/', '.');
                String artifactId = matcher.group(2);
                String version = matcher.group(3);
                String classifier = matcher.group(5);
                String type = matcher.group(6);
                if (classifier != null) {
                    classifier = classifier.substring(1);
                }
                if (StringUtils.isEmpty(classifier)) {
                    classifier = null;
                }

                Artifact artifact = new Artifact(groupId, artifactId, version, classifier, type);
                try {
                    store.get(artifact);
                    return new ArtifactFileEntry(this, parent, artifact, store);
                } catch (ArtifactNotFoundException e) {
                    return null;
                } catch (IOException e) {
                    return null;
                }
            } else {
                return new DefaultDirectoryEntry(this, parent, name);
            }
        }
    }
}

From source file:org.codehaus.mojo.mrm.impl.maven.MemoryArtifactStore.java

/**
 * {@inheritDoc}//www . j  a va2 s  .c o  m
 */
public synchronized Metadata getMetadata(String path) throws IOException, MetadataNotFoundException {
    Metadata metadata = new Metadata();
    boolean foundMetadata = false;
    path = StringUtils.stripEnd(StringUtils.stripStart(path, "/"), "/");
    String groupId = path.replace('/', '.');
    Set pluginArtifactIds = getArtifactIds(groupId);
    if (pluginArtifactIds != null) {
        List plugins = new ArrayList();
        for (Iterator i = pluginArtifactIds.iterator(); i.hasNext();) {
            String artifactId = (String) i.next();
            Set pluginVersions = getVersions(groupId, artifactId);
            if (pluginVersions == null || pluginVersions.isEmpty()) {
                continue;
            }
            String[] versions = (String[]) pluginVersions.toArray(new String[pluginVersions.size()]);
            Arrays.sort(versions, new VersionComparator());
            MavenXpp3Reader reader = new MavenXpp3Reader();
            for (int j = versions.length - 1; j >= 0; j--) {
                InputStream inputStream = null;
                try {
                    inputStream = get(new Artifact(groupId, artifactId, versions[j], "pom"));
                    Model model = reader.read(new XmlStreamReader(inputStream));
                    if (model == null || !"maven-plugin".equals(model.getPackaging())) {
                        continue;
                    }
                    Plugin plugin = new Plugin();
                    plugin.setArtifactId(artifactId);
                    plugin.setName(model.getName());
                    // TODO proper goal-prefix determination
                    // ugh! this is incredibly hacky and does not handle some fool that sets the goal prefix in
                    // a parent pom... ok unlikely, but stupid is as stupid does
                    boolean havePrefix = false;
                    final Build build = model.getBuild();
                    if (build != null && build.getPlugins() != null) {
                        havePrefix = setPluginGoalPrefixFromConfiguration(plugin, build.getPlugins());
                    }
                    if (!havePrefix && build != null && build.getPluginManagement() != null
                            && build.getPluginManagement().getPlugins() != null) {
                        havePrefix = setPluginGoalPrefixFromConfiguration(plugin,
                                build.getPluginManagement().getPlugins());
                    }
                    if (!havePrefix && artifactId.startsWith("maven-") && artifactId.endsWith("-plugin")) {
                        plugin.setPrefix(StringUtils.removeStart(StringUtils.removeEnd(artifactId, "-plugin"),
                                "maven-"));
                        havePrefix = true;
                    }
                    if (!havePrefix && artifactId.endsWith("-maven-plugin")) {
                        plugin.setPrefix(StringUtils.removeEnd(artifactId, "-maven-plugin"));
                        havePrefix = true;
                    }
                    if (!havePrefix) {
                        plugin.setPrefix(artifactId);
                    }
                    plugins.add(plugin);
                    foundMetadata = true;
                    break;
                } catch (ArtifactNotFoundException e) {
                    // ignore
                } catch (XmlPullParserException e) {
                    // ignore
                } finally {
                    IOUtils.closeQuietly(inputStream);
                }
            }
        }
        if (!plugins.isEmpty()) {
            metadata.setPlugins(plugins);
        }
    }
    int index = path.lastIndexOf('/');
    groupId = (index == -1 ? groupId : groupId.substring(0, index)).replace('/', '.');
    String artifactId = (index == -1 ? null : path.substring(index + 1));
    if (artifactId != null) {
        Set artifactVersions = getVersions(groupId, artifactId);
        if (artifactVersions != null && !artifactVersions.isEmpty()) {
            metadata.setGroupId(groupId);
            metadata.setArtifactId(artifactId);
            Versioning versioning = new Versioning();
            List versions = new ArrayList(artifactVersions);
            Collections.sort(versions, new VersionComparator()); // sort the Maven way
            long lastUpdated = 0;
            for (Iterator i = versions.iterator(); i.hasNext();) {
                String version = (String) i.next();
                try {
                    long lastModified = getLastModified(new Artifact(groupId, artifactId, version, "pom"));
                    versioning.addVersion(version);
                    if (lastModified >= lastUpdated) {
                        lastUpdated = lastModified;
                        versioning.setLastUpdatedTimestamp(new Date(lastModified));
                        versioning.setLatest(version);
                        if (!version.endsWith("-SNAPSHOT")) {
                            versioning.setRelease(version);
                        }
                    }
                } catch (ArtifactNotFoundException e) {
                    // ignore
                }
            }
            metadata.setVersioning(versioning);
            foundMetadata = true;
        }
    }

    int index2 = index == -1 ? -1 : path.lastIndexOf('/', index - 1);
    groupId = index2 == -1 ? groupId : groupId.substring(0, index2).replace('/', '.');
    artifactId = index2 == -1 ? artifactId : path.substring(index2 + 1, index);
    String version = index2 == -1 ? null : path.substring(index + 1);
    if (version != null && version.endsWith("-SNAPSHOT")) {
        Map artifactMap = (Map) contents.get(groupId);
        Map versionMap = (Map) (artifactMap == null ? null : artifactMap.get(artifactId));
        Map filesMap = (Map) (versionMap == null ? null : versionMap.get(version));
        if (filesMap != null) {
            List snapshotVersions = new ArrayList();
            int maxBuildNumber = 0;
            long lastUpdated = 0;
            String timestamp = null;
            boolean found = false;
            for (Iterator i = filesMap.entrySet().iterator(); i.hasNext();) {
                final Map.Entry entry = (Map.Entry) i.next();
                final Artifact artifact = (Artifact) entry.getKey();
                final Content content = (Content) entry.getValue();
                SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmss");
                fmt.setTimeZone(TimeZone.getTimeZone("GMT"));
                String lastUpdatedTime = fmt.format(new Date(content.getLastModified()));
                try {
                    Maven3.addSnapshotVersion(snapshotVersions, artifact, lastUpdatedTime);
                } catch (LinkageError e) {
                    // Maven 2
                }
                if ("pom".equals(artifact.getType())) {
                    if (artifact.getBuildNumber() != null
                            && maxBuildNumber < artifact.getBuildNumber().intValue()) {
                        maxBuildNumber = artifact.getBuildNumber().intValue();
                        timestamp = artifact.getTimestampString();
                    } else {
                        maxBuildNumber = Math.max(1, maxBuildNumber);
                    }
                    lastUpdated = Math.max(lastUpdated, content.getLastModified());
                    found = true;
                }
            }

            if (!snapshotVersions.isEmpty() || found) {
                Versioning versioning = metadata.getVersioning();
                if (versioning == null) {
                    versioning = new Versioning();
                }
                metadata.setGroupId(groupId);
                metadata.setArtifactId(artifactId);
                metadata.setVersion(version);
                try {
                    Maven3.addSnapshotVersions(versioning, snapshotVersions);
                } catch (LinkageError e) {
                    // Maven 2
                }
                if (maxBuildNumber > 0) {
                    Snapshot snapshot = new Snapshot();
                    snapshot.setBuildNumber(maxBuildNumber);
                    snapshot.setTimestamp(timestamp);
                    versioning.setSnapshot(snapshot);
                }
                versioning.setLastUpdatedTimestamp(new Date(lastUpdated));
                metadata.setVersioning(versioning);
                foundMetadata = true;
            }
        }

    }
    if (!foundMetadata) {
        throw new MetadataNotFoundException(path);
    }
    return metadata;
}

From source file:org.codehaus.mojo.mrm.impl.maven.MemoryArtifactStore.java

/**
 * {@inheritDoc}//from  w w w . j  a  v  a2 s  .  co m
 */
public synchronized long getMetadataLastModified(String path) throws IOException, MetadataNotFoundException {
    boolean haveResult = false;
    long result = 0;
    path = StringUtils.stripEnd(StringUtils.stripStart(path, "/"), "/");
    String groupId = path.replace('/', '.');
    Map artifactMap = (Map) contents.get(groupId);
    if (artifactMap != null) {
        for (Iterator i = artifactMap.values().iterator(); i.hasNext();) {
            Map versionMap = (Map) i.next();
            for (Iterator j = versionMap.values().iterator(); j.hasNext();) {
                Map filesMap = (Map) j.next();
                for (Iterator k = filesMap.values().iterator(); k.hasNext();) {
                    Content content = (Content) k.next();
                    haveResult = true;
                    result = Math.max(result, content.getLastModified());
                }
            }
        }
    }
    int index = path.lastIndexOf('/');
    groupId = index == -1 ? groupId : groupId.substring(0, index).replace('/', '.');
    String artifactId = (index == -1 ? null : path.substring(index + 1));
    if (artifactId != null) {
        artifactMap = (Map) contents.get(groupId);
        Map versionMap = (Map) (artifactMap == null ? null : artifactMap.get(artifactId));
        if (versionMap != null) {
            for (Iterator j = versionMap.values().iterator(); j.hasNext();) {
                Map filesMap = (Map) j.next();
                for (Iterator k = filesMap.values().iterator(); k.hasNext();) {
                    Content content = (Content) k.next();
                    haveResult = true;
                    result = Math.max(result, content.getLastModified());
                }
            }
        }
    }
    int index2 = index == -1 ? -1 : path.lastIndexOf('/', index - 1);
    groupId = index2 == -1 ? groupId : groupId.substring(0, index2).replace('/', '.');
    artifactId = index2 == -1 ? artifactId : path.substring(index2 + 1, index);
    String version = index2 == -1 ? null : path.substring(index + 1);
    if (version != null && version.endsWith("-SNAPSHOT")) {
        artifactMap = (Map) contents.get(groupId);
        Map versionMap = (Map) (artifactMap == null ? null : artifactMap.get(artifactId));
        Map filesMap = (Map) (versionMap == null ? null : versionMap.get(version));
        if (filesMap != null) {
            for (Iterator k = filesMap.values().iterator(); k.hasNext();) {
                Content content = (Content) k.next();
                haveResult = true;
                result = Math.max(result, content.getLastModified());
            }
        }
    }
    if (haveResult) {
        return result;
    }
    throw new MetadataNotFoundException(path);
}

From source file:org.codehaus.mojo.mrm.impl.maven.MockArtifactStore.java

/**
 * {@inheritDoc}//from w  w w  . j  a v a  2  s .c o  m
 */
public synchronized Metadata getMetadata(String path) throws IOException, MetadataNotFoundException {
    Metadata metadata = new Metadata();
    boolean foundMetadata = false;
    path = StringUtils.stripEnd(StringUtils.stripStart(path, "/"), "/");
    String groupId = path.replace('/', '.');
    Set<String> pluginArtifactIds = getArtifactIds(groupId);
    if (pluginArtifactIds != null) {
        List<Plugin> plugins = new ArrayList<Plugin>();
        for (String artifactId : pluginArtifactIds) {
            Set<String> pluginVersions = getVersions(groupId, artifactId);
            if (pluginVersions == null || pluginVersions.isEmpty()) {
                continue;
            }
            String[] versions = pluginVersions.toArray(new String[pluginVersions.size()]);
            Arrays.sort(versions, new VersionComparator());
            MavenXpp3Reader reader = new MavenXpp3Reader();
            for (int j = versions.length - 1; j >= 0; j--) {
                InputStream inputStream = null;
                try {
                    inputStream = get(new Artifact(groupId, artifactId, versions[j], "pom"));
                    Model model = reader.read(new XmlStreamReader(inputStream));
                    if (model == null || !"maven-plugin".equals(model.getPackaging())) {
                        continue;
                    }
                    Plugin plugin = new Plugin();
                    plugin.setArtifactId(artifactId);
                    plugin.setName(model.getName());
                    // TODO proper goal-prefix determination
                    // ugh! this is incredibly hacky and does not handle some fool that sets the goal prefix in
                    // a parent pom... ok unlikely, but stupid is as stupid does
                    boolean havePrefix = false;
                    final Build build = model.getBuild();
                    if (build != null && build.getPlugins() != null) {
                        havePrefix = setPluginGoalPrefixFromConfiguration(plugin, build.getPlugins());
                    }
                    if (!havePrefix && build != null && build.getPluginManagement() != null
                            && build.getPluginManagement().getPlugins() != null) {
                        havePrefix = setPluginGoalPrefixFromConfiguration(plugin,
                                build.getPluginManagement().getPlugins());
                    }
                    if (!havePrefix && artifactId.startsWith("maven-") && artifactId.endsWith("-plugin")) {
                        plugin.setPrefix(StringUtils.removeStart(StringUtils.removeEnd(artifactId, "-plugin"),
                                "maven-"));
                        havePrefix = true;
                    }
                    if (!havePrefix && artifactId.endsWith("-maven-plugin")) {
                        plugin.setPrefix(StringUtils.removeEnd(artifactId, "-maven-plugin"));
                        havePrefix = true;
                    }
                    if (!havePrefix) {
                        plugin.setPrefix(artifactId);
                    }
                    plugins.add(plugin);
                    foundMetadata = true;
                    break;
                } catch (ArtifactNotFoundException e) {
                    // ignore
                } catch (XmlPullParserException e) {
                    // ignore
                } finally {
                    IOUtils.closeQuietly(inputStream);
                }
            }
        }
        if (!plugins.isEmpty()) {
            metadata.setPlugins(plugins);
        }
    }
    int index = path.lastIndexOf('/');
    groupId = (index == -1 ? groupId : groupId.substring(0, index)).replace('/', '.');
    String artifactId = (index == -1 ? null : path.substring(index + 1));
    if (artifactId != null) {
        Set<String> artifactVersions = getVersions(groupId, artifactId);
        if (artifactVersions != null && !artifactVersions.isEmpty()) {
            metadata.setGroupId(groupId);
            metadata.setArtifactId(artifactId);
            Versioning versioning = new Versioning();
            List<String> versions = new ArrayList<String>(artifactVersions);
            Collections.sort(versions, new VersionComparator()); // sort the Maven way
            long lastUpdated = 0;
            for (String version : versions) {
                try {
                    long lastModified = getLastModified(new Artifact(groupId, artifactId, version, "pom"));
                    versioning.addVersion(version);
                    if (lastModified >= lastUpdated) {
                        lastUpdated = lastModified;
                        versioning.setLastUpdatedTimestamp(new Date(lastModified));
                        versioning.setLatest(version);
                        if (!version.endsWith("-SNAPSHOT")) {
                            versioning.setRelease(version);
                        }
                    }
                } catch (ArtifactNotFoundException e) {
                    // ignore
                }
            }
            metadata.setVersioning(versioning);
            foundMetadata = true;
        }
    }

    int index2 = index == -1 ? -1 : path.lastIndexOf('/', index - 1);
    groupId = index2 == -1 ? groupId : groupId.substring(0, index2).replace('/', '.');
    artifactId = index2 == -1 ? artifactId : path.substring(index2 + 1, index);
    String version = index2 == -1 ? null : path.substring(index + 1);
    if (version != null && version.endsWith("-SNAPSHOT")) {
        Map<String, Map<String, Map<Artifact, Content>>> artifactMap = contents.get(groupId);
        Map<String, Map<Artifact, Content>> versionMap = (artifactMap == null ? null
                : artifactMap.get(artifactId));
        Map<Artifact, Content> filesMap = (versionMap == null ? null : versionMap.get(version));
        if (filesMap != null) {
            List<SnapshotVersion> snapshotVersions = new ArrayList<SnapshotVersion>();
            int maxBuildNumber = 0;
            long lastUpdated = 0;
            String timestamp = null;
            boolean found = false;
            for (final Map.Entry<Artifact, Content> entry : filesMap.entrySet()) {
                final Artifact artifact = entry.getKey();
                final Content content = entry.getValue();
                SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmss");
                fmt.setTimeZone(TimeZone.getTimeZone("GMT"));
                String lastUpdatedTime = fmt.format(new Date(content.getLastModified()));
                try {
                    Maven3.addSnapshotVersion(snapshotVersions, artifact, lastUpdatedTime);
                } catch (LinkageError e) {
                    // Maven 2
                }
                if ("pom".equals(artifact.getType())) {
                    if (artifact.getBuildNumber() != null
                            && maxBuildNumber < artifact.getBuildNumber().intValue()) {
                        maxBuildNumber = artifact.getBuildNumber().intValue();
                        timestamp = artifact.getTimestampString();
                    } else {
                        maxBuildNumber = Math.max(1, maxBuildNumber);
                    }
                    lastUpdated = Math.max(lastUpdated, content.getLastModified());
                    found = true;
                }
            }

            if (!snapshotVersions.isEmpty() || found) {
                Versioning versioning = metadata.getVersioning();
                if (versioning == null) {
                    versioning = new Versioning();
                }
                metadata.setGroupId(groupId);
                metadata.setArtifactId(artifactId);
                metadata.setVersion(version);
                try {
                    Maven3.addSnapshotVersions(versioning, snapshotVersions);
                } catch (LinkageError e) {
                    // Maven 2
                }
                if (maxBuildNumber > 0) {
                    Snapshot snapshot = new Snapshot();
                    snapshot.setBuildNumber(maxBuildNumber);
                    snapshot.setTimestamp(timestamp);
                    versioning.setSnapshot(snapshot);
                }
                versioning.setLastUpdatedTimestamp(new Date(lastUpdated));
                metadata.setVersioning(versioning);
                foundMetadata = true;
            }
        }

    }
    if (!foundMetadata) {
        throw new MetadataNotFoundException(path);
    }
    return metadata;
}

From source file:org.codehaus.mojo.mrm.impl.maven.MockArtifactStore.java

/**
 * {@inheritDoc}//from   ww w .j ava2 s. co m
 */
public synchronized long getMetadataLastModified(String path) throws IOException, MetadataNotFoundException {
    boolean haveResult = false;
    long result = 0;
    path = StringUtils.stripEnd(StringUtils.stripStart(path, "/"), "/");
    String groupId = path.replace('/', '.');
    Map<String, Map<String, Map<Artifact, Content>>> artifactMap = contents.get(groupId);
    if (artifactMap != null) {
        for (Map<String, Map<Artifact, Content>> versionMap : artifactMap.values()) {
            for (Map<Artifact, Content> filesMap : versionMap.values()) {
                for (Content content : filesMap.values()) {
                    haveResult = true;
                    result = Math.max(result, content.getLastModified());
                }
            }
        }
    }
    int index = path.lastIndexOf('/');
    groupId = index == -1 ? groupId : groupId.substring(0, index).replace('/', '.');
    String artifactId = (index == -1 ? null : path.substring(index + 1));
    if (artifactId != null) {
        artifactMap = contents.get(groupId);
        Map<String, Map<Artifact, Content>> versionMap = (artifactMap == null ? null
                : artifactMap.get(artifactId));
        if (versionMap != null) {
            for (Map<Artifact, Content> filesMap : versionMap.values()) {
                for (Content content : filesMap.values()) {
                    haveResult = true;
                    result = Math.max(result, content.getLastModified());
                }
            }
        }
    }
    int index2 = index == -1 ? -1 : path.lastIndexOf('/', index - 1);
    groupId = index2 == -1 ? groupId : groupId.substring(0, index2).replace('/', '.');
    artifactId = index2 == -1 ? artifactId : path.substring(index2 + 1, index);
    String version = index2 == -1 ? null : path.substring(index + 1);
    if (version != null && version.endsWith("-SNAPSHOT")) {
        artifactMap = contents.get(groupId);
        Map<String, Map<Artifact, Content>> versionMap = (artifactMap == null ? null
                : artifactMap.get(artifactId));
        Map<Artifact, Content> filesMap = (versionMap == null ? null : versionMap.get(version));
        if (filesMap != null) {
            for (Content content : filesMap.values()) {
                haveResult = true;
                result = Math.max(result, content.getLastModified());
            }
        }
    }
    if (haveResult) {
        return result;
    }
    throw new MetadataNotFoundException(path);
}

From source file:org.craftercms.search.service.impl.RestClientSearchService.java

@Required
public void setServerUrl(String serverUrl) {
    this.serverUrl = StringUtils.stripEnd(serverUrl, "/");
}

From source file:org.dspace.importer.external.metadatamapping.processor.AuthorMetadataProcessorService.java

@Override
public String processMetadataValue(String value) {
    String ret = value;/*from ww  w  .  j  ava 2s  .co  m*/
    ret = StringUtils.strip(ret);
    ret = StringUtils.stripEnd(ret, ".");

    return ret;
}

From source file:org.dspace.importer.external.metadatamapping.transform.AuthorMetadataProcessorService.java

/**
 * Strip a given value of its last dot (.)
 * @param value the value to run the processing over
 * @return The initial param with its ending dot stripped
 */// w ww  .jav  a 2 s .c o  m
@Override
public String processMetadataValue(String value) {
    String ret = value;
    ret = StringUtils.strip(ret);
    ret = StringUtils.stripEnd(ret, ".");

    return ret;
}