Skip to main content
summaryrefslogtreecommitdiffstats
blob: 834f80d41296d7cdcd7ad95c2b29e02b78f00118 (plain) (blame)
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
124
125
/*******************************************************************************
 *  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
 *******************************************************************************/
package org.eclipse.equinox.p2.engine;

import java.util.*;
import org.eclipse.equinox.internal.p2.engine.*;
import org.eclipse.equinox.internal.p2.engine.phases.*;

/**
 * @since 2.0
 * @noextend This class is not intended to be subclassed by clients.
 */
public class PhaseSetFactory {

	private static final boolean forcedUninstall = Boolean.valueOf(EngineActivator.getContext().getProperty("org.eclipse.equinox.p2.engine.forcedUninstall")).booleanValue(); //$NON-NLS-1$

	/**
	 * A phase id (value "checkTrust") describing the certificate trust check phase.
	 * This phase examines the code signing certificates of the artifacts being installed
	 * to ensure they are signed and trusted by the running system.
	 */
	public static String PHASE_CHECK_TRUST = "checkTrust"; //$NON-NLS-1$
	/**
	 * A phase id (value "collect") describing the collect phase.
	 * This phase gathers all the artifacts to be installed, typically by copying them
	 * from some repository into a suitable local location for the application being installed.
	 */
	public static String PHASE_COLLECT = "collect"; //$NON-NLS-1$
	/**
	 * A phase id (value "configure") describing the configuration phase.
	 * This phase writes configuration data related to the software being provisioned.
	 * Until configuration occurs the end user of the software will be have access to
	 * the installed functionality.
	 */
	public static String PHASE_CONFIGURE = "configure"; //$NON-NLS-1$
	/**
	 * A phase id (value "install") describing the install phase.
	 * This phase performs any necessary transformations on the downloaded
	 * artifacts to put them in the correct shape for the running application, such
	 * as decompressing or moving content, setting file permissions, etc).
	 */
	public static String PHASE_INSTALL = "install"; //$NON-NLS-1$
	/**
	 * A phase id (value "property") describing the property modification phase.
	 * This phase performs changes to profile properties.
	 */
	public static String PHASE_PROPERTY = "property"; //$NON-NLS-1$
	/**
	 * A phase id (value "unconfigure") describing the unconfigure phase.
	 * This phase removes configuration data related to the software being removed.
	 * This phase is the inverse of the changes performed in the configure phase.
	 */
	public static String PHASE_UNCONFIGURE = "unconfigure"; //$NON-NLS-1$
	/**
	 * A phase id (value "uninstall") describing the uninstall phase.
	 * This phase removes artifacts from the system being provisioned that are
	 * no longer required in the new profile.
	 */
	public static String PHASE_UNINSTALL = "uninstall"; //$NON-NLS-1$

	private static final List<String> ALL_PHASES_LIST = Arrays.asList(new String[] {PHASE_COLLECT, PHASE_UNCONFIGURE, PHASE_UNINSTALL, PHASE_PROPERTY, PHASE_CHECK_TRUST, PHASE_INSTALL, PHASE_CONFIGURE});

	/**
	 * Creates a default phase set that covers all the provisioning operations.
	 * Phases can be specified for exclusion.
	 * 
	 * @param exclude - A set of bit options that specify the phases to exclude.
	 * See {@link PhaseSetFactory} for possible options
	 * @return the {@link PhaseSet}
	 */
	public static final IPhaseSet createDefaultPhaseSetExcluding(String[] exclude) {
		if (exclude == null || exclude.length == 0)
			return createDefaultPhaseSet();
		List<String> excludeList = Arrays.asList(exclude);
		List<String> includeList = new ArrayList<String>(ALL_PHASES_LIST);
		includeList.removeAll(excludeList);
		return createPhaseSetIncluding(includeList.toArray(new String[includeList.size()]));
	}

	/**
	 * Creates a default phase set that covers all the provisioning operations.
	 * Phases can be specified for inclusion.
	 * 
	 * @param include - A set of bit options that specify the phases to include.
	 * See {@link PhaseSetFactory} for possible options
	 * @return the {@link PhaseSet}
	 */
	public static final IPhaseSet createPhaseSetIncluding(String[] include) {
		if (include == null || include.length == 0)
			return new PhaseSet(new Phase[0]);
		List<String> includeList = Arrays.asList(include);
		ArrayList<Phase> phases = new ArrayList<Phase>();
		if (includeList.contains(PHASE_COLLECT))
			phases.add(new Collect(100));
		if (includeList.contains(PHASE_CHECK_TRUST))
			phases.add(new CheckTrust(10));
		if (includeList.contains(PHASE_UNCONFIGURE))
			phases.add(new Unconfigure(10, forcedUninstall));
		if (includeList.contains(PHASE_UNINSTALL))
			phases.add(new Uninstall(50, forcedUninstall));
		if (includeList.contains(PHASE_PROPERTY))
			phases.add(new Property(1));
		if (includeList.contains(PHASE_INSTALL))
			phases.add(new Install(50));
		if (includeList.contains(PHASE_CONFIGURE))
			phases.add(new Configure(10));
		return new PhaseSet(phases.toArray(new Phase[phases.size()]));
	}

	public static IPhaseSet createDefaultPhaseSet() {
		return createPhaseSetIncluding(ALL_PHASES_LIST.toArray(new String[ALL_PHASES_LIST.size()]));
	}

	public static ISizingPhaseSet createSizingPhaseSet() {
		return new SizingPhaseSet();
	}
}

Back to the top