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