org.apache.ivy.core.report.MetadataArtifactDownloadReport Java Examples

The following examples show how to use org.apache.ivy.core.report.MetadataArtifactDownloadReport. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NameSpaceHelper.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public static MetadataArtifactDownloadReport transform(MetadataArtifactDownloadReport report,
        NamespaceTransformer t) {
    if (t.isIdentity()) {
        return report;
    }
    MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport(transform(
        report.getArtifact(), t));
    madr.setSearched(report.isSearched());
    madr.setDownloadStatus(report.getDownloadStatus());
    madr.setDownloadDetails(report.getDownloadDetails());
    madr.setArtifactOrigin(report.getArtifactOrigin());
    madr.setDownloadTimeMillis(report.getDownloadTimeMillis());
    madr.setOriginalLocalFile(report.getOriginalLocalFile());
    madr.setLocalFile(report.getLocalFile());
    madr.setSize(report.getSize());
    return madr;
}
 
Example #2
Source File: DownloadingRepositoryCacheManager.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ResolvedModuleRevision cacheModuleDescriptor(DependencyResolver resolver, final ResolvedResource resolvedResource, DependencyDescriptor dd, Artifact moduleArtifact, ResourceDownloader downloader, CacheMetadataOptions options) throws ParseException {
    if (!moduleArtifact.isMetadata()) {
        return null;
    }

    ArtifactResourceResolver artifactResourceResolver = new ArtifactResourceResolver() {
        public ResolvedResource resolve(Artifact artifact) {
            return resolvedResource;
        }
    };
    ArtifactDownloadReport report = download(moduleArtifact, artifactResourceResolver, downloader, new CacheDownloadOptions().setListener(options.getListener()).setForce(true));

    if (report.getDownloadStatus() == DownloadStatus.FAILED) {
        LOGGER.warn("problem while downloading module descriptor: {}: {} ({} ms)", resolvedResource.getResource(), report.getDownloadDetails(), report.getDownloadTimeMillis());
        return null;
    }

    ModuleDescriptor md = parseModuleDescriptor(resolver, moduleArtifact, options, report.getLocalFile(), resolvedResource.getResource());
    LOGGER.debug("\t{}: parsed downloaded md file for {}; parsed={}" + getName(), moduleArtifact.getModuleRevisionId(), md.getModuleRevisionId());

    MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport(md.getMetadataArtifact());
    madr.setSearched(true);
    madr.setDownloadStatus(report.getDownloadStatus());
    madr.setDownloadDetails(report.getDownloadDetails());
    madr.setArtifactOrigin(report.getArtifactOrigin());
    madr.setDownloadTimeMillis(report.getDownloadTimeMillis());
    madr.setOriginalLocalFile(report.getLocalFile());
    madr.setSize(report.getSize());

    return new ResolvedModuleRevision(resolver, resolver, md, madr);
}
 
Example #3
Source File: DownloadingRepositoryCacheManager.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ResolvedModuleRevision cacheModuleDescriptor(DependencyResolver resolver, final ResolvedResource resolvedResource, DependencyDescriptor dd, Artifact moduleArtifact, ResourceDownloader downloader, CacheMetadataOptions options) throws ParseException {
    if (!moduleArtifact.isMetadata()) {
        return null;
    }

    ArtifactResourceResolver artifactResourceResolver = new ArtifactResourceResolver() {
        public ResolvedResource resolve(Artifact artifact) {
            return resolvedResource;
        }
    };
    ArtifactDownloadReport report = download(moduleArtifact, artifactResourceResolver, downloader, new CacheDownloadOptions().setListener(options.getListener()).setForce(true));

    if (report.getDownloadStatus() == DownloadStatus.FAILED) {
        LOGGER.warn("problem while downloading module descriptor: {}: {} ({} ms)", resolvedResource.getResource(), report.getDownloadDetails(), report.getDownloadTimeMillis());
        return null;
    }

    ModuleDescriptor md = parseModuleDescriptor(resolver, moduleArtifact, options, report.getLocalFile(), resolvedResource.getResource());
    LOGGER.debug("\t{}: parsed downloaded md file for {}; parsed={}" + getName(), moduleArtifact.getModuleRevisionId(), md.getModuleRevisionId());

    MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport(md.getMetadataArtifact());
    madr.setSearched(true);
    madr.setDownloadStatus(report.getDownloadStatus());
    madr.setDownloadDetails(report.getDownloadDetails());
    madr.setArtifactOrigin(report.getArtifactOrigin());
    madr.setDownloadTimeMillis(report.getDownloadTimeMillis());
    madr.setOriginalLocalFile(report.getLocalFile());
    madr.setSize(report.getSize());

    return new ResolvedModuleRevision(resolver, resolver, md, madr);
}
 
