Package org.apache.geronimo.kernel.repository

Examples of org.apache.geronimo.kernel.repository.Version


        } else {
            // todo: not very efficient
            SortedSet set = list();
            String targetGroup = query.getGroupId();
            String targetArtifact = query.getArtifactId();
            Version targetVersion = query.getVersion();
            String targetType = query.getType();
            for (Iterator it = set.iterator(); it.hasNext();) {
                Artifact candidate = (Artifact) it.next();
                if(targetGroup != null && !targetGroup.equals(candidate.getGroupId())) {
                    continue;
                }
                if(targetArtifact != null && !targetArtifact.equals(candidate.getArtifactId())) {
                    continue;
                }
                if(targetType != null && !targetType.equals(candidate.getType())) {
                    continue;
                }
                if(targetVersion != null && !targetVersion.equals(candidate.getVersion())) {
                    continue;
                }
                artifacts.add(candidate);
            }
        }
View Full Code Here


    public boolean canConvert(Class clazz) {
        return Version.class.isAssignableFrom(clazz);
    }

    protected Object fromString(String string) {
        return new Version(string);
    }
View Full Code Here

            return null;
        }
        list = ((Element)list.item(0)).getElementsByTagName("version");
        Version[] available = new Version[list.getLength()];
        for (int i = 0; i < available.length; i++) {
            available[i] = new Version(getText(list.item(i)));
        }
        Arrays.sort(available);
        for(int i=available.length-1; i>=0; i--) {
            Version version = available[i];
            URL test = new URL(url.toString()+base+"/"+version+"/"+query.getArtifactId()+"-"+version+"."+query.getType());
            InputStream testStream = connect(test, username, password, monitor, "HEAD");
            if(testStream == null) {
                log.warn("Maven repository "+url+" listed artifact "+query+" version "+version+" but I couldn't find it at "+test);
                continue;
View Full Code Here

    public boolean canConvert(Class clazz) {
        return Version.class.isAssignableFrom(clazz);
    }

    protected Object fromString(String string) {
        return new Version(string);
    }
View Full Code Here

            URL location = getURL(artifact);
            OpenResult result = open(artifact, location);
            if (result != null) {
                return result;
            }
            Version version = artifact.getVersion();
            // Snapshot artifacts can have a special filename in an online maven repo.
            // The version number is replaced with a timestmap and build number.
            // The maven-metadata file contains this extra information.
            if (version.toString().indexOf("SNAPSHOT") >= 0 && !(version instanceof SnapshotVersion)) {
                // base path for the artifact version in a maven repo
                URI basePath = base.resolve(artifact.getGroupId().replace('.', '/') + "/" + artifact.getArtifactId() + "/" + version + "/");

                // get the maven-metadata file
                Document metadata = getMavenMetadata(basePath);

                // determine the snapshot qualifier from the maven-metadata file
                if (metadata != null) {
                    NodeList snapshots = metadata.getDocumentElement().getElementsByTagName("snapshot");
                    if (snapshots.getLength() >= 1) {
                        Element snapshot = (Element) snapshots.item(0);
                        List<String> timestamp = getChildrenText(snapshot, "timestamp");
                        List<String> buildNumber = getChildrenText(snapshot, "buildNumber");
                        if (timestamp.size() >= 1 && buildNumber.size() >= 1) {
                            try {
                                // recurse back into this method using a SnapshotVersion
                                SnapshotVersion snapshotVersion = new SnapshotVersion(version);
                                snapshotVersion.setBuildNumber(Integer.parseInt(buildNumber.get(0)));
                                snapshotVersion.setTimestamp(timestamp.get(0));
                                Artifact newQuery = new Artifact(artifact.getGroupId(), artifact.getArtifactId(), snapshotVersion, artifact.getType());
                                location = getURL(newQuery);
                                return open(artifact, location);
                            } catch (NumberFormatException nfe) {
//                                log.error("Could not create snapshot version for " + artifact, nfe);
                            }
                        } else {
//                            log.error("Could not create snapshot version for " + artifact);
                        }
                    }
                }
            }
            return null;
        }

        // Version is not resolved.  Look in maven-metadata.xml and maven-metadata-local.xml for
        // the available version numbers.  If found then recurse into the enclosing method with
        // a resolved version number
        else {

            // base path for the artifact version in a maven repo
            URI basePath = base.resolve(artifact.getGroupId().replace('.', '/') + "/" + artifact.getArtifactId() + "/");

            // get the maven-metadata file
            Document metadata = getMavenMetadata(basePath);

            // determine the available versions from the maven-metadata file
            if (metadata != null) {
                Element root = metadata.getDocumentElement();
                NodeList list = root.getElementsByTagName("versions");
                list = ((Element) list.item(0)).getElementsByTagName("version");
                Version[] available = new Version[list.getLength()];
                for (int i = 0; i < available.length; i++) {
                    available[i] = new Version(getText(list.item(i)));
                }
                // desc sort
                Arrays.sort(available, new Comparator<Version>() {
                    public int compare(Version o1, Version o2) {
                        return o2.toString().compareTo(o1.toString());
View Full Code Here

        artifact1 = new Artifact("test", "1", "1.1", "bar");
        artifact2 = new Artifact("test", "2", "2.2", "bar");
        artifact3 = new Artifact("test", "3", "3.3", "bar");
        // As if it was deployed with no version, now its version is a timestamp
        artifact3NoVersion = new Artifact(artifact3.getGroupId(), artifact3.getArtifactId(), new Version(Long.toString(System.currentTimeMillis())), artifact3.getType());

        ConfigurationData configurationData1 = configStore.loadConfiguration(artifact1);
        gbean1 = configurationData1.addGBean("gbean1", TestBean.getGBeanInfo()).getAbstractName();
        configurations.put(artifact1, configurationData1);
View Full Code Here

    public boolean canConvert(Class clazz) {
        return Version.class.isAssignableFrom(clazz);
    }

    protected Object fromString(String string) {
        return new Version(string);
    }
View Full Code Here

public class ModuleIDBuilder {
    private Version defaultVersion;
    private String defaultGroup;

    public ModuleIDBuilder() {
        defaultVersion = new Version(Long.toString(System.currentTimeMillis()));
        defaultGroup = Artifact.DEFAULT_GROUP_ID;
    }
View Full Code Here

        artifact1 = new Artifact("test", "1", "1.1", "bar");
        artifact2 = new Artifact("test", "2", "2.2", "bar");
        artifact3 = new Artifact("test", "3", "3.3", "bar");
        // As if it was deployed with no version, now its version is a timestamp
        artifact3NoVersion = new Artifact(artifact3.getGroupId(), artifact3.getArtifactId(), new Version(Long.toString(System.currentTimeMillis())), artifact3.getType());

        ConfigurationData configurationData1 = configStore.loadConfiguration(artifact1);
        gbean1 = configurationData1.addGBean("gbean1", TestBean.getGBeanInfo()).getAbstractName();
        configurations.put(artifact1, configurationData1);
View Full Code Here

            URL location = getURL(artifact);
            OpenResult result = open(artifact, location);
            if (result != null) {
                return result;
            }
            Version version = artifact.getVersion();
            // Snapshot artifacts can have a special filename in an online maven repo.
            // The version number is replaced with a timestmap and build number.
            // The maven-metadata file contains this extra information.
            if (version.toString().indexOf("SNAPSHOT") >= 0 && !(version instanceof SnapshotVersion)) {
                // base path for the artifact version in a maven repo
                URI basePath = base.resolve(artifact.getGroupId().replace('.', '/') + "/" + artifact.getArtifactId() + "/" + version + "/");

                // get the maven-metadata file
                Document metadata = getMavenMetadata(basePath);

                // determine the snapshot qualifier from the maven-metadata file
                if (metadata != null) {
                    NodeList snapshots = metadata.getDocumentElement().getElementsByTagName("snapshot");
                    if (snapshots.getLength() >= 1) {
                        Element snapshot = (Element) snapshots.item(0);
                        List<String> timestamp = getChildrenText(snapshot, "timestamp");
                        List<String> buildNumber = getChildrenText(snapshot, "buildNumber");
                        if (timestamp.size() >= 1 && buildNumber.size() >= 1) {
                            try {
                                // recurse back into this method using a SnapshotVersion
                                SnapshotVersion snapshotVersion = new SnapshotVersion(version);
                                snapshotVersion.setBuildNumber(Integer.parseInt(buildNumber.get(0)));
                                snapshotVersion.setTimestamp(timestamp.get(0));
                                Artifact newQuery = new Artifact(artifact.getGroupId(), artifact.getArtifactId(), snapshotVersion, artifact.getType());
                                location = getURL(newQuery);
                                return open(artifact, location);
                            } catch (NumberFormatException nfe) {
//                                log.error("Could not create snapshot version for " + artifact, nfe);
                            }
                        } else {
//                            log.error("Could not create snapshot version for " + artifact);
                        }
                    }
                }
            }
            return null;
        }

        // Version is not resolved.  Look in maven-metadata.xml and maven-metadata-local.xml for
        // the available version numbers.  If found then recurse into the enclosing method with
        // a resolved version number
        else {

            // base path for the artifact version in a maven repo
            URI basePath = base.resolve(artifact.getGroupId().replace('.', '/') + "/" + artifact.getArtifactId() + "/");

            // get the maven-metadata file
            Document metadata = getMavenMetadata(basePath);

            // determine the available versions from the maven-metadata file
            if (metadata != null) {
                Element root = metadata.getDocumentElement();
                NodeList list = root.getElementsByTagName("versions");
                list = ((Element) list.item(0)).getElementsByTagName("version");
                Version[] available = new Version[list.getLength()];
                for (int i = 0; i < available.length; i++) {
                    available[i] = new Version(getText(list.item(i)));
                }
                // desc sort
                Arrays.sort(available, new Comparator<Version>() {
                    public int compare(Version o1, Version o2) {
                        return o2.toString().compareTo(o1.toString());
View Full Code Here

TOP

Related Classes of org.apache.geronimo.kernel.repository.Version

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.