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()));
}
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;
}
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;
}
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;
}
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;
}
Aggregations