use of aQute.bnd.service.ResourceHandle.Location in project bndtools by bndtools.
the class RepositoryEntry method isLocal.
public final boolean isLocal() {
boolean result = true;
try {
if (repo instanceof RemoteRepositoryPlugin) {
ResourceHandle handle = ((RemoteRepositoryPlugin) repo).getHandle(bsn, versionFinder.versionSpec, versionFinder.strategy, Collections.<String, String>emptyMap());
Location location = handle.getLocation();
result = location == Location.local || location == Location.remote_cached;
}
} catch (Exception e) {
logger.logError(MessageFormat.format("Failed to query repository {0} for bundle {1} version {2}.", repo.getName(), bsn, versionFinder), e);
}
return result;
}
use of aQute.bnd.service.ResourceHandle.Location in project bndtools by bndtools.
the class RepoDownloadJob method run.
@Override
protected IStatus run(IProgressMonitor progress) {
SubMonitor monitor = SubMonitor.convert(progress);
boolean locked = LOCK.tryLock();
try {
while (!locked) {
monitor.setBlocked(new Status(IStatus.INFO, Plugin.PLUGIN_ID, 0, "Waiting for other download jobs to complete.", null));
if (progress.isCanceled())
return Status.CANCEL_STATUS;
try {
locked = LOCK.tryLock(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
}
}
monitor.clearBlocked();
MultiStatus status = new MultiStatus(Plugin.PLUGIN_ID, 0, "One or more repository files failed to download.", null);
monitor.setTaskName("Expanding repository contents");
List<RepositoryBundleVersion> rbvs = new LinkedList<RepositoryBundleVersion>();
try {
for (RemoteRepositoryPlugin repo : repos) {
expandContentsInto(repo, rbvs);
}
for (RepositoryBundle bundle : bundles) {
expandContentsInto(bundle, rbvs);
}
rbvs.addAll(bundleVersions);
} catch (Exception e) {
return new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error listing repository contents", e);
}
monitor.setWorkRemaining(rbvs.size());
for (RepositoryBundleVersion rbv : rbvs) {
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
String resourceName = "<<unknown>>";
try {
RemoteRepositoryPlugin repo = (RemoteRepositoryPlugin) rbv.getRepo();
ResourceHandle handle = repo.getHandle(rbv.getBsn(), rbv.getVersion().toString(), Strategy.EXACT, Collections.<String, String>emptyMap());
resourceName = handle.getName();
Location location = handle.getLocation();
if (location == Location.remote) {
monitor.setTaskName("Downloading " + handle.getName());
handle.request();
}
} catch (Exception e) {
status.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, String.format("Download of %s:%s with remote name %s failed", rbv.getBsn(), rbv.getVersion(), resourceName), e));
} finally {
monitor.worked(1);
}
}
return status;
} finally {
if (locked)
LOCK.unlock();
}
}
Aggregations