Search in sources :

Example 36 with ProvisionException

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

the class ModuleArtifactRepositoryTest method testLoadRepositoryWithMissingGAVProperties.

@Test(expected = ProvisionException.class)
public void testLoadRepositoryWithMissingGAVProperties() throws Exception {
    // repository with a missing groupId in one of the descriptors -> loading should fail
    File corruptRepository = ResourceUtil.resourceFile("repositories/module/missingGAV/target");
    generateDefaultRepositoryArtifacts(corruptRepository);
    try {
        subject = (ModuleArtifactRepository) loadRepositoryViaAgent(corruptRepository);
    } catch (ProvisionException e) {
        assertThat(e.getStatus().getCode(), is(ProvisionException.REPOSITORY_FAILED_READ));
        assertThat(e.getStatus().getMessage(), containsString("Error while reading repository"));
        assertThat(e.getStatus().getMessage(), containsString("Maven coordinate properties are missing"));
        throw e;
    }
}
Also used : ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) File(java.io.File) Test(org.junit.Test)

Example 37 with ProvisionException

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

the class PublishingRepositoryTest method insertTestArtifact.

private static void insertTestArtifact(PublishingRepository publishingRepo) throws ProvisionException, IOException {
    IArtifactRepository writableArtifactRepo = publishingRepo.getArtifactRepositoryForWriting(AttachedTestArtifact.getWriteSessionForArtifact());
    OutputStream outputStream = writableArtifactRepo.getOutputStream(writableArtifactRepo.createArtifactDescriptor(AttachedTestArtifact.key));
    writeAndClose(outputStream, AttachedTestArtifact.size);
}
Also used : OutputStream(java.io.OutputStream) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository)

Example 38 with ProvisionException

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

the class SimpleArtifactRepositoryIO method read.

/**
 * Reads the artifact repository from the given stream, and returns the contained array of
 * abstract artifact repositories.
 *
 * This method performs buffering, and closes the stream when finished.
 */
public IArtifactRepository read(URL location, InputStream input, IProgressMonitor monitor) throws ProvisionException {
    BufferedInputStream bufferedInput = null;
    try {
        try {
            bufferedInput = new BufferedInputStream(input);
            Parser repositoryParser = new Parser(Activator.getContext(), Activator.ID);
            repositoryParser.parse(input);
            IStatus result = repositoryParser.getStatus();
            switch(result.getSeverity()) {
                case IStatus.CANCEL:
                    throw new OperationCanceledException();
                case IStatus.ERROR:
                    throw new ProvisionException(result);
                case IStatus.WARNING:
                case IStatus.INFO:
                    LogHelper.log(result);
                    break;
                case IStatus.OK:
                    break;
                default:
                    // $NON-NLS-1$
                    throw new IllegalStateException("Unknown serverity value: " + result.getSeverity());
            }
            SimpleArtifactRepository repository = repositoryParser.getRepository();
            if (repository == null)
                throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_READ, Messages.io_parseError, null));
            return repository;
        } finally {
            if (bufferedInput != null)
                bufferedInput.close();
        }
    } catch (IOException ioe) {
        String msg = NLS.bind(Messages.io_failedRead, location);
        throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_READ, msg, ioe));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) SimpleArtifactRepository(org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository) BufferedInputStream(java.io.BufferedInputStream) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IOException(java.io.IOException) XMLParser(org.eclipse.equinox.internal.p2.persistence.XMLParser)

Example 39 with ProvisionException

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

the class PackedFormatMirroringArtifactProvider method downloadMostSpecificNeededFormatOfArtifact.

@Override
protected IStatus downloadMostSpecificNeededFormatOfArtifact(IArtifactKey key) throws ProvisionException, ArtifactSinkException {
    IArtifactDescriptor[] allDescriptors = remoteProviders.getArtifactDescriptors(key);
    IArtifactDescriptor packedDescriptor = findPackedDescriptor(allDescriptors);
    if (packedDescriptor != null) {
        // TODO 393004 remove "maven-groupId", etc. properties to force storage as p2/osgi/bundle...
        return downloadRawArtifact(packedDescriptor);
    } else {
        logger.debug("No remote repository provides " + key.getId() + "_" + key.getVersion() + " in packed format. Only the canonical format will be available in the build.");
        return downloadCanonicalArtifact(key);
    }
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)

Example 40 with ProvisionException

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

the class LocalArtifactRepositoryFactoryTest method testLoad.

@Test
public void testLoad() throws ProvisionException {
    LocalArtifactRepository repo = new LocalArtifactRepository(localRepoIndices);
    repo.save();
    IArtifactRepository repo2 = subject.load(baseDir.toURI(), 0, new NullProgressMonitor());
    Assert.assertEquals(repo, repo2);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) Test(org.junit.Test)

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