Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodor Boev2017-05-05 14:16:44 +0000
committerAlexander Kurtakov2017-08-22 11:19:28 +0000
commit26f5272312c172e0c957f4bbdb4adff894490e2f (patch)
treecb7db49e5e9292c938cb4b1d3c05583a94a8ab1d
parent7b36283c02a7eb00fdd874dc6e6216f4036caa4c (diff)
downloadrt.equinox.p2-26f5272312c172e0c957f4bbdb4adff894490e2f.tar.gz
rt.equinox.p2-26f5272312c172e0c957f4bbdb4adff894490e2f.tar.xz
rt.equinox.p2-26f5272312c172e0c957f4bbdb4adff894490e2f.zip
Bug 486279 - Refactored SetStarLevelActionI20170822-2000
Refactored SetStarLevelAction to relay on Util.findBundleInfo() to find the entry in bundles.info, rather than to try to re-construct the BundleInfo from other data and use Object.equals() Change-Id: Ifc6e2e0378105630acb03089ab41ed23481158a8 Signed-off-by: Todor Boev <rinsvind@gmail.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetStartLevelAction.java71
1 files changed, 20 insertions, 51 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetStartLevelAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetStartLevelAction.java
index ea9b24a36..e575e954c 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetStartLevelAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetStartLevelAction.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions;
-import java.io.File;
-import java.util.Collection;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -19,10 +17,7 @@ import org.eclipse.equinox.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
-import org.eclipse.equinox.p2.core.IProvisioningAgent;
-import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
-import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.osgi.util.NLS;
@@ -30,73 +25,47 @@ public class SetStartLevelAction extends ProvisioningAction {
public static final String ID = "setStartLevel"; //$NON-NLS-1$
public IStatus execute(Map<String, Object> parameters) {
- IProvisioningAgent agent = (IProvisioningAgent) parameters.get(ActionConstants.PARM_AGENT);
- IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE);
Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU);
String startLevel = (String) parameters.get(ActionConstants.PARM_START_LEVEL);
- if (startLevel == null)
+ if (startLevel == null) {
return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_START_LEVEL, ID));
+ }
- Collection<IArtifactKey> artifacts = iu.getArtifacts();
- if (artifacts == null || artifacts.isEmpty())
- return Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu));
-
- IArtifactKey artifactKey = artifacts.iterator().next();
- // the bundleFile might be null here, that's OK.
- File bundleFile = Util.getArtifactFile(agent, artifactKey, profile);
-
- BundleInfo bundleInfo = Util.createBundleInfo(bundleFile, iu);
+ // Changes to this object will be reflected in the backing runtime configuration store
+ BundleInfo bundleInfo = Util.findBundleInfo(manipulator.getConfigData(), iu);
if (bundleInfo == null)
return Util.createError(NLS.bind(Messages.failed_bundleinfo, iu));
- if (bundleInfo.getFragmentHost() != null)
+ // Bundle fragments are not started
+ if (bundleInfo.getFragmentHost() != null) {
return Status.OK_STATUS;
+ }
- BundleInfo[] bundles = manipulator.getConfigData().getBundles();
- for (int i = 0; i < bundles.length; i++) {
- if (bundles[i].equals(bundleInfo)) {
- getMemento().put(ActionConstants.PARM_PREVIOUS_START_LEVEL, Integer.valueOf(bundles[i].getStartLevel()));
- try {
- bundles[i].setStartLevel(Integer.parseInt(startLevel));
- } catch (NumberFormatException e) {
- return Util.createError(NLS.bind(Messages.error_parsing_startlevel, startLevel, bundles[i].getSymbolicName()), e);
- }
- break;
- }
+ getMemento().put(ActionConstants.PARM_PREVIOUS_START_LEVEL, new Integer(bundleInfo.getStartLevel()));
+ try {
+ bundleInfo.setStartLevel(Integer.parseInt(startLevel));
+ return Status.OK_STATUS;
+ } catch (NumberFormatException e) {
+ return Util.createError(NLS.bind(Messages.error_parsing_startlevel, startLevel, bundleInfo.getSymbolicName()), e);
}
- return Status.OK_STATUS;
}
public IStatus undo(Map<String, Object> parameters) {
- IProvisioningAgent agent = (IProvisioningAgent) parameters.get(ActionConstants.PARM_AGENT);
Integer previousStartLevel = (Integer) getMemento().get(ActionConstants.PARM_PREVIOUS_START_LEVEL);
- if (previousStartLevel == null)
+ if (previousStartLevel == null) {
return Status.OK_STATUS;
-
- IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE);
+ }
Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU);
- Collection<IArtifactKey> artifacts = iu.getArtifacts();
- if (artifacts == null || artifacts.isEmpty())
- return Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu));
-
- IArtifactKey artifactKey = artifacts.iterator().next();
- // the bundleFile might be null here, that's OK.
- File bundleFile = Util.getArtifactFile(agent, artifactKey, profile);
-
- BundleInfo bundleInfo = Util.createBundleInfo(bundleFile, iu);
- if (bundleInfo == null)
+ // Changes to this object will be reflected in the backing runtime configuration store
+ BundleInfo bundleInfo = Util.findBundleInfo(manipulator.getConfigData(), iu);
+ if (bundleInfo == null) {
return Util.createError(NLS.bind(Messages.failed_bundleinfo, iu));
-
- BundleInfo[] bundles = manipulator.getConfigData().getBundles();
- for (int i = 0; i < bundles.length; i++) {
- if (bundles[i].equals(bundleInfo)) {
- bundles[i].setStartLevel(previousStartLevel.intValue());
- break;
- }
}
+
+ bundleInfo.setStartLevel(previousStartLevel.intValue());
return Status.OK_STATUS;
}
}

Back to the top