Package org.apache.ivy.core.report

Examples of org.apache.ivy.core.report.ArtifactDownloadReport


            new DownloadOptions(_settings, _cache));
        assertNotNull(report);

        assertEquals(2, report.getArtifactsReports().length);

        ArtifactDownloadReport ar = report.getArtifactReport(profiler);
        assertNotNull(ar);

        assertEquals(profiler, ar.getArtifact());
        assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());

        ar = report.getArtifactReport(trace);
        assertNotNull(ar);

        assertEquals(trace, ar.getArtifact());
        assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());

        // test to ask to download again, should use cache
        report = resolver.download(new Artifact[] {profiler, trace}, new DownloadOptions(_settings,
                _cache));
        assertNotNull(report);

        assertEquals(2, report.getArtifactsReports().length);

        ar = report.getArtifactReport(profiler);
        assertNotNull(ar);

        assertEquals(profiler, ar.getArtifact());
        assertEquals(DownloadStatus.NO, ar.getDownloadStatus());

        ar = report.getArtifactReport(trace);
        assertNotNull(ar);

        assertEquals(trace, ar.getArtifact());
        assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
    }
View Full Code Here


                _settings, _cache));
        assertNotNull(report);

        assertEquals(1, report.getArtifactsReports().length);

        ArtifactDownloadReport ar = report.getArtifactReport(artifact);
        assertNotNull(ar);

        assertEquals(artifact, ar.getArtifact());
        assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());

        // test to ask to download again, should use cache
        report = resolver.download(new Artifact[] {artifact},
            new DownloadOptions(_settings, _cache));
        assertNotNull(report);

        assertEquals(1, report.getArtifactsReports().length);

        ar = report.getArtifactReport(artifact);
        assertNotNull(ar);

        assertEquals(artifact, ar.getArtifact());
        assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
    }
View Full Code Here

                _settings, _cache));
        assertNotNull(report);

        assertEquals(1, report.getArtifactsReports().length);

        ArtifactDownloadReport ar = report.getArtifactReport(artifact);
        assertNotNull(ar);

        assertEquals(artifact, ar.getArtifact());
        assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());

        // test to ask to download again, should use cache
        report = resolver.download(new Artifact[] {artifact},
            new DownloadOptions(_settings, _cache));
        assertNotNull(report);

        assertEquals(1, report.getArtifactsReports().length);

        ar = report.getArtifactReport(artifact);
        assertNotNull(ar);

        assertEquals(artifact, ar.getArtifact());
        assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
    }
View Full Code Here

            new DownloadOptions(_settings, _cache));
        assertNotNull(report);

        assertEquals(2, report.getArtifactsReports().length);

        ArtifactDownloadReport ar = report.getArtifactReport(profiler);
        assertNotNull(ar);

        assertEquals(profiler, ar.getArtifact());
        assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());

        ar = report.getArtifactReport(trace);
        assertNotNull(ar);

        assertEquals(trace, ar.getArtifact());
        assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());

        // test to ask to download again, should use cache
        report = resolver.download(new Artifact[] {profiler, trace}, new DownloadOptions(_settings,
                _cache));
        assertNotNull(report);

        assertEquals(2, report.getArtifactsReports().length);

        ar = report.getArtifactReport(profiler);
        assertNotNull(ar);

        assertEquals(profiler, ar.getArtifact());
        assertEquals(DownloadStatus.NO, ar.getDownloadStatus());

        ar = report.getArtifactReport(trace);
        assertNotNull(ar);

        assertEquals(trace, ar.getArtifact());
        assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
    }
View Full Code Here

                _settings, _cache));
        assertNotNull(report);

        assertEquals(1, report.getArtifactsReports().length);

        ArtifactDownloadReport ar = report.getArtifactReport(artifact);
        assertNotNull(ar);

        assertEquals(artifact, ar.getArtifact());
        assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());

        // test to ask to download again, should use cache
        report = resolver.download(new Artifact[] {artifact},
            new DownloadOptions(_settings, _cache));
        assertNotNull(report);

        assertEquals(1, report.getArtifactsReports().length);

        ar = report.getArtifactReport(artifact);
        assertNotNull(ar);

        assertEquals(artifact, ar.getArtifact());
        assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
    }
View Full Code Here

            getDownloadOptions(false));
        assertNotNull(report);

        assertEquals(1, report.getArtifactsReports().length);

        ArtifactDownloadReport ar = report.getArtifactReport(artifact);
        assertNotNull(ar);

        assertEquals(artifact, ar.getArtifact());
        assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());

        // test to ask to download again, should use cache
        report = resolver.download(new Artifact[] {artifact}, getDownloadOptions(false));
        assertNotNull(report);

        assertEquals(1, report.getArtifactsReports().length);

        ar = report.getArtifactReport(artifact);
        assertNotNull(ar);

        assertEquals(artifact, ar.getArtifact());
        assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
    }
