Search in sources :

Example 1 with IMetadataRepository

use of org.eclipse.equinox.p2.repository.metadata.IMetadataRepository in project knime-core by knime.

the class InstallMissingNodesJob method findExtensions.

private IStatus findExtensions(final IProgressMonitor monitor, final List<NodeAndBundleInformation> missingNodes, final Set<IInstallableUnit> featuresToInstall) {
    ProvisioningSession session = ProvisioningUI.getDefaultUI().getSession();
    Bundle myself = FrameworkUtil.getBundle(getClass());
    try {
        IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) session.getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME);
        for (URI uri : metadataManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL)) {
            if (!missingNodes.isEmpty()) {
                IMetadataRepository repo = metadataManager.loadRepository(uri, monitor);
                for (Iterator<NodeAndBundleInformation> it = missingNodes.iterator(); it.hasNext(); ) {
                    NodeAndBundleInformation info = it.next();
                    if (searchInRepository(repo, info, metadataManager, monitor, featuresToInstall)) {
                        it.remove();
                    }
                }
            }
        }
        return Status.OK_STATUS;
    } catch (ProvisionException ex) {
        NodeLogger.getLogger(getClass()).error("Could not create provisioning agent: " + ex.getMessage(), ex);
        return new Status(IStatus.ERROR, myself.getSymbolicName(), "Could not query updates site for missing extensions", ex);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ProvisioningSession(org.eclipse.equinox.p2.operations.ProvisioningSession) IMetadataRepositoryManager(org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager) NodeAndBundleInformation(org.knime.core.node.NodeAndBundleInformation) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) Bundle(org.osgi.framework.Bundle) IMetadataRepository(org.eclipse.equinox.p2.repository.metadata.IMetadataRepository) URI(java.net.URI)

Aggregations

URI (java.net.URI)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)1 ProvisioningSession (org.eclipse.equinox.p2.operations.ProvisioningSession)1 IMetadataRepository (org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)1 IMetadataRepositoryManager (org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager)1 NodeAndBundleInformation (org.knime.core.node.NodeAndBundleInformation)1 Bundle (org.osgi.framework.Bundle)1