Example #4
Source File: AbstractOSGiResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public ResolvedResource[] findBundle(DependencyDescriptor dd, ResolveData data,
        Collection<ModuleDescriptor> mds) {
    ResolvedResource[] ret = new ResolvedResource[mds.size()];
    int i = 0;
    for (ModuleDescriptor md : mds) {
        MetadataArtifactDownloadReport report = new MetadataArtifactDownloadReport(null);
        report.setDownloadStatus(DownloadStatus.NO);
        report.setSearched(true);
        ResolvedModuleRevision rmr = new ResolvedModuleRevision(this, this, md, report);
        MDResolvedResource mdrr = new MDResolvedResource(null, md.getRevision(), rmr);
        ret[i++] = mdrr;
    }
    return ret;
}
 
Example #5
Source File: AbstractOSGiResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private MDResolvedResource buildResolvedCapabilityMd(DependencyDescriptor dd,
        ModuleDescriptor md) {
    String org = dd.getDependencyRevisionId().getOrganisation();
    String name = dd.getDependencyRevisionId().getName();
    String rev = md.getExtraInfoContentByTagName(BundleInfoAdapter.EXTRA_INFO_EXPORT_PREFIX
            + name);
    ModuleRevisionId capabilityRev = ModuleRevisionId.newInstance(org, name, rev,
        Collections.singletonMap(CAPABILITY_EXTRA_ATTR, md.getModuleRevisionId().toString()));

    DefaultModuleDescriptor capabilityMd = new DefaultModuleDescriptor(capabilityRev,
            getSettings().getStatusManager().getDefaultStatus(), new Date());

    String useConf = BundleInfoAdapter.CONF_USE_PREFIX + dd.getDependencyRevisionId().getName();

    capabilityMd.addConfiguration(BundleInfoAdapter.CONF_DEFAULT);
    capabilityMd.addConfiguration(BundleInfoAdapter.CONF_OPTIONAL);
    capabilityMd.addConfiguration(BundleInfoAdapter.CONF_TRANSITIVE_OPTIONAL);
    capabilityMd.addConfiguration(new Configuration(useConf));

    DefaultDependencyDescriptor capabilityDD = new DefaultDependencyDescriptor(
            md.getModuleRevisionId(), false);
    capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_DEFAULT,
        BundleInfoAdapter.CONF_NAME_DEFAULT);
    capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_OPTIONAL,
        BundleInfoAdapter.CONF_NAME_OPTIONAL);
    capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_TRANSITIVE_OPTIONAL,
        BundleInfoAdapter.CONF_NAME_TRANSITIVE_OPTIONAL);
    capabilityDD.addDependencyConfiguration(useConf, useConf);
    capabilityMd.addDependency(capabilityDD);

    MetadataArtifactDownloadReport report = new MetadataArtifactDownloadReport(null);
    report.setDownloadStatus(DownloadStatus.NO);
    report.setSearched(true);
    ResolvedModuleRevision rmr = new ResolvedModuleRevision(this, this, capabilityMd, report);
    return new MDResolvedResource(null, capabilityMd.getRevision(), rmr);
}
 
Example #6
Source File: ResolvedModuleRevision.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public ResolvedModuleRevision(DependencyResolver resolver, DependencyResolver artifactResolver,
        ModuleDescriptor descriptor, MetadataArtifactDownloadReport report) {
    this.resolver = resolver;
    this.artifactResolver = artifactResolver;
    this.descriptor = descriptor;
    this.report = report;
}
 
