Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2008-05-29 17:54:29 -0400
committerPascal Rapicault2008-05-29 17:54:29 -0400
commit2c8a1971c62dc48ffb2e146590810a3648f5c97c (patch)
treef6c46f70c19589c957c527074de49272e91a1da8 /bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing
parentbd678c7dff73fb11afe45e8501e08fb010b38457 (diff)
downloadrt.equinox.p2-2c8a1971c62dc48ffb2e146590810a3648f5c97c.tar.gz
rt.equinox.p2-2c8a1971c62dc48ffb2e146590810a3648f5c97c.tar.xz
rt.equinox.p2-2c8a1971c62dc48ffb2e146590810a3648f5c97c.zip
Bug 233201 / Bug 234518 - Some servers return a webpage instead of the requested file.
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing')
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/Messages.java23
-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.properties1
3 files changed, 67 insertions, 0 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
new file mode 100644
index 000000000..e81dc2635
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/Messages.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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 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 ZipVerifierStep_invalid_archive;
+ 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/ZipVerifierStep.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/ZipVerifierStep.java
new file mode 100644
index 000000000..a649b0c23
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/ZipVerifierStep.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * 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
new file mode 100644
index 000000000..5027dafa9
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/processing/messages.properties
@@ -0,0 +1 @@
+ZipVerifierStep_invalid_archive=Downloaded stream not a valid archive. Check the server.

Back to the top