use of aQute.bnd.service.RepositoryPlugin in project bndtools by bndtools.
the class RepoPluginsBundleLocator method locate.
@Override
public File locate(String bsn, String hash, String algo, URI location) throws Exception {
Map<String, String> searchProps = new HashMap<>();
searchProps.put("version", "hash");
searchProps.put("hash", algo + ":" + hash);
for (RepositoryPlugin plugin : plugins) {
try {
File file = plugin.get(bsn, null, searchProps);
if (file != null) {
return file;
}
} catch (Exception e) {
// ignore
}
}
// Fall back to direct download
// TODO: need some kind of download/cache service to avoid repeated downloads
File tempFile = File.createTempFile("download", "jar");
tempFile.deleteOnExit();
IO.copy(location.toURL(), tempFile);
return tempFile;
}
use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.
the class AetherRepsitoryTests method testStrategyExactVersion.
public void testStrategyExactVersion() throws Exception {
RepositoryPlugin repo = createRepo();
Map<String, String> attrs = new HashMap<String, String>();
attrs.put("version", "2.5");
attrs.put("strategy", "exact");
File file = repo.get("javax.servlet:servlet-api", new Version(2, 5, 0), attrs, listener);
assertNotNull(file);
assertEquals("servlet-api-2.5.jar", file.getName());
}
use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.
the class AetherRepsitoryTests method testStrategyExactVersionBadGAV.
public void testStrategyExactVersionBadGAV() throws Exception {
RepositoryPlugin repo = createRepo();
Map<String, String> attrs = new HashMap<String, String>();
attrs.put("version", "1.0");
attrs.put("strategy", "exact");
File file = repo.get("foo.bar:foobar-api", new Version(1, 0, 0), attrs, listener);
assertNull(file);
}
use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.
the class AetherRepsitoryTests method testVersionsBadBsn.
public void testVersionsBadBsn() throws Exception {
RepositoryPlugin repo = createRepo();
SortedSet<Version> versions = repo.versions("foo.bar.foobar");
assertNull(versions);
}
use of aQute.bnd.service.RepositoryPlugin in project bndtools by bndtools.
the class RepositoryBundlesContentProvider method getChildren.
@Override
public Object[] getChildren(Object parentElement) {
RepositoryPlugin repoPlugin = (RepositoryPlugin) parentElement;
List<String> bsns;
try {
bsns = repoPlugin.list(null);
} catch (Exception e) {
logger.logError("Error querying repository " + repoPlugin.getName(), e);
bsns = Collections.emptyList();
}
return bsns.toArray(new String[0]);
}
Aggregations