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.forgerock.opendj.server.config.meta;
027
028
029
030import java.util.Collection;
031import java.util.SortedSet;
032import org.forgerock.opendj.config.AdministratorAction;
033import org.forgerock.opendj.config.BooleanPropertyDefinition;
034import org.forgerock.opendj.config.ClassPropertyDefinition;
035import org.forgerock.opendj.config.client.ConcurrentModificationException;
036import org.forgerock.opendj.config.client.ManagedObject;
037import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException;
038import org.forgerock.opendj.config.client.OperationRejectedException;
039import org.forgerock.opendj.config.DefaultBehaviorProvider;
040import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider;
041import org.forgerock.opendj.config.EnumPropertyDefinition;
042import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException;
043import org.forgerock.opendj.config.ManagedObjectDefinition;
044import org.forgerock.opendj.config.PropertyOption;
045import org.forgerock.opendj.config.PropertyProvider;
046import org.forgerock.opendj.config.server.ConfigurationChangeListener;
047import org.forgerock.opendj.config.server.ServerManagedObject;
048import org.forgerock.opendj.config.Tag;
049import org.forgerock.opendj.ldap.DN;
050import org.forgerock.opendj.ldap.LdapException;
051import org.forgerock.opendj.server.config.client.LDAPAttributeDescriptionListPluginCfgClient;
052import org.forgerock.opendj.server.config.meta.PluginCfgDefn.PluginType;
053import org.forgerock.opendj.server.config.server.LDAPAttributeDescriptionListPluginCfg;
054import org.forgerock.opendj.server.config.server.PluginCfg;
055
056
057
058/**
059 * An interface for querying the LDAP Attribute Description List
060 * Plugin managed object definition meta information.
061 * <p>
062 * The LDAP Attribute Description List Plugin provides the ability for
063 * clients to include an attribute list in a search request that names
064 * object classes instead of (or in addition to) attributes.
065 */
066public final class LDAPAttributeDescriptionListPluginCfgDefn extends ManagedObjectDefinition<LDAPAttributeDescriptionListPluginCfgClient, LDAPAttributeDescriptionListPluginCfg> {
067
068  /** The singleton configuration definition instance. */
069  private static final LDAPAttributeDescriptionListPluginCfgDefn INSTANCE = new LDAPAttributeDescriptionListPluginCfgDefn();
070
071
072
073  /** The "java-class" property definition. */
074  private static final ClassPropertyDefinition PD_JAVA_CLASS;
075
076
077
078  /** The "plugin-type" property definition. */
079  private static final EnumPropertyDefinition<PluginType> PD_PLUGIN_TYPE;
080
081
082
083  /** Build the "java-class" property definition. */
084  static {
085      ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
086      builder.setOption(PropertyOption.MANDATORY);
087      builder.setOption(PropertyOption.ADVANCED);
088      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class"));
089      DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.plugins.LDAPADListPlugin");
090      builder.setDefaultBehaviorProvider(provider);
091      builder.addInstanceOf("org.opends.server.api.plugin.DirectoryServerPlugin");
092      PD_JAVA_CLASS = builder.getInstance();
093      INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
094  }
095
096
097
098  /** Build the "plugin-type" property definition. */
099  static {
100      EnumPropertyDefinition.Builder<PluginType> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "plugin-type");
101      builder.setOption(PropertyOption.MULTI_VALUED);
102      builder.setOption(PropertyOption.MANDATORY);
103      builder.setOption(PropertyOption.ADVANCED);
104      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "plugin-type"));
105      DefaultBehaviorProvider<PluginType> provider = new DefinedDefaultBehaviorProvider<PluginType>("preparsesearch");
106      builder.setDefaultBehaviorProvider(provider);
107      builder.setEnumClass(PluginType.class);
108      PD_PLUGIN_TYPE = builder.getInstance();
109      INSTANCE.registerPropertyDefinition(PD_PLUGIN_TYPE);
110  }
111
112
113
114  // Register the tags associated with this managed object definition.
115  static {
116    INSTANCE.registerTag(Tag.valueOf("core-server"));
117  }
118
119
120
121  /**
122   * Get the LDAP Attribute Description List Plugin configuration
123   * definition singleton.
124   *
125   * @return Returns the LDAP Attribute Description List Plugin
126   *         configuration definition singleton.
127   */
128  public static LDAPAttributeDescriptionListPluginCfgDefn getInstance() {
129    return INSTANCE;
130  }
131
132
133
134  /**
135   * Private constructor.
136   */
137  private LDAPAttributeDescriptionListPluginCfgDefn() {
138    super("ldap-attribute-description-list-plugin", PluginCfgDefn.getInstance());
139  }
140
141
142
143  /** {@inheritDoc} */
144  public LDAPAttributeDescriptionListPluginCfgClient createClientConfiguration(
145      ManagedObject<? extends LDAPAttributeDescriptionListPluginCfgClient> impl) {
146    return new LDAPAttributeDescriptionListPluginCfgClientImpl(impl);
147  }
148
149
150
151  /** {@inheritDoc} */
152  public LDAPAttributeDescriptionListPluginCfg createServerConfiguration(
153      ServerManagedObject<? extends LDAPAttributeDescriptionListPluginCfg> impl) {
154    return new LDAPAttributeDescriptionListPluginCfgServerImpl(impl);
155  }
156
157
158
159  /** {@inheritDoc} */
160  public Class<LDAPAttributeDescriptionListPluginCfg> getServerConfigurationClass() {
161    return LDAPAttributeDescriptionListPluginCfg.class;
162  }
163
164
165
166  /**
167   * Get the "enabled" property definition.
168   * <p>
169   * Indicates whether the plug-in is enabled for use.
170   *
171   * @return Returns the "enabled" property definition.
172   */
173  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
174    return PluginCfgDefn.getInstance().getEnabledPropertyDefinition();
175  }
176
177
178
179  /**
180   * Get the "invoke-for-internal-operations" property definition.
181   * <p>
182   * Indicates whether the plug-in should be invoked for internal
183   * operations.
184   * <p>
185   * Any plug-in that can be invoked for internal operations must
186   * ensure that it does not create any new internal operatons that can
187   * cause the same plug-in to be re-invoked.
188   *
189   * @return Returns the "invoke-for-internal-operations" property definition.
190   */
191  public BooleanPropertyDefinition getInvokeForInternalOperationsPropertyDefinition() {
192    return PluginCfgDefn.getInstance().getInvokeForInternalOperationsPropertyDefinition();
193  }
194
195
196
197  /**
198   * Get the "java-class" property definition.
199   * <p>
200   * Specifies the fully-qualified name of the Java class that
201   * provides the plug-in implementation.
202   *
203   * @return Returns the "java-class" property definition.
204   */
205  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
206    return PD_JAVA_CLASS;
207  }
208
209
210
211  /**
212   * Get the "plugin-type" property definition.
213   * <p>
214   * Specifies the set of plug-in types for the plug-in, which
215   * specifies the times at which the plug-in is invoked.
216   *
217   * @return Returns the "plugin-type" property definition.
218   */
219  public EnumPropertyDefinition<PluginType> getPluginTypePropertyDefinition() {
220    return PD_PLUGIN_TYPE;
221  }
222
223
224
225  /**
226   * Managed object client implementation.
227   */
228  private static class LDAPAttributeDescriptionListPluginCfgClientImpl implements
229    LDAPAttributeDescriptionListPluginCfgClient {
230
231    /** Private implementation. */
232    private ManagedObject<? extends LDAPAttributeDescriptionListPluginCfgClient> impl;
233
234
235
236    /** Private constructor. */
237    private LDAPAttributeDescriptionListPluginCfgClientImpl(
238        ManagedObject<? extends LDAPAttributeDescriptionListPluginCfgClient> impl) {
239      this.impl = impl;
240    }
241
242
243
244    /** {@inheritDoc} */
245    public Boolean isEnabled() {
246      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
247    }
248
249
250
251    /** {@inheritDoc} */
252    public void setEnabled(boolean value) {
253      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
254    }
255
256
257
258    /** {@inheritDoc} */
259    public boolean isInvokeForInternalOperations() {
260      return impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition());
261    }
262
263
264
265    /** {@inheritDoc} */
266    public void setInvokeForInternalOperations(Boolean value) {
267      impl.setPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition(), value);
268    }
269
270
271
272    /** {@inheritDoc} */
273    public String getJavaClass() {
274      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
275    }
276
277
278
279    /** {@inheritDoc} */
280    public void setJavaClass(String value) {
281      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
282    }
283
284
285
286    /** {@inheritDoc} */
287    public SortedSet<PluginType> getPluginType() {
288      return impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition());
289    }
290
291
292
293    /** {@inheritDoc} */
294    public void setPluginType(Collection<PluginType> values) {
295      impl.setPropertyValues(INSTANCE.getPluginTypePropertyDefinition(), values);
296    }
297
298
299
300    /** {@inheritDoc} */
301    public ManagedObjectDefinition<? extends LDAPAttributeDescriptionListPluginCfgClient, ? extends LDAPAttributeDescriptionListPluginCfg> definition() {
302      return INSTANCE;
303    }
304
305
306
307    /** {@inheritDoc} */
308    public PropertyProvider properties() {
309      return impl;
310    }
311
312
313
314    /** {@inheritDoc} */
315    public void commit() throws ManagedObjectAlreadyExistsException,
316        MissingMandatoryPropertiesException, ConcurrentModificationException,
317        OperationRejectedException, LdapException {
318      impl.commit();
319    }
320
321
322
323    /** {@inheritDoc} */
324    public String toString() {
325      return impl.toString();
326    }
327  }
328
329
330
331  /**
332   * Managed object server implementation.
333   */
334  private static class LDAPAttributeDescriptionListPluginCfgServerImpl implements
335    LDAPAttributeDescriptionListPluginCfg {
336
337    /** Private implementation. */
338    private ServerManagedObject<? extends LDAPAttributeDescriptionListPluginCfg> impl;
339
340    /** The value of the "enabled" property. */
341    private final boolean pEnabled;
342
343    /** The value of the "invoke-for-internal-operations" property. */
344    private final boolean pInvokeForInternalOperations;
345
346    /** The value of the "java-class" property. */
347    private final String pJavaClass;
348
349    /** The value of the "plugin-type" property. */
350    private final SortedSet<PluginType> pPluginType;
351
352
353
354    /** Private constructor. */
355    private LDAPAttributeDescriptionListPluginCfgServerImpl(ServerManagedObject<? extends LDAPAttributeDescriptionListPluginCfg> impl) {
356      this.impl = impl;
357      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
358      this.pInvokeForInternalOperations = impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition());
359      this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
360      this.pPluginType = impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition());
361    }
362
363
364
365    /** {@inheritDoc} */
366    public void addLDAPAttributeDescriptionListChangeListener(
367        ConfigurationChangeListener<LDAPAttributeDescriptionListPluginCfg> listener) {
368      impl.registerChangeListener(listener);
369    }
370
371
372
373    /** {@inheritDoc} */
374    public void removeLDAPAttributeDescriptionListChangeListener(
375        ConfigurationChangeListener<LDAPAttributeDescriptionListPluginCfg> listener) {
376      impl.deregisterChangeListener(listener);
377    }
378    /** {@inheritDoc} */
379    public void addChangeListener(
380        ConfigurationChangeListener<PluginCfg> listener) {
381      impl.registerChangeListener(listener);
382    }
383
384
385
386    /** {@inheritDoc} */
387    public void removeChangeListener(
388        ConfigurationChangeListener<PluginCfg> listener) {
389      impl.deregisterChangeListener(listener);
390    }
391
392
393
394    /** {@inheritDoc} */
395    public boolean isEnabled() {
396      return pEnabled;
397    }
398
399
400
401    /** {@inheritDoc} */
402    public boolean isInvokeForInternalOperations() {
403      return pInvokeForInternalOperations;
404    }
405
406
407
408    /** {@inheritDoc} */
409    public String getJavaClass() {
410      return pJavaClass;
411    }
412
413
414
415    /** {@inheritDoc} */
416    public SortedSet<PluginType> getPluginType() {
417      return pPluginType;
418    }
419
420
421
422    /** {@inheritDoc} */
423    public Class<? extends LDAPAttributeDescriptionListPluginCfg> configurationClass() {
424      return LDAPAttributeDescriptionListPluginCfg.class;
425    }
426
427
428
429    /** {@inheritDoc} */
430    public DN dn() {
431      return impl.getDN();
432    }
433
434
435
436    /** {@inheritDoc} */
437    public String toString() {
438      return impl.toString();
439    }
440  }
441}