Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2008-04-22 22:39:54 +0000
committerDJ Houghton2008-04-22 22:39:54 +0000
commitbc81b35af2042ac6ca1e222642b74c54ffd1a93d (patch)
tree17f6c914ba721aca309e9493a14c0bd69581740f
parenta1215079184a2a462a0bf27ea9d8a16190bf9518 (diff)
downloadrt.equinox.p2-bc81b35af2042ac6ca1e222642b74c54ffd1a93d.tar.gz
rt.equinox.p2-bc81b35af2042ac6ca1e222642b74c54ffd1a93d.tar.xz
rt.equinox.p2-bc81b35af2042ac6ca1e222642b74c54ffd1a93d.zip
Bug 228300 - Default platform.xml site policy is incorrect
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Site.java18
2 files changed, 40 insertions, 4 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java
index c1620c822..e453e0950 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java
@@ -91,18 +91,32 @@ public class PlatformConfigurationWrapper {
poolSite = getSite(poolURL);
if (poolSite == null) {
- poolSite = createSite(poolURL);
+ poolSite = createSite(poolURL, getDefaultPolicy());
configuration.add(poolSite);
}
}
/*
+ * Return the default policy to use when creating a new site. If there are
+ * any sites with the MANAGED-ONLY policy, then that is the default.
+ * Otherwise the default is USER-EXCLUDE.
+ */
+ private String getDefaultPolicy() {
+ for (Iterator iter = configuration.getSites().iterator(); iter.hasNext();) {
+ Site site = (Site) iter.next();
+ if (Site.POLICY_MANAGED_ONLY.equals(site.getPolicy()))
+ return Site.POLICY_MANAGED_ONLY;
+ }
+ return Site.POLICY_USER_EXCLUDE;
+ }
+
+ /*
* Create and return a site object based on the given location.
*/
- private Site createSite(URL location) {
+ private Site createSite(URL location, String policy) {
Site result = new Site();
result.setUrl(location.toExternalForm());
- result.setPolicy(Site.POLICY_MANAGED_ONLY);
+ result.setPolicy(policy);
result.setEnabled(true);
return result;
}
@@ -163,8 +177,12 @@ public class PlatformConfigurationWrapper {
}
Site site = getSite(fileURL);
if (site == null) {
- site = createSite(fileURL);
+ site = createSite(fileURL, getDefaultPolicy());
configuration.add(site);
+ } else {
+ // check to see if the feature already exists in this site
+ if (site.getFeature(id, version) != null)
+ return Status.OK_STATUS;
}
Feature addedFeature = new Feature(site);
addedFeature.setId(id);
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Site.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Site.java
index 234e29ac8..7e62cc7a0 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Site.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Site.java
@@ -41,6 +41,24 @@ public class Site {
return (Feature[]) features.toArray(new Feature[features.size()]);
}
+ /*
+ * Return the feature object with the specific id and version. Return null
+ * if there is no match or the id is null. If the version is null then return the
+ * first feature with a matching id.
+ */
+ public Feature getFeature(String id, String version) {
+ if (id == null)
+ return null;
+ for (Iterator iter = features.iterator(); iter.hasNext();) {
+ Feature feature = (Feature) iter.next();
+ if (id.equals(feature.getId())) {
+ if (version == null || version.equals(feature.getVersion()))
+ return feature;
+ }
+ }
+ return null;
+ }
+
public Feature removeFeature(String featureURL) {
for (Iterator iter = features.iterator(); iter.hasNext();) {
Feature feature = (Feature) iter.next();

Back to the top