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