Example #7
Source File: ResolvedModuleRevision.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public ResolvedModuleRevision(DependencyResolver resolver, DependencyResolver artifactResolver,
        ModuleDescriptor descriptor, MetadataArtifactDownloadReport report, boolean force) {
    this.resolver = resolver;
    this.artifactResolver = artifactResolver;
    this.descriptor = descriptor;
    this.report = report;
    this.force = force;
}
 
Example #8
Source File: XmlReportWriter.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private void outputMetadataArtifact(PrintWriter out, IvyNode dep) {
    if (dep.getModuleRevision() != null) {
        MetadataArtifactDownloadReport madr = dep.getModuleRevision().getReport();
        out.print("\t\t\t\t<metadata-artifact");
        out.print(" status=\"" + XMLHelper.escape(madr.getDownloadStatus().toString()) + "\"");
        out.print(" details=\"" + XMLHelper.escape(madr.getDownloadDetails()) + "\"");
        out.print(" size=\"" + madr.getSize() + "\"");
        out.print(" time=\"" + madr.getDownloadTimeMillis() + "\"");
        if (madr.getLocalFile() != null) {
            out.print(" location=\"" + XMLHelper.escape(madr.getLocalFile().getAbsolutePath())
                    + "\"");
        }

        out.print(" searched=\"" + madr.isSearched() + "\"");
        if (madr.getOriginalLocalFile() != null) {
            out.print(" original-local-location=\""
                    + XMLHelper.escape(madr.getOriginalLocalFile().getAbsolutePath()) + "\"");
        }

        ArtifactOrigin origin = madr.getArtifactOrigin();
        if (origin != null) {
            out.print(" origin-is-local=\"" + String.valueOf(origin.isLocal()) + "\"");
            out.print(" origin-location=\"" + XMLHelper.escape(origin.getLocation()) + "\"");
        }
        out.println("/>");

    }
}
 
Example #9
Source File: BasicResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
protected ResourceMDParser getDefaultRMDParser(final ModuleId mid) {
    return new ResourceMDParser() {
        public MDResolvedResource parse(Resource resource, String rev) {
            DefaultModuleDescriptor md = DefaultModuleDescriptor
                    .newDefaultInstance(new ModuleRevisionId(mid, rev));
            MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport(
                    md.getMetadataArtifact());
            madr.setDownloadStatus(DownloadStatus.NO);
            madr.setSearched(true);
            return new MDResolvedResource(resource, rev, new ResolvedModuleRevision(
                    BasicResolver.this, BasicResolver.this, md, madr, isForce()));
        }
    };
}
 
Example #10
Source File: MockResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
static MockResolver buildMockResolver(ResolverSettings settings, String name,
        boolean findRevision, final ModuleRevisionId mrid, final Date publicationDate,
        final boolean isdefault) {
    final MockResolver r = new MockResolver();
    r.setName(name);
    r.setSettings(settings);
    if (findRevision) {
        DefaultModuleDescriptor md = new DefaultModuleDescriptor(mrid, "integration",
                publicationDate, isdefault);
        r.rmr = new ResolvedModuleRevision(r, r, md, new MetadataArtifactDownloadReport(
                md.getMetadataArtifact()));
    }
    return r;
}
 
Example #11
Source File: XmlReportParser.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public MetadataArtifactDownloadReport getMetadataArtifactReport(ModuleRevisionId id) {
    return metadataReports.get(id);
}
 
Example #12
Source File: XmlReportParser.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public MetadataArtifactDownloadReport getMetadataArtifactReport(ModuleRevisionId id) {
    return parser.getMetadataArtifactReport(id);
}
 
Example #13
Source File: AbstractResolver.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
protected MetadataArtifactDownloadReport toSystem(MetadataArtifactDownloadReport report) {
    return NameSpaceHelper.transform(report, getNamespace().getToSystemTransformer());
}
 
Example #14
Source File: ResolvedModuleRevision.java    From ant-ivy with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a report of the resolved module metadata artifact provisioning.
 *
 * @return a report of the resolved module metadata artifact provisioning.
 */
public MetadataArtifactDownloadReport getReport() {
    return report;
}