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.JPEGAttributeSyntaxCfgClient;
050import org.forgerock.opendj.server.config.server.AttributeSyntaxCfg;
051import org.forgerock.opendj.server.config.server.JPEGAttributeSyntaxCfg;
052
053
054
055/**
056 * An interface for querying the JPEG Attribute Syntax managed object
057 * definition meta information.
058 * <p>
059 * JPEG Attribute Syntaxes define an attribute syntax for storing JPEG
060 * information.
061 */
062public final class JPEGAttributeSyntaxCfgDefn extends ManagedObjectDefinition<JPEGAttributeSyntaxCfgClient, JPEGAttributeSyntaxCfg> {
063
064  /** The singleton configuration definition instance. */
065  private static final JPEGAttributeSyntaxCfgDefn INSTANCE = new JPEGAttributeSyntaxCfgDefn();
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.JPEGSyntax");
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 JPEG Attribute Syntax configuration definition singleton.
117   *
118   * @return Returns the JPEG Attribute Syntax configuration
119   *         definition singleton.
120   */
121  public static JPEGAttributeSyntaxCfgDefn getInstance() {
122    return INSTANCE;
123  }
124
125
126
127  /**
128   * Private constructor.
129   */
130  private JPEGAttributeSyntaxCfgDefn() {
131    super("jpeg-attribute-syntax", AttributeSyntaxCfgDefn.getInstance());
132  }
133
134
135
136  /** {@inheritDoc} */
137  public JPEGAttributeSyntaxCfgClient createClientConfiguration(
138      ManagedObject<? extends JPEGAttributeSyntaxCfgClient> impl) {
139    return new JPEGAttributeSyntaxCfgClientImpl(impl);
140  }
141
142
143
144  /** {@inheritDoc} */
145  public JPEGAttributeSyntaxCfg createServerConfiguration(
146      ServerManagedObject<? extends JPEGAttributeSyntaxCfg> impl) {
147    return new JPEGAttributeSyntaxCfgServerImpl(impl);
148  }
149
150
151
152  /** {@inheritDoc} */
153  public Class<JPEGAttributeSyntaxCfg> getServerConfigurationClass() {
154    return JPEGAttributeSyntaxCfg.class;
155  }
156
157
158
159  /**
160   * Get the "enabled" property definition.
161   * <p>
162   * Indicates whether the JPEG Attribute Syntax is enabled.
163   *
164   * @return Returns the "enabled" property definition.
165   */
166  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
167    return AttributeSyntaxCfgDefn.getInstance().getEnabledPropertyDefinition();
168  }
169
170
171
172  /**
173   * Get the "java-class" property definition.
174   * <p>
175   * Specifies the fully-qualified name of the Java class that
176   * provides the JPEG Attribute Syntax implementation.
177   *
178   * @return Returns the "java-class" property definition.
179   */
180  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
181    return PD_JAVA_CLASS;
182  }
183
184
185
186  /**
187   * Get the "strict-format" property definition.
188   * <p>
189   * Indicates whether to require JPEG values to strictly comply with
190   * the standard definition for this syntax.
191   *
192   * @return Returns the "strict-format" property definition.
193   */
194  public BooleanPropertyDefinition getStrictFormatPropertyDefinition() {
195    return PD_STRICT_FORMAT;
196  }
197
198
199
200  /**
201   * Managed object client implementation.
202   */
203  private static class JPEGAttributeSyntaxCfgClientImpl implements
204    JPEGAttributeSyntaxCfgClient {
205
206    /** Private implementation. */
207    private ManagedObject<? extends JPEGAttributeSyntaxCfgClient> impl;
208
209
210
211    /** Private constructor. */
212    private JPEGAttributeSyntaxCfgClientImpl(
213        ManagedObject<? extends JPEGAttributeSyntaxCfgClient> impl) {
214      this.impl = impl;
215    }
216
217
218
219    /** {@inheritDoc} */
220    public Boolean isEnabled() {
221      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
222    }
223
224
225
226    /** {@inheritDoc} */
227    public void setEnabled(boolean value) {
228      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
229    }
230
231
232
233    /** {@inheritDoc} */
234    public String getJavaClass() {
235      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
236    }
237
238
239
240    /** {@inheritDoc} */
241    public void setJavaClass(String value) throws PropertyException {
242      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
243    }
244
245
246
247    /** {@inheritDoc} */
248    public boolean isStrictFormat() {
249      return impl.getPropertyValue(INSTANCE.getStrictFormatPropertyDefinition());
250    }
251
252
253
254    /** {@inheritDoc} */
255    public void setStrictFormat(Boolean value) {
256      impl.setPropertyValue(INSTANCE.getStrictFormatPropertyDefinition(), value);
257    }
258
259
260
261    /** {@inheritDoc} */
262    public ManagedObjectDefinition<? extends JPEGAttributeSyntaxCfgClient, ? extends JPEGAttributeSyntaxCfg> definition() {
263      return INSTANCE;
264    }
265
266
267
268    /** {@inheritDoc} */
269    public PropertyProvider properties() {
270      return impl;
271    }
272
273
274
275    /** {@inheritDoc} */
276    public void commit() throws ManagedObjectAlreadyExistsException,
277        MissingMandatoryPropertiesException, ConcurrentModificationException,
278        OperationRejectedException, LdapException {
279      impl.commit();
280    }
281
282
283
284    /** {@inheritDoc} */
285    public String toString() {
286      return impl.toString();
287    }
288  }
289
290
291
292  /**
293   * Managed object server implementation.
294   */
295  private static class JPEGAttributeSyntaxCfgServerImpl implements
296    JPEGAttributeSyntaxCfg {
297
298    /** Private implementation. */
299    private ServerManagedObject<? extends JPEGAttributeSyntaxCfg> impl;
300
301    /** The value of the "enabled" property. */
302    private final boolean pEnabled;
303
304    /** The value of the "java-class" property. */
305    private final String pJavaClass;
306
307    /** The value of the "strict-format" property. */
308    private final boolean pStrictFormat;
309
310
311
312    /** Private constructor. */
313    private JPEGAttributeSyntaxCfgServerImpl(ServerManagedObject<? extends JPEGAttributeSyntaxCfg> impl) {
314      this.impl = impl;
315      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
316      this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
317      this.pStrictFormat = impl.getPropertyValue(INSTANCE.getStrictFormatPropertyDefinition());
318    }
319
320
321
322    /** {@inheritDoc} */
323    public void addJPEGChangeListener(
324        ConfigurationChangeListener<JPEGAttributeSyntaxCfg> listener) {
325      impl.registerChangeListener(listener);
326    }
327
328
329
330    /** {@inheritDoc} */
331    public void removeJPEGChangeListener(
332        ConfigurationChangeListener<JPEGAttributeSyntaxCfg> listener) {
333      impl.deregisterChangeListener(listener);
334    }
335    /** {@inheritDoc} */
336    public void addChangeListener(
337        ConfigurationChangeListener<AttributeSyntaxCfg> listener) {
338      impl.registerChangeListener(listener);
339    }
340
341
342
343    /** {@inheritDoc} */
344    public void removeChangeListener(
345        ConfigurationChangeListener<AttributeSyntaxCfg> listener) {
346      impl.deregisterChangeListener(listener);
347    }
348
349
350
351    /** {@inheritDoc} */
352    public boolean isEnabled() {
353      return pEnabled;
354    }
355
356
357
358    /** {@inheritDoc} */
359    public String getJavaClass() {
360      return pJavaClass;
361    }
362
363
364
365    /** {@inheritDoc} */
366    public boolean isStrictFormat() {
367      return pStrictFormat;
368    }
369
370
371
372    /** {@inheritDoc} */
373    public Class<? extends JPEGAttributeSyntaxCfg> configurationClass() {
374      return JPEGAttributeSyntaxCfg.class;
375    }
376
377
378
379    /** {@inheritDoc} */
380    public DN dn() {
381      return impl.getDN();
382    }
383
384
385
386    /** {@inheritDoc} */
387    public String toString() {
388      return impl.toString();
389    }
390  }
391}