use of aQute.bnd.osgi.resource.ResourceUtils.ContentCapability in project bnd by bndtools.
the class FileSetRepository method get.
private Promise<File> get(final String bsn, final Version version) throws Exception {
logger.debug("{}: get {} {}", getName(), bsn, version);
Resource resource = getBridge().get(bsn, version);
if (resource == null) {
logger.debug("{}: resource not found {} {}", getName(), bsn, version);
return null;
}
ContentCapability content = ResourceUtils.getContentCapability(resource);
if (content == null) {
logger.warn("{}: No content capability for {}", getName(), resource);
return null;
}
URI uri = content.url();
if (uri == null) {
logger.warn("{}: No content URI for {}", getName(), resource);
return null;
}
logger.debug("{}: get returning {}", getName(), uri);
return Promises.resolved(new File(uri));
}
use of aQute.bnd.osgi.resource.ResourceUtils.ContentCapability in project bnd by bndtools.
the class OSGiIndex method get.
Promise<File> get(String bsn, Version version, File file) throws Exception {
Resource resource = getBridge().get(bsn, version);
if (resource == null)
return null;
ContentCapability content = ResourceUtils.getContentCapability(resource);
if (content == null) {
logger.warn("{}: No content capability for {}", name, resource);
return null;
}
URI url = content.url();
if (url == null) {
logger.warn("{}: No content capability for {}", name, resource);
return null;
}
return client.build().useCache(file, staleTime).async(url);
}
use of aQute.bnd.osgi.resource.ResourceUtils.ContentCapability 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;
}
use of aQute.bnd.osgi.resource.ResourceUtils.ContentCapability in project bnd by bndtools.
the class ResourceImpl method getContent.
@Override
public InputStream getContent() {
try {
ContentCapability c = ResourceUtils.getContentCapability(this);
URI url = c.url();
return url.toURL().openStream();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations