org.apache.ivy.core.cache.CacheDownloadOptions Java Examples
The following examples show how to use
org.apache.ivy.core.cache.CacheDownloadOptions.
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: LocalFileRepositoryCacheManager.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public EnhancedArtifactDownloadReport download(Artifact artifact, ArtifactResourceResolver resourceResolver, ResourceDownloader resourceDownloader, CacheDownloadOptions options) { ResolvedResource resolvedResource = resourceResolver.resolve(artifact); long start = System.currentTimeMillis(); EnhancedArtifactDownloadReport report = new EnhancedArtifactDownloadReport(artifact); if (resolvedResource == null) { report.setDownloadStatus(DownloadStatus.FAILED); report.setDownloadDetails(ArtifactDownloadReport.MISSING_ARTIFACT); report.setDownloadTimeMillis(System.currentTimeMillis() - start); return report; } assert resolvedResource.getResource().isLocal(); File file = new File(resolvedResource.getResource().getName()); assert file.isFile(); ArtifactOrigin origin = new ArtifactOrigin(artifact, true, file.getAbsolutePath()); report.setDownloadStatus(DownloadStatus.NO); report.setArtifactOrigin(origin); report.setSize(file.length()); report.setLocalFile(file); return report; }
Example #2
Source File: LocalFileRepositoryCacheManager.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public EnhancedArtifactDownloadReport download(Artifact artifact, ArtifactResourceResolver resourceResolver, ResourceDownloader resourceDownloader, CacheDownloadOptions options) { ResolvedResource resolvedResource = resourceResolver.resolve(artifact); long start = System.currentTimeMillis(); EnhancedArtifactDownloadReport report = new EnhancedArtifactDownloadReport(artifact); if (resolvedResource == null) { report.setDownloadStatus(DownloadStatus.FAILED); report.setDownloadDetails(ArtifactDownloadReport.MISSING_ARTIFACT); report.setDownloadTimeMillis(System.currentTimeMillis() - start); return report; } assert resolvedResource.getResource().isLocal(); File file = new File(resolvedResource.getResource().getName()); assert file.isFile(); ArtifactOrigin origin = new ArtifactOrigin(artifact, true, file.getAbsolutePath()); report.setDownloadStatus(DownloadStatus.NO); report.setArtifactOrigin(origin); report.setSize(file.length()); report.setLocalFile(file); return report; }
Example #3
Source File: DownloadingRepositoryCacheManager.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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: DownloadingRepositoryCacheManager.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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 #5
Source File: DownloadingRepositoryCacheManager.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public EnhancedArtifactDownloadReport download(Artifact artifact, ArtifactResourceResolver resourceResolver, ResourceDownloader resourceDownloader, CacheDownloadOptions options) { EnhancedArtifactDownloadReport adr = new EnhancedArtifactDownloadReport(artifact); DownloadListener listener = options.getListener(); if (listener != null) { listener.needArtifact(this, artifact); } long start = System.currentTimeMillis(); try { ResolvedResource artifactRef = resourceResolver.resolve(artifact); if (artifactRef != null) { final Resource resource = artifactRef.getResource(); ArtifactOrigin origin = new ArtifactOrigin(artifact, resource.isLocal(), resource.getName()); if (listener != null) { listener.startArtifactDownload(this, artifactRef, artifact, origin); } ModuleRevisionId moduleRevisionId = artifact.getModuleRevisionId(); ModuleComponentIdentifier componentIdentifier = DefaultModuleComponentIdentifier.newId(moduleRevisionId.getOrganisation(), moduleRevisionId.getName(), moduleRevisionId.getRevision()); File artifactFile = downloadAndCacheArtifactFile(new DefaultModuleVersionArtifactMetaData(componentIdentifier, artifact), artifact, resourceDownloader, artifactRef.getResource()); adr.setDownloadTimeMillis(System.currentTimeMillis() - start); adr.setSize(artifactFile.length()); adr.setDownloadStatus(DownloadStatus.SUCCESSFUL); adr.setArtifactOrigin(origin); adr.setLocalFile(artifactFile); } else { adr.setDownloadTimeMillis(System.currentTimeMillis() - start); adr.setDownloadStatus(DownloadStatus.FAILED); adr.setDownloadDetails(ArtifactDownloadReport.MISSING_ARTIFACT); } } catch (Throwable throwable) { adr.setDownloadTimeMillis(System.currentTimeMillis() - start); adr.failed(throwable); } if (listener != null) { listener.endArtifactDownload(this, artifact, adr, adr.getLocalFile()); } return adr; }
Example #6
Source File: DownloadingRepositoryCacheManager.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public EnhancedArtifactDownloadReport download(Artifact artifact, ArtifactResourceResolver resourceResolver, ResourceDownloader resourceDownloader, CacheDownloadOptions options) { EnhancedArtifactDownloadReport adr = new EnhancedArtifactDownloadReport(artifact); DownloadListener listener = options.getListener(); if (listener != null) { listener.needArtifact(this, artifact); } long start = System.currentTimeMillis(); try { ResolvedResource artifactRef = resourceResolver.resolve(artifact); if (artifactRef != null) { final Resource resource = artifactRef.getResource(); ArtifactOrigin origin = new ArtifactOrigin(artifact, resource.isLocal(), resource.getName()); if (listener != null) { listener.startArtifactDownload(this, artifactRef, artifact, origin); } ModuleRevisionId moduleRevisionId = artifact.getModuleRevisionId(); ModuleComponentIdentifier componentIdentifier = DefaultModuleComponentIdentifier.newId(moduleRevisionId.getOrganisation(), moduleRevisionId.getName(), moduleRevisionId.getRevision()); File artifactFile = downloadAndCacheArtifactFile(new DefaultModuleVersionArtifactMetaData(componentIdentifier, artifact), artifact, resourceDownloader, artifactRef.getResource()); adr.setDownloadTimeMillis(System.currentTimeMillis() - start); adr.setSize(artifactFile.length()); adr.setDownloadStatus(DownloadStatus.SUCCESSFUL); adr.setArtifactOrigin(origin); adr.setLocalFile(artifactFile); } else { adr.setDownloadTimeMillis(System.currentTimeMillis() - start); adr.setDownloadStatus(DownloadStatus.FAILED); adr.setDownloadDetails(ArtifactDownloadReport.MISSING_ARTIFACT); } } catch (Throwable throwable) { adr.setDownloadTimeMillis(System.currentTimeMillis() - start); adr.failed(throwable); } if (listener != null) { listener.endArtifactDownload(this, artifact, adr, adr.getLocalFile()); } return adr; }
Example #7
Source File: AbstractResolver.java From ant-ivy with Apache License 2.0 | 4 votes |
protected CacheDownloadOptions getCacheDownloadOptions(DownloadOptions options) { CacheDownloadOptions cacheDownloadOptions = new CacheDownloadOptions(); cacheDownloadOptions.setListener(getDownloadListener(options)); return cacheDownloadOptions; }