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