Search in sources :

Example 1 with ProvisionException

use of org.eclipse.equinox.p2.core.ProvisionException 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)

Example 2 with ProvisionException

use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.

the class MetadataSerializableImplTest method testSerializeAndLoad.

@Test
public void testSerializeAndLoad() throws IOException, ProvisionException, OperationCanceledException {
    File tmpDir = createTempDir("repo");
    try {
        Set<IInstallableUnit> units = new HashSet<>(Arrays.asList(InstallableUnitUtil.createIU("org.example.test", "1.0.0")));
        MetadataSerializableImpl subject = new MetadataSerializableImpl();
        serialize(subject, units, tmpDir);
        Assert.assertEquals(units, deserialize(tmpDir));
    } finally {
        deleteRecursive(tmpDir);
    }
}
Also used : MetadataSerializableImpl(org.eclipse.tycho.p2.impl.repo.MetadataSerializableImpl) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) File(java.io.File) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with ProvisionException

use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.

the class RemoteAgentCompositeLoadingTest method testLoadingCompositeRepositoryWithMissingChildFailsByDefault.

@Test
public void testLoadingCompositeRepositoryWithMissingChildFailsByDefault() throws IOException {
    /*
         * In Tycho, we want composite repositories to fail if they have missing children (and don't
         * explicitly specify the "p2.atomic.composite.loading" property).
         */
    ProvisionException expectedException = null;
    try {
        subject.getService(IArtifactRepositoryManager.class).loadRepository(ResourceUtil.resourceFile("repositories/composite/missingChildAndAtomicUnset").toURI(), new NullProgressMonitor());
    } catch (ProvisionException e) {
        expectedException = e;
    }
    assertThat(expectedException, not(nullValue()));
    assertThat(expectedException.getStatus().getCode(), is(ProvisionException.REPOSITORY_FAILED_READ));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) IArtifactRepositoryManager(org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager) Test(org.junit.Test)

Example 4 with ProvisionException

use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.

the class RemoteAgentMetadataRepositoryCacheTest method loadHttpRepository.

private IMetadataRepository loadHttpRepository(RemoteAgent agent) throws ProvisionException {
    IMetadataRepositoryManager metadataRepositoryManager = agent.getService(IMetadataRepositoryManager.class);
    IMetadataRepository repo = metadataRepositoryManager.loadRepository(localHttpRepo, null);
    return repo;
}
Also used : IMetadataRepositoryManager(org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager) IMetadataRepository(org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)

Example 5 with ProvisionException

use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.

the class RepositoryFactoryTools method invalidCreationLocation.

public static ProvisionException invalidCreationLocation(String repositoryType, URI location) {
    String message = "Cannot create repositories of type " + repositoryType + " at location " + location;
    int errorCode = ProvisionException.REPOSITORY_INVALID_LOCATION;
    return new ProvisionException(new Status(IStatus.ERROR, BUNDLE_ID, errorCode, message, null));
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException)

Aggregations

ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)29 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)14 IStatus (org.eclipse.core.runtime.IStatus)13 IMetadataRepository (org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)10 Test (org.junit.Test)9 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)8 IArtifactRepository (org.eclipse.equinox.p2.repository.artifact.IArtifactRepository)8 IMetadataRepositoryManager (org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager)8 URI (java.net.URI)7 ArrayList (java.util.ArrayList)7 File (java.io.File)6 Status (org.eclipse.core.runtime.Status)6 IOException (java.io.IOException)5 IProvisioningAgent (org.eclipse.equinox.p2.core.IProvisioningAgent)5 IProvisioningAgentProvider (org.eclipse.equinox.p2.core.IProvisioningAgentProvider)5 OutputStream (java.io.OutputStream)4 HashSet (java.util.HashSet)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 ProvisioningSession (org.eclipse.equinox.p2.operations.ProvisioningSession)4 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)4