Search in sources :

Example 11 with ResourceDescriptor

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();
        }
    }
}
Also used : SearchableRepository(aQute.bnd.service.repository.SearchableRepository) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) Workspace(aQute.bnd.build.Workspace) ResourceDescriptor(aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor)

Example 12 with ResourceDescriptor

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();
    }
}
Also used : SubMonitor(org.eclipse.core.runtime.SubMonitor) InvocationTargetException(java.lang.reflect.InvocationTargetException) ResourceDescriptor(aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor)

Example 13 with ResourceDescriptor

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());
}
Also used : Version(aQute.bnd.version.Version) File(java.io.File) ResourceDescriptor(aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor)

Example 14 with ResourceDescriptor

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;
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SubMonitor(org.eclipse.core.runtime.SubMonitor) MultiStatus(org.eclipse.core.runtime.MultiStatus) InvocationTargetException(java.lang.reflect.InvocationTargetException) ResourceDescriptor(aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 15 with ResourceDescriptor

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();
    }
}
Also used : Jar(aQute.bnd.osgi.Jar) Manifest(java.util.jar.Manifest) ResourceDescriptor(aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor)

Aggregations

ResourceDescriptor (aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor)19 File (java.io.File)10 Version (aQute.bnd.version.Version)7 IOException (java.io.IOException)5 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 Workspace (aQute.bnd.build.Workspace)3 Parameters (aQute.bnd.header.Parameters)3 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)3 DownloadListener (aQute.bnd.service.RepositoryPlugin.DownloadListener)3 InfoRepository (aQute.bnd.service.repository.InfoRepository)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 DownloadBlocker (aQute.bnd.build.DownloadBlocker)2 Attrs (aQute.bnd.header.Attrs)2 Repository (aQute.bnd.jpm.Repository)2 Jar (aQute.bnd.osgi.Jar)2 PutResult (aQute.bnd.service.RepositoryPlugin.PutResult)2 Listener (aQute.bnd.service.repository.ResourceRepository.Listener)2 ResourceRepositoryEvent (aQute.bnd.service.repository.ResourceRepository.ResourceRepositoryEvent)2