use of aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor in project bndtools by bndtools.
the class JpmDependencyWizardPage method runQuery.
private void runQuery() {
if (!queried) {
errorText = null;
try {
Workspace workspace = Central.getWorkspace();
repository = workspace.getPlugin(SearchableRepository.class);
if (repository == null)
throw new Exception("No searchable repository is configured in the workspace. Try adding the JPM4J plugin.");
QueryJpmDependenciesRunnable query = new QueryJpmDependenciesRunnable(originUri, repository);
getContainer().run(true, true, query);
queried = true;
errorText = query.getError();
directResources = query.getDirectResources();
indirectResources = query.getIndirectResources();
selectedIndirectResources = new HashSet<ResourceDescriptor>();
} catch (InvocationTargetException e) {
errorText = e.getCause().getMessage();
} catch (InterruptedException e) {
// ignore
} catch (Exception e) {
errorText = e.getMessage();
} finally {
updateUi();
}
}
}
use of aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor in project bndtools by bndtools.
the class QueryJpmDependenciesRunnable method run.
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
SubMonitor progress = SubMonitor.convert(monitor, 5);
progress.setTaskName("Querying dependencies...");
try {
Set<ResourceDescriptor> resources = repository.getResources(origin, true);
directResources = new HashSet<ResourceDescriptor>();
indirectResources = new HashSet<ResourceDescriptor>();
for (ResourceDescriptor resource : resources) {
if (resource.dependency)
indirectResources.add(resource);
else
directResources.add(resource);
}
progress.worked(5);
} catch (Exception e) {
error = "Error searching repository: " + e.getMessage();
}
}
use of aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor in project bnd by bndtools.
the class JPMTest method testJpm.
public void testJpm() throws Exception {
File file = IO.getFile("testdata/ws/cnf/jar/biz.aQute.bnd.annotation-2.3.0.jar");
boolean dropTarget = repo.dropTarget(file.toURI());
assertTrue(dropTarget);
File f = repo.get("biz.aQute.bnd.annotation", new Version("2.3.0.201404170725"), null);
assertNotNull(f);
ResourceDescriptor descriptor = repo.getDescriptor("biz.aQute.bnd.annotation", new Version("2.3.0.201404170725"));
assertNotNull(descriptor);
assertEquals("230ae22893a124cdda8910e240d9c12edbacbbe13d8d080610adfc12b06623ff", Hex.toHexString(descriptor.sha256));
assertEquals(file.toURI().toString(), descriptor.url.toString());
SortedSet<Version> versions = repo.versions("biz.aQute.bnd.annotation");
assertEquals(1, versions.size());
assertEquals(new Version("2.3.0.201404170725"), versions.iterator().next());
}
use of aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor in project bndtools by bndtools.
the class AddJpmDependenciesWizard method performFinish.
@Override
public boolean performFinish() {
result.clear();
result.addAll(depsPage.getDirectResources());
result.addAll(depsPage.getSelectedIndirectResources());
final Set<ResourceDescriptor> indirectResources;
if (depsPage.getIndirectResources() != null) {
indirectResources = new HashSet<SearchableRepository.ResourceDescriptor>(depsPage.getIndirectResources());
indirectResources.removeAll(result);
} else {
indirectResources = Collections.<ResourceDescriptor>emptySet();
}
final MultiStatus status = new MultiStatus(Plugin.PLUGIN_ID, 0, "Errors occurred while processing JPM4J dependencies.", null);
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
SubMonitor progress = SubMonitor.convert(monitor, result.size() + indirectResources.size());
progress.setTaskName("Processing dependencies...");
// Process all resources (including non-selected ones) into the repository
for (ResourceDescriptor resource : result) processResource(resource, status, progress.newChild(1));
for (ResourceDescriptor resource : indirectResources) processResource(resource, status, progress.newChild(1));
}
};
try {
getContainer().run(true, true, runnable);
if (!status.isOK())
ErrorDialog.openError(getShell(), "Errors", null, status);
return true;
} catch (InvocationTargetException e) {
MessageDialog.openError(getShell(), "Error", e.getCause().getMessage());
return false;
} catch (InterruptedException e) {
return false;
}
}
use of aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor in project bnd by bndtools.
the class FileRepo method buildDescriptor.
private ResourceDescriptor buildDescriptor(File f, Jar jar, byte[] digest, String bsn, Version version) throws NoSuchAlgorithmException, Exception {
init();
Jar tmpjar = jar;
if (jar == null)
tmpjar = new Jar(f);
try {
Manifest m = tmpjar.getManifest();
ResourceDescriptor rd = new ResourceDescriptor();
rd.bsn = bsn;
rd.version = version;
rd.description = m.getMainAttributes().getValue(Constants.BUNDLE_DESCRIPTION);
rd.id = digest;
if (rd.id == null)
rd.id = SHA1.digest(f).digest();
rd.sha256 = SHA256.digest(f).digest();
rd.url = f.toURI();
return rd;
} finally {
if (tmpjar != null)
tmpjar.close();
}
}
Aggregations