Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2009-04-09 15:33:25 +0000
committerPascal Rapicault2009-04-09 15:33:25 +0000
commit36233908293d95192b69ca94a4c815b5a423085e (patch)
treea36808bbd71e0db7a3f45082bfe53112c773dce1 /bundles
parent6dc095d52bcf7a11bf504ec4969d8654b88e3784 (diff)
downloadrt.equinox.p2-36233908293d95192b69ca94a4c815b5a423085e.tar.gz
rt.equinox.p2-36233908293d95192b69ca94a4c815b5a423085e.tar.xz
rt.equinox.p2-36233908293d95192b69ca94a4c815b5a423085e.zip
Bug 266141 - Timeout exception are converted into MD5 hash mismatch error
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/Messages.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/ProcessingStepHandler.java38
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/messages.properties13
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java51
5 files changed, 124 insertions, 7 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
index b8a42b8c1..f551ad4c9 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
@@ -832,7 +832,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
save();
}
- public IStatus reportStatus(IArtifactDescriptor descriptor, OutputStream destination, IStatus status) {
+ private IStatus reportStatus(IArtifactDescriptor descriptor, OutputStream destination, IStatus status) {
// 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))
@@ -846,13 +846,29 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
return new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.sar_reportStatus, descriptor.getArtifactKey().toExternalForm()), e);
}
- IStatus stepStatus = ProcessingStepHandler.getStatus(destination, true);
+ // An error occurred obtaining the artifact, ProcessingStep errors aren't important
+ if (status.matches(IStatus.ERROR))
+ return status;
+
+ IStatus stepStatus = ProcessingStepHandler.getErrorStatus(destination);
// 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 steps
MultiStatus result = new MultiStatus(Activator.ID, IStatus.OK, new IStatus[0], NLS.bind(Messages.sar_reportStatus, descriptor.getArtifactKey().toExternalForm()), null);
- result.merge(status);
+
+ if (!status.isOK()) {
+ // Transport pushes its status onto the output stream if the stream implements IStateful, to prevent
+ // duplication determine if the Status is present in the ProcessingStep status.
+ boolean found = false;
+ IStatus[] stepStatusChildren = stepStatus.getChildren();
+ for (int i = 0; i < stepStatusChildren.length && !found; i++)
+ if (stepStatusChildren[i] == status)
+ found = true;
+ if (!found)
+ result.merge(status);
+ }
+
result.merge(stepStatus);
return result;
}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/Messages.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/Messages.java
index e81dc2635..6d35da258 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/Messages.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others. All rights reserved. This
+ * Copyright (c) 2008, 2009 IBM Corporation and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -12,12 +12,17 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.messages"; //$NON-NLS-1$
+ public static String cannot_get_extension;
+ public static String cannot_instantiate_step;
public static String ZipVerifierStep_invalid_archive;
+ public static String processing_step_results;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private Messages() {
+ //
}
}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/ProcessingStepHandler.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/ProcessingStepHandler.java
index 20d287e76..9db48ca81 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/ProcessingStepHandler.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/ProcessingStepHandler.java
@@ -18,6 +18,7 @@ import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.ArtifactOutputStream;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor;
import org.eclipse.equinox.internal.provisional.p2.repository.IStateful;
+import org.eclipse.osgi.util.NLS;
/**
* Creates processing step instances from extensions and executes them.
@@ -64,7 +65,38 @@ public class ProcessingStepHandler {
if (severity == IStatus.OK)
return Status.OK_STATUS;
IStatus[] result = (IStatus[]) list.toArray(new IStatus[list.size()]);
- return new MultiStatus(Activator.ID, severity, result, "Result of processing steps", null);
+ return new MultiStatus(Activator.ID, severity, result, Messages.processing_step_results, null);
+ }
+
+ /**
+ * Return statuses from this step and any linked step, discarding OK statuses until an error status is received.
+ * @param stream the stream representing the first step
+ * @return the requested status
+ */
+ public static IStatus getErrorStatus(OutputStream stream) {
+ ArrayList list = new ArrayList();
+ int severity = collectErrorStatus(stream, list);
+ if (severity == IStatus.OK)
+ return Status.OK_STATUS;
+ IStatus[] result = (IStatus[]) list.toArray(new IStatus[list.size()]);
+ return new MultiStatus(Activator.ID, 0, result, Messages.processing_step_results, null);
+ }
+
+ private static int collectErrorStatus(OutputStream stream, ArrayList list) {
+ IStatus status = getStatus(stream);
+ if (!status.isOK())
+ list.add(status);
+ if (status.matches(IStatus.ERROR))
+ // Errors past this should be bogus as they rely on output from this step
+ return status.getSeverity();
+
+ OutputStream destination = getDestination(stream);
+ if (destination == null || !(destination instanceof IStateful))
+ return status.getSeverity();
+ int result = collectErrorStatus(destination, list);
+ // TODO greater than test here is a little brittle but it is very unlikely that we will add
+ // a new status severity.
+ return status.getSeverity() > result ? status.getSeverity() : result;
}
public static IStatus getStatus(OutputStream stream) {
@@ -115,11 +147,11 @@ public class ProcessingStepHandler {
error = e;
}
} else
- error = new ProcessingStepHandlerException("Could not get extension " + PROCESSING_STEPS_EXTENSION_ID + " for desriptor id " + descriptor.getProcessorId());
+ error = new ProcessingStepHandlerException(NLS.bind(Messages.cannot_get_extension, PROCESSING_STEPS_EXTENSION_ID, descriptor.getProcessorId()));
int severity = descriptor.isRequired() ? IStatus.ERROR : IStatus.INFO;
ProcessingStep result = new EmptyProcessingStep();
- result.setStatus(new Status(severity, Activator.ID, "Could not instantiate step:" + descriptor.getProcessorId(), error));
+ result.setStatus(new Status(severity, Activator.ID, Messages.cannot_instantiate_step + descriptor.getProcessorId(), error));
return result;
}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/messages.properties b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/messages.properties
index 5027dafa9..9459df431 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/messages.properties
@@ -1 +1,14 @@
+cannot_instantiate_step=Could not instantiate step:
+###############################################################################
+# Copyright (c) 2007, 2009 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+cannot_get_extension=Could not get extension {0} for descriptor id {1}.
ZipVerifierStep_invalid_archive=Downloaded stream not a valid archive. Check the server.
+processing_step_results=Result of processing steps. \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java
index cd3955ed1..c9c63a89b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java
@@ -211,4 +211,55 @@ public class ProcessingStepHandlerTest extends TestCase {
assertTrue(Arrays.equals(new byte[] {4, 6, 8, 10, 12}, result.toByteArray()));
}
+ public void testPSHgetStatusOK() {
+ ProcessingStep ok1, ok2;
+ ok1 = new ProcessingStep() {
+ public IStatus getStatus() {
+ return Status.OK_STATUS;
+ }
+ };
+ ok2 = new ProcessingStep() {
+ public IStatus getStatus() {
+ return Status.OK_STATUS;
+ }
+ };
+
+ OutputStream testStream = handler.link(new ProcessingStep[] {ok1, ok2}, null, monitor);
+ IStatus status = ProcessingStepHandler.getStatus(testStream);
+ IStatus errStatus = ProcessingStepHandler.getStatus(testStream);
+ assertTrue(status.isOK() && errStatus.isOK());
+ assertTrue(!status.isMultiStatus());
+ assertTrue(!errStatus.isMultiStatus());
+ }
+
+ public void testPSHgetStatus() {
+ ProcessingStep ok, info, warning, error;
+ ok = new ProcessingStep() {
+ public IStatus getStatus() {
+ return Status.OK_STATUS;
+ }
+ };
+
+ info = new ProcessingStep() {
+ public IStatus getStatus() {
+ return new Status(IStatus.INFO, "ID", "INFO");
+ }
+ };
+
+ warning = new ProcessingStep() {
+ public IStatus getStatus() {
+ return new Status(IStatus.WARNING, "ID", "WARNING");
+ }
+ };
+
+ error = new ProcessingStep() {
+ public IStatus getStatus() {
+ return new Status(IStatus.ERROR, "ID", "ERROR");
+ }
+ };
+
+ OutputStream testStream = handler.link(new ProcessingStep[] {info, ok, error, warning}, null, monitor);
+ assertTrue(ProcessingStepHandler.getErrorStatus(testStream).getChildren().length == 2);
+ assertTrue(ProcessingStepHandler.getStatus(testStream, true).getChildren().length == 4);
+ }
}

Back to the top