1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*******************************************************************************
* Copyright (c) 2007, 2009 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* WindRiver - https://bugs.eclipse.org/bugs/show_bug.cgi?id=227372
*******************************************************************************/
package org.eclipse.equinox.internal.p2.engine;
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.ITouchpointData;
import org.eclipse.equinox.internal.provisional.p2.metadata.ITouchpointInstruction;
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
import org.eclipse.equinox.p2.engine.spi.Touchpoint;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
public abstract class InstallableUnitPhase extends Phase {
public static final String PARM_ARTIFACT = "artifact"; //$NON-NLS-1$
public static final String PARM_IU = "iu"; //$NON-NLS-1$
public static final String PARM_INSTALL_FOLDER = "installFolder"; //$NON-NLS-1$
protected InstallableUnitPhase(String phaseId, int weight, boolean forced) {
super(phaseId, weight, forced);
}
protected InstallableUnitPhase(String phaseId, int weight) {
this(phaseId, weight, false);
}
protected IStatus initializePhase(IProgressMonitor monitor, IProfile profile, Map parameters) {
parameters.put(PARM_INSTALL_FOLDER, profile.getProperty(IProfile.PROP_INSTALL_FOLDER));
return super.initializePhase(monitor, profile, parameters);
}
protected IStatus initializeOperand(IProfile profile, Operand operand, Map parameters, IProgressMonitor monitor) {
InstallableUnitOperand iuOperand = (InstallableUnitOperand) operand;
MultiStatus status = new MultiStatus(EngineActivator.ID, IStatus.OK, null, null);
mergeStatus(status, initializeOperand(profile, iuOperand, parameters, monitor));
IInstallableUnit unit = (IInstallableUnit) parameters.get(PARM_IU);
if (unit != null) {
Touchpoint touchpoint = getActionManager().getTouchpointPoint(unit.getTouchpointType());
if (touchpoint != null) {
parameters.put(PARM_TOUCHPOINT, touchpoint);
}
}
mergeStatus(status, super.initializeOperand(profile, operand, parameters, monitor));
return status;
}
protected IStatus initializeOperand(IProfile profile, InstallableUnitOperand operand, Map parameters, IProgressMonitor monitor) {
return Status.OK_STATUS;
}
protected IStatus completeOperand(IProfile profile, Operand operand, Map parameters, IProgressMonitor monitor) {
InstallableUnitOperand iuOperand = (InstallableUnitOperand) operand;
MultiStatus status = new MultiStatus(EngineActivator.ID, IStatus.OK, null, null);
mergeStatus(status, super.completeOperand(profile, iuOperand, parameters, monitor));
mergeStatus(status, completeOperand(profile, iuOperand, parameters, monitor));
return status;
}
protected IStatus completeOperand(IProfile profile, InstallableUnitOperand operand, Map parameters, IProgressMonitor monitor) {
return Status.OK_STATUS;
}
final protected ProvisioningAction[] getActions(Operand operand) {
if (!(operand instanceof InstallableUnitOperand))
return null;
InstallableUnitOperand iuOperand = (InstallableUnitOperand) operand;
return getActions(iuOperand);
}
protected abstract ProvisioningAction[] getActions(InstallableUnitOperand operand);
final public boolean isApplicable(Operand operand) {
if (!(operand instanceof InstallableUnitOperand))
return false;
InstallableUnitOperand iuOperand = (InstallableUnitOperand) operand;
return isApplicable(iuOperand);
}
protected boolean isApplicable(InstallableUnitOperand operand) {
return true;
}
protected final ProvisioningAction[] getActions(IInstallableUnit unit, String key) {
ITouchpointInstruction[] instructions = getInstructions(unit, key);
if (instructions == null || instructions.length == 0)
return null;
List actions = new ArrayList();
InstructionParser instructionParser = new InstructionParser(getActionManager());
for (int i = 0; i < instructions.length; i++) {
actions.addAll(Arrays.asList(instructionParser.parseActions(instructions[i], unit.getTouchpointType())));
}
return (ProvisioningAction[]) actions.toArray(new ProvisioningAction[actions.size()]);
}
private final static ITouchpointInstruction[] getInstructions(IInstallableUnit unit, String key) {
ITouchpointData[] data = unit.getTouchpointData();
if (data == null)
return null;
ArrayList matches = new ArrayList(data.length);
for (int i = 0; i < data.length; i++) {
ITouchpointInstruction instructions = data[i].getInstruction(key);
if (instructions != null)
matches.add(instructions);
}
ITouchpointInstruction[] result = (ITouchpointInstruction[]) matches.toArray(new ITouchpointInstruction[matches.size()]);
return result;
}
}
|