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