Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHamdan Msheik2014-04-07 11:35:34 -0400
committerPascal Rapicault2014-04-11 13:43:16 -0400
commitbcf9be8266fab291a114a4ebaa08eb709dd3c14c (patch)
treedb3efbc8beeec92b3f3c9166ee5a50a5698f76ca
parent0e15247b949b50972dc0fc5b9892a1c0a4cf1820 (diff)
downloadrt.equinox.p2-bcf9be8266fab291a114a4ebaa08eb709dd3c14c.tar.gz
rt.equinox.p2-bcf9be8266fab291a114a4ebaa08eb709dd3c14c.tar.xz
rt.equinox.p2-bcf9be8266fab291a114a4ebaa08eb709dd3c14c.zip
Fix - Bug 432167. Prevents migration wizard from
importing plug-ins of a succeeding eclipse version. Change-Id: Ifcfcdf596c41559249971895e795e69682523c87 Signed-off-by: Hamdan Msheik <hamdan.msheik@ericsson.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/PreviousConfigurationFinderTest.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithDifferentPlatfrom/org.eclipse.platform_3.8.0_11111111_linux-gtk-x86_64/empty.txt0
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithDifferentPlatfrom/org.eclipse.platform_4.3.1_11111111_win32_win32_x86/empty.txt0
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithDifferentPlatfrom/org.eclipse.platform_4.4.0_11111111_win32_win32_x86/empty.txt0
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithNullPlatfrom/org.eclipse.platform_3.8.0_1213/empty.txt0
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithNullPlatfrom/org.eclipse.platform_4.3.1_11111111_win32_win32_x86/empty.txt0
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithNullPlatfrom/org.eclipse.platform_4.4.0_11111111_win32_win32_x86/empty.txt0
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/noMatch/org.eclipse.platform_4.3.1_11111111_win32_win32_x86/empty.txt0
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/noMatch/org.eclipse.platform_4.4.0_11111111_win32_win32_x86/empty.txt0
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreviousConfigurationFinder.java98
10 files changed, 98 insertions, 26 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/PreviousConfigurationFinderTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/PreviousConfigurationFinderTest.java
index 1d3c18327..989775f5f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/PreviousConfigurationFinderTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/PreviousConfigurationFinderTest.java
@@ -106,4 +106,30 @@ public class PreviousConfigurationFinderTest extends AbstractProvisioningTest {
assertNull(match.getPlatformConfig());
}
+
+ public void testNoMatchFromSucceedingVersion() throws Exception {
+ File configFolder = getTestData("sameProduct", "testData/previousConfigurationFinder/testSuccedingVersion/noMatch");
+ List<ConfigurationDescriptor> configs = new PreviousConfigurationFinder(configFolder).readPreviousConfigurations(configFolder);
+ ConfigurationDescriptor match = new PreviousConfigurationFinder(configFolder).findMostRelevantConfigurationFromProductId(configs, referenceConfiguration);
+ assertNull(match);
+ }
+
+ public void testMatchFromPreceedingVersionWithDifferentPaltform() throws Exception {
+ File configFolder = getTestData("sameProduct", "testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithDifferentPlatfrom");
+ List<ConfigurationDescriptor> configs = new PreviousConfigurationFinder(configFolder).readPreviousConfigurations(configFolder);
+ ConfigurationDescriptor match = new PreviousConfigurationFinder(configFolder).findMostRelevantConfigurationFromProductId(configs, referenceConfiguration);
+ assertNotNull(match);
+ assertEquals(new Identifier(3, 8, 0), match.getVersion());
+ assertEquals("linux-gtk-x86_64", match.getPlatformConfig());
+ }
+
+ public void testMatchFromPreceedingVersionWithNullPaltform() throws Exception {
+ File configFolder = getTestData("sameProduct", "testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithNullPlatfrom");
+ List<ConfigurationDescriptor> configs = new PreviousConfigurationFinder(configFolder).readPreviousConfigurations(configFolder);
+ ConfigurationDescriptor match = new PreviousConfigurationFinder(configFolder).findMostRelevantConfigurationFromProductId(configs, referenceConfiguration);
+ assertNotNull(match);
+ assertEquals(new Identifier(3, 8, 0), match.getVersion());
+ assertNull(match.getPlatformConfig());
+ }
+
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithDifferentPlatfrom/org.eclipse.platform_3.8.0_11111111_linux-gtk-x86_64/empty.txt b/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithDifferentPlatfrom/org.eclipse.platform_3.8.0_11111111_linux-gtk-x86_64/empty.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithDifferentPlatfrom/org.eclipse.platform_3.8.0_11111111_linux-gtk-x86_64/empty.txt
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithDifferentPlatfrom/org.eclipse.platform_4.3.1_11111111_win32_win32_x86/empty.txt b/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithDifferentPlatfrom/org.eclipse.platform_4.3.1_11111111_win32_win32_x86/empty.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithDifferentPlatfrom/org.eclipse.platform_4.3.1_11111111_win32_win32_x86/empty.txt
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithDifferentPlatfrom/org.eclipse.platform_4.4.0_11111111_win32_win32_x86/empty.txt b/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithDifferentPlatfrom/org.eclipse.platform_4.4.0_11111111_win32_win32_x86/empty.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithDifferentPlatfrom/org.eclipse.platform_4.4.0_11111111_win32_win32_x86/empty.txt
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithNullPlatfrom/org.eclipse.platform_3.8.0_1213/empty.txt b/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithNullPlatfrom/org.eclipse.platform_3.8.0_1213/empty.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithNullPlatfrom/org.eclipse.platform_3.8.0_1213/empty.txt
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithNullPlatfrom/org.eclipse.platform_4.3.1_11111111_win32_win32_x86/empty.txt b/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithNullPlatfrom/org.eclipse.platform_4.3.1_11111111_win32_win32_x86/empty.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithNullPlatfrom/org.eclipse.platform_4.3.1_11111111_win32_win32_x86/empty.txt
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithNullPlatfrom/org.eclipse.platform_4.4.0_11111111_win32_win32_x86/empty.txt b/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithNullPlatfrom/org.eclipse.platform_4.4.0_11111111_win32_win32_x86/empty.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/matchFromSuccedingAndPreccedingWithNullPlatfrom/org.eclipse.platform_4.4.0_11111111_win32_win32_x86/empty.txt
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/noMatch/org.eclipse.platform_4.3.1_11111111_win32_win32_x86/empty.txt b/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/noMatch/org.eclipse.platform_4.3.1_11111111_win32_win32_x86/empty.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/noMatch/org.eclipse.platform_4.3.1_11111111_win32_win32_x86/empty.txt
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/noMatch/org.eclipse.platform_4.4.0_11111111_win32_win32_x86/empty.txt b/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/noMatch/org.eclipse.platform_4.4.0_11111111_win32_win32_x86/empty.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/previousConfigurationFinder/testSuccedingVersion/noMatch/org.eclipse.platform_4.4.0_11111111_win32_win32_x86/empty.txt
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreviousConfigurationFinder.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreviousConfigurationFinder.java
index 4bef663f8..325568f76 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreviousConfigurationFinder.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreviousConfigurationFinder.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Ericsson AB - initial API and implementation
+ * Ericsson AB (Hamdan Msheik) - bug- 432167
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.sdk.scheduler;
@@ -22,7 +23,7 @@ public class PreviousConfigurationFinder {
private static final Pattern path = Pattern.compile("(.+?)_{1}?([0-9\\.]+)_{1}?(\\d+)(_*?([^_].*)|$)"); //$NON-NLS-1$
- public static class Identifier {
+ public static class Identifier implements Comparable<Identifier> {
private static final String DELIM = ". _-"; //$NON-NLS-1$
private int major, minor, service;
@@ -95,6 +96,29 @@ public class PreviousConfigurationFinder {
public String toString() {
return "" + major + '.' + minor + '.' + service; //$NON-NLS-1$
}
+
+ public int compareTo(Identifier o) {
+
+ if (o != null) {
+ if (major < o.major) {
+ return -1;
+ } else if (major > o.major) {
+ return 1;
+ } else if (minor < o.minor) {
+ return -1;
+ } else if (minor > o.minor) {
+ return 1;
+ } else if (service < o.service) {
+ return -1;
+ } else if (service > o.service) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
+ return 1;
+ }
}
public static class ConfigurationDescriptor {
@@ -133,6 +157,32 @@ public class PreviousConfigurationFinder {
}
}
+ public static class ConfigurationDescriptorComparator implements Comparator<ConfigurationDescriptor> {
+
+ // compare ConfigurationDescriptor according to their versions and when equals according to their lastModified field
+ public int compare(ConfigurationDescriptor o1, ConfigurationDescriptor o2) {
+ int result = -1;
+ if (o1 != null && o2 != null) {
+ if (o1.getVersion().compareTo(o2.getVersion()) != 0) {
+ result = o1.getVersion().compareTo(o2.getVersion());
+ } else {
+ if (o1.getConfig().lastModified() > o2.getConfig().lastModified()) {
+ result = 1;
+ } else if (o1.getConfig().lastModified() < o2.getConfig().lastModified()) {
+ result = -1;
+ } else
+ result = 0;
+ }
+ } else if (o1 == null) {
+ result = -1;
+ } else if (o2 == null) {
+ result = 1;
+ }
+ return result;
+ }
+
+ }
+
private File currentConfig;
public PreviousConfigurationFinder(File currentConfiguration) {
@@ -180,7 +230,7 @@ public class PreviousConfigurationFinder {
}
});
if (match.length != 0)
- return new ConfigurationDescriptor("unknown", new Identifier("0.0.0"), "unknown", "unknown", match[0]); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
+ return new ConfigurationDescriptor("unknown", new Identifier("0.0.0"), "unknown", "unknown", match[0]); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
}
return null;
}
@@ -232,35 +282,31 @@ public class PreviousConfigurationFinder {
//Out of a set of configuration, find the one with the most similar product info.
public ConfigurationDescriptor findMostRelevantConfigurationFromProductId(List<ConfigurationDescriptor> configurations, ConfigurationDescriptor configToMatch) {
ConfigurationDescriptor bestMatch = null;
- int numberOfcriteriaMet = 0;
+
+ List<ConfigurationDescriptor> candidates = new ArrayList<ConfigurationDescriptor>();
+ List<ConfigurationDescriptor> candidatesWithUnkonwArchitecture = new ArrayList<ConfigurationDescriptor>();
for (ConfigurationDescriptor candidate : configurations) {
- int criteriaMet = 0;
- if (!configToMatch.getProductId().equals(candidate.getProductId()))
- continue;
+ if (configToMatch.getProductId().equals(candidate.getProductId()) && configToMatch.getVersion().isGreaterEqualTo(candidate.getVersion())) {
+ if (configToMatch.getPlatformConfig().equals(candidate.getPlatformConfig())) {
+ candidates.add(candidate);
+ } else { //candidate.getPlatformConfig() returns null in legacy installation prior to 4.x.x releases
+ candidatesWithUnkonwArchitecture.add(candidate);
+ }
+ }
+ }
- if (configToMatch.getPlatformConfig().equals(candidate.getPlatformConfig()))
- criteriaMet++;
+ if (!candidates.isEmpty()) {
+ Collections.sort(candidates, new ConfigurationDescriptorComparator());
+ bestMatch = candidates.get(candidates.size() - 1);
+ }
- if (configToMatch.getVersion().isGreaterEqualTo(candidate.getVersion())) {
- //We have a match
- criteriaMet++;
- }
- if (criteriaMet == 0)
- continue;
- if (criteriaMet > numberOfcriteriaMet) {
- bestMatch = candidate;
- numberOfcriteriaMet = criteriaMet;
- } else if (criteriaMet == numberOfcriteriaMet) {
- if (bestMatch.getVersion().equals(candidate.getVersion())) {
- if (bestMatch.getConfig().lastModified() < candidate.getConfig().lastModified()) {
- bestMatch = candidate;
- }
- } else {
- if (candidate.getVersion().isGreaterEqualTo(bestMatch.getVersion()))
- bestMatch = candidate;
- }
+ if (bestMatch == null) {
+ if (!candidatesWithUnkonwArchitecture.isEmpty()) {
+ Collections.sort(candidatesWithUnkonwArchitecture, new ConfigurationDescriptorComparator());
+ bestMatch = candidatesWithUnkonwArchitecture.get(candidatesWithUnkonwArchitecture.size() - 1);
}
}
+
return bestMatch;
}

Back to the top