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