*** empty log message ***
diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/ConfiguredSite.java b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/ConfiguredSite.java
index 5d93f0b..9bdf4c4 100644
--- a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/ConfiguredSite.java
+++ b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/ConfiguredSite.java
@@ -34,6 +34,9 @@
// verification status
private IStatus verifyStatus;
+ // transient: true if the site was just created so we can remove it
+ private transient boolean justCreated = false;
+
/*
* Default Constructor
*/
@@ -90,7 +93,7 @@
//$NON-NLS-1$ //$NON-NLS-2$
w.println(gap + increment + "platformURL=\"" + getPlatformURLString() + "\"");
//$NON-NLS-1$ //$NON-NLS-2$
- w.println(gap + increment + "enable=\"" + (isEnabled()?"true":"false") + "\"");
+ w.println(gap + increment + "enable=\"" + (isEnabled() ? "true" : "false") + "\"");
//$NON-NLS-1$ //$NON-NLS-2$
w.println(gap + increment + "policy=\"" + getConfigurationPolicy().getPolicy() + "\" >");
//$NON-NLS-1$ //$NON-NLS-2$
@@ -155,6 +158,9 @@
*/
public IFeatureReference install(IFeature feature, IFeatureReference[] optionalFeatures, IVerificationListener verificationListener, IProgressMonitor monitor) throws InstallAbortedException, CoreException {
+ // change the status if justCreated
+ if (justCreated) justCreated=false;
+
// ConfigSite is read only
if (!isUpdatable()) {
String errorMessage = Policy.bind("ConfiguredSite.NonInstallableSite", getSite().getURL().toExternalForm());
@@ -789,16 +795,17 @@
*
*/
public boolean isConfigured(IFeature feature) {
- if (!isEnabled()) return false;
-
+ if (!isEnabled())
+ return false;
+
if (getConfigurationPolicy() == null)
return false;
IFeatureReference featureReference = getSite().getFeatureReference(feature);
- if (featureReference == null){
+ if (featureReference == null) {
if (UpdateCore.DEBUG && UpdateCore.DEBUG_SHOW_WARNINGS)
- UpdateCore.warn("Unable to retrieve featureReference for feature:"+feature);
+ UpdateCore.warn("Unable to retrieve featureReference for feature:" + feature);
return false;
- }
+ }
return getConfigurationPolicy().isConfigured(featureReference);
}
@@ -1005,16 +1012,21 @@
*
*/
/*package*/
- void createPrivateSiteMarker() {
+ boolean createPrivateSiteMarker() {
URL siteURL = getSite().getURL();
- if (siteURL == null)
+ if (siteURL == null) {
UpdateCore.warn("Unable to create marker. The Site url is null.");
+ return false;
+ }
- if (!"file".equalsIgnoreCase(siteURL.getProtocol()))
+ if (!"file".equalsIgnoreCase(siteURL.getProtocol())) {
UpdateCore.warn("Unable to create private marker. The Site is not on the local file system.");
+ return false;
+ }
String siteLocation = siteURL.getFile();
File productFile = getProductFile();
+ boolean success = false;
if (productFile != null) {
String productId = getProductIdentifier("id", productFile);
String productName = getProductIdentifier("name", productFile);
@@ -1033,6 +1045,8 @@
w.println("name=" + productName);
if (productVer != null)
w.println("version=" + productVer);
+ success = true;
+ justCreated = true;
} catch (Exception e) {
UpdateCore.warn("Unable to create private Marker at:" + file, e);
} finally {
@@ -1042,6 +1056,43 @@
}
}
}
+ return success;
+ }
+
+ /*
+ *
+ */
+ /*package*/
+ boolean removePrivateSiteMarker() {
+
+ if (!justCreated) {
+ UpdateCore.warn("Unable to remove marker. The site was not created during this activity.");
+ return false;
+ }
+
+ URL siteURL = getSite().getURL();
+ if (siteURL == null) {
+ UpdateCore.warn("Unable to remove marker. The Site url is null.");
+ return false;
+ }
+
+ if (!"file".equalsIgnoreCase(siteURL.getProtocol())) {
+ UpdateCore.warn("Unable to remove private marker. The Site is not on the local file system.");
+ return false;
+ }
+
+ String siteLocation = siteURL.getFile();
+ File productFile = getProductFile();
+ File file = new File(siteLocation, PRIVATE_SITE_MARKER);
+ boolean success = false;
+ if (file.exists()) {
+ try {
+ success = file.delete();
+ } catch (Exception e) {
+ UpdateCore.warn("Unable to remove private Marker at:" + file, e);
+ }
+ }
+ return success;
}
/*
diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/InstallConfiguration.java b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/InstallConfiguration.java
index 7a92e3e..1f8593f 100644
--- a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/InstallConfiguration.java
+++ b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/InstallConfiguration.java
@@ -233,6 +233,9 @@
listener.installSiteRemoved(site);
}
+ // remove marker and directory if we just created it
+ ((ConfiguredSite)site).removePrivateSiteMarker();
+
//activity
ConfigurationActivity activity = new ConfigurationActivity(IActivity.ACTION_SITE_REMOVE);
activity.setLabel(site.getSite().getURL().toExternalForm());
diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteReconciler.java b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteReconciler.java
index 9692b17..e008ac1 100644
--- a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteReconciler.java
+++ b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteReconciler.java
@@ -172,7 +172,7 @@
siteLocal.addConfiguration(newInstallConfiguration);
siteLocal.save();
- return saveNewFeatures();
+ return saveNewFeatures(newInstallConfiguration);
}
/**
@@ -484,7 +484,7 @@
/*
*
*/
- private boolean saveNewFeatures() throws CoreException {
+ private boolean saveNewFeatures(IInstallConfiguration installConfig) throws CoreException {
if (getFeatureReferences().length == 0) {
UpdateCore.warn("No new features found");
@@ -500,11 +500,22 @@
newFoundFeatures.add(refs[i]);
}
+
if (getFeatureReferences().length == 0) {
UpdateCore.warn("No root feature found when saving new features");
return false;
}
+ // remove efixes from the delta that patch disabled feature from the installConfig
+ // bug 71730
+ removeInvalidEfixes(installConfig);
+
+ if (getFeatureReferences().length == 0) {
+ UpdateCore.warn("No new features found after removing invalid efixes");
+ return false;
+ }
+
+
date = new Date();
String fileName = UpdateManagerUtils.getLocalRandomIdentifier(DEFAULT_INSTALL_CHANGE_NAME, date);
IPath path = UpdateCore.getPlugin().getStateLocation();
@@ -689,12 +700,14 @@
// expand non efix top level features (compute full nesting structures).
ArrayList configuredFeatures = expandFeatures(topNonEfixFeatures, configuredSite);
- // retrieve efixes that patch enable feature and add them to the list of enabled features
- if (topFeatures.size() != topNonEfixFeatures.size()){
- Map patches = getPatches(allPossibleConfiguredFeatures);
- if (!patches.isEmpty()){
- // get efixes to enable from all possibles efixes
+ // retrieve efixes that patch enable feature
+ // they must be kept enabled
+ if (topFeatures.size() != topNonEfixFeatures.size()) {
+ Map patches = getPatchesAsFeature(allPossibleConfiguredFeatures);
+ if (!patches.isEmpty()) {
+ // calculate efixes to enable
List efixesToEnable = getPatchesToEnable(patches, configuredFeatures);
+ // add efies to keep enable
//add them to the enable list
for (Iterator iter = efixesToEnable.iterator(); iter.hasNext();) {
IFeature element = (IFeature) iter.next();
@@ -920,7 +933,7 @@
/*
* get the list of enabled patches
*/
- private static Map getPatches(ArrayList allConfiguredFeatures) {
+ private static Map getPatchesAsFeature(ArrayList allConfiguredFeatures) {
// get all efixes and the associated patched features
Map patches = new HashMap();
if (allConfiguredFeatures != null) {
@@ -992,7 +1005,7 @@
* returns the feature that are not patches
*/
private static ArrayList getNonEfixFeatures(ArrayList topFeatures) {
- Map efixFeatures = getPatches(topFeatures);
+ Map efixFeatures = getPatchesAsFeature(topFeatures);
Set keySet = efixFeatures.keySet();
if (keySet == null || keySet.isEmpty())
return topFeatures;
@@ -1008,6 +1021,133 @@
return result;
}
+
+ /*
+ * get the map of enabled patches (as feature reference) or an empty map
+ */
+ private Map getPatchesAsFeatureReference(List listOfFeatureReferences) {
+ // get all efixes and the associated patched features
+ Map patches = new HashMap();
+ if (listOfFeatureReferences != null) {
+ Iterator iter = listOfFeatureReferences.iterator();
+ while (iter.hasNext()) {
+ List patchedFeaturesID = new ArrayList();
+ IFeatureReference element = (IFeatureReference) iter.next();
+ // add the patched feature identifiers
+ try {
+ IFeature feature = element.getFeature(null);
+ if (feature != null) {
+ IImport[] imports = feature.getImports();
+ for (int i = 0; i < imports.length; i++) {
+ if (imports[i].isPatch()) {
+ VersionedIdentifier id = imports[i].getVersionedIdentifier();
+ if (UpdateCore.DEBUG && UpdateCore.DEBUG_SHOW_RECONCILER)
+ UpdateCore.debug("Found patch " + element + " for feature identifier " + id);
+ patchedFeaturesID.add(id);
+ }
+ }
+ }
+
+ if (!patchedFeaturesID.isEmpty()) {
+ patches.put(element, patchedFeaturesID);
+ }
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ return patches;
+ }
+
+
+ /*
+ * Removes efixes from new found features if they do not patch an enable feature
+ * either from the found delta or from the file system
+ */
+ private void removeInvalidEfixes(IInstallConfiguration installConfig) {
+
+ // disable new found efixes if the feature is not in the list nor enabled features
+ // on the file system
+ Map newFoundEfixesAsReference = getPatchesAsFeatureReference(newFoundFeatures);
+
+ if (newFoundEfixesAsReference.size() > 0) {
+ // retrieve all enabled features on all the sites
+ ArrayList allEnabledFeatures = new ArrayList();
+ IConfiguredSite[] configSites = installConfig.getConfiguredSites();
+ for (int i = 0; i < configSites.length; i++) {
+ IFeatureReference[] references = configSites[i].getConfiguredFeatures();
+ for (int j = 0; j < references.length; j++) {
+ try {
+ allEnabledFeatures.add(references[j].getFeature(null));
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ // create a List of eFixes Features
+ List arrayOfNewFoundFeatures = new ArrayList();
+ for (Iterator iter = newFoundFeatures.iterator(); iter.hasNext();) {
+ IFeatureReference element = (IFeatureReference) iter.next();
+ try {
+ arrayOfNewFoundFeatures.add(element.getFeature(null));
+ } catch (CoreException e) {
+ }
+ }
+
+ // retrieve the efixes that patch enable features in delta and enabled features on the
+ // file system
+ List patchesForNewFoundFeatures = getFeatureReferencePatchesToEnable(newFoundEfixesAsReference, allEnabledFeatures);
+ List patchesForEnabledFeatures = getFeatureReferencePatchesToEnable(newFoundEfixesAsReference, arrayOfNewFoundFeatures);
+
+ // IMPORTANT: add efixes first so they will be processed first
+ newFoundFeatures.removeAll(newFoundEfixesAsReference.keySet());
+ newFoundFeatures.addAll(0,patchesForEnabledFeatures);
+ newFoundFeatures.addAll(0,patchesForNewFoundFeatures);
+ }
+ }
+
+ /*
+ * retruns the list of pathes-featureReference who patch enabled features
+ */
+ private List getFeatureReferencePatchesToEnable(Map efixes, List configuredFeatures) {
+
+ ArrayList enabledVersionedIdentifier = new ArrayList();
+ Iterator iter = configuredFeatures.iterator();
+ while (iter.hasNext()) {
+ IFeature element = (IFeature) iter.next();
+ enabledVersionedIdentifier.add(element.getVersionedIdentifier());
+ }
+
+ // loop through the patches
+ List result = new ArrayList();
+ iter = efixes.keySet().iterator();
+ while (iter.hasNext()) {
+ boolean toEnable = false;
+ IFeatureReference efixFeatureReference = (IFeatureReference) iter.next();
+ List patchedFeatures = (List) efixes.get(efixFeatureReference);
+ // loop through the 'patched features identifier' the for this patch
+ // see if it the patch patches at least one enable feature
+ Iterator patchedFeaturesIter = patchedFeatures.iterator();
+ while (patchedFeaturesIter.hasNext() && !toEnable) {
+ VersionedIdentifier patchedFeatureID = (VersionedIdentifier) patchedFeaturesIter.next();
+ if (enabledVersionedIdentifier.contains(patchedFeatureID)) {
+ toEnable = true;
+ }
+ }
+
+ if (!toEnable) {
+ if (UpdateCore.DEBUG && UpdateCore.DEBUG_SHOW_RECONCILER)
+ UpdateCore.debug("The Patch " + efixFeatureReference + " does not patch any enabled features: it will be disabled");
+ } else {
+ if (UpdateCore.DEBUG && UpdateCore.DEBUG_SHOW_RECONCILER)
+ UpdateCore.debug("The patch " + efixFeatureReference + " will be enabled.");
+
+ result.add(efixFeatureReference);
+ }
+ }
+ return result;
+ }
+
}
\ No newline at end of file