use of org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor in project tycho by eclipse.
the class ArtifactRepositoryBaseImpl method getArtifact.
@Override
public final IStatus getArtifact(IArtifactSink sink, IProgressMonitor monitor) throws ArtifactSinkException {
canWriteToSink(sink);
// method signature allows calls with a IRawArtifactSink -> make sure this is only done if sink requests a raw artifact in canonical format
canWriteCanonicalArtifactToSink(sink);
IArtifactKey requestedKey = sink.getArtifactToBeWritten();
IArtifactDescriptor[] availableFormats = getArtifactDescriptors(requestedKey);
List<IArtifactDescriptor> formatsByPreference = transferPolicy.sortFormatsByPreference(availableFormats);
for (IArtifactDescriptor descriptor : formatsByPreference) {
IStatus result = getProcessedRawArtifact(descriptor, sink.beginWrite(), monitor);
// trying other formats is no use case for the LocalArtifactRepository - if the preferred format (=canonical) is corrupt, it can fail straight away
// TODO implement retry for other implementations?
closeSinkAccordingToStatus(sink, result);
return result;
}
return errorStatus("Artifact " + requestedKey + " is not available in the repository " + getLocation(), null, ProvisionException.ARTIFACT_NOT_FOUND);
}
use of org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor in project tycho by eclipse.
the class ModuleArtifactRepository method getInternalDescriptorForAdding.
@Override
protected ModuleArtifactDescriptor getInternalDescriptorForAdding(IArtifactDescriptor descriptor) throws IllegalArgumentException {
if (descriptor == null) {
throw new NullPointerException();
} else if (!(descriptor instanceof ModuleArtifactDescriptor) || descriptor.getRepository() != this) {
throw new IllegalArgumentException("Cannot add artifact descriptor which has not been created by this repository");
}
ModuleArtifactDescriptor internalDescriptor = (ModuleArtifactDescriptor) descriptor;
try {
MavenRepositoryCoordinates coordinates = internalDescriptor.getMavenCoordinates();
artifactsMap.addToAutomaticLocation(coordinates.getClassifier(), coordinates.getExtension());
} catch (ProvisionException e) {
// TODO 393004 Revise exception handling
throw new RuntimeException(e);
}
return internalDescriptor;
}
use of org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor 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.IArtifactDescriptor 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.IArtifactDescriptor in project tycho by eclipse.
the class CompositeArtifactProvider method getRawArtifactFromAnySource.
@Override
protected void getRawArtifactFromAnySource(IRawArtifactSink sink, IProgressMonitor monitor, List<IStatus> statusCollector) throws ArtifactSinkException {
IArtifactDescriptor requestedDescriptor = sink.getArtifactFormatToBeWritten();
for (IRawArtifactFileProvider component : components) {
if (component.contains(requestedDescriptor)) {
if (!sink.canBeginWrite()) {
return;
}
IStatus transferStatus = component.getRawArtifact(sink, monitor);
statusCollector.add(transferStatus);
if (!isFatal(transferStatus)) {
// read was successful -> done
return;
}
}
}
}
Aggregations