diff options
author | Pascal Rapicault | 2009-04-09 15:33:25 +0000 |
---|---|---|
committer | Pascal Rapicault | 2009-04-09 15:33:25 +0000 |
commit | 36233908293d95192b69ca94a4c815b5a423085e (patch) | |
tree | a36808bbd71e0db7a3f45082bfe53112c773dce1 /bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing | |
parent | 6dc095d52bcf7a11bf504ec4969d8654b88e3784 (diff) | |
download | rt.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/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing')
3 files changed, 54 insertions, 4 deletions
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 |