001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2008-2009 Sun Microsystems, Inc.
015 * Portions Copyright 2014-2016 ForgeRock AS.
016 */
017package org.forgerock.opendj.config.client;
018
019import java.io.Closeable;
020import java.util.SortedSet;
021
022import org.forgerock.opendj.config.AbstractManagedObjectDefinition;
023import org.forgerock.opendj.config.Configuration;
024import org.forgerock.opendj.config.ConfigurationClient;
025import org.forgerock.opendj.config.DefinitionDecodingException;
026import org.forgerock.opendj.config.InstantiableRelationDefinition;
027import org.forgerock.opendj.config.ManagedObjectNotFoundException;
028import org.forgerock.opendj.config.ManagedObjectPath;
029import org.forgerock.opendj.config.OptionalRelationDefinition;
030import org.forgerock.opendj.config.PropertyDefinition;
031import org.forgerock.opendj.config.PropertyException;
032import org.forgerock.opendj.config.SetRelationDefinition;
033import org.forgerock.opendj.ldap.LdapException;
034import org.forgerock.opendj.server.config.client.RootCfgClient;
035
036/** Client management connection context. */
037public interface ManagementContext extends Closeable {
038
039    /**
040     * Deletes the named instantiable child managed object from the named parent
041     * managed object.
042     *
043     * @param <C>
044     *            The type of client managed object configuration that the
045     *            relation definition refers to.
046     * @param <S>
047     *            The type of server managed object configuration that the
048     *            relation definition refers to.
049     * @param parent
050     *            The path of the parent managed object.
051     * @param rd
052     *            The instantiable relation definition.
053     * @param name
054     *            The name of the child managed object to be removed.
055     * @return Returns <code>true</code> if the named instantiable child managed
056     *         object was found, or <code>false</code> if it was not found.
057     * @throws IllegalArgumentException
058     *             If the relation definition is not associated with the parent
059     *             managed object's definition.
060     * @throws ManagedObjectNotFoundException
061     *             If the parent managed object could not be found.
062     * @throws OperationRejectedException
063     *             If the managed object cannot be removed due to some
064     *             client-side or server-side constraint which cannot be
065     *             satisfied (for example, if it is referenced by another
066     *             managed object).
067     * @throws LdapException
068     *             If any other error occurs.
069     */
070    <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject(
071            ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd, String name)
072            throws ManagedObjectNotFoundException, OperationRejectedException, LdapException;
073
074    /**
075     * Deletes the optional child managed object from the named parent managed
076     * object.
077     *
078     * @param <C>
079     *            The type of client managed object configuration that the
080     *            relation definition refers to.
081     * @param <S>
082     *            The type of server managed object configuration that the
083     *            relation definition refers to.
084     * @param parent
085     *            The path of the parent managed object.
086     * @param rd
087     *            The optional relation definition.
088     * @return Returns <code>true</code> if the optional child managed object
089     *         was found, or <code>false</code> if it was not found.
090     * @throws IllegalArgumentException
091     *             If the relation definition is not associated with the parent
092     *             managed object's definition.
093     * @throws ManagedObjectNotFoundException
094     *             If the parent managed object could not be found.
095     * @throws OperationRejectedException
096     *             If the managed object cannot be removed due to some
097     *             client-side or server-side constraint which cannot be
098     *             satisfied (for example, if it is referenced by another
099     *             managed object).
100     * @throws LdapException
101     *             If any other error occurs.
102     */
103    <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject(
104            ManagedObjectPath<?, ?> parent, OptionalRelationDefinition<C, S> rd) throws
105            ManagedObjectNotFoundException, OperationRejectedException, LdapException;
106
107    /**
108     * Deletes s set child managed object from the named parent managed object.
109     *
110     * @param <C>
111     *            The type of client managed object configuration that the
112     *            relation definition refers to.
113     * @param <S>
114     *            The type of server managed object configuration that the
115     *            relation definition refers to.
116     * @param parent
117     *            The path of the parent managed object.
118     * @param rd
119     *            The set relation definition.
120     * @param name
121     *            The name of the child managed object to be removed.
122     * @return Returns <code>true</code> if the set child managed object was
123     *         found, or <code>false</code> if it was not found.
124     * @throws IllegalArgumentException
125     *             If the relation definition is not associated with the parent
126     *             managed object's definition.
127     * @throws ManagedObjectNotFoundException
128     *             If the parent managed object could not be found.
129     * @throws OperationRejectedException
130     *             If the managed object cannot be removed due to some
131     *             client-side or server-side constraint which cannot be
132     *             satisfied (for example, if it is referenced by another
133     *             managed object).
134     * @throws LdapException
135     *             If any other error occurs.
136     */
137    <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject(
138            ManagedObjectPath<?, ?> parent, SetRelationDefinition<C, S> rd, String name)
139            throws ManagedObjectNotFoundException, OperationRejectedException, LdapException;
140
141    /**
142     * Gets the named managed object.
143     *
144     * @param <C>
145     *            The type of client managed object configuration that the path
146     *            definition refers to.
147     * @param <S>
148     *            The type of server managed object configuration that the path
149     *            definition refers to.
150     * @param path
151     *            The path of the managed object.
152     * @return Returns the named managed object.
153     * @throws DefinitionDecodingException
154     *             If the managed object was found but its type could not be
155     *             determined.
156     * @throws ManagedObjectDecodingException
157     *             If the managed object was found but one or more of its
158     *             properties could not be decoded.
159     * @throws ManagedObjectNotFoundException
160     *             If the requested managed object could not be found on the
161     *             server.
162     * @throws LdapException
163     *             If any other error occurs.
164     */
165    <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getManagedObject(
166            ManagedObjectPath<C, S> path) throws DefinitionDecodingException, ManagedObjectDecodingException,
167            ManagedObjectNotFoundException, LdapException;
168
169    /**
170     * Gets the effective value of a property in the named managed object.
171     *
172     * @param <P>
173     *            The type of the property to be retrieved.
174     * @param path
175     *            The path of the managed object containing the property.
176     * @param pd
177     *            The property to be retrieved.
178     * @return Returns the property's effective value, or <code>null</code> if
179     *         there are no values defined.
180     * @throws IllegalArgumentException
181     *             If the property definition is not associated with the
182     *             referenced managed object's definition.
183     * @throws DefinitionDecodingException
184     *             If the managed object was found but its type could not be
185     *             determined.
186     * @throws PropertyException
187     *             If the managed object was found but the requested property
188     *             could not be decoded.
189     * @throws ManagedObjectNotFoundException
190     *             If the requested managed object could not be found on the
191     *             server.
192     * @throws LdapException
193     *             If any other error occurs.
194     */
195    <P> P getPropertyValue(ManagedObjectPath<?, ?> path, PropertyDefinition<P> pd)
196            throws DefinitionDecodingException, LdapException, ManagedObjectNotFoundException;
197
198    /**
199     * Gets the effective values of a property in the named managed object.
200     *
201     * @param <P>
202     *            The type of the property to be retrieved.
203     * @param path
204     *            The path of the managed object containing the property.
205     * @param pd
206     *            The property to be retrieved.
207     * @return Returns the property's effective values, or an empty set if there
208     *         are no values defined.
209     * @throws IllegalArgumentException
210     *             If the property definition is not associated with the
211     *             referenced managed object's definition.
212     * @throws DefinitionDecodingException
213     *             If the managed object was found but its type could not be
214     *             determined.
215     * @throws PropertyException
216     *             If the managed object was found but the requested property
217     *             could not be decoded.
218     * @throws ManagedObjectNotFoundException
219     *             If the requested managed object could not be found on the
220     *             server.
221     * @throws LdapException
222     *             If any other error occurs.
223     */
224    <P> SortedSet<P> getPropertyValues(ManagedObjectPath<?, ?> path, PropertyDefinition<P> pd)
225            throws DefinitionDecodingException, LdapException, ManagedObjectNotFoundException;
226
227    /**
228     * Gets the root configuration client associated with this management
229     * context.
230     *
231     * @return Returns the root configuration client associated with this
232     *         management context.
233     */
234    RootCfgClient getRootConfiguration();
235
236    /**
237     * Gets the root configuration managed object associated with this
238     * management context.
239     *
240     * @return Returns the root configuration managed object associated with
241     *         this management context.
242     */
243    ManagedObject<RootCfgClient> getRootConfigurationManagedObject();
244
245    /**
246     * Lists the child managed objects of the named parent managed object.
247     *
248     * @param <C>
249     *            The type of client managed object configuration that the
250     *            relation definition refers to.
251     * @param <S>
252     *            The type of server managed object configuration that the
253     *            relation definition refers to.
254     * @param parent
255     *            The path of the parent managed object.
256     * @param rd
257     *            The instantiable relation definition.
258     * @return Returns the names of the child managed objects.
259     * @throws IllegalArgumentException
260     *             If the relation definition is not associated with the parent
261     *             managed object's definition.
262     * @throws ManagedObjectNotFoundException
263     *             If the parent managed object could not be found.
264     * @throws LdapException
265     *             If any other error occurs.
266     */
267    <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects(
268            ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd) throws
269            ManagedObjectNotFoundException, LdapException;
270
271    /**
272     * Lists the child managed objects of the named parent managed object which
273     * are a sub-type of the specified managed object definition.
274     *
275     * @param <C>
276     *            The type of client managed object configuration that the
277     *            relation definition refers to.
278     * @param <S>
279     *            The type of server managed object configuration that the
280     *            relation definition refers to.
281     * @param parent
282     *            The path of the parent managed object.
283     * @param rd
284     *            The instantiable relation definition.
285     * @param d
286     *            The managed object definition.
287     * @return Returns the names of the child managed objects which are a
288     *         sub-type of the specified managed object definition.
289     * @throws IllegalArgumentException
290     *             If the relation definition is not associated with the parent
291     *             managed object's definition.
292     * @throws ManagedObjectNotFoundException
293     *             If the parent managed object could not be found.
294     * @throws LdapException
295     *             If any other error occurs.
296     */
297    <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects(
298            ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd,
299            AbstractManagedObjectDefinition<? extends C, ? extends S> d) throws
300            ManagedObjectNotFoundException, LdapException;
301
302    /**
303     * Lists the child managed objects of the named parent managed object.
304     *
305     * @param <C>
306     *            The type of client managed object configuration that the
307     *            relation definition refers to.
308     * @param <S>
309     *            The type of server managed object configuration that the
310     *            relation definition refers to.
311     * @param parent
312     *            The path of the parent managed object.
313     * @param rd
314     *            The set relation definition.
315     * @return Returns the names of the child managed objects.
316     * @throws IllegalArgumentException
317     *             If the relation definition is not associated with the parent
318     *             managed object's definition.
319     * @throws ManagedObjectNotFoundException
320     *             If the parent managed object could not be found.
321     * @throws LdapException
322     *             If any other error occurs.
323     */
324    <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects(
325            ManagedObjectPath<?, ?> parent, SetRelationDefinition<C, S> rd) throws
326            ManagedObjectNotFoundException, LdapException;
327
328    /**
329     * Determines whether the named managed object exists.
330     *
331     * @param path
332     *            The path of the named managed object.
333     * @return Returns <code>true</code> if the named managed object exists,
334     *         <code>false</code> otherwise.
335     * @throws ManagedObjectNotFoundException
336     *             If the parent managed object could not be found.
337     * @throws LdapException
338     *             If any other error occurs.
339     */
340    boolean managedObjectExists(ManagedObjectPath<?, ?> path) throws ManagedObjectNotFoundException, LdapException;
341}