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 org.forgerock.opendj.ldap.DN;
021import org.opends.server.admin.AdministratorAction;
022import org.opends.server.admin.BooleanPropertyDefinition;
023import org.opends.server.admin.ClassPropertyDefinition;
024import org.opends.server.admin.client.AuthorizationException;
025import org.opends.server.admin.client.CommunicationException;
026import org.opends.server.admin.client.ConcurrentModificationException;
027import org.opends.server.admin.client.ManagedObject;
028import org.opends.server.admin.client.MissingMandatoryPropertiesException;
029import org.opends.server.admin.client.OperationRejectedException;
030import org.opends.server.admin.ManagedObjectAlreadyExistsException;
031import org.opends.server.admin.ManagedObjectDefinition;
032import org.opends.server.admin.PropertyOption;
033import org.opends.server.admin.PropertyProvider;
034import org.opends.server.admin.server.ConfigurationChangeListener;
035import org.opends.server.admin.server.ServerManagedObject;
036import org.opends.server.admin.std.client.GroupImplementationCfgClient;
037import org.opends.server.admin.std.server.GroupImplementationCfg;
038import org.opends.server.admin.Tag;
039import org.opends.server.admin.TopCfgDefn;
040import org.opends.server.admin.UndefinedDefaultBehaviorProvider;
041
042
043
044/**
045 * An interface for querying the Group Implementation managed object
046 * definition meta information.
047 * <p>
048 * Group Implementations define named collections of users.
049 */
050public final class GroupImplementationCfgDefn extends ManagedObjectDefinition<GroupImplementationCfgClient, GroupImplementationCfg> {
051
052  // The singleton configuration definition instance.
053  private static final GroupImplementationCfgDefn INSTANCE = new GroupImplementationCfgDefn();
054
055
056
057  // The "enabled" property definition.
058  private static final BooleanPropertyDefinition PD_ENABLED;
059
060
061
062  // The "java-class" property definition.
063  private static final ClassPropertyDefinition PD_JAVA_CLASS;
064
065
066
067  // Build the "enabled" property definition.
068  static {
069      BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "enabled");
070      builder.setOption(PropertyOption.MANDATORY);
071      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "enabled"));
072      builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<Boolean>());
073      PD_ENABLED = builder.getInstance();
074      INSTANCE.registerPropertyDefinition(PD_ENABLED);
075  }
076
077
078
079  // Build the "java-class" property definition.
080  static {
081      ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
082      builder.setOption(PropertyOption.MANDATORY);
083      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class"));
084      builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>());
085      builder.addInstanceOf("org.opends.server.api.Group");
086      PD_JAVA_CLASS = builder.getInstance();
087      INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
088  }
089
090
091
092  // Register the tags associated with this managed object definition.
093  static {
094    INSTANCE.registerTag(Tag.valueOf("core-server"));
095  }
096
097
098
099  /**
100   * Get the Group Implementation configuration definition singleton.
101   *
102   * @return Returns the Group Implementation configuration definition
103   *         singleton.
104   */
105  public static GroupImplementationCfgDefn getInstance() {
106    return INSTANCE;
107  }
108
109
110
111  /**
112   * Private constructor.
113   */
114  private GroupImplementationCfgDefn() {
115    super("group-implementation", TopCfgDefn.getInstance());
116  }
117
118
119
120  /**
121   * {@inheritDoc}
122   */
123  public GroupImplementationCfgClient createClientConfiguration(
124      ManagedObject<? extends GroupImplementationCfgClient> impl) {
125    return new GroupImplementationCfgClientImpl(impl);
126  }
127
128
129
130  /**
131   * {@inheritDoc}
132   */
133  public GroupImplementationCfg createServerConfiguration(
134      ServerManagedObject<? extends GroupImplementationCfg> impl) {
135    return new GroupImplementationCfgServerImpl(impl);
136  }
137
138
139
140  /**
141   * {@inheritDoc}
142   */
143  public Class<GroupImplementationCfg> getServerConfigurationClass() {
144    return GroupImplementationCfg.class;
145  }
146
147
148
149  /**
150   * Get the "enabled" property definition.
151   * <p>
152   * Indicates whether the Group Implementation is enabled.
153   *
154   * @return Returns the "enabled" property definition.
155   */
156  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
157    return PD_ENABLED;
158  }
159
160
161
162  /**
163   * Get the "java-class" property definition.
164   * <p>
165   * Specifies the fully-qualified name of the Java class that
166   * provides the Group Implementation implementation.
167   *
168   * @return Returns the "java-class" property definition.
169   */
170  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
171    return PD_JAVA_CLASS;
172  }
173
174
175
176  /**
177   * Managed object client implementation.
178   */
179  private static class GroupImplementationCfgClientImpl implements
180    GroupImplementationCfgClient {
181
182    // Private implementation.
183    private ManagedObject<? extends GroupImplementationCfgClient> impl;
184
185
186
187    // Private constructor.
188    private GroupImplementationCfgClientImpl(
189        ManagedObject<? extends GroupImplementationCfgClient> impl) {
190      this.impl = impl;
191    }
192
193
194
195    /**
196     * {@inheritDoc}
197     */
198    public Boolean isEnabled() {
199      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
200    }
201
202
203
204    /**
205     * {@inheritDoc}
206     */
207    public void setEnabled(boolean value) {
208      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
209    }
210
211
212
213    /**
214     * {@inheritDoc}
215     */
216    public String getJavaClass() {
217      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
218    }
219
220
221
222    /**
223     * {@inheritDoc}
224     */
225    public void setJavaClass(String value) {
226      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
227    }
228
229
230
231    /**
232     * {@inheritDoc}
233     */
234    public ManagedObjectDefinition<? extends GroupImplementationCfgClient, ? extends GroupImplementationCfg> definition() {
235      return INSTANCE;
236    }
237
238
239
240    /**
241     * {@inheritDoc}
242     */
243    public PropertyProvider properties() {
244      return impl;
245    }
246
247
248
249    /**
250     * {@inheritDoc}
251     */
252    public void commit() throws ManagedObjectAlreadyExistsException,
253        MissingMandatoryPropertiesException, ConcurrentModificationException,
254        OperationRejectedException, AuthorizationException,
255        CommunicationException {
256      impl.commit();
257    }
258
259
260
261    /** {@inheritDoc} */
262    public String toString() {
263      return impl.toString();
264    }
265  }
266
267
268
269  /**
270   * Managed object server implementation.
271   */
272  private static class GroupImplementationCfgServerImpl implements
273    GroupImplementationCfg {
274
275    // Private implementation.
276    private ServerManagedObject<? extends GroupImplementationCfg> impl;
277
278    // The value of the "enabled" property.
279    private final boolean pEnabled;
280
281    // The value of the "java-class" property.
282    private final String pJavaClass;
283
284
285
286    // Private constructor.
287    private GroupImplementationCfgServerImpl(ServerManagedObject<? extends GroupImplementationCfg> impl) {
288      this.impl = impl;
289      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
290      this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
291    }
292
293
294
295    /**
296     * {@inheritDoc}
297     */
298    public void addChangeListener(
299        ConfigurationChangeListener<GroupImplementationCfg> listener) {
300      impl.registerChangeListener(listener);
301    }
302
303
304
305    /**
306     * {@inheritDoc}
307     */
308    public void removeChangeListener(
309        ConfigurationChangeListener<GroupImplementationCfg> listener) {
310      impl.deregisterChangeListener(listener);
311    }
312
313
314
315    /**
316     * {@inheritDoc}
317     */
318    public boolean isEnabled() {
319      return pEnabled;
320    }
321
322
323
324    /**
325     * {@inheritDoc}
326     */
327    public String getJavaClass() {
328      return pJavaClass;
329    }
330
331
332
333    /**
334     * {@inheritDoc}
335     */
336    public Class<? extends GroupImplementationCfg> configurationClass() {
337      return GroupImplementationCfg.class;
338    }
339
340
341
342    /**
343     * {@inheritDoc}
344     */
345    public DN dn() {
346      return impl.getDN();
347    }
348
349
350
351    /** {@inheritDoc} */
352    public String toString() {
353      return impl.toString();
354    }
355  }
356}