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.AttributeTypePropertyDefinition;
034import org.forgerock.opendj.config.BooleanPropertyDefinition;
035import org.forgerock.opendj.config.ClassPropertyDefinition;
036import org.forgerock.opendj.config.client.ConcurrentModificationException;
037import org.forgerock.opendj.config.client.ManagedObject;
038import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException;
039import org.forgerock.opendj.config.client.OperationRejectedException;
040import org.forgerock.opendj.config.DefaultBehaviorProvider;
041import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider;
042import org.forgerock.opendj.config.DNPropertyDefinition;
043import org.forgerock.opendj.config.EnumPropertyDefinition;
044import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException;
045import org.forgerock.opendj.config.ManagedObjectDefinition;
046import org.forgerock.opendj.config.PropertyOption;
047import org.forgerock.opendj.config.PropertyProvider;
048import org.forgerock.opendj.config.server.ConfigurationChangeListener;
049import org.forgerock.opendj.config.server.ServerManagedObject;
050import org.forgerock.opendj.config.StringPropertyDefinition;
051import org.forgerock.opendj.config.Tag;
052import org.forgerock.opendj.ldap.DN;
053import org.forgerock.opendj.ldap.LdapException;
054import org.forgerock.opendj.ldap.schema.AttributeType;
055import org.forgerock.opendj.server.config.client.HasSubordinatesVirtualAttributeCfgClient;
056import org.forgerock.opendj.server.config.meta.VirtualAttributeCfgDefn.ConflictBehavior;
057import org.forgerock.opendj.server.config.meta.VirtualAttributeCfgDefn.Scope;
058import org.forgerock.opendj.server.config.server.HasSubordinatesVirtualAttributeCfg;
059import org.forgerock.opendj.server.config.server.VirtualAttributeCfg;
060
061
062
063/**
064 * An interface for querying the Has Subordinates Virtual Attribute
065 * managed object definition meta information.
066 * <p>
067 * The Has Subordinates Virtual Attribute generates a virtual
068 * attribute that indicates whether the entry has any subordinate
069 * entries.
070 */
071public final class HasSubordinatesVirtualAttributeCfgDefn extends ManagedObjectDefinition<HasSubordinatesVirtualAttributeCfgClient, HasSubordinatesVirtualAttributeCfg> {
072
073  /** The singleton configuration definition instance. */
074  private static final HasSubordinatesVirtualAttributeCfgDefn INSTANCE = new HasSubordinatesVirtualAttributeCfgDefn();
075
076
077
078  /** The "attribute-type" property definition. */
079  private static final AttributeTypePropertyDefinition PD_ATTRIBUTE_TYPE;
080
081
082
083  /** The "conflict-behavior" property definition. */
084  private static final EnumPropertyDefinition<ConflictBehavior> PD_CONFLICT_BEHAVIOR;
085
086
087
088  /** The "java-class" property definition. */
089  private static final ClassPropertyDefinition PD_JAVA_CLASS;
090
091
092
093  /** Build the "attribute-type" property definition. */
094  static {
095      AttributeTypePropertyDefinition.Builder builder = AttributeTypePropertyDefinition.createBuilder(INSTANCE, "attribute-type");
096      builder.setOption(PropertyOption.MANDATORY);
097      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "attribute-type"));
098      DefaultBehaviorProvider<AttributeType> provider = new DefinedDefaultBehaviorProvider<AttributeType>("hasSubordinates");
099      builder.setDefaultBehaviorProvider(provider);
100      PD_ATTRIBUTE_TYPE = builder.getInstance();
101      INSTANCE.registerPropertyDefinition(PD_ATTRIBUTE_TYPE);
102  }
103
104
105
106  /** Build the "conflict-behavior" property definition. */
107  static {
108      EnumPropertyDefinition.Builder<ConflictBehavior> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "conflict-behavior");
109      builder.setOption(PropertyOption.ADVANCED);
110      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "conflict-behavior"));
111      DefaultBehaviorProvider<ConflictBehavior> provider = new DefinedDefaultBehaviorProvider<ConflictBehavior>("virtual-overrides-real");
112      builder.setDefaultBehaviorProvider(provider);
113      builder.setEnumClass(ConflictBehavior.class);
114      PD_CONFLICT_BEHAVIOR = builder.getInstance();
115      INSTANCE.registerPropertyDefinition(PD_CONFLICT_BEHAVIOR);
116  }
117
118
119
120  /** Build the "java-class" property definition. */
121  static {
122      ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
123      builder.setOption(PropertyOption.MANDATORY);
124      builder.setOption(PropertyOption.ADVANCED);
125      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class"));
126      DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.HasSubordinatesVirtualAttributeProvider");
127      builder.setDefaultBehaviorProvider(provider);
128      builder.addInstanceOf("org.opends.server.api.VirtualAttributeProvider");
129      PD_JAVA_CLASS = builder.getInstance();
130      INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
131  }
132
133
134
135  // Register the tags associated with this managed object definition.
136  static {
137    INSTANCE.registerTag(Tag.valueOf("core-server"));
138  }
139
140
141
142  /**
143   * Get the Has Subordinates Virtual Attribute configuration
144   * definition singleton.
145   *
146   * @return Returns the Has Subordinates Virtual Attribute
147   *         configuration definition singleton.
148   */
149  public static HasSubordinatesVirtualAttributeCfgDefn getInstance() {
150    return INSTANCE;
151  }
152
153
154
155  /**
156   * Private constructor.
157   */
158  private HasSubordinatesVirtualAttributeCfgDefn() {
159    super("has-subordinates-virtual-attribute", VirtualAttributeCfgDefn.getInstance());
160  }
161
162
163
164  /** {@inheritDoc} */
165  public HasSubordinatesVirtualAttributeCfgClient createClientConfiguration(
166      ManagedObject<? extends HasSubordinatesVirtualAttributeCfgClient> impl) {
167    return new HasSubordinatesVirtualAttributeCfgClientImpl(impl);
168  }
169
170
171
172  /** {@inheritDoc} */
173  public HasSubordinatesVirtualAttributeCfg createServerConfiguration(
174      ServerManagedObject<? extends HasSubordinatesVirtualAttributeCfg> impl) {
175    return new HasSubordinatesVirtualAttributeCfgServerImpl(impl);
176  }
177
178
179
180  /** {@inheritDoc} */
181  public Class<HasSubordinatesVirtualAttributeCfg> getServerConfigurationClass() {
182    return HasSubordinatesVirtualAttributeCfg.class;
183  }
184
185
186
187  /**
188   * Get the "attribute-type" property definition.
189   * <p>
190   * Specifies the attribute type for the attribute whose values are
191   * to be dynamically assigned by the virtual attribute.
192   *
193   * @return Returns the "attribute-type" property definition.
194   */
195  public AttributeTypePropertyDefinition getAttributeTypePropertyDefinition() {
196    return PD_ATTRIBUTE_TYPE;
197  }
198
199
200
201  /**
202   * Get the "base-dn" property definition.
203   * <p>
204   * Specifies the base DNs for the branches containing entries that
205   * are eligible to use this virtual attribute.
206   * <p>
207   * If no values are given, then the server generates virtual
208   * attributes anywhere in the server.
209   *
210   * @return Returns the "base-dn" property definition.
211   */
212  public DNPropertyDefinition getBaseDNPropertyDefinition() {
213    return VirtualAttributeCfgDefn.getInstance().getBaseDNPropertyDefinition();
214  }
215
216
217
218  /**
219   * Get the "conflict-behavior" property definition.
220   * <p>
221   * Specifies the behavior that the server is to exhibit for entries
222   * that already contain one or more real values for the associated
223   * attribute.
224   *
225   * @return Returns the "conflict-behavior" property definition.
226   */
227  public EnumPropertyDefinition<ConflictBehavior> getConflictBehaviorPropertyDefinition() {
228    return PD_CONFLICT_BEHAVIOR;
229  }
230
231
232
233  /**
234   * Get the "enabled" property definition.
235   * <p>
236   * Indicates whether the Has Subordinates Virtual Attribute is
237   * enabled for use.
238   *
239   * @return Returns the "enabled" property definition.
240   */
241  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
242    return VirtualAttributeCfgDefn.getInstance().getEnabledPropertyDefinition();
243  }
244
245
246
247  /**
248   * Get the "filter" property definition.
249   * <p>
250   * Specifies the search filters to be applied against entries to
251   * determine if the virtual attribute is to be generated for those
252   * entries.
253   * <p>
254   * If no values are given, then any entry is eligible to have the
255   * value generated. If one or more filters are specified, then only
256   * entries that match at least one of those filters are allowed to
257   * have the virtual attribute.
258   *
259   * @return Returns the "filter" property definition.
260   */
261  public StringPropertyDefinition getFilterPropertyDefinition() {
262    return VirtualAttributeCfgDefn.getInstance().getFilterPropertyDefinition();
263  }
264
265
266
267  /**
268   * Get the "group-dn" property definition.
269   * <p>
270   * Specifies the DNs of the groups whose members can be eligible to
271   * use this virtual attribute.
272   * <p>
273   * If no values are given, then group membership is not taken into
274   * account when generating the virtual attribute. If one or more
275   * group DNs are specified, then only members of those groups are
276   * allowed to have the virtual attribute.
277   *
278   * @return Returns the "group-dn" property definition.
279   */
280  public DNPropertyDefinition getGroupDNPropertyDefinition() {
281    return VirtualAttributeCfgDefn.getInstance().getGroupDNPropertyDefinition();
282  }
283
284
285
286  /**
287   * Get the "java-class" property definition.
288   * <p>
289   * Specifies the fully-qualified name of the virtual attribute
290   * provider class that generates the attribute values.
291   *
292   * @return Returns the "java-class" property definition.
293   */
294  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
295    return PD_JAVA_CLASS;
296  }
297
298
299
300  /**
301   * Get the "scope" property definition.
302   * <p>
303   * Specifies the LDAP scope associated with base DNs for entries
304   * that are eligible to use this virtual attribute.
305   *
306   * @return Returns the "scope" property definition.
307   */
308  public EnumPropertyDefinition<Scope> getScopePropertyDefinition() {
309    return VirtualAttributeCfgDefn.getInstance().getScopePropertyDefinition();
310  }
311
312
313
314  /**
315   * Managed object client implementation.
316   */
317  private static class HasSubordinatesVirtualAttributeCfgClientImpl implements
318    HasSubordinatesVirtualAttributeCfgClient {
319
320    /** Private implementation. */
321    private ManagedObject<? extends HasSubordinatesVirtualAttributeCfgClient> impl;
322
323
324
325    /** Private constructor. */
326    private HasSubordinatesVirtualAttributeCfgClientImpl(
327        ManagedObject<? extends HasSubordinatesVirtualAttributeCfgClient> impl) {
328      this.impl = impl;
329    }
330
331
332
333    /** {@inheritDoc} */
334    public AttributeType getAttributeType() {
335      return impl.getPropertyValue(INSTANCE.getAttributeTypePropertyDefinition());
336    }
337
338
339
340    /** {@inheritDoc} */
341    public void setAttributeType(AttributeType value) {
342      impl.setPropertyValue(INSTANCE.getAttributeTypePropertyDefinition(), value);
343    }
344
345
346
347    /** {@inheritDoc} */
348    public SortedSet<DN> getBaseDN() {
349      return impl.getPropertyValues(INSTANCE.getBaseDNPropertyDefinition());
350    }
351
352
353
354    /** {@inheritDoc} */
355    public void setBaseDN(Collection<DN> values) {
356      impl.setPropertyValues(INSTANCE.getBaseDNPropertyDefinition(), values);
357    }
358
359
360
361    /** {@inheritDoc} */
362    public ConflictBehavior getConflictBehavior() {
363      return impl.getPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition());
364    }
365
366
367
368    /** {@inheritDoc} */
369    public void setConflictBehavior(ConflictBehavior value) {
370      impl.setPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition(), value);
371    }
372
373
374
375    /** {@inheritDoc} */
376    public Boolean isEnabled() {
377      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
378    }
379
380
381
382    /** {@inheritDoc} */
383    public void setEnabled(boolean value) {
384      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
385    }
386
387
388
389    /** {@inheritDoc} */
390    public SortedSet<String> getFilter() {
391      return impl.getPropertyValues(INSTANCE.getFilterPropertyDefinition());
392    }
393
394
395
396    /** {@inheritDoc} */
397    public void setFilter(Collection<String> values) {
398      impl.setPropertyValues(INSTANCE.getFilterPropertyDefinition(), values);
399    }
400
401
402
403    /** {@inheritDoc} */
404    public SortedSet<DN> getGroupDN() {
405      return impl.getPropertyValues(INSTANCE.getGroupDNPropertyDefinition());
406    }
407
408
409
410    /** {@inheritDoc} */
411    public void setGroupDN(Collection<DN> values) {
412      impl.setPropertyValues(INSTANCE.getGroupDNPropertyDefinition(), values);
413    }
414
415
416
417    /** {@inheritDoc} */
418    public String getJavaClass() {
419      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
420    }
421
422
423
424    /** {@inheritDoc} */
425    public void setJavaClass(String value) {
426      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
427    }
428
429
430
431    /** {@inheritDoc} */
432    public Scope getScope() {
433      return impl.getPropertyValue(INSTANCE.getScopePropertyDefinition());
434    }
435
436
437
438    /** {@inheritDoc} */
439    public void setScope(Scope value) {
440      impl.setPropertyValue(INSTANCE.getScopePropertyDefinition(), value);
441    }
442
443
444
445    /** {@inheritDoc} */
446    public ManagedObjectDefinition<? extends HasSubordinatesVirtualAttributeCfgClient, ? extends HasSubordinatesVirtualAttributeCfg> definition() {
447      return INSTANCE;
448    }
449
450
451
452    /** {@inheritDoc} */
453    public PropertyProvider properties() {
454      return impl;
455    }
456
457
458
459    /** {@inheritDoc} */
460    public void commit() throws ManagedObjectAlreadyExistsException,
461        MissingMandatoryPropertiesException, ConcurrentModificationException,
462        OperationRejectedException, LdapException {
463      impl.commit();
464    }
465
466
467
468    /** {@inheritDoc} */
469    public String toString() {
470      return impl.toString();
471    }
472  }
473
474
475
476  /**
477   * Managed object server implementation.
478   */
479  private static class HasSubordinatesVirtualAttributeCfgServerImpl implements
480    HasSubordinatesVirtualAttributeCfg {
481
482    /** Private implementation. */
483    private ServerManagedObject<? extends HasSubordinatesVirtualAttributeCfg> impl;
484
485    /** The value of the "attribute-type" property. */
486    private final AttributeType pAttributeType;
487
488    /** The value of the "base-dn" property. */
489    private final SortedSet<DN> pBaseDN;
490
491    /** The value of the "conflict-behavior" property. */
492    private final ConflictBehavior pConflictBehavior;
493
494    /** The value of the "enabled" property. */
495    private final boolean pEnabled;
496
497    /** The value of the "filter" property. */
498    private final SortedSet<String> pFilter;
499
500    /** The value of the "group-dn" property. */
501    private final SortedSet<DN> pGroupDN;
502
503    /** The value of the "java-class" property. */
504    private final String pJavaClass;
505
506    /** The value of the "scope" property. */
507    private final Scope pScope;
508
509
510
511    /** Private constructor. */
512    private HasSubordinatesVirtualAttributeCfgServerImpl(ServerManagedObject<? extends HasSubordinatesVirtualAttributeCfg> impl) {
513      this.impl = impl;
514      this.pAttributeType = impl.getPropertyValue(INSTANCE.getAttributeTypePropertyDefinition());
515      this.pBaseDN = impl.getPropertyValues(INSTANCE.getBaseDNPropertyDefinition());
516      this.pConflictBehavior = impl.getPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition());
517      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
518      this.pFilter = impl.getPropertyValues(INSTANCE.getFilterPropertyDefinition());
519      this.pGroupDN = impl.getPropertyValues(INSTANCE.getGroupDNPropertyDefinition());
520      this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
521      this.pScope = impl.getPropertyValue(INSTANCE.getScopePropertyDefinition());
522    }
523
524
525
526    /** {@inheritDoc} */
527    public void addHasSubordinatesChangeListener(
528        ConfigurationChangeListener<HasSubordinatesVirtualAttributeCfg> listener) {
529      impl.registerChangeListener(listener);
530    }
531
532
533
534    /** {@inheritDoc} */
535    public void removeHasSubordinatesChangeListener(
536        ConfigurationChangeListener<HasSubordinatesVirtualAttributeCfg> listener) {
537      impl.deregisterChangeListener(listener);
538    }
539    /** {@inheritDoc} */
540    public void addChangeListener(
541        ConfigurationChangeListener<VirtualAttributeCfg> listener) {
542      impl.registerChangeListener(listener);
543    }
544
545
546
547    /** {@inheritDoc} */
548    public void removeChangeListener(
549        ConfigurationChangeListener<VirtualAttributeCfg> listener) {
550      impl.deregisterChangeListener(listener);
551    }
552
553
554
555    /** {@inheritDoc} */
556    public AttributeType getAttributeType() {
557      return pAttributeType;
558    }
559
560
561
562    /** {@inheritDoc} */
563    public SortedSet<DN> getBaseDN() {
564      return pBaseDN;
565    }
566
567
568
569    /** {@inheritDoc} */
570    public ConflictBehavior getConflictBehavior() {
571      return pConflictBehavior;
572    }
573
574
575
576    /** {@inheritDoc} */
577    public boolean isEnabled() {
578      return pEnabled;
579    }
580
581
582
583    /** {@inheritDoc} */
584    public SortedSet<String> getFilter() {
585      return pFilter;
586    }
587
588
589
590    /** {@inheritDoc} */
591    public SortedSet<DN> getGroupDN() {
592      return pGroupDN;
593    }
594
595
596
597    /** {@inheritDoc} */
598    public String getJavaClass() {
599      return pJavaClass;
600    }
601
602
603
604    /** {@inheritDoc} */
605    public Scope getScope() {
606      return pScope;
607    }
608
609
610
611    /** {@inheritDoc} */
612    public Class<? extends HasSubordinatesVirtualAttributeCfg> configurationClass() {
613      return HasSubordinatesVirtualAttributeCfg.class;
614    }
615
616
617
618    /** {@inheritDoc} */
619    public DN dn() {
620      return impl.getDN();
621    }
622
623
624
625    /** {@inheritDoc} */
626    public String toString() {
627      return impl.toString();
628    }
629  }
630}