use of org.apache.karaf.features.internal.download.DownloadCallback in project karaf by apache.
the class VerifyMojo method loadRepositories.
public static Map<String, Features> loadRepositories(DownloadManager manager, Set<String> uris) throws Exception {
final Map<String, Features> loaded = new HashMap<>();
final Downloader downloader = manager.createDownloader();
for (String repository : uris) {
downloader.download(repository, new DownloadCallback() {
@Override
public void downloaded(final StreamProvider provider) throws Exception {
try (InputStream is = provider.open()) {
Features featuresModel = JaxbUtil.unmarshal(provider.getUrl(), is, false);
synchronized (loaded) {
loaded.put(provider.getUrl(), featuresModel);
for (String innerRepository : featuresModel.getRepository()) {
downloader.download(innerRepository, this);
}
}
}
}
});
}
downloader.await();
return loaded;
}
use of org.apache.karaf.features.internal.download.DownloadCallback in project karaf by apache.
the class Builder method loadRepositories.
private Map<String, Features> loadRepositories(DownloadManager manager, Collection<String> repositories, final boolean install) throws Exception {
final Map<String, Features> loaded = new HashMap<>();
final Downloader downloader = manager.createDownloader();
final List<String> blacklist = new ArrayList<>();
blacklist.addAll(blacklistedBundles);
blacklist.addAll(blacklistedFeatures);
final List<String> blacklistRepos = new ArrayList<>();
blacklistRepos.addAll(blacklistedRepositories);
final Clause[] clauses = org.apache.felix.utils.manifest.Parser.parseClauses(blacklist.toArray(new String[blacklist.size()]));
final Clause[] clausesRepos = org.apache.felix.utils.manifest.Parser.parseClauses(blacklistRepos.toArray(new String[blacklistRepos.size()]));
for (String repository : repositories) {
downloader.download(repository, new DownloadCallback() {
@Override
public void downloaded(final StreamProvider provider) throws Exception {
String url = provider.getUrl();
if (Blacklist.isBlacklisted(clausesRepos, url, TYPE_REPOSITORY)) {
return;
}
synchronized (loaded) {
if (!loaded.containsKey(provider.getUrl())) {
if (install) {
synchronized (provider) {
Path path = pathFromProviderUrl(url);
Files.createDirectories(path.getParent());
Files.copy(provider.getFile().toPath(), path, StandardCopyOption.REPLACE_EXISTING);
}
}
try (InputStream is = provider.open()) {
Features featuresModel = JaxbUtil.unmarshal(url, is, false);
if (blacklistPolicy == BlacklistPolicy.Discard) {
Blacklist.blacklist(featuresModel, clauses);
}
loaded.put(provider.getUrl(), featuresModel);
for (String innerRepository : featuresModel.getRepository()) {
downloader.download(innerRepository, this);
}
}
}
}
}
});
}
downloader.await();
return loaded;
}
Aggregations