View Full Code Here

            getDownloadOptions(true));
        assertNotNull(report);

        assertEquals(1, report.getArtifactsReports().length);

        ArtifactDownloadReport ar = report.getArtifactReport(artifact);
        assertNotNull(ar);

        assertEquals(artifact, ar.getArtifact());
        assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
    }
View Full Code Here

    public DownloadReport download(Artifact[] artifacts, DownloadOptions options) {
        clearArtifactAttempts();
        DownloadReport dr = new DownloadReport();
        for (int i = 0; i < artifacts.length; i++) {
            final ArtifactDownloadReport adr = new ArtifactDownloadReport(artifacts[i]);
            dr.addArtifactReport(adr);
            File archiveFile = options.getCacheManager().getArchiveFileInCache(artifacts[i]);
            if (archiveFile.exists()) {
                Message.verbose("\t[NOT REQUIRED] " + artifacts[i]);
                adr.setDownloadStatus(DownloadStatus.NO);
                adr.setSize(archiveFile.length());
            } else {
                logArtifactAttempt(artifacts[i], archiveFile.getAbsolutePath());
                adr.setDownloadStatus(DownloadStatus.FAILED);
            }
        }
        return dr;
    }
View Full Code Here

            boolean useOrigin = options.isUseOrigin();

            clearArtifactAttempts();
            DownloadReport dr = new DownloadReport();
            for (int i = 0; i < artifacts.length; i++) {
                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],
                                    origin);
                                adr.setDownloadStatus(DownloadStatus.NO);
                                adr.setSize(archiveFile.length());
                                adr.setArtifactOrigin(origin);
                            } else {
                                // refresh archive file now that we better now its origin
                                archiveFile = cacheManager.getArchiveFileInCache(artifacts[i],
                                    origin, useOrigin);
                                if (ResourceHelper.equals(artifactRef.getResource(), archiveFile)) {
                                    Message.error("invalid configuration for resolver '"
                                            + getName()
                                            + "': pointing artifacts to ivy cache is forbidden !");
                                    return null;
                                }
                                Message.info("downloading " + artifactRef.getResource() + " ...");
                                if (eventManager != null) {
                                    eventManager.fireIvyEvent(new StartArtifactDownloadEvent(this,
                                            artifacts[i], origin));
                                }

                                File tmp = cacheManager.getArchiveFileInCache(new DefaultArtifact(
                                        artifacts[i].getModuleRevisionId(), artifacts[i]
                                                .getPublicationDate(), artifacts[i].getName(),
                                        artifacts[i].getType(), artifacts[i].getExt() + ".part",
                                        artifacts[i].getExtraAttributes()), origin, useOrigin);

                                // deal with artifact with url special case
                                if (artifactRef.getResource().getName().equals(
                                    String.valueOf(artifacts[i].getUrl()))) {
                                    Message.verbose("\t" + getName() + ": downloading "
                                            + artifactRef.getResource().getName());
                                    Message.debug("\t\tto " + tmp);
                                    if (tmp.getParentFile() != null) {
                                        tmp.getParentFile().mkdirs();
                                    }
                                    extartifactrep.get(artifactRef.getResource().getName(), tmp);
                                    adr.setSize(tmp.length());
                                } else {
                                    adr.setSize(getAndCheck(artifactRef.getResource(), tmp));
                                }
                                if (!tmp.renameTo(archiveFile)) {
                                    Message.warn("\t[FAILED     ] " + artifacts[i]
                                            + " impossible to move temp file to definitive one ("
                                            + (System.currentTimeMillis() - start) + "ms)");
                                    adr.setDownloadStatus(DownloadStatus.FAILED);
                                } else {
                                    cacheManager.saveArtifactOrigin(artifacts[i], origin);
                                    Message.info("\t[SUCCESSFUL ] " + artifacts[i] + " ("
                                            + (System.currentTimeMillis() - start) + "ms)");
                                    adr.setDownloadStatus(DownloadStatus.SUCCESSFUL);
                                    adr.setArtifactOrigin(origin);
                                }
                            }
                        } else {
                            adr.setDownloadStatus(DownloadStatus.FAILED);
                        }
                    } catch (Exception ex) {
                        Message.warn("\t[FAILED     ] " + artifacts[i] + " : " + ex.getMessage()
                                + " (" + (System.currentTimeMillis() - start) + "ms)");
                        adr.setDownloadStatus(DownloadStatus.FAILED);
                    }
                    checkInterrupted();
                }
                if (eventManager != null) {
                    eventManager.fireIvyEvent(new EndArtifactDownloadEvent(this, artifacts[i], adr,
View Full Code Here

     * avoid the download
     */
    public boolean exists(Artifact artifact) {
        DownloadReport dr = download(new Artifact[] {artifact}, new DownloadOptions(getSettings(),
                new CacheManager(getSettings(), getSettings().getDefaultCache()), null, true));
        ArtifactDownloadReport adr = dr.getArtifactReport(artifact);
        return adr.getDownloadStatus() != DownloadStatus.FAILED;
    }
View Full Code Here

TOP

Related Classes of org.apache.ivy.core.report.ArtifactDownloadReport

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.