use of aQute.bnd.util.repository.DownloadListenerPromise in project bnd by bndtools.
the class BndPomRepository method get.
@Override
public File get(String bsn, Version version, Map<String, String> properties, DownloadListener... listeners) throws Exception {
init();
ResourceInfo resource = bridge.getInfo(bsn, version);
if (resource == null)
return null;
String name = resource.getInfo().name();
Archive archive = Archive.valueOf(name);
Promise<File> p = repoImpl.getMavenRepository().get(archive);
if (listeners.length == 0)
return p.getValue();
new DownloadListenerPromise(reporter, name + ": get " + bsn + ";" + version, p, listeners);
return repoImpl.getMavenRepository().toLocalFile(archive);
}
use of aQute.bnd.util.repository.DownloadListenerPromise in project bnd by bndtools.
the class OSGiRepository method get.
@Override
public File get(String bsn, Version version, Map<String, String> properties, DownloadListener... listeners) throws Exception {
File target = IO.getFile(getIndex().getCache(), bsn + "-" + version + ".jar");
Promise<File> promise = getIndex().get(bsn, version, target);
if (promise == null)
return null;
if (listeners.length == 0) {
return promise.getValue();
}
new DownloadListenerPromise(reporter, "Download " + bsn + "-" + version + " into " + config.name(), promise, listeners);
return target;
}
use of aQute.bnd.util.repository.DownloadListenerPromise in project bnd by bndtools.
the class P2Indexer method get.
File get(String bsn, Version version, Map<String, String> properties, DownloadListener... listeners) throws Exception {
Resource resource = getBridge().get(bsn, version);
if (resource == null)
return null;
ContentCapability contentCapability = ResourceUtils.getContentCapability(resource);
if (contentCapability == null)
return null;
URI url = contentCapability.url();
final File source = client.getCacheFileFor(url);
final File link = new File(location, bsn + "-" + version + ".jar");
IO.createSymbolicLinkOrCopy(link, source);
Promise<File> go = client.build().useCache(MAX_STALE).async(url.toURL()).map(new Function<File, File>() {
@Override
public File apply(File t) {
return link;
}
});
if (listeners.length == 0)
return go.getValue();
new DownloadListenerPromise(reporter, name + ": get " + bsn + ";" + version + " " + url, go, listeners);
return link;
}
Aggregations