Package org.apache.ivy.core.cache

Examples of org.apache.ivy.core.cache.ArtifactOrigin


        assertNotNull(artifact);

        String expectedLocation = new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar")
                .getAbsolutePath();

        ArtifactOrigin origin = getSavedArtifactOrigin(artifact);
        File artInCache = new File(cache, getArchivePathInCache(artifact, origin));
        assertFalse("should not download artifact in useOrigin mode.", artInCache.exists());
        assertEquals("location for artifact not correct.", expectedLocation,
                getArchiveFileInCache(artifact).getAbsolutePath());
    }
View Full Code Here


    }
   
    public ArtifactOrigin locate(Artifact artifact) {
        for (Iterator iter = chain.iterator(); iter.hasNext();) {
            DependencyResolver resolver = (DependencyResolver) iter.next();
            ArtifactOrigin origin = resolver.locate(artifact);
            if (!ArtifactOrigin.isUnknown(origin)) {
                return origin;
            }
        }
        return ArtifactOrigin.unkwnown(artifact);
View Full Code Here

            DependencyResolver resolver = parserSettings.getResolver(mrid);
           
            if (resolver != null) {
                DefaultArtifact artifact = new DefaultArtifact(
                                    mrid, new Date(), artifactId, "jar", "jar");
                ArtifactOrigin artifactOrigin = resolver.locate(artifact);
               
                if (!ArtifactOrigin.isUnknown(artifactOrigin)) {
                    mainArtifact = artifact;
                    ivyModuleDescriptor.addArtifact("master", mainArtifact);
                }
View Full Code Here

    private void writeOriginLocationIfPresent(
            RepositoryCacheManager cache, TransformerHandler saxHandler,
            ArtifactDownloadReport artifact)
            throws IOException, SAXException {
        ArtifactOrigin origin = artifact.getArtifactOrigin();
        if (!ArtifactOrigin.isUnknown(origin)) {
            String originName = origin.getLocation();
            boolean isOriginLocal = origin.isLocal();

            String originLocation;
            AttributesImpl originLocationAttrs = new AttributesImpl();
            if (isOriginLocal) {
                originLocationAttrs.addAttribute(null, "is-local", "is-local", "CDATA", "true");
View Full Code Here

            new DefaultArtifact(ModuleRevisionId.parse("org1#mod1.1;1.0"), new Date(), "mod1.1", "jar", "jar"),
            new File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar"));
    }

    private void testLocateThenDownload(ResolveEngine engine, Artifact artifact, File artifactFile) {
        ArtifactOrigin origin = engine.locate(artifact);
        assertNotNull(origin);
        assertTrue(origin.isLocal());
        assertEquals(
            artifactFile.getAbsolutePath(),
            new File(origin.getLocation()).getAbsolutePath());
       
        ArtifactDownloadReport r = engine.download(origin, new DownloadOptions());
        assertNotNull(r);
        assertEquals(DownloadStatus.SUCCESSFUL, r.getDownloadStatus());
        assertNotNull(r.getLocalFile());
View Full Code Here

            final ArtifactDownloadReport adr = new ArtifactDownloadReport(artifacts[i]);
            dr.addArtifactReport(adr);
            ResolvedResource artifactRef = getArtifactRef(artifacts[i], null);
            if (artifactRef != null) {
                Message.verbose("\t[NOT REQUIRED] " + artifacts[i]);
                ArtifactOrigin origin = new ArtifactOrigin(
                    artifacts[i], true, artifactRef.getResource().getName());
                File archiveFile = ((FileResource) artifactRef.getResource()).getFile();
                adr.setDownloadStatus(DownloadStatus.NO);
                adr.setSize(archiveFile.length());
                adr.setArtifactOrigin(origin);
View Full Code Here

        addAttribute("status", this.report.getDownloadStatus().toString());
        addAttribute("details", this.report.getDownloadDetails());
        addAttribute("size", String.valueOf(this.report.getSize()));
        addAttribute("file", dest.getAbsolutePath());
        addAttribute("duration", String.valueOf(this.report.getDownloadTimeMillis()));
        ArtifactOrigin origin = report.getArtifactOrigin();
        if (!ArtifactOrigin.isUnknown(origin)) {
            addAttribute("origin", origin.getLocation());
            addAttribute("local", String.valueOf(origin.isLocal()));
        } else {
            addAttribute("origin", "");
            addAttribute("local", "");
        }
    }
View Full Code Here

        }
        return false;
    }
   
    public ArtifactOrigin locate(Artifact artifact) {
        ArtifactOrigin origin = getRepositoryCacheManager().getSavedArtifactOrigin(artifact);
        if (!ArtifactOrigin.isUnknown(origin)) {
            return origin;
        }
        ResolvedResource artifactRef = getArtifactRef(artifact, null);
        if (artifactRef != null && artifactRef.getResource().exists()) {
            return new ArtifactOrigin(
                artifact,
                artifactRef.getResource().isLocal(),
                artifactRef.getResource().getName());
        }
        return null;
View Full Code Here

       
        if (resolver == null) {
            Message.debug("no resolver found for " + mrid
                             + ": no source or javadoc artifact lookup");
        } else {
            ArtifactOrigin mainArtifact = resolver.locate(mdBuilder.getMainArtifact());
           
            if (!ArtifactOrigin.isUnknown(mainArtifact)) {
                String mainArtifactLocation = mainArtifact.getLocation();

                ArtifactOrigin sourceArtifact = resolver.locate(mdBuilder.getSourceArtifact());
                if (!ArtifactOrigin.isUnknown(sourceArtifact)
                        && !sourceArtifact.getLocation().equals(mainArtifactLocation)) {
                    Message.debug("source artifact found for " + mrid);
                    mdBuilder.addSourceArtifact();
                } else {
                    Message.debug("no source artifact found for " + mrid);
                }
                ArtifactOrigin javadocArtifact = resolver.locate(mdBuilder.getJavadocArtifact());
                if (!ArtifactOrigin.isUnknown(javadocArtifact)
                        && !javadocArtifact.getLocation().equals(mainArtifactLocation)) {
                    Message.debug("javadoc artifact found for " + mrid);
                    mdBuilder.addJavadocArtifact();
                } else {
                    Message.debug("no javadoc artifact found for " + mrid);
                }
View Full Code Here

                        if (attributes.getValue("origin-location") != null) {
                            if (ArtifactOrigin.isUnknown(attributes.getValue("origin-location"))) {
                                madr.setArtifactOrigin(ArtifactOrigin.unkwnown(madr.getArtifact()));
                            } else {
                                madr.setArtifactOrigin(
                                    new ArtifactOrigin(
                                        madr.getArtifact(),
                                        parseBoolean(attributes.getValue("origin-is-local")),
                                        attributes.getValue("origin-location")));
                            }
                        }
                    }
                } else if ("artifact".equals(qName)) {
                    if (skip) {
                        return;
                    }
                    String status = attributes.getValue("status");
                    String artifactName = attributes.getValue("name");
                    String type = attributes.getValue("type");
                    String ext = attributes.getValue("ext");
                    Artifact artifact = new DefaultArtifact(mrid, pubdate, artifactName,
                            type, ext, ExtendableItemHelper.getExtraAttributes(attributes,
                                "extra-"));
                    ArtifactDownloadReport aReport = new ArtifactDownloadReport(artifact);
                    aReport.setDownloadStatus(DownloadStatus.fromString(status));
                    aReport.setDownloadDetails(attributes.getValue("details"));
                    aReport.setSize(Long.parseLong(attributes.getValue("size")));
                    aReport.setDownloadTimeMillis(Long.parseLong(attributes.getValue("time")));
                    if (attributes.getValue("location") != null) {
                        aReport.setLocalFile(new File(attributes.getValue("location")));
                    }
                    revisionArtifacts.add(aReport);
                } else if ("origin-location".equals(qName)) {
                    if (skip) {
                        return;
                    }
                    ArtifactDownloadReport aReport = (ArtifactDownloadReport)
                        revisionArtifacts.get(revisionArtifacts.size() - 1);
                   
                    if (ArtifactOrigin.isUnknown(attributes.getValue("location"))) {
                        aReport.setArtifactOrigin(ArtifactOrigin.unkwnown(aReport.getArtifact()));
                    } else {
                        aReport.setArtifactOrigin(
                            new ArtifactOrigin(
                                aReport.getArtifact(),
                                parseBoolean(attributes.getValue("is-local")),
                                attributes.getValue("location")));
                    }
                } else if ("info".equals(qName)) {
View Full Code Here

TOP

Related Classes of org.apache.ivy.core.cache.ArtifactOrigin

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.