Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional')
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/Messages.java28
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/ProcessingStep.java128
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/ProcessingStepHandler.java205
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/ZipVerifierStep.java43
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/messages.properties14
5 files changed, 0 insertions, 418 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
deleted file mode 100644
index 6d35da258..000000000
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/Messages.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * 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
- *
- * Contributors: IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing;
-
-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/ProcessingStep.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/ProcessingStep.java
deleted file mode 100644
index c0e4858ec..000000000
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/ProcessingStep.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2007, 2009 compeople AG 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:
-* compeople AG (Stefan Liebig) - initial API and implementation
-* IBM Corporation - continuing development
-*******************************************************************************/
-package org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.provisional.p2.repository.IStateful;
-import org.eclipse.equinox.p2.core.IProvisioningAgent;
-import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
-import org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor;
-
-/**
- * ProcessingSteps process the data written to them and pass the resultant data on
- * to a configured destination stream. Steps may monitor (e.g., count) the data, compute information
- * about the data (e.g., checksum or hash) or transform the data (e.g., unpack200).
- */
-public abstract class ProcessingStep extends OutputStream implements IStateful {
-
- private OutputStream destination;
- private IProgressMonitor monitor;
- private IStatus status = Status.OK_STATUS;
-
- protected ProcessingStep() {
- super();
- }
-
- /**
- * Initialize this processing step according to the information in the given
- * descriptor and context. After initialization, this step is ready for linking
- * with other steps or output streams
- * @param descriptor description of the step
- * @param context the context in which the step is being used
- */
- public void initialize(IProvisioningAgent agent, IProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
- // nothing to do here!
- }
-
- /**
- * Link this step with the given output stream and configure the step to use the given
- * progress monitor. After linking the step is ready to have data written to it.
- * @param destination the stream into which to write the processed data
- * @param monitor the progress monitor to use for reporting activity
- */
- public void link(OutputStream destination, IProgressMonitor monitor) {
- this.destination = destination;
- this.monitor = monitor;
- }
-
- /**
- * Process the given byte and pass the result on to the configured destination stream
- * @param b the byte being written
- */
- public void write(int b) throws IOException {
- // nothing to do here!
- }
-
- /**
- * Flush any unwritten data from this stream.
- */
- public void flush() throws IOException {
- super.flush();
- if (destination != null)
- destination.flush();
- }
-
- /**
- * Close this stream and, if the configured destination is a ProcessingStep,
- * close it as well. Typically a chain of steps terminates in a conventional
- * output stream. Implementors of this method should ensure they set the
- * status of the step.
- */
- public void close() throws IOException {
- super.close();
- if (destination instanceof ProcessingStep)
- destination.close();
- monitor = null;
- }
-
- public IStatus getStatus() {
- return status;
- }
-
- public void setStatus(IStatus value) {
- if (value == null)
- value = Status.OK_STATUS;
- if (status != null && status.getSeverity() >= value.getSeverity())
- return;
- status = value;
- }
-
- /**
- * Get the progress monitor.
- * @return the progress monitor; may be null
- */
- protected IProgressMonitor getProgressMonitor() {
- return monitor;
- }
-
- /**
- * Get the stream to write the processed data into.
- *
- * @return output stream for processed data
- */
- protected OutputStream getDestination() {
- return destination;
- }
-
- /**
- * Return the status of this step. The status will be <code>null</code> if the
- * step has not yet executed. If the step has executed the returned status
- * indicates the success or failure of the step.
- * @param deep whether or not to aggregate the status of any linked steps
- * @return the requested status
- */
- public IStatus getStatus(boolean deep) {
- return ProcessingStepHandler.getStatus(this, deep);
- }
-}
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
deleted file mode 100644
index e5530e937..000000000
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/ProcessingStepHandler.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2007, 2009 compeople AG 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:
-* compeople AG (Stefan Liebig) - initial API and implementation
-* IBM - continuing development
-*******************************************************************************/
-package org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing;
-
-import java.io.OutputStream;
-import java.util.ArrayList;
-import org.eclipse.core.runtime.*;
-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.repository.IStateful;
-import org.eclipse.equinox.p2.core.IProvisioningAgent;
-import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
-import org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor;
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Creates processing step instances from extensions and executes them.
- */
-public class ProcessingStepHandler {
-
- private static final String PROCESSING_STEPS_EXTENSION_ID = "org.eclipse.equinox.p2.artifact.repository.processingSteps"; //$NON-NLS-1$
-
- //TODO This method can go
- public static IStatus checkStatus(OutputStream output) {
- return getStatus(output, true);
- }
-
- /**
- * Check to see that we have processors for all the steps in the given descriptor
- * @param descriptor the descriptor to check
- * @return whether or not processors for all the descriptor's steps are installed
- */
- public static boolean canProcess(IArtifactDescriptor descriptor) {
- IExtensionRegistry registry = RegistryFactory.getRegistry();
- IExtensionPoint point = registry.getExtensionPoint(PROCESSING_STEPS_EXTENSION_ID);
- if (point == null)
- return false;
- IProcessingStepDescriptor[] steps = descriptor.getProcessingSteps();
- for (int i = 0; i < steps.length; i++) {
- if (point.getExtension(steps[i].getProcessorId()) == null)
- return false;
- }
- return true;
- }
-
- /**
- * Return the status of this step. The status will be <code>null</code> if the
- * step has not yet executed. If the step has executed the returned status
- * indicates the success or failure of the step.
- * @param deep whether or not to aggregate the status of any linked steps
- * @return the requested status
- */
- public static IStatus getStatus(OutputStream stream, boolean deep) {
- if (!deep)
- return getStatus(stream);
- ArrayList<IStatus> list = new ArrayList<IStatus>();
- int severity = collectStatus(stream, list);
- if (severity == IStatus.OK)
- return Status.OK_STATUS;
- IStatus[] result = list.toArray(new IStatus[list.size()]);
- 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<IStatus> list = new ArrayList<IStatus>();
- int severity = collectErrorStatus(stream, list);
- if (severity == IStatus.OK)
- return Status.OK_STATUS;
- IStatus[] result = 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<IStatus> 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) {
- if (stream instanceof IStateful)
- return ((IStateful) stream).getStatus();
- return Status.OK_STATUS;
- }
-
- private static int collectStatus(OutputStream stream, ArrayList<IStatus> list) {
- IStatus status = getStatus(stream);
- list.add(status);
- OutputStream destination = getDestination(stream);
- if (destination == null || !(destination instanceof IStateful))
- return status.getSeverity();
- int result = collectStatus(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;
- }
-
- private static OutputStream getDestination(OutputStream stream) {
- if (stream instanceof ProcessingStep)
- return ((ProcessingStep) stream).getDestination();
- if (stream instanceof ArtifactOutputStream)
- return ((ArtifactOutputStream) stream).getDestination();
- return null;
- }
-
- public ProcessingStep[] create(IProvisioningAgent agent, IProcessingStepDescriptor[] descriptors, IArtifactDescriptor context) {
- ProcessingStep[] result = new ProcessingStep[descriptors.length];
- for (int i = 0; i < descriptors.length; i++)
- result[i] = create(agent, descriptors[i], context);
- return result;
- }
-
- public ProcessingStep create(IProvisioningAgent agent, IProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
- IExtensionRegistry registry = RegistryFactory.getRegistry();
- IExtension extension = registry.getExtension(PROCESSING_STEPS_EXTENSION_ID, descriptor.getProcessorId());
- Exception error;
- if (extension != null) {
- IConfigurationElement[] config = extension.getConfigurationElements();
- try {
- Object object = config[0].createExecutableExtension("class"); //$NON-NLS-1$
- ProcessingStep step = (ProcessingStep) object;
- step.initialize(agent, descriptor, context);
- return step;
- } catch (Exception e) {
- error = e;
- }
- } else
- 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, Messages.cannot_instantiate_step + descriptor.getProcessorId(), error));
- return result;
- }
-
- public OutputStream createAndLink(IProvisioningAgent agent, IProcessingStepDescriptor[] descriptors, IArtifactDescriptor context, OutputStream output, IProgressMonitor monitor) {
- if (descriptors == null)
- return output;
- ProcessingStep[] steps = create(agent, descriptors, context);
- return link(steps, output, monitor);
- }
-
- public OutputStream link(ProcessingStep[] steps, OutputStream output, IProgressMonitor monitor) {
- OutputStream previous = output;
- for (int i = steps.length - 1; i >= 0; i--) {
- ProcessingStep step = steps[i];
- step.link(previous, monitor);
- previous = step;
- }
- if (steps.length == 0)
- return previous;
- // now link the artifact stream to the first stream in the new chain
- ArtifactOutputStream lastLink = getArtifactStream(previous);
- if (lastLink != null)
- lastLink.setFirstLink(previous);
- return previous;
- }
-
- // Traverse the chain of processing steps and return the stream served up by
- // the artifact repository or null if one cannot be found.
- private ArtifactOutputStream getArtifactStream(OutputStream stream) {
- OutputStream current = stream;
- while (current instanceof ProcessingStep)
- current = ((ProcessingStep) current).getDestination();
- if (current instanceof ArtifactOutputStream)
- return (ArtifactOutputStream) current;
- return null;
- }
-
- protected static final class EmptyProcessingStep extends ProcessingStep {
- // Just to hold the status
- }
-
- protected static final class ProcessingStepHandlerException extends Exception {
- private static final long serialVersionUID = 1L;
-
- public ProcessingStepHandlerException(String message) {
- super(message);
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/ZipVerifierStep.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/ZipVerifierStep.java
deleted file mode 100644
index a649b0c23..000000000
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/ZipVerifierStep.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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
- ******************************************************************************/
-package org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing;
-
-import java.io.IOException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
-
-public class ZipVerifierStep extends ProcessingStep {
- static final int[] ZIP_HEADER = new int[] {0x50, 0x4b, 0x03, 0x04};
-
- private int valid = 0; //-1 indicates that it is not a zip, >3 indicates that we are done the verification
-
- public void write(int b) throws IOException {
- getDestination().write(b);
- if (valid > 3)
- return;
- if (valid == -1) {
- return;
- }
- if (b != ZIP_HEADER[valid++]) {
- valid = -1;
- setStatus(new Status(IStatus.ERROR, Activator.ID, Messages.ZipVerifierStep_invalid_archive));
- return;
- }
- }
-
- public void close() throws IOException {
- if (valid > 3) {
- setStatus(Status.OK_STATUS);
- } else {
- setStatus(new Status(IStatus.ERROR, Activator.ID, Messages.ZipVerifierStep_invalid_archive));
- }
- super.close();
- }
-}
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
deleted file mode 100644
index 9459df431..000000000
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/messages.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-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

Back to the top