summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Sievers2012-10-29 10:55:32 (EDT)
committer Tobias Oberlies2012-10-30 11:59:32 (EDT)
commit90d59f62e6929fd3e5c4d2b60ca3c401245b85ea (patch)
tree6a62717d0ae3044d401dda91eff172cf183c6d5d
parent2d7160d2d72b0425dc436ba5495c50b07e8e9e4d (diff)
downloadrt.equinox.p2-90d59f62e6929fd3e5c4d2b60ca3c401245b85ea.zip
rt.equinox.p2-90d59f62e6929fd3e5c4d2b60ca3c401245b85ea.tar.gz
rt.equinox.p2-90d59f62e6929fd3e5c4d2b60ca3c401245b85ea.tar.bz2
393051 Use case-insensitive dictionary in bundle publisher
Use the Dictionary implementation with case-insensitive getters org.eclipse.osgi.framework.util.Headers to parse the MANIFEST stream.
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/BundlesActionTest/test3/META-INF/MANIFEST.MF20
4 files changed, 21 insertions, 14 deletions
diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.publisher.eclipse/META-INF/MANIFEST.MF
index 2884ece..ec0e879 100644
--- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/META-INF/MANIFEST.MF
@@ -32,6 +32,7 @@ Import-Package: org.eclipse.equinox.app;version="[1.0.0,2.0.0)",
org.eclipse.equinox.p2.repository.spi;version="[2.0.0,3.0.0)",
org.eclipse.equinox.simpleconfigurator.manipulator;version="[2.0.0,3.0.0)",
org.eclipse.equinox.spi.p2.publisher,
+ org.eclipse.osgi.framework.util,
org.eclipse.osgi.service.datalocation;version="1.3.0",
org.eclipse.osgi.service.environment;version="1.1.0",
org.eclipse.osgi.service.pluginconversion;version="1.0.0",
diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java
index 10790a0..cc29cb4 100644
--- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java
@@ -37,6 +37,7 @@ import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.spi.p2.publisher.LocalizationHelper;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
+import org.eclipse.osgi.framework.util.Headers;
import org.eclipse.osgi.service.pluginconversion.PluginConversionException;
import org.eclipse.osgi.service.pluginconversion.PluginConverter;
import org.eclipse.osgi.service.resolver.*;
@@ -591,10 +592,7 @@ public class BundlesAction extends AbstractPublisherAction {
try {
if (manifestStream != null) {
try {
- Map<String, String> manifestMap = ManifestElement.parseBundleManifest(manifestStream, null);
- // TODO temporary hack. We are reading a Map but everyone wants a Dictionary so convert.
- // real answer is to have people expect a Map but that is a wider change.
- manifest = new Hashtable<String, String>(manifestMap);
+ manifest = parseBundleManifestIntoModifyableDictionaryWithCaseInsensitiveKeys(manifestStream);
} catch (IOException e) {
String message = NLS.bind(Messages.exception_errorReadingManifest, bundleLocation, e.getMessage());
LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message, e));
@@ -626,6 +624,13 @@ public class BundlesAction extends AbstractPublisherAction {
}
+ /**
+ * @return the same result as {@link Headers#parseManifest(InputStream)}, but with a modifiable {@link Headers} instance
+ */
+ private static Headers<String, String> parseBundleManifestIntoModifyableDictionaryWithCaseInsensitiveKeys(InputStream manifestStream) throws IOException, BundleException {
+ return (Headers<String, String>) ManifestElement.parseBundleManifest(manifestStream, new Headers<String, String>(10));
+ }
+
private static ManifestElement[] parseManifestHeader(String header, Map<String, String> manifest, String bundleLocation) {
try {
return ManifestElement.parseHeader(header, manifest.get(header));
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java
index 7f88243..34ee5be 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java
@@ -282,6 +282,7 @@ public class BundlesActionTest extends ActionTest {
}
private void verifyBundle3() {
+ // also a regression test for bug 393051: manifest headers use uncommon (but valid) capitalization
ArrayList ius = new ArrayList(publisherResult.getIUs(TEST3_PROVBUNDLE_NAME, IPublisherResult.ROOT));
assertTrue(ius.size() == 1);
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/BundlesActionTest/test3/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.tests/testData/BundlesActionTest/test3/META-INF/MANIFEST.MF
index 45bce0b..bd46555 100644
--- a/bundles/org.eclipse.equinox.p2.tests/testData/BundlesActionTest/test3/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/BundlesActionTest/test3/META-INF/MANIFEST.MF
@@ -1,11 +1,11 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: test3
-Bundle-SymbolicName: test3;singleton:=true
-Bundle-Version: 0.1.0.qualifier
-Import-Package: iud;version="1.3.0"
-Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: J2SE-1.4,
+manifest-Version: 1.0
+bundle-ManifestVersion: 2
+bundle-Name: test3
+bundle-SymbolicName: test3;singleton:=true
+bundle-Version: 0.1.0.qualifier
+import-Package: iud;version="1.3.0"
+bundle-ActivationPolicy: lazy
+bundle-RequiredExecutionEnvironment: J2SE-1.4,
CDC-1.1/Foundation-1.1
-Export-Package: iuz;x-friends:="friend1,friend2"
-Eclipse-SourceBundle: test2;version="1.0.0.qualifier"
+export-package: iuz;x-friends:="friend1,friend2"
+eclipse-SourceBundle: test2;version="1.0.0.qualifier"