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