001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2008 Sun Microsystems, Inc.
025 */
026package org.opends.server.admin.std.meta;
027
028
029
030import java.util.Collection;
031import java.util.SortedSet;
032import org.opends.server.admin.AdministratorAction;
033import org.opends.server.admin.AliasDefaultBehaviorProvider;
034import org.opends.server.admin.BooleanPropertyDefinition;
035import org.opends.server.admin.client.AuthorizationException;
036import org.opends.server.admin.client.CommunicationException;
037import org.opends.server.admin.client.ConcurrentModificationException;
038import org.opends.server.admin.client.ManagedObject;
039import org.opends.server.admin.client.MissingMandatoryPropertiesException;
040import org.opends.server.admin.client.OperationRejectedException;
041import org.opends.server.admin.DNPropertyDefinition;
042import org.opends.server.admin.ManagedObjectAlreadyExistsException;
043import org.opends.server.admin.ManagedObjectDefinition;
044import org.opends.server.admin.ManagedObjectOption;
045import org.opends.server.admin.PropertyOption;
046import org.opends.server.admin.PropertyProvider;
047import org.opends.server.admin.server.ConfigurationChangeListener;
048import org.opends.server.admin.server.ServerManagedObject;
049import org.opends.server.admin.std.client.RootDSEBackendCfgClient;
050import org.opends.server.admin.std.server.RootDSEBackendCfg;
051import org.opends.server.admin.Tag;
052import org.opends.server.admin.TopCfgDefn;
053import org.opends.server.admin.UndefinedDefaultBehaviorProvider;
054import org.opends.server.types.DN;
055
056
057
058/**
059 * An interface for querying the Root DSE Backend managed object
060 * definition meta information.
061 * <p>
062 * The Root DSE Backend contains the directory server root DSE.
063 */
064public final class RootDSEBackendCfgDefn extends ManagedObjectDefinition<RootDSEBackendCfgClient, RootDSEBackendCfg> {
065
066  // The singleton configuration definition instance.
067  private static final RootDSEBackendCfgDefn INSTANCE = new RootDSEBackendCfgDefn();
068
069
070
071  // The "show-all-attributes" property definition.
072  private static final BooleanPropertyDefinition PD_SHOW_ALL_ATTRIBUTES;
073
074
075
076  // The "subordinate-base-dn" property definition.
077  private static final DNPropertyDefinition PD_SUBORDINATE_BASE_DN;
078
079
080
081  // Build the "show-all-attributes" property definition.
082  static {
083      BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "show-all-attributes");
084      builder.setOption(PropertyOption.MANDATORY);
085      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "show-all-attributes"));
086      builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<Boolean>());
087      PD_SHOW_ALL_ATTRIBUTES = builder.getInstance();
088      INSTANCE.registerPropertyDefinition(PD_SHOW_ALL_ATTRIBUTES);
089  }
090
091
092
093  // Build the "subordinate-base-dn" property definition.
094  static {
095      DNPropertyDefinition.Builder builder = DNPropertyDefinition.createBuilder(INSTANCE, "subordinate-base-dn");
096      builder.setOption(PropertyOption.MULTI_VALUED);
097      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "subordinate-base-dn"));
098      builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<DN>(INSTANCE, "subordinate-base-dn"));
099      PD_SUBORDINATE_BASE_DN = builder.getInstance();
100      INSTANCE.registerPropertyDefinition(PD_SUBORDINATE_BASE_DN);
101  }
102
103
104
105  // Register the options associated with this managed object definition.
106  static {
107    INSTANCE.registerOption(ManagedObjectOption.ADVANCED);
108  }
109
110
111
112  // Register the tags associated with this managed object definition.
113  static {
114    INSTANCE.registerTag(Tag.valueOf("core-server"));
115    INSTANCE.registerTag(Tag.valueOf("database"));
116  }
117
118
119
120  /**
121   * Get the Root DSE Backend configuration definition singleton.
122   *
123   * @return Returns the Root DSE Backend configuration definition
124   *         singleton.
125   */
126  public static RootDSEBackendCfgDefn getInstance() {
127    return INSTANCE;
128  }
129
130
131
132  /**
133   * Private constructor.
134   */
135  private RootDSEBackendCfgDefn() {
136    super("root-dse-backend", TopCfgDefn.getInstance());
137  }
138
139
140
141  /**
142   * {@inheritDoc}
143   */
144  public RootDSEBackendCfgClient createClientConfiguration(
145      ManagedObject<? extends RootDSEBackendCfgClient> impl) {
146    return new RootDSEBackendCfgClientImpl(impl);
147  }
148
149
150
151  /**
152   * {@inheritDoc}
153   */
154  public RootDSEBackendCfg createServerConfiguration(
155      ServerManagedObject<? extends RootDSEBackendCfg> impl) {
156    return new RootDSEBackendCfgServerImpl(impl);
157  }
158
159
160
161  /**
162   * {@inheritDoc}
163   */
164  public Class<RootDSEBackendCfg> getServerConfigurationClass() {
165    return RootDSEBackendCfg.class;
166  }
167
168
169
170  /**
171   * Get the "show-all-attributes" property definition.
172   * <p>
173   * Indicates whether all attributes in the root DSE are to be
174   * treated like user attributes (and therefore returned to clients by
175   * default) regardless of the directory server schema configuration.
176   *
177   * @return Returns the "show-all-attributes" property definition.
178   */
179  public BooleanPropertyDefinition getShowAllAttributesPropertyDefinition() {
180    return PD_SHOW_ALL_ATTRIBUTES;
181  }
182
183
184
185  /**
186   * Get the "subordinate-base-dn" property definition.
187   * <p>
188   * Specifies the set of base DNs used for singleLevel, wholeSubtree,
189   * and subordinateSubtree searches based at the root DSE.
190   *
191   * @return Returns the "subordinate-base-dn" property definition.
192   */
193  public DNPropertyDefinition getSubordinateBaseDNPropertyDefinition() {
194    return PD_SUBORDINATE_BASE_DN;
195  }
196
197
198
199  /**
200   * Managed object client implementation.
201   */
202  private static class RootDSEBackendCfgClientImpl implements
203    RootDSEBackendCfgClient {
204
205    // Private implementation.
206    private ManagedObject<? extends RootDSEBackendCfgClient> impl;
207
208
209
210    // Private constructor.
211    private RootDSEBackendCfgClientImpl(
212        ManagedObject<? extends RootDSEBackendCfgClient> impl) {
213      this.impl = impl;
214    }
215
216
217
218    /**
219     * {@inheritDoc}
220     */
221    public Boolean isShowAllAttributes() {
222      return impl.getPropertyValue(INSTANCE.getShowAllAttributesPropertyDefinition());
223    }
224
225
226
227    /**
228     * {@inheritDoc}
229     */
230    public void setShowAllAttributes(boolean value) {
231      impl.setPropertyValue(INSTANCE.getShowAllAttributesPropertyDefinition(), value);
232    }
233
234
235
236    /**
237     * {@inheritDoc}
238     */
239    public SortedSet<DN> getSubordinateBaseDN() {
240      return impl.getPropertyValues(INSTANCE.getSubordinateBaseDNPropertyDefinition());
241    }
242
243
244
245    /**
246     * {@inheritDoc}
247     */
248    public void setSubordinateBaseDN(Collection<DN> values) {
249      impl.setPropertyValues(INSTANCE.getSubordinateBaseDNPropertyDefinition(), values);
250    }
251
252
253
254    /**
255     * {@inheritDoc}
256     */
257    public ManagedObjectDefinition<? extends RootDSEBackendCfgClient, ? extends RootDSEBackendCfg> definition() {
258      return INSTANCE;
259    }
260
261
262
263    /**
264     * {@inheritDoc}
265     */
266    public PropertyProvider properties() {
267      return impl;
268    }
269
270
271
272    /**
273     * {@inheritDoc}
274     */
275    public void commit() throws ManagedObjectAlreadyExistsException,
276        MissingMandatoryPropertiesException, ConcurrentModificationException,
277        OperationRejectedException, AuthorizationException,
278        CommunicationException {
279      impl.commit();
280    }
281
282
283
284    /** {@inheritDoc} */
285    public String toString() {
286      return impl.toString();
287    }
288  }
289
290
291
292  /**
293   * Managed object server implementation.
294   */
295  private static class RootDSEBackendCfgServerImpl implements
296    RootDSEBackendCfg {
297
298    // Private implementation.
299    private ServerManagedObject<? extends RootDSEBackendCfg> impl;
300
301    // The value of the "show-all-attributes" property.
302    private final boolean pShowAllAttributes;
303
304    // The value of the "subordinate-base-dn" property.
305    private final SortedSet<DN> pSubordinateBaseDN;
306
307
308
309    // Private constructor.
310    private RootDSEBackendCfgServerImpl(ServerManagedObject<? extends RootDSEBackendCfg> impl) {
311      this.impl = impl;
312      this.pShowAllAttributes = impl.getPropertyValue(INSTANCE.getShowAllAttributesPropertyDefinition());
313      this.pSubordinateBaseDN = impl.getPropertyValues(INSTANCE.getSubordinateBaseDNPropertyDefinition());
314    }
315
316
317
318    /**
319     * {@inheritDoc}
320     */
321    public void addChangeListener(
322        ConfigurationChangeListener<RootDSEBackendCfg> listener) {
323      impl.registerChangeListener(listener);
324    }
325
326
327
328    /**
329     * {@inheritDoc}
330     */
331    public void removeChangeListener(
332        ConfigurationChangeListener<RootDSEBackendCfg> listener) {
333      impl.deregisterChangeListener(listener);
334    }
335
336
337
338    /**
339     * {@inheritDoc}
340     */
341    public boolean isShowAllAttributes() {
342      return pShowAllAttributes;
343    }
344
345
346
347    /**
348     * {@inheritDoc}
349     */
350    public SortedSet<DN> getSubordinateBaseDN() {
351      return pSubordinateBaseDN;
352    }
353
354
355
356    /**
357     * {@inheritDoc}
358     */
359    public Class<? extends RootDSEBackendCfg> configurationClass() {
360      return RootDSEBackendCfg.class;
361    }
362
363
364
365    /**
366     * {@inheritDoc}
367     */
368    public DN dn() {
369      return impl.getDN();
370    }
371
372
373
374    /** {@inheritDoc} */
375    public String toString() {
376      return impl.toString();
377    }
378  }
379}