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