diff options
author | Simon Kaegi | 2009-10-19 02:39:08 +0000 |
---|---|---|
committer | Simon Kaegi | 2009-10-19 02:39:08 +0000 |
commit | a9de2ccc0ebee0d6d5f8da9b1131a69df83b3fb7 (patch) | |
tree | 2e8db0a5e24c23b32bb04afb42f2a37367a294cc /bundles/org.eclipse.equinox.p2.touchpoint.eclipse | |
parent | e500d8cec8418a77593d1cebf080346bdb582ff0 (diff) | |
download | rt.equinox.p2-a9de2ccc0ebee0d6d5f8da9b1131a69df83b3fb7.tar.gz rt.equinox.p2-a9de2ccc0ebee0d6d5f8da9b1131a69df83b3fb7.tar.xz rt.equinox.p2-a9de2ccc0ebee0d6d5f8da9b1131a69df83b3fb7.zip |
Bug 275404 - [engine] Consistent handling of @artifact in actions/touchpoints
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.touchpoint.eclipse')
9 files changed, 38 insertions, 94 deletions
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 e280bc927..8cf88ba61 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 @@ -31,6 +31,8 @@ public class EclipseTouchpoint extends Touchpoint { public static final String PARM_PLATFORM_CONFIGURATION = "platformConfiguration"; //$NON-NLS-1$ public static final String PARM_SOURCE_BUNDLES = "sourceBundles"; //$NON-NLS-1$ public static final String PARM_IU = "iu"; //$NON-NLS-1$ + public static final String PARM_ARTIFACT = "artifact"; //$NON-NLS-1$ + public static final String PARM_ARTIFACT_LOCATION = "artifact.location"; //$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[] {"mkdir", "rmdir"}); //$NON-NLS-1$//$NON-NLS-2$ @@ -173,17 +175,24 @@ public class EclipseTouchpoint extends Touchpoint { public IStatus initializeOperand(IProfile profile, Operand operand, Map parameters) { IInstallableUnit iu = (IInstallableUnit) parameters.get(PARM_IU); + IArtifactKey artifactKey = (IArtifactKey) parameters.get(PARM_ARTIFACT); if (iu != null && Boolean.valueOf(iu.getProperty(IInstallableUnit.PROP_PARTIAL_IU)).booleanValue()) { - IInstallableUnit preparedIU = prepareIU(iu, profile); + IInstallableUnit preparedIU = prepareIU(iu, artifactKey, profile); if (preparedIU == null) return Util.createError(NLS.bind(Messages.failed_prepareIU, iu)); parameters.put(PARM_IU, preparedIU); } + + if (!parameters.containsKey(PARM_ARTIFACT_LOCATION) && artifactKey != null) { + File fileLocation = Util.getArtifactFile(artifactKey, profile); + if (fileLocation != null && fileLocation.exists()) + parameters.put(PARM_ARTIFACT_LOCATION, fileLocation.getAbsolutePath()); + } return Status.OK_STATUS; } - public IInstallableUnit prepareIU(IInstallableUnit iu, IProfile profile) { + public IInstallableUnit prepareIU(IInstallableUnit iu, IArtifactKey artifactKey, IProfile profile) { IInstallableUnit preparedIU = getPreparedIU(profile, iu); if (preparedIU != null) return preparedIU; @@ -199,11 +208,6 @@ public class EclipseTouchpoint extends Touchpoint { } if (c != null) { - IArtifactKey[] artifacts = iu.getArtifacts(); - if (artifacts == null || artifacts.length == 0) - return iu; - - IArtifactKey artifactKey = artifacts[0]; if (artifactKey == null) return iu; diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Messages.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Messages.java index 686719b49..22f91b576 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Messages.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Messages.java @@ -24,6 +24,7 @@ public class Messages extends NLS { public static String error_parsing_configuration; public static String publisher_not_available; public static String artifact_write_unsupported; + public static String iu_contains_no_arifacts; public static String artifact_file_not_found; public static String artifact_retrieval_unsupported; public static String bundle_pool_not_writeable; diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java index bbe7cd346..68784218c 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java @@ -327,4 +327,18 @@ public class Util { String launcherConfig = profile.getProperty(IProfile.PROP_LAUNCHER_CONFIGURATION); return launcherConfig == null ? null : new File(launcherConfig); } + + public static String resolveArtifactParam(Map parameters) throws CoreException { + String artifactLocation = (String) parameters.get(EclipseTouchpoint.PARM_ARTIFACT_LOCATION); + if (artifactLocation != null) + return artifactLocation; + + IArtifactKey artifactKey = (IArtifactKey) parameters.get(EclipseTouchpoint.PARM_ARTIFACT); + if (artifactKey == null) { + IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU); + throw new CoreException(Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu))); + } + + throw new CoreException(Util.createError(NLS.bind(Messages.artifact_file_not_found, artifactKey))); + } } diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java index ab9e86968..78a56eb6c 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java @@ -10,7 +10,7 @@ package org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions; public class ActionConstants { - public static final String PARM_ARTIFACT = "@artifact"; //$NON-NLS-1$ + public static final String PARM_AT_ARTIFACT = "@artifact"; //$NON-NLS-1$ public static final String PARM_ARTIFACT_FILES = "artifactFiles"; //$NON-NLS-1$ public static final String PARM_ARTIFACT_REQUESTS = "artifactRequests"; //$NON-NLS-1$ public static final String PARM_BUNDLE = "bundle"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddProgramArgumentAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddProgramArgumentAction.java index efaa3b30a..7672437dc 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddProgramArgumentAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddProgramArgumentAction.java @@ -10,16 +10,12 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions; -import java.io.File; import java.util.Map; import org.eclipse.core.runtime.*; 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.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; import org.eclipse.osgi.util.NLS; public class AddProgramArgumentAction extends ProvisioningAction { @@ -35,9 +31,9 @@ public class AddProgramArgumentAction extends ProvisioningAction { if (ActionConstants.PARM_IGNORE.equals(programArgValue)) return Status.OK_STATUS; - if (programArg.equals(ActionConstants.PARM_ARTIFACT)) { + if (programArg.equals(ActionConstants.PARM_AT_ARTIFACT)) { try { - programArg = resolveArtifactParam(parameters); + programArg = Util.resolveArtifactParam(parameters); } catch (CoreException e) { return e.getStatus(); } @@ -45,9 +41,9 @@ public class AddProgramArgumentAction extends ProvisioningAction { manipulator.getLauncherData().addProgramArg(programArg); if (programArgValue != null) { - if (programArgValue.equals(ActionConstants.PARM_ARTIFACT)) { + if (programArgValue.equals(ActionConstants.PARM_AT_ARTIFACT)) { try { - programArgValue = resolveArtifactParam(parameters); + programArgValue = Util.resolveArtifactParam(parameters); } catch (CoreException e) { return e.getStatus(); } @@ -72,19 +68,4 @@ public class AddProgramArgumentAction extends ProvisioningAction { manipulator.getLauncherData().removeProgramArg(programArg); return Status.OK_STATUS; } - - private static String resolveArtifactParam(Map parameters) throws CoreException { - IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE); - IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU); - IArtifactKey[] artifacts = iu.getArtifacts(); - if (artifacts == null || artifacts.length == 0) - throw new CoreException(Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu))); - - IArtifactKey artifactKey = artifacts[0]; - - File fileLocation = Util.getArtifactFile(artifactKey, profile); - if (fileLocation == null || !fileLocation.exists()) - throw new CoreException(Util.createError(NLS.bind(Messages.artifact_file_not_found, artifactKey))); - return fileLocation.getAbsolutePath(); - } }
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java index f5557b5c0..0aaeb6717 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java @@ -16,12 +16,8 @@ import java.io.*; import java.util.ArrayList; import java.util.Map; import org.eclipse.core.runtime.*; -import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; import org.eclipse.osgi.util.NLS; // This basically a copy of the chmod action in the native touchpoint only it provides @artifact support. @@ -33,9 +29,9 @@ public class ChmodAction extends ProvisioningAction { String targetDir = (String) parameters.get(ActionConstants.PARM_TARGET_DIR); if (targetDir == null) return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_TARGET_DIR, ACTION_CHMOD)); - if (targetDir.equals(ActionConstants.PARM_ARTIFACT)) { + if (targetDir.equals(ActionConstants.PARM_AT_ARTIFACT)) { try { - targetDir = resolveArtifactParam(parameters); + targetDir = Util.resolveArtifactParam(parameters); } catch (CoreException e) { return e.getStatus(); } @@ -132,19 +128,4 @@ public class ChmodAction extends ProvisioningAction { } } } - - private static String resolveArtifactParam(Map parameters) throws CoreException { - IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE); - IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU); - IArtifactKey[] artifacts = iu.getArtifacts(); - if (artifacts == null || artifacts.length == 0) - throw new CoreException(Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu))); - - IArtifactKey artifactKey = artifacts[0]; - - File fileLocation = Util.getArtifactFile(artifactKey, profile); - if (fileLocation == null || !fileLocation.exists()) - throw new CoreException(Util.createError(NLS.bind(Messages.artifact_file_not_found, artifactKey))); - return fileLocation.getAbsolutePath(); - } }
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/LinkAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/LinkAction.java index e18ef9b9b..13b860045 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/LinkAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/LinkAction.java @@ -13,12 +13,8 @@ package org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions; import java.io.*; import java.util.Map; import org.eclipse.core.runtime.*; -import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; import org.eclipse.osgi.util.NLS; //This is basically a copy of the ln action in the native touchpoint only it provides @artifact support and does not support the backup store. @@ -31,9 +27,9 @@ public class LinkAction extends ProvisioningAction { if (targetDir == null) return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_TARGET_DIR, ID)); - if (targetDir.equals(ActionConstants.PARM_ARTIFACT)) { + if (targetDir.equals(ActionConstants.PARM_AT_ARTIFACT)) { try { - targetDir = resolveArtifactParam(parameters); + targetDir = Util.resolveArtifactParam(parameters); } catch (CoreException e) { return e.getStatus(); } @@ -104,19 +100,4 @@ public class LinkAction extends ProvisioningAction { } } } - - private static String resolveArtifactParam(Map parameters) throws CoreException { - IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE); - IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU); - IArtifactKey[] artifacts = iu.getArtifacts(); - if (artifacts == null || artifacts.length == 0) - throw new CoreException(Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu))); - - IArtifactKey artifactKey = artifacts[0]; - - File fileLocation = Util.getArtifactFile(artifactKey, profile); - if (fileLocation == null || !fileLocation.exists()) - throw new CoreException(Util.createError(NLS.bind(Messages.artifact_file_not_found, artifactKey))); - return fileLocation.getAbsolutePath(); - } } diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetProgramPropertyAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetProgramPropertyAction.java index cdc72ce39..7d31fbc4e 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetProgramPropertyAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetProgramPropertyAction.java @@ -10,16 +10,12 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions; -import java.io.File; import java.util.Map; import org.eclipse.core.runtime.*; 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.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; import org.eclipse.osgi.util.NLS; public class SetProgramPropertyAction extends ProvisioningAction { @@ -31,9 +27,9 @@ public class SetProgramPropertyAction extends ProvisioningAction { if (propName == null) return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_PROP_NAME, ID)); String propValue = (String) parameters.get(ActionConstants.PARM_PROP_VALUE); - if (propValue != null && propValue.equals(ActionConstants.PARM_ARTIFACT)) { + if (propValue != null && propValue.equals(ActionConstants.PARM_AT_ARTIFACT)) { try { - propValue = resolveArtifactParam(parameters); + propValue = Util.resolveArtifactParam(parameters); } catch (CoreException e) { return e.getStatus(); } @@ -53,19 +49,4 @@ public class SetProgramPropertyAction extends ProvisioningAction { manipulator.getConfigData().setProperty(propName, previousValue); return Status.OK_STATUS; } - - private static String resolveArtifactParam(Map parameters) throws CoreException { - IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE); - IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU); - IArtifactKey[] artifacts = iu.getArtifacts(); - if (artifacts == null || artifacts.length == 0) - throw new CoreException(Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu))); - - IArtifactKey artifactKey = artifacts[0]; - - File fileLocation = Util.getArtifactFile(artifactKey, profile); - if (fileLocation == null || !fileLocation.exists()) - throw new CoreException(Util.createError(NLS.bind(Messages.artifact_file_not_found, artifactKey))); - return fileLocation.getAbsolutePath(); - } }
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/messages.properties b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/messages.properties index 36436a3ef..81f1ab022 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/messages.properties +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/messages.properties @@ -27,3 +27,4 @@ parent_dir_features=Parent directory should be "features": {0}. platform_config_unavailable=Platform configuration not available. unexpected_prepareiu_error=Unexpected state: prepareIU error_validating_profile=Error validating profile {0}. +iu_contains_no_arifacts=Installable unit contains no artifacts: {0}. |