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 org.opends.server.admin.AdministratorAction;
032    import org.opends.server.admin.BooleanPropertyDefinition;
033    import org.opends.server.admin.ClassPropertyDefinition;
034    import org.opends.server.admin.client.AuthorizationException;
035    import org.opends.server.admin.client.CommunicationException;
036    import org.opends.server.admin.client.ConcurrentModificationException;
037    import org.opends.server.admin.client.ManagedObject;
038    import org.opends.server.admin.client.MissingMandatoryPropertiesException;
039    import org.opends.server.admin.client.OperationRejectedException;
040    import org.opends.server.admin.DefaultBehaviorProvider;
041    import org.opends.server.admin.DefinedDefaultBehaviorProvider;
042    import org.opends.server.admin.ManagedObjectAlreadyExistsException;
043    import org.opends.server.admin.ManagedObjectDefinition;
044    import org.opends.server.admin.PropertyIsReadOnlyException;
045    import org.opends.server.admin.PropertyOption;
046    import org.opends.server.admin.PropertyProvider;
047    import org.opends.server.admin.server.ConfigurationChangeListener;
048    import org.opends.server.admin.server.ServerManagedObject;
049    import org.opends.server.admin.std.client.TelephoneNumberAttributeSyntaxCfgClient;
050    import org.opends.server.admin.std.server.AttributeSyntaxCfg;
051    import org.opends.server.admin.std.server.TelephoneNumberAttributeSyntaxCfg;
052    import org.opends.server.admin.Tag;
053    import org.opends.server.types.DN;
054    
055    
056    
057    /**
058     * An interface for querying the Telephone Number Attribute Syntax
059     * managed object definition meta information.
060     * <p>
061     * Telephone Number Attribute Syntaxes define an attribute syntax for
062     * storing telephone number information.
063     */
064    public final class TelephoneNumberAttributeSyntaxCfgDefn extends ManagedObjectDefinition<TelephoneNumberAttributeSyntaxCfgClient, TelephoneNumberAttributeSyntaxCfg> {
065    
066      // The singleton configuration definition instance.
067      private static final TelephoneNumberAttributeSyntaxCfgDefn INSTANCE = new TelephoneNumberAttributeSyntaxCfgDefn();
068    
069    
070    
071      // The "java-class" property definition.
072      private static final ClassPropertyDefinition PD_JAVA_CLASS;
073    
074    
075    
076      // The "strict-format" property definition.
077      private static final BooleanPropertyDefinition PD_STRICT_FORMAT;
078    
079    
080    
081      // Build the "java-class" property definition.
082      static {
083          ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
084          builder.setOption(PropertyOption.READ_ONLY);
085          builder.setOption(PropertyOption.MANDATORY);
086          builder.setOption(PropertyOption.ADVANCED);
087          builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class"));
088          DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.schema.TelephoneNumberSyntax");
089          builder.setDefaultBehaviorProvider(provider);
090          builder.addInstanceOf("org.opends.server.api.AttributeSyntax");
091          PD_JAVA_CLASS = builder.getInstance();
092          INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
093      }
094    
095    
096    
097      // Build the "strict-format" property definition.
098      static {
099          BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "strict-format");
100          builder.setOption(PropertyOption.ADVANCED);
101          builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "strict-format"));
102          DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false");
103          builder.setDefaultBehaviorProvider(provider);
104          PD_STRICT_FORMAT = builder.getInstance();
105          INSTANCE.registerPropertyDefinition(PD_STRICT_FORMAT);
106      }
107    
108    
109    
110      // Register the tags associated with this managed object definition.
111      static {
112        INSTANCE.registerTag(Tag.valueOf("core-server"));
113      }
114    
115    
116    
117      /**
118       * Get the Telephone Number Attribute Syntax configuration
119       * definition singleton.
120       *
121       * @return Returns the Telephone Number Attribute Syntax
122       *         configuration definition singleton.
123       */
124      public static TelephoneNumberAttributeSyntaxCfgDefn getInstance() {
125        return INSTANCE;
126      }
127    
128    
129    
130      /**
131       * Private constructor.
132       */
133      private TelephoneNumberAttributeSyntaxCfgDefn() {
134        super("telephone-number-attribute-syntax", AttributeSyntaxCfgDefn.getInstance());
135      }
136    
137    
138    
139      /**
140       * {@inheritDoc}
141       */
142      public TelephoneNumberAttributeSyntaxCfgClient createClientConfiguration(
143          ManagedObject<? extends TelephoneNumberAttributeSyntaxCfgClient> impl) {
144        return new TelephoneNumberAttributeSyntaxCfgClientImpl(impl);
145      }
146    
147    
148    
149      /**
150       * {@inheritDoc}
151       */
152      public TelephoneNumberAttributeSyntaxCfg createServerConfiguration(
153          ServerManagedObject<? extends TelephoneNumberAttributeSyntaxCfg> impl) {
154        return new TelephoneNumberAttributeSyntaxCfgServerImpl(impl);
155      }
156    
157    
158    
159      /**
160       * {@inheritDoc}
161       */
162      public Class<TelephoneNumberAttributeSyntaxCfg> getServerConfigurationClass() {
163        return TelephoneNumberAttributeSyntaxCfg.class;
164      }
165    
166    
167    
168      /**
169       * Get the "enabled" property definition.
170       * <p>
171       * Indicates whether the Telephone Number Attribute Syntax is
172       * enabled.
173       *
174       * @return Returns the "enabled" property definition.
175       */
176      public BooleanPropertyDefinition getEnabledPropertyDefinition() {
177        return AttributeSyntaxCfgDefn.getInstance().getEnabledPropertyDefinition();
178      }
179    
180    
181    
182      /**
183       * Get the "java-class" property definition.
184       * <p>
185       * Specifies the fully-qualified name of the Java class that
186       * provides the Telephone Number Attribute Syntax implementation.
187       *
188       * @return Returns the "java-class" property definition.
189       */
190      public ClassPropertyDefinition getJavaClassPropertyDefinition() {
191        return PD_JAVA_CLASS;
192      }
193    
194    
195    
196      /**
197       * Get the "strict-format" property definition.
198       * <p>
199       * Indicates whether to require telephone number values to strictly
200       * comply with the standard definition for this syntax.
201       *
202       * @return Returns the "strict-format" property definition.
203       */
204      public BooleanPropertyDefinition getStrictFormatPropertyDefinition() {
205        return PD_STRICT_FORMAT;
206      }
207    
208    
209    
210      /**
211       * Managed object client implementation.
212       */
213      private static class TelephoneNumberAttributeSyntaxCfgClientImpl implements
214        TelephoneNumberAttributeSyntaxCfgClient {
215    
216        // Private implementation.
217        private ManagedObject<? extends TelephoneNumberAttributeSyntaxCfgClient> impl;
218    
219    
220    
221        // Private constructor.
222        private TelephoneNumberAttributeSyntaxCfgClientImpl(
223            ManagedObject<? extends TelephoneNumberAttributeSyntaxCfgClient> impl) {
224          this.impl = impl;
225        }
226    
227    
228    
229        /**
230         * {@inheritDoc}
231         */
232        public Boolean isEnabled() {
233          return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
234        }
235    
236    
237    
238        /**
239         * {@inheritDoc}
240         */
241        public void setEnabled(boolean value) {
242          impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
243        }
244    
245    
246    
247        /**
248         * {@inheritDoc}
249         */
250        public String getJavaClass() {
251          return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
252        }
253    
254    
255    
256        /**
257         * {@inheritDoc}
258         */
259        public void setJavaClass(String value) throws PropertyIsReadOnlyException {
260          impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
261        }
262    
263    
264    
265        /**
266         * {@inheritDoc}
267         */
268        public boolean isStrictFormat() {
269          return impl.getPropertyValue(INSTANCE.getStrictFormatPropertyDefinition());
270        }
271    
272    
273    
274        /**
275         * {@inheritDoc}
276         */
277        public void setStrictFormat(Boolean value) {
278          impl.setPropertyValue(INSTANCE.getStrictFormatPropertyDefinition(), value);
279        }
280    
281    
282    
283        /**
284         * {@inheritDoc}
285         */
286        public ManagedObjectDefinition<? extends TelephoneNumberAttributeSyntaxCfgClient, ? extends TelephoneNumberAttributeSyntaxCfg> definition() {
287          return INSTANCE;
288        }
289    
290    
291    
292        /**
293         * {@inheritDoc}
294         */
295        public PropertyProvider properties() {
296          return impl;
297        }
298    
299    
300    
301        /**
302         * {@inheritDoc}
303         */
304        public void commit() throws ManagedObjectAlreadyExistsException,
305            MissingMandatoryPropertiesException, ConcurrentModificationException,
306            OperationRejectedException, AuthorizationException,
307            CommunicationException {
308          impl.commit();
309        }
310    
311      }
312    
313    
314    
315      /**
316       * Managed object server implementation.
317       */
318      private static class TelephoneNumberAttributeSyntaxCfgServerImpl implements
319        TelephoneNumberAttributeSyntaxCfg {
320    
321        // Private implementation.
322        private ServerManagedObject<? extends TelephoneNumberAttributeSyntaxCfg> impl;
323    
324        // The value of the "enabled" property.
325        private final boolean pEnabled;
326    
327        // The value of the "java-class" property.
328        private final String pJavaClass;
329    
330        // The value of the "strict-format" property.
331        private final boolean pStrictFormat;
332    
333    
334    
335        // Private constructor.
336        private TelephoneNumberAttributeSyntaxCfgServerImpl(ServerManagedObject<? extends TelephoneNumberAttributeSyntaxCfg> impl) {
337          this.impl = impl;
338          this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
339          this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
340          this.pStrictFormat = impl.getPropertyValue(INSTANCE.getStrictFormatPropertyDefinition());
341        }
342    
343    
344    
345        /**
346         * {@inheritDoc}
347         */
348        public void addTelephoneNumberChangeListener(
349            ConfigurationChangeListener<TelephoneNumberAttributeSyntaxCfg> listener) {
350          impl.registerChangeListener(listener);
351        }
352    
353    
354    
355        /**
356         * {@inheritDoc}
357         */
358        public void removeTelephoneNumberChangeListener(
359            ConfigurationChangeListener<TelephoneNumberAttributeSyntaxCfg> listener) {
360          impl.deregisterChangeListener(listener);
361        }
362        /**
363         * {@inheritDoc}
364         */
365        public void addChangeListener(
366            ConfigurationChangeListener<AttributeSyntaxCfg> listener) {
367          impl.registerChangeListener(listener);
368        }
369    
370    
371    
372        /**
373         * {@inheritDoc}
374         */
375        public void removeChangeListener(
376            ConfigurationChangeListener<AttributeSyntaxCfg> listener) {
377          impl.deregisterChangeListener(listener);
378        }
379    
380    
381    
382        /**
383         * {@inheritDoc}
384         */
385        public boolean isEnabled() {
386          return pEnabled;
387        }
388    
389    
390    
391        /**
392         * {@inheritDoc}
393         */
394        public String getJavaClass() {
395          return pJavaClass;
396        }
397    
398    
399    
400        /**
401         * {@inheritDoc}
402         */
403        public boolean isStrictFormat() {
404          return pStrictFormat;
405        }
406    
407    
408    
409        /**
410         * {@inheritDoc}
411         */
412        public Class<? extends TelephoneNumberAttributeSyntaxCfg> configurationClass() {
413          return TelephoneNumberAttributeSyntaxCfg.class;
414        }
415    
416    
417    
418        /**
419         * {@inheritDoc}
420         */
421        public DN dn() {
422          return impl.getDN();
423        }
424    
425      }
426    }