Package org.apache.ivy.core.cache

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


        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 (origin != null && origin != ArtifactOrigin.UNKNOWN) {
            addAttribute("origin", origin.getLocation());
            addAttribute("local", String.valueOf(origin.isLocal()));
        } else {
            addAttribute("origin", "");
            addAttribute("local", "");
        }
    }
View Full Code Here


    private void writeOriginLocationIfPresent(
            RepositoryCacheManager cache, TransformerHandler saxHandler,
            ArtifactDownloadReport artifact)
            throws IOException, SAXException {
        ArtifactOrigin origin = artifact.getArtifactOrigin();
        if (origin != ArtifactOrigin.UNKNOWN && origin != null) {
            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

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

                String[] confs = rmr.getDescriptor().getConfigurationsNames();
                for (int i = 0; i < confs.length; i++) {
                    Artifact[] arts = rmr.getDescriptor().getArtifacts(confs[i]);
                    for (int j = 0; j < arts.length; j++) {
                        Artifact transformedArtifact = toSystem(arts[j]);
                        ArtifactOrigin origin = data.getCacheManager().getSavedArtifactOrigin(
                            transformedArtifact);
                        File artFile = data.getCacheManager().getArchiveFileInCache(
                            transformedArtifact, origin, false);
                        if (artFile.exists()) {
                            Message.debug("deleting " + artFile);
View Full Code Here

                final ArtifactDownloadReport adr = new ArtifactDownloadReport(artifacts[i]);
                dr.addArtifactReport(adr);
                if (eventManager != null) {
                    eventManager.fireIvyEvent(new NeedArtifactEvent(this, artifacts[i]));
                }
                ArtifactOrigin origin = cacheManager.getSavedArtifactOrigin(artifacts[i]);
                // if we can use origin file, we just ask ivy for the file in cache, and it will
                // return
                // the original one if possible. If we are not in useOrigin mode, we use the
                // getArchivePath
                // method which always return a path in the actual cache
                File archiveFile = cacheManager.getArchiveFileInCache(artifacts[i], origin, options
                        .isUseOrigin());

                if (archiveFile.exists()) {
                    Message.verbose("\t[NOT REQUIRED] " + artifacts[i]);
                    adr.setDownloadStatus(DownloadStatus.NO);
                    adr.setSize(archiveFile.length());
                    adr.setArtifactOrigin(origin);
                } else {
                    Artifact artifact = fromSystem(artifacts[i]);
                    if (!artifact.equals(artifacts[i])) {
                        Message.verbose("\t" + getName() + "looking for artifact " + artifact
                                + " (is " + artifacts[i] + " in system namespace)");
                    }
                    long start = System.currentTimeMillis();
                    try {
                        ResolvedResource artifactRef = getArtifactRef(artifact, null);
                        if (artifactRef != null) {
                            origin = new ArtifactOrigin(artifactRef.getResource().isLocal(),
                                    artifactRef.getResource().getName());
                            if (useOrigin && artifactRef.getResource().isLocal()) {
                                Message.verbose("\t[NOT REQUIRED] " + artifacts[i]);
                                cacheManager.saveArtifactOrigin(artifacts[i], origin);
                                archiveFile = cacheManager.getArchiveFileInCache(artifacts[i],
View Full Code Here

                                        + "\"");
                    }
                    out.print(" status=\"" + adr[i].getDownloadStatus() + "\"");
                    out.print(" size=\"" + adr[i].getSize() + "\"");

                    ArtifactOrigin origin = adr[i].getArtifactOrigin();
                    if (origin != null) {
                        out.println(">");
                        out.println("\t\t\t\t\t\t<origin-location is-local=\""
                                + String.valueOf(origin.isLocal()) + "\"" + " location=\""
                                + origin.getLocation() + "\"/>");
                        out.println("\t\t\t\t\t</artifact>");
                    } else {
                        out.println("/>");
                    }
                }
View Full Code Here

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

        // verify the origin in the report
        ArtifactOrigin reportOrigin = dReports[0].getArtifactOrigin();
        assertNotNull(reportOrigin);
        assertEquals("isLocal for artifact not correct", true, reportOrigin.isLocal());
        assertEquals("location for artifact not correct", expectedLocation, reportOrigin
                .getLocation());

        // verify the saved origin on disk
        ArtifactOrigin ivyOrigin = cacheManager.getSavedArtifactOrigin(artifact);
        assertNotNull(ivyOrigin);
        assertEquals("isLocal for artifact not correct", true, ivyOrigin.isLocal());
        assertEquals("location for artifact not correct", expectedLocation, ivyOrigin.getLocation());

        // now resolve the same artifact again and verify the origin of the (not-downloaded)
        // artifact
        report = ivy.resolve(new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURL(),
            getResolveOptions(new String[] {"default"}));
View Full Code Here

        assertNotNull(artifact);

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

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

        saxHandler.startElement(null, "artifact", "artifact", artifactAttrs);
    }

    private void writeOriginLocationIfPresent(CacheManager cache, TransformerHandler saxHandler,
            Artifact artifact) throws IOException, SAXException {
        ArtifactOrigin origin = cache.getSavedArtifactOrigin(artifact);
        if (origin != null) {
            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

        }
    }

    private void writeCacheLocation(CacheManager cache, TransformerHandler saxHandler,
            Artifact artifact) throws SAXException {
        ArtifactOrigin origin = cache.getSavedArtifactOrigin(artifact);
        File archiveInCache = cache.getArchiveFileInCache(artifact, origin, false);

        saxHandler.startElement(null, "cache-location", "cache-location", new AttributesImpl());
        char[] archiveInCacheAsChars = archiveInCache.getPath().replace('\\', '/').toCharArray();
        saxHandler.characters(archiveInCacheAsChars, 0, archiveInCacheAsChars.length);
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.