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