Search in sources :

Example 1 with IArtifactRepository

use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepository in project tycho by eclipse.

the class LocalArtifactRepositoryTest method testGetArtifactsErrorRequest.

@Test
public void testGetArtifactsErrorRequest() {
    LocalArtifactRepository repo = new LocalArtifactRepository(localRepoIndices);
    IArtifactRequest errorRequest = new IArtifactRequest() {

        @Override
        public void perform(IArtifactRepository sourceRepository, IProgressMonitor monitor) {
        }

        @Override
        public IStatus getResult() {
            return new Status(IStatus.ERROR, "test-bundle", "Error");
        }

        @Override
        public IArtifactKey getArtifactKey() {
            return null;
        }
    };
    IStatus status = repo.getArtifacts(new IArtifactRequest[] { errorRequest }, new NullProgressMonitor());
    assertThat(status, not(okStatus()));
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) StatusMatchers.okStatus(org.eclipse.tycho.test.util.StatusMatchers.okStatus) Status(org.eclipse.core.runtime.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) IArtifactRequest(org.eclipse.equinox.p2.repository.artifact.IArtifactRequest) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) Test(org.junit.Test)

Example 2 with IArtifactRepository

use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepository in project tycho by eclipse.

the class RepositoryArtifactProvider method getArtifactFromOneMirror.

private boolean getArtifactFromOneMirror(List<IArtifactDescriptor> availableDescriptors, IArtifactRepository repository, IArtifactSink sink, List<IStatus> statusCollector, RetryTracker retryTracker, IProgressMonitor monitor) throws ArtifactSinkException {
    for (IArtifactDescriptor descriptor : availableDescriptors) {
        if (!sink.canBeginWrite()) {
            return false;
        }
        // there is no way to explicitly select a mirror - the repository magically picks one
        IStatus status = repository.getArtifact(descriptor, sink.beginWrite(), monitor);
        statusCollector.add(improveMessageIfError(status, repository, descriptor));
        if (isFatal(status)) {
            sink.abortWrite();
            /*
                 * CODE_RETRY is how the repository signals that it has more mirrors to try, and
                 * that we can call the same method with exactly the same parameters (!) again.
                 * However we try another format first, so that we don't "spoil" all mirrors by
                 * continuing to querying for a pack200 artifact that is actually broken in the
                 * master repository (cf. bug 412945).
                 */
            if (status.getCode() != IArtifactRepository.CODE_RETRY) {
                retryTracker.noMoreRetries();
            }
        } else {
            sink.commitWrite();
            return true;
        }
    }
    return false;
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) IStatus(org.eclipse.core.runtime.IStatus)

Example 3 with IArtifactRepository

use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepository in project tycho by eclipse.

the class RepositoryArtifactProvider method getRawArtifactFromRepository.

// TODO 393004 retry mirrors
private boolean getRawArtifactFromRepository(IArtifactRepository repository, IRawArtifactSink sink, List<IStatus> statusCollector, IProgressMonitor monitor) throws ArtifactSinkException {
    IArtifactDescriptor requestedDescriptor = sink.getArtifactFormatToBeWritten();
    if (repository.contains(requestedDescriptor)) {
        if (!sink.canBeginWrite()) {
            return false;
        }
        IStatus status = repository.getRawArtifact(requestedDescriptor, sink.beginWrite(), monitor);
        statusCollector.add(improveMessageIfError(status, repository, requestedDescriptor));
        if (isFatal(status)) {
            sink.abortWrite();
        } else {
            sink.commitWrite();
            return true;
        }
    }
    return false;
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) IStatus(org.eclipse.core.runtime.IStatus)

Example 4 with IArtifactRepository

use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepository in project tycho by eclipse.

the class PublisherActionRunner method newPublisherInfo.

private IPublisherInfo newPublisherInfo(IMetadataRepository metadataOutput, IArtifactRepository artifactsOutput) {
    final PublisherInfo publisherInfo = new PublisherInfo();
    publisherInfo.setMetadataRepository(metadataOutput);
    publisherInfo.setArtifactRepository(artifactsOutput);
    publisherInfo.setArtifactOptions(IPublisherInfo.A_INDEX | IPublisherInfo.A_PUBLISH);
    // TODO publishers only need an IQueryable<IInstallableUnit> -> changing this in p2 would simplify things for us
    publisherInfo.setContextMetadataRepository(contextIUs);
    // no (known) publisher action needs context artifact repositories
    setTargetEnvironments(publisherInfo);
    return publisherInfo;
}
Also used : PublisherInfo(org.eclipse.equinox.p2.publisher.PublisherInfo) IPublisherInfo(org.eclipse.equinox.p2.publisher.IPublisherInfo)

Example 5 with IArtifactRepository

use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepository in project tycho by eclipse.

the class VerifierServiceImpl method verifyAllArtifactContent.

private boolean verifyAllArtifactContent(IArtifactRepository repository, MavenLogger logger) {
    boolean valid = true;
    IQueryResult<IArtifactKey> allKeys = repository.query(new ExpressionMatchQuery<>(IArtifactKey.class, ExpressionUtil.TRUE_EXPRESSION), null);
    for (Iterator<IArtifactKey> keyIt = allKeys.iterator(); keyIt.hasNext(); ) {
        IArtifactKey key = keyIt.next();
        IArtifactDescriptor[] descriptors = repository.getArtifactDescriptors(key);
        for (IArtifactDescriptor descriptor : descriptors) {
            valid &= verifyArtifactContent(repository, logger, descriptor);
        }
    }
    return valid;
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) IArtifactKey(org.eclipse.equinox.p2.metadata.IArtifactKey)

Aggregations

IArtifactRepository (org.eclipse.equinox.p2.repository.artifact.IArtifactRepository)23 Test (org.junit.Test)11 IStatus (org.eclipse.core.runtime.IStatus)7 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)6 File (java.io.File)4 OutputStream (java.io.OutputStream)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 Status (org.eclipse.core.runtime.Status)3 IProvisioningAgent (org.eclipse.equinox.p2.core.IProvisioningAgent)3 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)3 IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)3 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)3 IMetadataRepository (org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 IPublisherAction (org.eclipse.equinox.p2.publisher.IPublisherAction)2 IPublisherAdvice (org.eclipse.equinox.p2.publisher.IPublisherAdvice)2 IPublisherInfo (org.eclipse.equinox.p2.publisher.IPublisherInfo)2 Publisher (org.eclipse.equinox.p2.publisher.Publisher)2