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