Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff McAffer2007-10-17 04:35:19 +0000
committerJeff McAffer2007-10-17 04:35:19 +0000
commit0030f4ab6809ba0085ac1eac482d995099f15d2f (patch)
tree0b30cc8b9218271ccdd57b9a62bf521b0308fd4e /bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/SimpleArtifactRepository.java
parent275d9ccca728dfa889c226449e73b7a18af19701 (diff)
downloadrt.equinox.p2-0030f4ab6809ba0085ac1eac482d995099f15d2f.tar.gz
rt.equinox.p2-0030f4ab6809ba0085ac1eac482d995099f15d2f.tar.xz
rt.equinox.p2-0030f4ab6809ba0085ac1eac482d995099f15d2f.zip
add repository optmizer
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/SimpleArtifactRepository.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/SimpleArtifactRepository.java47
1 files changed, 30 insertions, 17 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/SimpleArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/SimpleArtifactRepository.java
index d9f07b1eb..d7254e09f 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/SimpleArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/SimpleArtifactRepository.java
@@ -16,7 +16,6 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.p2.artifact.repository.*;
import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStep;
import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStepHandler;
-import org.eclipse.equinox.p2.core.helpers.MultiStatus;
import org.eclipse.equinox.p2.core.repository.IRepository;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.spi.p2.artifact.repository.AbstractArtifactRepository;
@@ -81,7 +80,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) {
SubMonitor subMonitor = SubMonitor.convert(monitor, requests.length);
try {
- MultiStatus overallStatus = new MultiStatus();
+ MultiStatus overallStatus = new MultiStatus(Activator.ID, IStatus.OK, null, null);
for (int i = 0; i < requests.length; i++) {
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
@@ -169,23 +168,37 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
public IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
ProcessingStepHandler handler = new ProcessingStepHandler();
- try {
- destination = addPostSteps(handler, descriptor, destination, monitor);
- destination = handler.createAndLink(descriptor.getProcessingSteps(), descriptor, destination, monitor);
- destination = addPreSteps(handler, descriptor, destination, monitor);
- IStatus status = handler.validateSteps(destination);
- if (status.isOK() || status.getSeverity() == IStatus.INFO)
- return getTransport().download(getLocation(descriptor), destination, monitor);
+ destination = addPostSteps(handler, descriptor, destination, monitor);
+ destination = handler.createAndLink(descriptor.getProcessingSteps(), descriptor, destination, monitor);
+ destination = addPreSteps(handler, descriptor, destination, monitor);
+ IStatus status = handler.validateSteps(destination);
+ if (!status.isOK() && status.getSeverity() != IStatus.INFO)
return status;
- } finally {
- try {
- //don't close the underlying output stream - the caller will do that
- if (destination instanceof ProcessingStep)
- destination.close();
- } catch (IOException e) {
- return new Status(IStatus.ERROR, Activator.ID, "Error closing processing steps", e);
- }
+ String toDownload = getLocation(descriptor);
+ status = getTransport().download(toDownload, destination, monitor);
+
+ // If the destination is just a normal stream then the status is simple. Just return
+ // it and do not close the destination
+ if (!(destination instanceof ProcessingStep))
+ return status;
+
+ // If the destination is a processing step then close the stream to flush the data through all
+ // the steps. then collect up the status from all the steps and return
+ try {
+ destination.close();
+ } catch (IOException e) {
+ return new Status(IStatus.ERROR, Activator.ID, "Error closing processing steps", e);
}
+
+ IStatus stepStatus = ((ProcessingStep) destination).getStatus(true);
+ // if the steps all ran ok and there is no interesting information, return the status from this method
+ if (!stepStatus.isMultiStatus() && stepStatus.isOK())
+ return status;
+ // else gather up the status from the
+ MultiStatus result = new MultiStatus(Activator.ID, IStatus.OK, null, "Status of getting artifact " + toDownload, null);
+ result.merge(status);
+ result.merge(stepStatus);
+ return result;
}
private OutputStream addPostSteps(ProcessingStepHandler handler, IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {

Back to the top