summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault (Ericsson)2013-02-05 15:24:47 (EST)
committerPascal Rapicault2013-02-05 15:24:47 (EST)
commitdaacdc430d00d136bc1eec1706275a07b8cc46be (patch)
treeeeb56f327fb8e405e7808a11db73026adcf52a2f
parentcf85b76d32aec28219087b85fb3b6d41ae928023 (diff)
downloadrt.equinox.p2-daacdc430d00d136bc1eec1706275a07b8cc46be.zip
rt.equinox.p2-daacdc430d00d136bc1eec1706275a07b8cc46be.tar.gz
rt.equinox.p2-daacdc430d00d136bc1eec1706275a07b8cc46be.tar.bz2
Bug 400011 - [shared][engine] Cleanup the SurrogateProfileHandler code
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ISurrogateProfileHandler.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java48
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java39
4 files changed, 5 insertions, 93 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ISurrogateProfileHandler.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ISurrogateProfileHandler.java
index 36eaee3..b51ecf9 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ISurrogateProfileHandler.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ISurrogateProfileHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * Copyright (c) 2008, 2013 IBM Corporation 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
@@ -7,12 +7,12 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Ericsson AB - Bug 400011 - [shared] Cleanup the SurrogateProfileHandler code
*******************************************************************************/
package org.eclipse.equinox.internal.p2.engine;
-import org.eclipse.equinox.p2.engine.IProfile;
-
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
@@ -28,6 +28,4 @@ public interface ISurrogateProfileHandler {
public abstract IQueryResult<IInstallableUnit> queryProfile(IProfile profile, IQuery<IInstallableUnit> query, IProgressMonitor monitor);
- public abstract boolean updateProfile(IProfile selfProfile);
-
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java
index bc83ea9..e99a0f2 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2013 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Ericsson AB - Bug 400011 - [shared] Cleanup the SurrogateProfileHandler code
*******************************************************************************/
package org.eclipse.equinox.internal.p2.engine;
@@ -20,8 +21,6 @@ import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.IProfile;
-import org.eclipse.equinox.p2.engine.query.IUProfilePropertyQuery;
-import org.eclipse.equinox.p2.engine.query.UserVisibleRootQuery;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
@@ -38,10 +37,7 @@ public class SurrogateProfileHandler implements ISurrogateProfileHandler {
private static final String ECLIPSE_INI_IGNORED = "eclipse.ini.ignored"; //$NON-NLS-1$
private static final String IU_LOCKED = Integer.toString(IProfile.LOCK_UNINSTALL | IProfile.LOCK_UPDATE);
private static final String PROP_SURROGATE = "org.eclipse.equinox.p2.surrogate"; //$NON-NLS-1$
- private static final String PROP_SHARED_TIMESTAMP = "org.eclipse.equinox.p2.shared.timestamp"; //$NON-NLS-1$
private static final String PROP_BASE = "org.eclipse.equinox.p2.base"; //$NON-NLS-1$
- private static final String PROP_RESOLVE = "org.eclipse.equinox.p2.resolve"; //$NON-NLS-1$
- private static final String OPTIONAL = "OPTIONAL"; //$NON-NLS-1$
private static final String STRICT = "STRICT"; //$NON-NLS-1$
private static final String PROP_INCLUSION_RULES = "org.eclipse.equinox.p2.internal.inclusion.rules"; //$NON-NLS-1$
@@ -94,25 +90,7 @@ public class SurrogateProfileHandler implements ISurrogateProfileHandler {
return sharedProfileIU;
}
- private static void removeUserProfileBaseIUs(final Profile userProfile) {
- IQuery<IInstallableUnit> baseIUQuery = new IUProfilePropertyQuery(PROP_BASE, Boolean.TRUE.toString());
- IQueryResult<IInstallableUnit> rootIUs = userProfile.query(baseIUQuery, null);
- for (Iterator<IInstallableUnit> iterator = rootIUs.iterator(); iterator.hasNext();) {
- IInstallableUnit iu = iterator.next();
- userProfile.removeInstallableUnit(iu);
- }
- }
-
- private static void markRootsOptional(final Profile userProfile) {
- IQueryResult<IInstallableUnit> rootIUs = userProfile.query(new UserVisibleRootQuery(), null);
- for (Iterator<IInstallableUnit> iterator = rootIUs.iterator(); iterator.hasNext();) {
- IInstallableUnit iu = iterator.next();
- userProfile.setInstallableUnitProperty(iu, PROP_INCLUSION_RULES, OPTIONAL);
- }
- }
-
private static void updateProperties(final IProfile sharedProfile, Profile userProfile) {
- userProfile.setProperty(PROP_SHARED_TIMESTAMP, Long.toString(sharedProfile.getTimestamp()));
Location installLocation = (Location) ServiceHelper.getService(EngineActivator.getContext(), Location.class.getName(), Location.INSTALL_FILTER);
File installFolder = new File(installLocation.getURL().getPath());
@@ -221,26 +199,4 @@ public class SurrogateProfileHandler implements ISurrogateProfileHandler {
result.addAll(profile.query(query, monitor));
return result;
}
-
- public boolean updateProfile(IProfile userProfile) {
- final IProfile sharedProfile = getSharedProfile(userProfile.getProfileId());
- if (sharedProfile == null)
- throw new IllegalStateException(NLS.bind(Messages.shared_profile_not_found, userProfile.getProfileId()));
-
- String sharedTimeStamp = Long.toString(sharedProfile.getTimestamp());
- String userSharedTimeStamp = userProfile.getProperty(PROP_SHARED_TIMESTAMP);
-
- if (userSharedTimeStamp != null && userSharedTimeStamp.equals(sharedTimeStamp))
- return false;
-
- Profile writableUserProfile = (Profile) userProfile;
- updateProperties(sharedProfile, writableUserProfile);
- removeUserProfileBaseIUs(writableUserProfile);
- if (!userProfile.query(QueryUtil.createIUAnyQuery(), null).isEmpty()) {
- writableUserProfile.setProperty(PROP_RESOLVE, Boolean.TRUE.toString());
- markRootsOptional(writableUserProfile);
- }
- addSharedProfileBaseIUs(sharedProfile, writableUserProfile);
- return true;
- }
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java
index c587304..fae0e54 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java
@@ -142,9 +142,6 @@ public class ProfileTest extends AbstractProvisioningTest {
return new Collector();
}
- public boolean updateProfile(IProfile selfProfile) {
- return false;
- }
});
assertTrue(profile.available(QueryUtil.createIUAnyQuery(), null).isEmpty());
assertTrue(profile.snapshot().available(QueryUtil.createIUAnyQuery(), null).isEmpty());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java
index fa09468..e546302 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java
@@ -22,8 +22,6 @@ import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class SurrogateProfileHandlerTest extends AbstractProvisioningTest {
private static final String PROFILE_NAME = "profile.SurrogateProfileHandlerTest";
- private static final String PROP_TYPE_ROOT = "org.eclipse.equinox.p2.type.root"; //$NON-NLS-1$
- private static final String PROP_SHARED_TIMESTAMP = "org.eclipse.equinox.p2.shared.timestamp"; //$NON-NLS-1$
public static Test suite() {
return new TestSuite(SurrogateProfileHandlerTest.class);
@@ -85,41 +83,4 @@ public class SurrogateProfileHandlerTest extends AbstractProvisioningTest {
assertEquals(1, queryResultSize(surrogateProfile.query(QueryUtil.createIUAnyQuery(), null)));
assertEquals(2, queryResultSize(surrogateProfile.available(QueryUtil.createIUAnyQuery(), null)));
}
-
- public void testUpdateProfile() throws ProvisionException {
- Profile profile = (Profile) registry.addProfile(PROFILE_NAME);
- profile.addInstallableUnit(createIU("test"));
- profile.setInstallableUnitProperty(createIU("test"), PROP_TYPE_ROOT, Boolean.TRUE.toString());
- saveProfile(registry, profile);
- IProfile surrogateProfile = handler.createProfile(PROFILE_NAME);
- assertEquals(2, queryResultSize(surrogateProfile.query(QueryUtil.createIUAnyQuery(), null)));
- // HashSet used here to eliminate duplicates
- assertEquals(2, queryResultUniqueSize(surrogateProfile.available(QueryUtil.createIUAnyQuery(), null)));
- handler.updateProfile(surrogateProfile);
- assertEquals(2, queryResultSize(surrogateProfile.query(QueryUtil.createIUAnyQuery(), null)));
- // HashSet used here to eliminate duplicates
- assertEquals(2, queryResultUniqueSize(surrogateProfile.available(QueryUtil.createIUAnyQuery(), null)));
-
- Profile writeableSurrogateProfile = (Profile) surrogateProfile;
-
- writeableSurrogateProfile.addInstallableUnit(createIU("surrogate.test"));
- writeableSurrogateProfile.setInstallableUnitProperty(createIU("surrogate.test"), PROP_TYPE_ROOT, Boolean.TRUE.toString());
- assertEquals(3, queryResultSize(surrogateProfile.query(QueryUtil.createIUAnyQuery(), null)));
- // HashSet used here to eliminate duplicates
- assertEquals(3, queryResultUniqueSize(surrogateProfile.available(QueryUtil.createIUAnyQuery(), null)));
-
- profile.addInstallableUnit(createIU("test2"));
- profile.setInstallableUnitProperty(createIU("test2"), PROP_TYPE_ROOT, Boolean.TRUE.toString());
- saveProfile(registry, profile);
- assertEquals(3, queryResultSize(surrogateProfile.query(QueryUtil.createIUAnyQuery(), null)));
- // HashSet used here to eliminate duplicates
- assertEquals(4, queryResultUniqueSize(surrogateProfile.available(QueryUtil.createIUAnyQuery(), null)));
-
- //Strictly speaking this should not be necessary however without resetting the timestamp this test will sometimes fail
- writeableSurrogateProfile.setProperty(PROP_SHARED_TIMESTAMP, null);
- handler.updateProfile(surrogateProfile);
- assertEquals(4, queryResultSize(surrogateProfile.query(QueryUtil.createIUAnyQuery(), null)));
- // HashSet used here to eliminate duplicates
- assertEquals(4, queryResultUniqueSize(surrogateProfile.available(QueryUtil.createIUAnyQuery(), null)));
- }
}