Debian Codegraph @

bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/IProfileRegistry.java

raw
1 /*******************************************************************************
2 * Copyright (c) 2007, 2013 IBM Corporation and others.
3 *
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
8 *
9 * SPDX-License-Identifier: EPL-2.0
10 *
11 * Contributors:
12 * IBM Corporation - initial API and implementation
13 * Ericsson AB - ongoing development
14 *******************************************************************************/
15 package org.eclipse.equinox.p2.engine;
16
17 import java.util.Collection;
18 import java.util.Map;
19 import org.eclipse.core.runtime.IStatus;
20 import org.eclipse.equinox.p2.core.ProvisionException;
21
22 /**
23 * This encapsulates the access to the profile registry.
24 * It deals with persistence in a transparent way.
25 *
26 * @noimplement This interface is not intended to be implemented by clients.
27 * @noextend This interface is not intended to be extended by clients.
28 * @since 2.0
29 */
30 public interface IProfileRegistry {
31 /**
32 * A special profile id representing the profile of the currently running system.
33 * This constant can be used when invoking {@link #getProfile(String)} to obtain
34 * the profile of the currently running system. Note that a given profile registry
35 * may not have a defined self profile, for example if the running system doesn't
36 * have a profile, or resides in a different profile registry.
37 */
38 public static final String SELF = "_SELF_"; //$NON-NLS-1$
39 /**
40 * Service name constant for the profile registry service.
41 */
42 public static final String SERVICE_NAME = IProfileRegistry.class.getName();
43
44 /**
45 * Return the profile in the registry that has the given id. If it does not exist,
46 * then return <code>null</code>.
47 *
48 * @param id the profile identifier
49 * @return the profile or <code>null</code>
50 */
51 public IProfile getProfile(String id);
52
53 /**
54 * Return the profile in the registry that has the given id and timestamp. If it does not exist,
55 * then return <code>null</code>.
56 *
57 * @param id the profile identifier
58 * @param timestamp the profile's timestamp
59 * @return the profile or <code>null</code>
60 */
61 public IProfile getProfile(String id, long timestamp);
62
63 /**
64 * Return an array of timestamps in ascending order for the profile id in question.
65 * If there are none, then return an empty array.
66 *
67 * @param id the id of the profile to list timestamps for
68 * @return the array of timestamps
69 */
70 public long[] listProfileTimestamps(String id);
71
72 /**
73 * Return an array of profiles known to this registry. If there are none, then
74 * return an empty array.
75 *
76 * @return the array of profiles
77 */
78 public IProfile[] getProfiles();
79
80 /**
81 * Add the given profile to this profile registry.
82 *
83 * @param id the profile id
84 * @throws ProvisionException if a profile
85 * with the same id is already present in the registry.
86 * @return the new empty profile
87 */
88 public IProfile addProfile(String id) throws ProvisionException;
89
90 /**
91 * Add the given profile to this profile registry.
92 *
93 * @param id the profile id
94 * @param properties the profile properties
95 * @throws ProvisionException if a profile
96 * with the same id is already present in the registry.
97 * @return the new empty profile
98 */
99 public IProfile addProfile(String id, Map<String, String> properties) throws ProvisionException;
100
101 /**
102 * Returns whether this profile registry contains a profile with the given id.
103 *
104 * @param profileId The id of the profile to search for
105 * @return <code>true</code> if this registry contains a profile with the given id,
106 * and <code>false</code> otherwise.
107 */
108 public boolean containsProfile(String profileId);
109
110 /**
111 * Remove the given profile snapshot from this profile registry. This method has no effect
112 * if this registry does not contain a profile with the given id and timestamp.
113 * The current profile cannot be removed using this method. When a particular profile state
114 * is removed from the registry, the corresponding profile state properties for that
115 * particular state are also removed.
116 *
117 * @param id the profile to remove
118 * @param timestamp the timestamp of the profile to remove
119 * @throws ProvisionException if the profile with the specified id and timestamp is the current profile.
120 */
121 public void removeProfile(String id, long timestamp) throws ProvisionException;
122
123 /**
124 * Remove the given profile from this profile registry. This method has no effect
125 * if this registry does not contain a profile with the given id. When a profile is removed
126 * from the registry, all of its associated profile state properties are removed as well.
127 *
128 * @param id the profile to remove
129 */
130 public void removeProfile(String id);
131
132 /**
133 * Check if the given profile from this profile registry is up-to-date.
134 *
135 * @param profile the profile to check
136 * @return boolean true if the profile is current; false otherwise.
137 */
138 public boolean isCurrent(IProfile profile);
139
140 /**
141 * Set properties on a specific profile state. Overwrite existing properties if present.
142 *
143 * @param id the identifier of the profile
144 * @param timestamp the timestamp of the profile
145 * @param properties the properties to set on the profile
146 * @return status object indicating success or failure
147 * @throws NullPointerException if either id or properties are <code>null</code>
148 * @since 2.1
149 */
150 public IStatus setProfileStateProperties(String id, long timestamp, Map<String, String> properties);
151
152 /**
153 * Set a specific property on a specific profile state. Overwrite existing properties if present.
154 * <p>
155 * Use of this method is discouraged if multiple properties will be set on the same state since
156 * the implementation of this method may access the file-system with each call. Callers should use
157 * {@link #setProfileStateProperties(String, long, Map)} instead.
158 * </p>
159 *
160 * @param id the profile identifier
161 * @param timestamp the timestamp of the profile
162 * @param key the property key to set
163 * @param value the property value to set
164 * @return status object indicating success or failure
165 * @throws NullPointerException if any of id, key or value is <code>null</code>
166 * @since 2.1
167 */
168 public IStatus setProfileStateProperty(String id, long timestamp, String key, String value);
169
170 /**
171 * Return all properties for a particular profile state. Both the key and the values are <code>String</code>.
172 * Return an empty map if there was a problem accessing the properties.
173 * <p>
174 * There is no guarantee that all state timestamps returned will still exist in the registry
175 * since the user could delete profile states from the file system.
176 * </p>
177 * @param id the profile identifier
178 * @param timestamp the profile timestamp
179 * @return a property map of key value pairs. An empty map if the profile state has no properties or does not exist
180 * @throws NullPointerException if profile id is <code>null</code>.
181 * @since 2.1
182 */
183 public Map<String, String> getProfileStateProperties(String id, long timestamp);
184
185 /**
186 * Return a map of profile timestamps to values for all profile states that contain the given property key.
187 * Both the key and value are of type <code>String</code>.
188 * Return an empty map if there was a problem accessing the properties.
189 * <p>
190 * There is no guarantee that all state timestamps returned will still exist in the registry
191 * since the user could delete profile states from the file system.
192 * </p>
193 * @param id the profile identifier
194 * @param key the property key
195 * @return A map of timestamp and values for the given key. An empty map if no states define the given key.
196 * @throws NullPointerException if the profile id or key is <code>null</code>.
197 * @since 2.1
198 */
199 public Map<String, String> getProfileStateProperties(String id, String key);
200
201 /**
202 * Remove all properties with matching keys from the given profile state. Non-existent keys are
203 * ignored. If the state does not exist the method performs a no-op and returns normally. If the keys
204 * parameter is <code>null</code> then remove all properties from the profile state.
205 *
206 * @param id the profile identifier
207 * @param timestamp the profile timestamp
208 * @param keys the property keys to remove, or <code>null</code>
209 * @return a status object indicating success or failure
210 * @throws NullPointerException if the profile id is <code>null</code>.
211 * @since 2.1
212 */
213 public IStatus removeProfileStateProperties(String id, long timestamp, Collection<String> keys);
214 }