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