Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2010-04-20 22:45:50 +0000
committerspingel2010-04-20 22:45:50 +0000
commitf87dc37c1844e17dcfb54bb97b5f2aabef1af068 (patch)
tree1166421f12aeef4257867a24de9d851cd3143191 /bundles/org.eclipse.equinox.p2.discovery.compatibility
parentce9742d62261b96f9aaa0e9b91a9ff4f059a7582 (diff)
downloadrt.equinox.p2-f87dc37c1844e17dcfb54bb97b5f2aabef1af068.tar.gz
rt.equinox.p2-f87dc37c1844e17dcfb54bb97b5f2aabef1af068.tar.xz
rt.equinox.p2-f87dc37c1844e17dcfb54bb97b5f2aabef1af068.zip
bug 309873 - [discovery] allow arbitrary tags to be specified in bundle catalogs
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.discovery.compatibility')
-rw-r--r--bundles/org.eclipse.equinox.p2.discovery.compatibility/schema/connectorDiscovery.exsd2
-rw-r--r--bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/BundleDiscoveryStrategy.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/ConnectorDiscoveryExtensionReader.java44
-rw-r--r--bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/RemoteBundleDiscoveryStrategy.java2
4 files changed, 48 insertions, 6 deletions
diff --git a/bundles/org.eclipse.equinox.p2.discovery.compatibility/schema/connectorDiscovery.exsd b/bundles/org.eclipse.equinox.p2.discovery.compatibility/schema/connectorDiscovery.exsd
index e3db6e689..73f19d087 100644
--- a/bundles/org.eclipse.equinox.p2.discovery.compatibility/schema/connectorDiscovery.exsd
+++ b/bundles/org.eclipse.equinox.p2.discovery.compatibility/schema/connectorDiscovery.exsd
@@ -62,7 +62,7 @@
<element ref="overview" minOccurs="0" maxOccurs="1"/>
<element ref="iu" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
- <attribute name="kind" type="string" use="required">
+ <attribute name="kind" type="string">
<annotation>
<documentation>
must be a comma-delimited list of the following values: &apos;document&apos;, &apos;task&apos;, &apos;vcs&apos;
diff --git a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/BundleDiscoveryStrategy.java b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/BundleDiscoveryStrategy.java
index 912d399df..2629e4bb4 100644
--- a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/BundleDiscoveryStrategy.java
+++ b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/BundleDiscoveryStrategy.java
@@ -24,6 +24,10 @@ import org.osgi.framework.Bundle;
*/
public class BundleDiscoveryStrategy extends AbstractDiscoveryStrategy {
+ public BundleDiscoveryStrategy() {
+ // constructor
+ }
+
@Override
public void performDiscovery(IProgressMonitor monitor) throws CoreException {
if (items == null || categories == null) {
@@ -79,6 +83,8 @@ public class BundleDiscoveryStrategy extends AbstractDiscoveryStrategy {
}
monitor.worked(1);
}
+
+ tags.addAll(extensionReader.getTags());
} finally {
monitor.done();
}
diff --git a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/ConnectorDiscoveryExtensionReader.java b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/ConnectorDiscoveryExtensionReader.java
index 2ee7e25b5..84afa69f5 100644
--- a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/ConnectorDiscoveryExtensionReader.java
+++ b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/ConnectorDiscoveryExtensionReader.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Task top Technologies and others.
+ * Copyright (c) 2009 Tasktop Technologies 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
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.discovery.compatibility;
+import java.util.*;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.equinox.internal.p2.discovery.model.*;
@@ -45,7 +46,13 @@ public class ConnectorDiscoveryExtensionReader {
public static Tag VCS = new Tag("vcs", Messages.ConnectorDiscoveryExtensionReader_Version_Control); //$NON-NLS-1$
- public static final Tag[] TAGS = new Tag[] {DOCUMENT, TASK, VCS};
+ public static final Tag[] DEFAULT_TAGS = new Tag[] {DOCUMENT, TASK, VCS};
+
+ private Map<String, Tag> tagById = new HashMap<String, Tag>();
+
+ public ConnectorDiscoveryExtensionReader() {
+ // constructor
+ }
/**
* return the enum constant whose {@link Tag#getValue() value} is the same as the given value.
@@ -60,7 +67,7 @@ public class ConnectorDiscoveryExtensionReader {
if (value == null) {
return null;
}
- for (Tag tag : TAGS) {
+ for (Tag tag : DEFAULT_TAGS) {
if (tag.getValue().equals(value)) {
return tag;
}
@@ -68,6 +75,32 @@ public class ConnectorDiscoveryExtensionReader {
throw new IllegalArgumentException(value);
}
+ public Set<Tag> getTags() {
+ return new HashSet<Tag>(tagById.values());
+ }
+
+ private Tag getTag(String id) {
+ if (id == null) {
+ return null;
+ }
+ // first, look for known tag
+ Tag result = tagById.get(id);
+ if (result != null) {
+ return result;
+ }
+ // second, search default tags
+ for (Tag tag : DEFAULT_TAGS) {
+ if (tag.getValue().equals(id)) {
+ tagById.put(id, tag);
+ return tag;
+ }
+ }
+ // third, create new tag
+ result = new Tag(id, id);
+ tagById.put(id, result);
+ return result;
+ }
+
public CatalogItem readConnectorDescriptor(IConfigurationElement element) throws ValidationException {
return readConnectorDescriptor(element, CatalogItem.class);
}
@@ -85,7 +118,10 @@ public class ConnectorDiscoveryExtensionReader {
if (kinds != null) {
String[] akinds = kinds.split("\\s*,\\s*"); //$NON-NLS-1$
for (String kind : akinds) {
- connectorDescriptor.addTag(fromValue(kind));
+ Tag tag = getTag(kind);
+ if (tag != null) {
+ connectorDescriptor.addTag(tag);
+ }
}
}
} catch (IllegalArgumentException e) {
diff --git a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/RemoteBundleDiscoveryStrategy.java b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/RemoteBundleDiscoveryStrategy.java
index 427ba89f5..ddafba1f3 100644
--- a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/RemoteBundleDiscoveryStrategy.java
+++ b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/RemoteBundleDiscoveryStrategy.java
@@ -42,7 +42,7 @@ public class RemoteBundleDiscoveryStrategy extends BundleDiscoveryStrategy {
@Override
public void performDiscovery(IProgressMonitor monitor) throws CoreException {
- if (items == null || categories == null || directoryUrl == null) {
+ if (items == null || categories == null || directoryUrl == null || tags == null) {
throw new IllegalStateException();
}
if (registryStrategy != null) {

Back to the top