Search in sources :

Example 51 with ProvisionException

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

the class RemoteMetadataRepositoryManager method loadRepository.

@Override
public IMetadataRepository loadRepository(URI location, int flags, IProgressMonitor monitor) throws ProvisionException, OperationCanceledException {
    URI effectiveLocation = translateAndPrepareLoad(location);
    IMetadataRepository loadedRepository = delegate.loadRepository(effectiveLocation, flags, monitor);
    failIfRepositoryContainsPartialIUs(loadedRepository, effectiveLocation);
    return loadedRepository;
}
Also used : IMetadataRepository(org.eclipse.equinox.p2.repository.metadata.IMetadataRepository) URI(java.net.URI)

Example 52 with ProvisionException

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

the class RemoteMetadataRepositoryManager method failIfRepositoryContainsPartialIUs.

private void failIfRepositoryContainsPartialIUs(IMetadataRepository repository, URI effectiveLocation) throws ProvisionException {
    IQueryResult<IInstallableUnit> allUnits = repository.query(QueryUtil.ALL_UNITS, null);
    boolean hasPartialIUs = false;
    for (IInstallableUnit unit : allUnits.toUnmodifiableSet()) {
        if (Boolean.valueOf(unit.getProperty(IInstallableUnit.PROP_PARTIAL_IU))) {
            hasPartialIUs = true;
            logger.error("Partial IU: " + unit.getId());
        }
    }
    if (hasPartialIUs) {
        String message = "The p2 repository at " + effectiveLocation + " contains partial IUs (see above) from an old style update site which cannot be used for dependency resolution";
        throw new ProvisionException(message);
    }
}
Also used : ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 53 with ProvisionException

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

the class VerifierServiceImpl method verify.

@Override
public boolean verify(URI metadataRepositoryUri, URI artifactRepositoryUri, BuildOutputDirectory tempDirectory) throws FacadeException {
    MavenLogger logger = mavenContext.getLogger();
    logger.debug("Checking metadata from '" + metadataRepositoryUri + "' and artifacts from '" + artifactRepositoryUri + "'");
    IProvisioningAgent agent = Activator.createProvisioningAgent(tempDirectory);
    try {
        try {
            final IMetadataRepository metadata = loadMetadataRepository(metadataRepositoryUri, agent);
            final IArtifactRepository artifactRepository = loadArtifactRepository(artifactRepositoryUri, agent);
            boolean valid = true;
            valid &= verifyReferencedArtifactsExist(metadata, artifactRepository, logger);
            valid &= verifyAllArtifactContent(artifactRepository, logger);
            if (valid) {
                logger.info("The integrity of the metadata repository '" + metadataRepositoryUri + "' and artifact repository '" + artifactRepositoryUri + "' has been verified successfully");
            }
            return valid;
        } catch (ProvisionException e) {
            throw new FacadeException(e);
        }
    } finally {
        agent.stop();
    }
}
Also used : FacadeException(org.eclipse.tycho.p2.tools.FacadeException) MavenLogger(org.eclipse.tycho.core.shared.MavenLogger) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) IProvisioningAgent(org.eclipse.equinox.p2.core.IProvisioningAgent) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) IMetadataRepository(org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)

Example 54 with ProvisionException

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

the class Activator method createProvisioningAgent.

public static IProvisioningAgent createProvisioningAgent(final URI targetLocation) throws ProvisionException {
    ServiceReference<IProvisioningAgentProvider> serviceReference = context.getServiceReference(IProvisioningAgentProvider.class);
    IProvisioningAgentProvider agentFactory = context.getService(serviceReference);
    try {
        return agentFactory.createAgent(targetLocation);
    } finally {
        context.ungetService(serviceReference);
    }
}
Also used : IProvisioningAgentProvider(org.eclipse.equinox.p2.core.IProvisioningAgentProvider)

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