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
|
/*******************************************************************************
* 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
* 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.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
import org.eclipse.equinox.p2.engine.spi.Touchpoint;
import org.eclipse.equinox.p2.metadata.*;
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<String, Object> 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<String, Object> 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<String, Object> parameters, IProgressMonitor monitor) {
return Status.OK_STATUS;
}
protected IStatus completeOperand(IProfile profile, Operand operand, Map<String, Object> 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<String, Object> parameters, IProgressMonitor monitor) {
return Status.OK_STATUS;
}
final protected List<ProvisioningAction> getActions(Operand operand) {
if (!(operand instanceof InstallableUnitOperand))
return null;
InstallableUnitOperand iuOperand = (InstallableUnitOperand) operand;
return getActions(iuOperand);
}
protected abstract List<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 List<ProvisioningAction> getActions(IInstallableUnit unit, String key) {
List<ITouchpointInstruction> instructions = getInstructions(unit, key);
int instrSize = instructions.size();
if (instrSize == 0)
return null;
List<ProvisioningAction> actions = new ArrayList<ProvisioningAction>();
InstructionParser instructionParser = new InstructionParser(getActionManager());
for (int i = 0; i < instrSize; i++) {
actions.addAll(instructionParser.parseActions(instructions.get(i), unit.getTouchpointType()));
}
return actions;
}
private final static List<ITouchpointInstruction> getInstructions(IInstallableUnit unit, String key) {
Collection<ITouchpointData> data = unit.getTouchpointData();
int dataSize = data.size();
if (dataSize == 0)
return Collections.<ITouchpointInstruction> emptyList();
ArrayList<ITouchpointInstruction> matches = new ArrayList<ITouchpointInstruction>(dataSize);
for (ITouchpointData td : data) {
ITouchpointInstruction instructions = td.getInstruction(key);
if (instructions != null)
matches.add(instructions);
}
return matches;
}
}
|