public static Artifact fromMvnUrl()

in src/main/java/org/apache/sling/provisioning/model/Artifact.java [101:152]


    public static Artifact fromMvnUrl(final String url) {
        if ( url == null || !url.startsWith("mvn:") ) {
            throw new IllegalArgumentException("Invalid mvn url: " + url);
        }
        final String content = url.substring(4);
        // ignore repository url
        int pos = content.indexOf('!');
        if ( pos != -1 ) {
            throw new IllegalArgumentException("Repository url is not supported for Maven artifacts at the moment.");
        }
        final String coordinates = (pos == -1 ? content : content.substring(pos + 1));
        String gId = null;
        String aId = null;
        String version = null;
        String type = null;
        String classifier = null;
        int part = 0;
        String value = coordinates;
        while ( value != null ) {
            pos = value.indexOf('/');
            final String current;
            if ( pos == -1 ) {
                current = value;
                value = null;
            } else {
                if ( pos == 0 ) {
                    current = null;
                } else {
                    current = value.substring(0, pos);
                }
                value = value.substring(pos + 1);
            }
            if ( current != null ) {
                if ( part == 0 ) {
                    gId = current;
                } else if ( part == 1 ) {
                    aId = current;
                } else if ( part == 2 ) {
                    version = current;
                } else if ( part == 3 ) {
                    type = current;
                } else if ( part == 4 ) {
                    classifier = current;
                }
            }
            part++;
        }
        if ( version == null ) {
            version = "LATEST";
        }
        return new Artifact(gId, aId, version, classifier, type);
    }