*** empty log message ***
diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SessionDelta.java b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SessionDelta.java
index 43ecfd7..53ec939 100644
--- a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SessionDelta.java
+++ b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SessionDelta.java
@@ -59,23 +59,27 @@
// find the configured site each feature belongs to
if (process == ENABLE) {
if (UpdateManagerPlugin.DEBUG && UpdateManagerPlugin.DEBUG_SHOW_CONFIGURATION)
- UpdateManagerPlugin.warn("ENABLE SESSION DELTA");
+ UpdateManagerPlugin.warn("ENABLE SESSION DELTA");
if (featureReferences != null && featureReferences.size() > 0) {
- // manage ProgressMonitor
- if (pm != null) {
- int nbFeatures = featureReferences.size();
- pm.beginTask(Policy.bind("SessionDelta.EnableFeatures"), nbFeatures);
- }
// since 2.0.2 ISite.getConfiguredSite()
// find the configuredSite that maintains this featureReference
// configure the feature
- Iterator iterator = featureReferences.iterator();
+
+ // remove duplicate and any efixes that should not be enabled
+ List featureReferencesToEnable = processDuplicate(featureReferences);
+
+ // manage ProgressMonitor
+ if (pm != null) {
+ int nbFeatures = featureReferencesToEnable.size();
+ pm.beginTask(Policy.bind("SessionDelta.EnableFeatures"), nbFeatures);
+ }
+
IFeatureReference ref = null;
IConfiguredSite configSite = null;
IFeature featureToConfigure = null;
- while (iterator.hasNext()) {
- ref = (IFeatureReference) iterator.next();
-
+ for (Iterator iter = featureReferencesToEnable.iterator(); iter.hasNext();) {
+ ref = (IFeatureReference) iter.next();
+
try {
featureToConfigure = ref.getFeature();
} catch (CoreException e) {
@@ -85,11 +89,11 @@
if (featureToConfigure != null) {
if (pm != null)
pm.worked(1);
-
+
configSite = ref.getSite().getCurrentConfiguredSite();
try {
// make sure only the latest version of the configured features
- // is configured across sites [16502]
+ // is configured across sites [16502]
if (enable(featureToConfigure)) {
configSite.configure(featureToConfigure);
} else {
@@ -101,9 +105,8 @@
UpdateManagerPlugin.warn("Unable to configure feature:" + featureToConfigure, e);
}
} else {
- UpdateManagerPlugin.warn("Unable to configure null feature:" + ref,null);
+ UpdateManagerPlugin.warn("Unable to configure null feature:" + ref, null);
}
-
}
}
}
@@ -263,4 +266,140 @@
return 0;
};
+ /*
+ * Method processDuplicate.
+ * @param featureReferences
+ * @return List of features to enable of empty list
+ */
+ private List processDuplicate(List featureReferencesToProcess) {
+
+ // eliminate duplicate versions (keep latest)
+ IFeatureReference[] list = (IFeatureReference[]) featureReferencesToProcess.toArray(new IFeatureReference[0]);
+ boolean foundDuplicate = false;
+ for (int i = 0; i < list.length - 1; i++) {
+ IFeatureReference left = list[i];
+ try {
+ VersionedIdentifier leftVid = left.getVersionedIdentifier();
+ for (int j = i + 1; j < list.length; j++) {
+ IFeatureReference right = list[j];
+ try {
+ VersionedIdentifier rightVid = right.getVersionedIdentifier();
+ if (leftVid.getIdentifier().equals(rightVid.getIdentifier())) {
+ // duplicate versions ... keep latest
+ IFeatureReference oldest = null;
+ // bug 31940. If right>left remove left ELSE REMOVE RIGHT
+ if (rightVid.getVersion().isGreaterOrEqualTo(leftVid.getVersion()))
+ oldest = left;
+ else
+ oldest = right;
+ featureReferencesToProcess.remove(oldest);
+ // debug
+ if (UpdateManagerPlugin.DEBUG && UpdateManagerPlugin.DEBUG_SHOW_RECONCILER) {
+ UpdateManagerPlugin.debug("Removing \"duplicate\" during delta processing" + oldest.getVersionedIdentifier().toString());
+ }
+ foundDuplicate = true;
+ }
+ } catch (CoreException e) {
+ };
+ }
+ } catch (CoreException e1) {
+ };
+ }
+
+ // duplicate found, remove any efixes of the removed duplicate
+ if (foundDuplicate) {
+ ArrayList result = new ArrayList();
+ Map patches = getPatchesAsFeatureReference(featureReferencesToProcess);
+ if (!patches.isEmpty()){
+ List patchesToEnable = getFeatureReferencePatchesToEnable(patches,featureReferencesToProcess);
+ featureReferencesToProcess.removeAll(patches.keySet());
+ // add efixes first so they will be processed first and may be disabled
+ result.addAll(patchesToEnable);
+ result.addAll(featureReferencesToProcess);
+ return result;
+ }
+ }
+ return featureReferencesToProcess;
+ }
+
+ /*
+ * 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();
+ 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 (UpdateManagerPlugin.DEBUG && UpdateManagerPlugin.DEBUG_SHOW_RECONCILER)
+ UpdateManagerPlugin.debug("Found patch " + element + " for feature identifier " + id);
+ patchedFeaturesID.add(id);
+ }
+ }
+ }
+
+ if (!patchedFeaturesID.isEmpty()) {
+ patches.put(element, patchedFeaturesID);
+ }
+ } catch (CoreException e) {
+ }
+ }
+ }
+ return patches;
+ }
+
+ /*
+ * retruns the list of pathes-featureReference who patch enabled features
+ */
+ private List getFeatureReferencePatchesToEnable(Map efixes, List configuredFeatureReferences) {
+
+ ArrayList enabledVersionedIdentifier = new ArrayList();
+ Iterator iter = configuredFeatureReferences.iterator();
+ while (iter.hasNext()) {
+ IFeatureReference element = (IFeatureReference) iter.next();
+ try {
+ enabledVersionedIdentifier.add(element.getVersionedIdentifier());
+ } catch (CoreException e){};
+ }
+
+ // 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 (UpdateManagerPlugin.DEBUG && UpdateManagerPlugin.DEBUG_SHOW_RECONCILER)
+ UpdateManagerPlugin.debug("The Patch " + efixFeatureReference + " does not patch any enabled features: it will be disabled");
+ } else {
+ if (UpdateManagerPlugin.DEBUG && UpdateManagerPlugin.DEBUG_SHOW_RECONCILER)
+ UpdateManagerPlugin.debug("The patch " + efixFeatureReference + " will be enabled.");
+
+ result.add(efixFeatureReference);
+ }
+ }
+ return result;
+ }
+
}
\ No newline at end of file
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 4df5bb6..80a18af 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);
}
/**
@@ -483,20 +483,28 @@
/*
*
*/
- private boolean saveNewFeatures() throws CoreException {
+ private boolean saveNewFeatures(IInstallConfiguration installConfig) throws CoreException {
if (getFeatureReferences().length == 0) {
UpdateManagerPlugin.warn("No new features found");
return false;
}
+ if (UpdateManagerPlugin.DEBUG && UpdateManagerPlugin.DEBUG_SHOW_RECONCILER) {
+ UpdateManagerPlugin.debug("Processing new found features during reconciliation");
+ }
// recompute list of new features to only keep root features [16496]
IFeatureReference[] refs = getFeatureReferences();
newFoundFeatures = new ArrayList();
for (int i = 0; i < refs.length; i++) {
IFeatureReference[] parents = UpdateManagerUtils.getParentFeatures(refs[i], refs, false);
- if (parents.length == 0)
+ if (parents.length == 0) {
newFoundFeatures.add(refs[i]);
+ // debug
+ if (UpdateManagerPlugin.DEBUG && UpdateManagerPlugin.DEBUG_SHOW_RECONCILER) {
+ UpdateManagerPlugin.debug("Adding new found feature reference:" + refs[i]);
+ }
+ }
}
if (getFeatureReferences().length == 0) {
@@ -504,6 +512,14 @@
return false;
}
+ // remove efixes from the delta that patch disabled feature from the installConfig
+ removeInvalidEfixes(installConfig);
+
+ if (getFeatureReferences().length == 0) {
+ UpdateManagerPlugin.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 = UpdateManagerPlugin.getPlugin().getStateLocation();
@@ -691,7 +707,7 @@
// retrieve efixes that patch enable feature
// they must be kept enabled
if (topFeatures.size() != topNonEfixFeatures.size()) {
- Map patches = getPatches(allPossibleConfiguredFeatures);
+ Map patches = getPatchesAsFeature(allPossibleConfiguredFeatures);
if (!patches.isEmpty()) {
// calculate efixes to enable
List efixesToEnable = getPatchesToEnable(patches, configuredFeatures);
@@ -919,11 +935,11 @@
/*
* get the list of enabled patches
*/
- private static Map getPatches(ArrayList allConfiguredFeatures) {
+ private static Map getPatchesAsFeature(List listOfFeatures) {
// get all efixes and the associated patched features
Map patches = new HashMap();
- if (allConfiguredFeatures != null) {
- Iterator iter = allConfiguredFeatures.iterator();
+ if (listOfFeatures != null) {
+ Iterator iter = listOfFeatures.iterator();
while (iter.hasNext()) {
List patchedFeaturesID = new ArrayList();
IFeature element = (IFeature) iter.next();
@@ -947,9 +963,46 @@
}
/*
+ * 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();
+ 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 (UpdateManagerPlugin.DEBUG && UpdateManagerPlugin.DEBUG_SHOW_RECONCILER)
+ UpdateManagerPlugin.debug("Found patch " + element + " for feature identifier " + id);
+ patchedFeaturesID.add(id);
+ }
+ }
+ }
+
+ if (!patchedFeaturesID.isEmpty()) {
+ patches.put(element, patchedFeaturesID);
+ }
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ return patches;
+ }
+
+ /*
* retruns the list of pathes-feature who patch enabled features
*/
- private static List getPatchesToEnable(Map efixes, ArrayList configuredFeatures) {
+ private static List getPatchesToEnable(Map efixes, List configuredFeatures) {
ArrayList enabledVersionedIdentifier = new ArrayList();
Iterator iter = configuredFeatures.iterator();
@@ -992,7 +1045,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,4 +1061,89 @@
return result;
}
+ /*
+ * 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
+ 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());
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ List arrayOfNewFoundFeatures = new ArrayList();
+ for (Iterator iter = newFoundFeatures.iterator(); iter.hasNext();) {
+ IFeatureReference element = (IFeatureReference) iter.next();
+ try {
+ arrayOfNewFoundFeatures.add(element.getFeature());
+ } catch (CoreException e) {
+ }
+ }
+
+ List patchesForNewFoundFeatures = getFeatureReferencePatchesToEnable(newFoundEfixesAsReference, allEnabledFeatures);
+ List patchesForEnabledFeatures = getFeatureReferencePatchesToEnable(newFoundEfixesAsReference, arrayOfNewFoundFeatures);
+
+ // 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 (UpdateManagerPlugin.DEBUG && UpdateManagerPlugin.DEBUG_SHOW_RECONCILER)
+ UpdateManagerPlugin.debug("The Patch " + efixFeatureReference + " does not patch any enabled features: it will be disabled");
+ } else {
+ if (UpdateManagerPlugin.DEBUG && UpdateManagerPlugin.DEBUG_SHOW_RECONCILER)
+ UpdateManagerPlugin.debug("The patch " + efixFeatureReference + " will be enabled.");
+
+ result.add(efixFeatureReference);
+ }
+ }
+ return result;
+ }
+
}
\ No newline at end of file