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