Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Kaegi2009-04-20 14:57:26 -0400
committerSimon Kaegi2009-04-20 14:57:26 -0400
commitdf8ab0e33e54a7de08ac3a7bbceaea7237e81324 (patch)
tree48bb28df6be141f5c6e897eb1778ab524cc91057 /bundles/org.eclipse.equinox.p2.touchpoint.eclipse
parent785bb3245ede5146d814198833cdd59a4a1672f5 (diff)
downloadrt.equinox.p2-df8ab0e33e54a7de08ac3a7bbceaea7237e81324.tar.gz
rt.equinox.p2-df8ab0e33e54a7de08ac3a7bbceaea7237e81324.tar.xz
rt.equinox.p2-df8ab0e33e54a7de08ac3a7bbceaea7237e81324.zip
Bug 272959 Validate profile after expanding partial IUs
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.touchpoint.eclipse')
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF3
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/DirectorUtil.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java62
3 files changed, 82 insertions, 2 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF
index d290e9ef5..5e59e1210 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF
@@ -15,12 +15,13 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.internal.provisional.p2.core,
org.eclipse.equinox.internal.provisional.p2.core.eventbus,
org.eclipse.equinox.internal.provisional.p2.core.location,
- org.eclipse.equinox.internal.provisional.p2.repository,
+ org.eclipse.equinox.internal.provisional.p2.director;resolution:=optional,
org.eclipse.equinox.internal.provisional.p2.engine,
org.eclipse.equinox.internal.provisional.p2.metadata,
org.eclipse.equinox.internal.provisional.p2.metadata.query,
org.eclipse.equinox.internal.provisional.p2.metadata.repository,
org.eclipse.equinox.internal.provisional.p2.query,
+ org.eclipse.equinox.internal.provisional.p2.repository,
org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository,
org.eclipse.equinox.internal.simpleconfigurator.manipulator,
org.eclipse.equinox.p2.publisher;resolution:=optional,
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/DirectorUtil.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/DirectorUtil.java
new file mode 100644
index 000000000..ffc4f3ba6
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/DirectorUtil.java
@@ -0,0 +1,19 @@
+package org.eclipse.equinox.internal.p2.touchpoint.eclipse;
+
+import java.net.URI;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
+import org.eclipse.equinox.internal.provisional.p2.director.IPlanner;
+import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
+import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
+import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext;
+
+public class DirectorUtil {
+
+ public static IStatus validateProfile(IProfile profile) {
+ ProfileChangeRequest pcr = new ProfileChangeRequest(profile);
+ ProvisioningContext ctx = new ProvisioningContext(new URI[0]);
+ IPlanner planner = (IPlanner) ServiceHelper.getService(Activator.getContext(), IPlanner.class.getName());
+ return planner.getProvisioningPlan(pcr, ctx, null).getStatus();
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java
index c88b29d9e..1db71d810 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java
@@ -32,10 +32,12 @@ public class EclipseTouchpoint extends Touchpoint {
public static final String PARM_INSTALL_FOLDER = "installFolder"; //$NON-NLS-1$
private static final String NATIVE_TOUCHPOINT_ID = "org.eclipse.equinox.p2.touchpoint.natives"; //$NON-NLS-1$
private static List NATIVE_ACTIONS = Arrays.asList(new String[] {"chmod", "ln", "mkdir", "rmdir"}); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
+ private static final String VALIDATE_PROFILE = "org.eclipse.equinox.internal.p2.touchpoint.eclipse.validateProfile"; //$NON-NLS-1$
private static Map manipulators = new WeakHashMap();
private static Map wrappers = new WeakHashMap();
private static Map sourceManipulators = new WeakHashMap();
+ private static Map preparedIUs = new WeakHashMap();
private static synchronized LazyManipulator getManipulator(IProfile profile) {
LazyManipulator manipulator = (LazyManipulator) manipulators.get(profile);
@@ -84,10 +86,42 @@ public class EclipseTouchpoint extends Touchpoint {
sourceManipulator.save();
}
+ private static synchronized IInstallableUnit getPreparedIU(IProfile profile, IInstallableUnit iu) {
+ Map preparedProfileIUs = (Map) preparedIUs.get(profile);
+ if (preparedProfileIUs == null)
+ return null;
+
+ return (IInstallableUnit) preparedProfileIUs.get(iu);
+ }
+
+ private static synchronized void savePreparedIU(IProfile profile, IInstallableUnit iu) {
+ Map preparedProfileIUs = (Map) preparedIUs.get(profile);
+ if (preparedProfileIUs == null) {
+ preparedProfileIUs = new HashMap();
+ preparedIUs.put(profile, preparedProfileIUs);
+ }
+ preparedProfileIUs.put(iu, iu);
+ }
+
+ private static synchronized boolean hasPreparedIUs(IProfile profile) {
+ return preparedIUs.get(profile) != null;
+ }
+
private static synchronized void clearProfileState(IProfile profile) {
manipulators.remove(profile);
wrappers.remove(profile);
sourceManipulators.remove(profile);
+ preparedIUs.remove(profile);
+ }
+
+ public IStatus prepare(IProfile profile) {
+ try {
+ if (hasPreparedIUs(profile))
+ return validateProfile(profile);
+ } catch (RuntimeException e) {
+ return Util.createError(Messages.error_saving_manipulator, e);
+ }
+ return Status.OK_STATUS;
}
public IStatus commit(IProfile profile) {
@@ -149,6 +183,10 @@ public class EclipseTouchpoint extends Touchpoint {
}
public IInstallableUnit prepareIU(IInstallableUnit iu, IProfile profile) {
+ IInstallableUnit preparedIU = getPreparedIU(profile, iu);
+ if (preparedIU != null)
+ return preparedIU;
+
Class c = null;
try {
c = Class.forName("org.eclipse.equinox.p2.publisher.eclipse.BundlesAction"); //$NON-NLS-1$
@@ -173,10 +211,32 @@ public class EclipseTouchpoint extends Touchpoint {
LogHelper.log(Util.createError(NLS.bind(Messages.artifact_file_not_found, artifactKey.toString())));
return null;
}
- return PublisherUtil.createBundleIU(artifactKey, bundleFile);
+ preparedIU = PublisherUtil.createBundleIU(artifactKey, bundleFile);
+ savePreparedIU(profile, preparedIU);
+ return preparedIU;
}
// should not occur
throw new IllegalStateException(Messages.unexpected_prepareiu_error);
}
+
+ private IStatus validateProfile(IProfile profile) {
+ // by default we validate
+ if (Boolean.FALSE.toString().equals(profile.getProperty(VALIDATE_PROFILE)))
+ return Status.OK_STATUS;
+
+ Class c = null;
+ try {
+ c = Class.forName("org.eclipse.equinox.internal.provisional.p2.director.IPlanner"); //$NON-NLS-1$
+ } catch (ClassNotFoundException e) {
+ //ignore and proceed without validation
+ return null;
+ }
+
+ if (c != null) {
+ return DirectorUtil.validateProfile(profile);
+ }
+
+ return null;
+ }
}

Back to the top