Package org.apache.ivy.core.report

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


                }
            }
        }
        for (Iterator iter = artifactsToDownload.iterator(); iter.hasNext();) {
            Artifact art = (Artifact) iter.next();
            ArtifactDownloadReport adr = new ArtifactDownloadReport(art);
            adr.setDownloadStatus(DownloadStatus.FAILED);
            report.addArtifactReport(adr);
        }
        return report;
    }
View Full Code Here


            Collection targetIvysStructure = new HashSet(); // same for ivy files

            // do retrieve
            long totalCopiedSize = 0;
            for (Iterator iter = artifactsToCopy.keySet().iterator(); iter.hasNext();) {
                ArtifactDownloadReport artifact = (ArtifactDownloadReport) iter.next();
                File archive = artifact.getLocalFile();
                if (archive == null) {
                    Message.verbose("\tno local file available for " + artifact + ": skipping");
                    continue;
                }
                Set dest = (Set) artifactsToCopy.get(artifact);
                Message.verbose("\tretrieving " + archive);
                for (Iterator it2 = dest.iterator(); it2.hasNext();) {
                    IvyContext.getContext().checkInterrupted();
                    File destFile = settings.resolveFile((String) it2.next());
                    if (!settings.isCheckUpToDate() || !upToDate(archive, destFile, options)) {
                        Message.verbose("\t\tto " + destFile);
                        if (this.eventManager != null) {
                            this.eventManager.fireIvyEvent(
                                new StartRetrieveArtifactEvent(artifact, destFile));
                        }
                        if (options.isMakeSymlinks()) {
                            FileUtil.symlink(archive, destFile, null, true);
                        } else {
                            FileUtil.copy(archive, destFile, null, true);
                        }
                        if (this.eventManager != null) {
                            this.eventManager.fireIvyEvent(
                                new EndRetrieveArtifactEvent(artifact, destFile));
                        }
                        totalCopiedSize += destFile.length();
                        report.addCopiedFile(destFile, artifact);
                    } else {
                        Message.verbose("\t\tto " + destFile + " [NOT REQUIRED]");
                        report.addUpToDateFile(destFile, artifact);
                    }

                    if ("ivy".equals(artifact.getType())) {
                        targetIvysStructure
                                .addAll(FileUtil.getPathFiles(ivyRetrieveRoot, destFile));
                    } else {
                        targetArtifactsStructure.addAll(FileUtil.getPathFiles(fileRetrieveRoot,
                            destFile));
View Full Code Here

                for (int j = 0; j < mrids.length; j++) {
                    artifacts.add(parser.getMetadataArtifactReport(mrids[j]));
                }
            }
            for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
                ArtifactDownloadReport artifact = (ArtifactDownloadReport) iter.next();
                String destPattern = "ivy".equals(artifact.getType()) ? destIvyPattern
                        : destFilePattern;
               
                if (!"ivy".equals(artifact.getType())
                        && !options.getArtifactFilter().accept(artifact.getArtifact())) {
                    continue; // skip this artifact, the filter didn't accept it!
                }

                String destFileName = IvyPatternHelper.substitute(destPattern,
                            artifact.getArtifact().getModuleRevisionId(), artifact.getArtifact(),
                            conf, artifact.getArtifactOrigin());
                Set dest = (Set) artifactsToCopy.get(artifact);
                if (dest == null) {
                    dest = new HashSet();
                    artifactsToCopy.put(artifact, dest);
                }
                String copyDest = settings.resolveFile(destFileName).getAbsolutePath();

                String[] destinations = new String[] {copyDest};
                if (options.getMapper() != null) {
                    destinations = options.getMapper().mapFileName(copyDest);
                }

                for (int j = 0; j < destinations.length; j++) {
                    dest.add(destinations[j]);

                    Set conflicts = (Set) conflictsMap.get(destinations[j]);
                    Set conflictsReports = (Set) conflictsReportsMap.get(destinations[j]);
                    Set conflictsConf = (Set) conflictsConfMap.get(destinations[j]);
                    if (conflicts == null) {
                        conflicts = new HashSet();
                        conflictsMap.put(destinations[j], conflicts);
                    }
                    if (conflictsReports == null) {
                        conflictsReports = new HashSet();
                        conflictsReportsMap.put(destinations[j], conflictsReports);
                    }
                    if (conflictsConf == null) {
                        conflictsConf = new HashSet();
                        conflictsConfMap.put(destinations[j], conflictsConf);
                    }
                    if (conflicts.add(artifact.getArtifact().getId())) {
                        conflictsReports.add(artifact);
                        conflictsConf.add(conf);
                    }
                }
            }
        }
       
        // resolve conflicts if any
        for (Iterator iter = conflictsMap.keySet().iterator(); iter.hasNext();) {
            String copyDest = (String) iter.next();
            Set artifacts = (Set) conflictsMap.get(copyDest);
            Set conflictsConfs = (Set) conflictsConfMap.get(copyDest);
            if (artifacts.size() > 1) {
                List artifactsList = new ArrayList((Collection) conflictsReportsMap.get(copyDest));
                // conflicts battle is resolved by a sort using a conflict resolving policy
                // comparator which consider as greater a winning artifact
                Collections.sort(artifactsList, getConflictResolvingPolicy());
               
                // after the sort, the winning artifact is the greatest one, i.e. the last one
                // we fail if different artifacts of the same module are mapped to the same file
                ArtifactDownloadReport winner = (ArtifactDownloadReport)
                        artifactsList.get(artifactsList.size() - 1);
                ModuleRevisionId winnerMD = winner.getArtifact().getModuleRevisionId();
                for (int i = artifactsList.size() - 2; i >= 0; i--) {
                    ArtifactDownloadReport current = (ArtifactDownloadReport) artifactsList.get(i);
                    if (winnerMD.equals(current.getArtifact().getModuleRevisionId())) {
                        throw new RuntimeException("Multiple artifacts of the module " + winnerMD
                                + " are retrieved to the same file! Update the retrieve pattern "
                                + " to fix this error.");
                    }
                }
               
                Message.info("\tconflict on "
                        + copyDest
                        + " in "
                        + conflictsConfs
                        + ": "
                        + winnerMD.getRevision() + " won");

                // we now iterate over the list beginning with the artifact preceding the winner,
                // and going backward to the least artifact
                for (int i = artifactsList.size() - 2; i >= 0; i--) {
                    ArtifactDownloadReport looser = (ArtifactDownloadReport) artifactsList.get(i);
                    Message.verbose("\t\tremoving conflict looser artifact: "
                        + looser.getArtifact());
                    // for each loser, we remove the pair (loser - copyDest) in the artifactsToCopy
                    // map
                    Set dest = (Set) artifactsToCopy.get(looser);
                    dest.remove(copyDest);
                    if (dest.isEmpty()) {
View Full Code Here

                    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)) {
                    String organisation = attributes.getValue("organisation");
View Full Code Here

                    // add the artifacts in the correct order
                    for (Iterator it = revisionsMap.values().iterator(); it.hasNext();) {
                        List artifactReports = (List) it.next();
                        SaxXmlReportParser.this.artifactReports.addAll(artifactReports);
                        for (Iterator iter = artifactReports.iterator(); iter.hasNext();) {
                            ArtifactDownloadReport artifactReport
                                = (ArtifactDownloadReport) iter.next();
                            if (artifactReport.getDownloadStatus() != DownloadStatus.FAILED) {
                                artifacts.add(artifactReport.getArtifact());
                            }
                        }
                       
                    }
                }
View Full Code Here

        DownloadReport report = resolver.download(new Artifact[] {artifact}, new DownloadOptions(_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

        DownloadReport report = resolver.download(new Artifact[] {artifact}, new DownloadOptions(_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

        DownloadReport report = resolver.download(new Artifact[] {artifact}, 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

        DownloadReport report = resolver.download(new Artifact[] {artifact}, 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

        DownloadReport report = resolver.download(new Artifact[] {profiler, trace}, 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

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.