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