summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2013-01-20 21:19:19 (EST)
committerPascal Rapicault2013-01-20 21:19:19 (EST)
commit1ba6fe6bbbea34898fe28e7cb502a4071711c68d (patch)
tree4df6029b132a96bdf83bfc4028381ced25b71d30
parentf3c8538ab4bda75b610b2537288a2a4bddb5ed07 (diff)
downloadrt.equinox.p2-1ba6fe6bbbea34898fe28e7cb502a4071711c68d.zip
rt.equinox.p2-1ba6fe6bbbea34898fe28e7cb502a4071711c68d.tar.gz
rt.equinox.p2-1ba6fe6bbbea34898fe28e7cb502a4071711c68d.tar.bz2
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/AssignVariableAction.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ParameterizedProvisioningAction.java47
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Phase.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/spi/ProvisioningAction.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/spi/Value.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/plugin.xml8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/AllTests.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/VariableTest.java115
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Messages.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ActionConstants.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ChmodAction.java53
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CleanupzipAction.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/UnzipAction.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/messages.properties1
14 files changed, 29 insertions, 297 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/AssignVariableAction.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/AssignVariableAction.java
deleted file mode 100644
index bcadf35..0000000
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/AssignVariableAction.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.eclipse.equinox.internal.p2.engine;
-
-import java.util.Map;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
-
-public class AssignVariableAction extends ProvisioningAction {
-
- @Override
- public IStatus execute(Map<String, Object> parameters) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public IStatus undo(Map<String, Object> parameters) {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ParameterizedProvisioningAction.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ParameterizedProvisioningAction.java
index eed4c31..8437cb3 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ParameterizedProvisioningAction.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ParameterizedProvisioningAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 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,21 +7,19 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Landmark Graphics Corporation - bug 397183
*******************************************************************************/
package org.eclipse.equinox.internal.p2.engine;
import java.util.*;
import java.util.Map.Entry;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.equinox.p2.engine.spi.*;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.engine.spi.Touchpoint;
public class ParameterizedProvisioningAction extends ProvisioningAction {
+
private ProvisioningAction action;
private Map<String, String> actionParameters;
- //ActualParameter is used to keep values to which variables have been resolved.
- //This is especially useful when undoing in the presence of variables that change (e.g. lastResult)
- private Map<String, Object> actualParameters;
private String actionText;
public ParameterizedProvisioningAction(ProvisioningAction action, Map<String, String> actionParameters, String actionText) {
@@ -29,7 +27,6 @@ public class ParameterizedProvisioningAction extends ProvisioningAction {
throw new IllegalArgumentException(Messages.ParameterizedProvisioningAction_action_or_parameters_null);
this.action = action;
this.actionParameters = actionParameters;
- this.actualParameters = new HashMap<String, Object>(actionParameters.size());
this.actionText = actionText;
}
@@ -47,14 +44,14 @@ public class ParameterizedProvisioningAction extends ProvisioningAction {
Map<String, Object> result = new HashMap<String, Object>(parameters);
for (Entry<String, String> entry : actionParameters.entrySet()) {
String name = entry.getKey();
- Object value = processVariables(entry.getValue(), parameters, false);
+ String value = processVariables(entry.getValue(), parameters);
result.put(name, value);
}
return Collections.unmodifiableMap(result);
}
- //allowInfixReplacement triggers the replacement of the variables found in the middle of a string (e.g. abc${var}def)
- private Object processVariables(String parameterValue, Map<String, Object> parameters, boolean allowInfixReplacement) {
+ private String processVariables(String parameterValue, Map<String, Object> parameters) {
+
int variableBeginIndex = parameterValue.indexOf("${"); //$NON-NLS-1$
if (variableBeginIndex == -1)
return parameterValue;
@@ -65,25 +62,7 @@ public class ParameterizedProvisioningAction extends ProvisioningAction {
String preVariable = parameterValue.substring(0, variableBeginIndex);
String variableName = parameterValue.substring(variableBeginIndex + 2, variableEndIndex);
-
- //replace the internal name by the user visible name
- if (Phase.LAST_RESULT_PUBLIC_NAME.equals(variableName)) {
- variableName = Phase.LAST_RESULT_INTERNAL_NAME;
- }
- Object valueUsed = actualParameters.get(variableName);
- Object value = valueUsed == null ? parameters.get(variableName) : valueUsed;
- actualParameters.put(variableName, value);
-
- if (value instanceof Value) {
- if (allowInfixReplacement == false && variableBeginIndex == 0 && variableEndIndex == parameterValue.length() - 1)
- return value;
-
- Value<?> result = (Value<?>) value;
- if (result.getClazz() == String.class)
- value = result.getValue();
- else
- throw new RuntimeException("The type of the variable is expected to be a String"); //$NON-NLS-1$
- }
+ Object value = parameters.get(variableName);
// try to replace this parameter with a character
if (value == null && variableName.charAt(0) == '#') {
@@ -96,8 +75,8 @@ public class ParameterizedProvisioningAction extends ProvisioningAction {
}
}
- String variableValue = value == null ? "" : value.toString(); //$NON-NLS-1$ //TODO This is where we replace the values
- String postVariable = (String) processVariables(parameterValue.substring(variableEndIndex + 1), parameters, true);
+ String variableValue = value == null ? "" : value.toString(); //$NON-NLS-1$
+ String postVariable = processVariables(parameterValue.substring(variableEndIndex + 1), parameters);
return preVariable + variableValue + postVariable;
}
@@ -120,10 +99,4 @@ public class ParameterizedProvisioningAction extends ProvisioningAction {
public void setTouchpoint(Touchpoint touchpoint) {
throw new UnsupportedOperationException();
}
-
- @Override
- public Value<?> getResult() {
- return action.getResult();
- }
-
}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Phase.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Phase.java
index ccc05ef..bcf9129 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Phase.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Phase.java
@@ -7,7 +7,6 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Landmark Graphics Corporation - bug 397183
*******************************************************************************/
package org.eclipse.equinox.internal.p2.engine;
@@ -17,7 +16,8 @@ import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
-import org.eclipse.equinox.p2.engine.spi.*;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.engine.spi.Touchpoint;
import org.eclipse.osgi.util.NLS;
public abstract class Phase {
@@ -32,8 +32,6 @@ public abstract class Phase {
protected static final String PARM_AGENT = "agent"; //$NON-NLS-1$
protected static final String PARM_FORCED = "forced"; //$NON-NLS-1$
protected static final String PARM_TOUCHPOINT = "touchpoint"; //$NON-NLS-1$
- protected static final String LAST_RESULT_INTERNAL_NAME = "_p2_internal_last_result_variable_"; //$NON-NLS-1$ //
- protected static final String LAST_RESULT_PUBLIC_NAME = "lastResult"; //$NON-NLS-1$
protected final String phaseId;
protected final int weight;
@@ -157,8 +155,8 @@ public abstract class Phase {
operandParameters = touchpointToTouchpointOperandParameters.get(operandTouchpoint);
}
+ operandParameters = Collections.unmodifiableMap(operandParameters);
if (actions != null) {
- Object lastResult = null;
for (int j = 0; j < actions.size(); j++) {
ProvisioningAction action = actions.get(j);
Map<String, Object> parameters = operandParameters;
@@ -170,17 +168,10 @@ public abstract class Phase {
parameters = touchpointToTouchpointOperandParameters.get(touchpoint);
}
- if (lastResult != null && lastResult != Value.NO_VALUE) {
- parameters = new HashMap<String, Object>(parameters);
- parameters.put(LAST_RESULT_INTERNAL_NAME, lastResult);
- }
- parameters = Collections.unmodifiableMap(parameters);
-
IStatus actionStatus = null;
try {
session.recordActionExecute(action, parameters);
actionStatus = action.execute(parameters);
- lastResult = action.getResult().getValue();
} catch (RuntimeException e) {
if (!forced)
throw e;
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/spi/ProvisioningAction.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/spi/ProvisioningAction.java
index fbe50e9..ef88e2a 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/spi/ProvisioningAction.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/spi/ProvisioningAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2012 IBM Corporation and others.
+ * Copyright (c) 2007, 2010 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,7 +7,6 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Landmark Graphics Corporation - bug 397183
*******************************************************************************/
package org.eclipse.equinox.p2.engine.spi;
@@ -30,16 +29,6 @@ public abstract class ProvisioningAction {
public abstract IStatus undo(Map<String, Object> parameters);
- /**
- * This method is meant for provisioning actions that need to communicate the result of their execution
- * to subsequent actions.
- * This method is only invoked by p2 once execute() has been executed.
- * @return the result of the action execution.
- */
- public Value<?> getResult() {
- return Value.NO_VALUE;
- }
-
// TODO: these probably should not be visible
public void setTouchpoint(Touchpoint touchpoint) {
this.touchpoint = touchpoint;
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/spi/Value.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/spi/Value.java
deleted file mode 100644
index 15ecf15..0000000
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/spi/Value.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Landmark Graphics Corporation
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Landmark Graphics Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.engine.spi;
-
-public class Value<T> {
- public static final Value<Object> NO_VALUE = new Value<Object>(null);
- private T value;
- private Class<T> clazz;
-
- public Value(T val) {
- value = val;
- }
-
- public T getValue() {
- return value;
- }
-
- public Class<T> getClazz() {
- return clazz;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests/plugin.xml b/bundles/org.eclipse.equinox.p2.tests/plugin.xml
index cec9954..021e9ca 100644
--- a/bundles/org.eclipse.equinox.p2.tests/plugin.xml
+++ b/bundles/org.eclipse.equinox.p2.tests/plugin.xml
@@ -45,14 +45,6 @@
version="1.0.0">
</action>
</extension>
- <extension
- point="org.eclipse.equinox.p2.engine.actions">
- <action
- class="org.eclipse.equinox.p2.tests.engine.VariableTest$Action"
- name="test.actionForVariableTesting"
- version="1.0.0">
- </action>
- </extension>
<extension
point="org.eclipse.equinox.p2.engine.actions">
<action
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/AllTests.java
index c420ed9..69100ff 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/AllTests.java
@@ -37,7 +37,6 @@ public class AllTests extends TestCase {
suite.addTestSuite(TouchpointManagerTest.class);
suite.addTestSuite(TouchpointTest.class);
suite.addTestSuite(ProvisioningEventTest.class);
- suite.addTestSuite(VariableTest.class);
return suite;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/VariableTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/VariableTest.java
deleted file mode 100644
index 9df16a5..0000000
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/VariableTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Landmark Graphics Corporation
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Landmark Graphics Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.tests.engine;
-
-import java.util.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.p2.engine.*;
-import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
-import org.eclipse.equinox.p2.engine.spi.Value;
-import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
-import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
-
-public class VariableTest extends AbstractProvisioningTest {
-
- private IInstallableUnit createIUWithVariable() {
- InstallableUnitDescription description = new MetadataFactory.InstallableUnitDescription();
- description.setId("artifactWithZip");
- description.setVersion(Version.create("1.0.0"));
- Map touchpointData = new HashMap();
- touchpointData.put("install", "test.actionForVariableTesting( arg1: expectedValue ); test.actionForVariableTesting ( arg1: ${lastResult} ); test.actionForVariableTesting ( arg1: ${lastResult} )");
-
- description.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
-
- return MetadataFactory.createInstallableUnit(description);
- }
-
- public void testVariable() {
- Action.reinitForNextTest();
- Map properties = new HashMap();
- properties.put(IProfile.PROP_INSTALL_FOLDER, getTempFolder().getAbsolutePath());
- IProfile profile = createProfile("testVariable1", properties);
-
- Iterator ius = getInstallableUnits(profile);
- assertFalse(ius.hasNext());
-
- IProvisioningPlan plan = getEngine().createPlan(profile, null);
- plan.addInstallableUnit(createIUWithVariable());
- IStatus result = getEngine().perform(plan, PhaseSetFactory.createPhaseSetIncluding(new String[] {PhaseSetFactory.PHASE_INSTALL}), new NullProgressMonitor());
- assertOK(result);
- assertEquals("expectedValueaaa", Action.result);
- }
-
- public void testUndo() {
- Action.reinitForNextTest();
- Action.failMode = true;
- Map properties = new HashMap();
- properties.put(IProfile.PROP_INSTALL_FOLDER, getTempFolder().getAbsolutePath());
- IProfile profile = createProfile("testVariable2", properties);
-
- Iterator ius = getInstallableUnits(profile);
- assertFalse(ius.hasNext());
-
- IProvisioningPlan plan = getEngine().createPlan(profile, null);
- plan.addInstallableUnit(createIUWithVariable());
- IStatus result = getEngine().perform(plan, PhaseSetFactory.createPhaseSetIncluding(new String[] {PhaseSetFactory.PHASE_INSTALL}), new NullProgressMonitor());
- assertNotOK(result);
- assertEquals(3, Action.inputValues.size());
- assertEquals(3, Action.undoValues.size());
-
- //The undo values should be the same than the input values
- assertEquals(Action.inputValues.get(0), Action.undoValues.get(2));
- assertEquals(Action.inputValues.get(1), Action.undoValues.get(1));
- assertEquals(Action.inputValues.get(2), Action.undoValues.get(0));
- }
-
- public static class Action extends ProvisioningAction {
- public static String result;
- public static boolean failMode;
- private static int count = 0;
- private static final int failAt = 3;
-
- public static ArrayList<String> inputValues = new ArrayList<String>();
- public static ArrayList<String> undoValues = new ArrayList<String>();
-
- public static void reinitForNextTest() {
- inputValues = new ArrayList<String>();
- undoValues = new ArrayList<String>();
- failMode = false;
- count = 0;
- }
-
- @Override
- public IStatus execute(Map<String, Object> parameters) {
- inputValues.add((String) parameters.get("arg1"));
- System.out.println(this.hashCode());
- System.out.println((String) parameters.get("arg1"));
- count++;
- if (failMode && count == failAt)
- throw new RuntimeException("GENERATED Exception");
- result = ((String) parameters.get("arg1")) + "a";
-
- return Status.OK_STATUS;
- }
-
- @Override
- public IStatus undo(Map<String, Object> parameters) {
- undoValues.add((String) parameters.get("arg1"));
- System.out.println("undo arg --> " + (String) parameters.get("arg1"));
- return Status.OK_STATUS;
- }
-
- public Value<String> getResult() {
- return new Value<String>(result);
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Messages.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Messages.java
index c8aade1..0d73c2a 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Messages.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Messages.java
@@ -47,7 +47,6 @@ public class Messages extends NLS {
public static String download_cache_not_writeable;
public static String unzipping;
public static String param_not_set;
- public static String chmod_param_cant_be_set_together;
public static String copy_failed;
public static String failed_backup_restore;
public static String backup_file_failed;
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ActionConstants.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ActionConstants.java
index bb22ee5..daa448b 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ActionConstants.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ActionConstants.java
@@ -33,5 +33,4 @@ public class ActionConstants {
public static final String PARM_COPY_SOURCE = "source"; //$NON-NLS-1$
public static final String PARM_COPY_OVERWRITE = "overwrite"; //$NON-NLS-1$
public static final String PARM_OPTIONS = "options"; //$NON-NLS-1$
- public static final String PARM_ABSOLUTE_FILES = "absoluteFiles"; //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ChmodAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ChmodAction.java
index 535e095..321258d 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ChmodAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ChmodAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 IBM Corporation and others.
+ * Copyright (c) 2008, 2010 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
@@ -9,7 +9,6 @@
* Red Hat Incorporated - initial API and implementation
* IBM Corporation - ongoing development
* Cloudsmith Inc - ongoing development
- * Landmark Graphics Corporation - bug 397183
*******************************************************************************/
package org.eclipse.equinox.internal.p2.touchpoint.natives.actions;
@@ -26,52 +25,23 @@ public class ChmodAction extends ProvisioningAction {
private static final String ACTION_CHMOD = "chmod"; //$NON-NLS-1$
private static final boolean WINDOWS = java.io.File.separatorChar == '\\';
- // target targetFile absoluteFiles
- // Y Y Y can't set all these arguments
- // Y Y N Y -> today, add the ability to specifty a list of fileNames
- // Y N Y warning? targetFolder unecessary
- // Y N N incorrect, missing targetFile
- // N Y Y incorrect, target file can't be with absoluteFiles
- // N Y N incorrect, missing the targetFolder
- // N N Y Y
- // N N N
public IStatus execute(Map<String, Object> parameters) {
- Object absoluteFiles = parameters.get(ActionConstants.PARM_ABSOLUTE_FILES); //String or String[]
String targetDir = (String) parameters.get(ActionConstants.PARM_TARGET_DIR);
+ if (targetDir == null)
+ return Util.createError(NLS.bind(Messages.param_not_set, ActionConstants.PARM_TARGET_DIR, ACTION_CHMOD));
String targetFile = (String) parameters.get(ActionConstants.PARM_TARGET_FILE);
-
- if (targetFile != null && absoluteFiles != null)
- return Util.createError(Messages.chmod_param_cant_be_set_together);
-
- if (targetDir != null && targetFile == null)
+ if (targetFile == null)
return Util.createError(NLS.bind(Messages.param_not_set, ActionConstants.PARM_TARGET_FILE, ACTION_CHMOD));
-
- if (targetDir == null && targetFile != null)
- return Util.createError(NLS.bind(Messages.param_not_set, ActionConstants.PARM_TARGET_DIR, ACTION_CHMOD));
-
String permissions = (String) parameters.get(ActionConstants.PARM_PERMISSIONS);
if (permissions == null)
return Util.createError(NLS.bind(Messages.param_not_set, ActionConstants.PARM_PERMISSIONS, ACTION_CHMOD));
String optionsString = (String) parameters.get(ActionConstants.PARM_OPTIONS);
- String[] filesToProcess = absoluteFiles != null ? ((absoluteFiles instanceof String) ? new String[] {(String) absoluteFiles} : (String[]) absoluteFiles) : makeFilesAbsolute(targetDir, targetFile);
- for (String fileToChmod : filesToProcess) {
- // Check that file exist
- File probe = new File(fileToChmod);
- if (!probe.exists())
- return Util.createError(NLS.bind(Messages.action_0_failed_file_1_doesNotExist, ACTION_CHMOD, probe.toString()));
-
- doChmod(fileToChmod, permissions, optionsString);
- }
-
- return Status.OK_STATUS;
- }
+ // Check that file exist
+ File probe = new File(targetDir + IPath.SEPARATOR + targetFile);
+ if (!probe.exists())
+ return Util.createError(NLS.bind(Messages.action_0_failed_file_1_doesNotExist, ACTION_CHMOD, probe.toString()));
- private String[] makeFilesAbsolute(String targetDir, String targetFile) {
- return new String[] {new String(targetDir + IPath.SEPARATOR + targetFile)};
- }
-
- private void doChmod(String fileToChmod, String permissions, String optionsString) {
String options[] = null;
if (optionsString != null) {
ArrayList<String> collect = new ArrayList<String>();
@@ -93,7 +63,8 @@ public class ChmodAction extends ProvisioningAction {
}
}
- chmod(fileToChmod, permissions, options);
+ chmod(targetDir, targetFile, permissions, options);
+ return Status.OK_STATUS;
}
public IStatus undo(Map<String, Object> parameters) {
@@ -101,7 +72,7 @@ public class ChmodAction extends ProvisioningAction {
return Status.OK_STATUS;
}
- public void chmod(String fileToChmod, String perms, String[] options) {
+ public void chmod(String targetDir, String targetFile, String perms, String[] options) {
if (WINDOWS)
return;
Runtime r = Runtime.getRuntime();
@@ -115,7 +86,7 @@ public class ChmodAction extends ProvisioningAction {
args[i++] = options[j];
}
args[i++] = perms;
- args[i] = fileToChmod;
+ args[i] = targetDir + IPath.SEPARATOR + targetFile;
Process process = r.exec(args);
readOffStream(process.getErrorStream());
readOffStream(process.getInputStream());
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CleanupzipAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CleanupzipAction.java
index 4c14147..61a2acf 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CleanupzipAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CleanupzipAction.java
@@ -31,7 +31,7 @@ public class CleanupzipAction extends ProvisioningAction {
}
public IStatus undo(Map<String, Object> parameters) {
- return new UnzipAction().unzip(parameters, false);
+ return UnzipAction.unzip(parameters, false);
}
public static IStatus cleanupzip(Map<String, Object> parameters, boolean restoreable) {
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/UnzipAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/UnzipAction.java
index 2c93bba..0d87a57 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/UnzipAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/UnzipAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 IBM Corporation and others.
+ * Copyright (c) 2008, 2010 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,7 +7,6 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Landmark Graphics Corporation - bug 397183
*******************************************************************************/
package org.eclipse.equinox.internal.p2.touchpoint.natives.actions;
@@ -18,7 +17,6 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.engine.Profile;
import org.eclipse.equinox.internal.p2.touchpoint.natives.*;
import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
-import org.eclipse.equinox.p2.engine.spi.Value;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.osgi.util.NLS;
@@ -26,7 +24,6 @@ import org.eclipse.osgi.util.NLS;
public class UnzipAction extends ProvisioningAction {
public static final String ACTION_UNZIP = "unzip"; //$NON-NLS-1$
- private Value<String[]> result;
public IStatus execute(Map<String, Object> parameters) {
return unzip(parameters, true);
@@ -43,7 +40,7 @@ public class UnzipAction extends ProvisioningAction {
* @param restoreable - if the unzip should be backed up
* @return status
*/
- public IStatus unzip(Map<String, Object> parameters, boolean restoreable) {
+ public static IStatus unzip(Map<String, Object> parameters, boolean restoreable) {
String source = (String) parameters.get(ActionConstants.PARM_SOURCE);
if (source == null)
return Util.createError(NLS.bind(Messages.param_not_set, ActionConstants.PARM_SOURCE, ACTION_UNZIP));
@@ -71,12 +68,6 @@ public class UnzipAction extends ProvisioningAction {
String excludePattern = (String) parameters.get(ActionConstants.PARM_EXCLUDE);
File[] unzippedFiles = unzip(source, target, path, includePattern, excludePattern, store);
- String[] filesAsString = new String[unzippedFiles.length];
- for (int i = 0; i < unzippedFiles.length; i++) {
- filesAsString[i] = unzippedFiles[i].getAbsolutePath();
- }
- result = new Value<String[]>(filesAsString);
-
StringBuffer unzippedFileNameBuffer = new StringBuffer();
for (int i = 0; i < unzippedFiles.length; i++)
unzippedFileNameBuffer.append(unzippedFiles[i].getAbsolutePath()).append(ActionConstants.PIPE);
@@ -105,9 +96,4 @@ public class UnzipAction extends ProvisioningAction {
}
return new File[0];
}
-
- @Override
- public Value<String[]> getResult() {
- return result;
- }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/messages.properties b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/messages.properties
index 1bbd401..1dbe1a1 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/messages.properties
@@ -33,7 +33,6 @@ action_0_failed_file_1_doesNotExist=The action {0} failed - file {1} does not ex
artifact_not_available=The artifact for {0} is not available.
unzipping=Extracting {0}
param_not_set=The \"{0}\" parameter was not set in the \"{1}\" action.
-chmod_param_cant_be_set_together=The parameters targetFile and absoluteFiles can't be set at the same time.
artifact_repo_not_found=The artifact repository manager could not be found.
could_not_obtain_download_cache=Could not obtain the download cache location.
download_cache_not_writeable=Agent download cache not writeable: {0}.