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.AttributeTypeDescriptionAttributeSyntaxCfgClient; 050import org.forgerock.opendj.server.config.server.AttributeSyntaxCfg; 051import org.forgerock.opendj.server.config.server.AttributeTypeDescriptionAttributeSyntaxCfg; 052 053 054 055/** 056 * An interface for querying the Attribute Type Description Attribute 057 * Syntax managed object definition meta information. 058 * <p> 059 * Attribute Type Description Attribute Syntaxes describe the format 060 * of the directory schema attribute type definitions. 061 */ 062public final class AttributeTypeDescriptionAttributeSyntaxCfgDefn extends ManagedObjectDefinition<AttributeTypeDescriptionAttributeSyntaxCfgClient, AttributeTypeDescriptionAttributeSyntaxCfg> { 063 064 // The singleton configuration definition instance. 065 private static final AttributeTypeDescriptionAttributeSyntaxCfgDefn INSTANCE = new AttributeTypeDescriptionAttributeSyntaxCfgDefn(); 066 067 068 069 // The "java-class" property definition. 070 private static final ClassPropertyDefinition PD_JAVA_CLASS; 071 072 073 074 // The "strip-syntax-min-upper-bound" property definition. 075 private static final BooleanPropertyDefinition PD_STRIP_SYNTAX_MIN_UPPER_BOUND; 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.AttributeTypeSyntax"); 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 "strip-syntax-min-upper-bound" property definition. 096 static { 097 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "strip-syntax-min-upper-bound"); 098 builder.setOption(PropertyOption.ADVANCED); 099 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "strip-syntax-min-upper-bound")); 100 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false"); 101 builder.setDefaultBehaviorProvider(provider); 102 PD_STRIP_SYNTAX_MIN_UPPER_BOUND = builder.getInstance(); 103 INSTANCE.registerPropertyDefinition(PD_STRIP_SYNTAX_MIN_UPPER_BOUND); 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 Attribute Type Description Attribute Syntax configuration 117 * definition singleton. 118 * 119 * @return Returns the Attribute Type Description Attribute Syntax 120 * configuration definition singleton. 121 */ 122 public static AttributeTypeDescriptionAttributeSyntaxCfgDefn getInstance() { 123 return INSTANCE; 124 } 125 126 127 128 /** 129 * Private constructor. 130 */ 131 private AttributeTypeDescriptionAttributeSyntaxCfgDefn() { 132 super("attribute-type-description-attribute-syntax", AttributeSyntaxCfgDefn.getInstance()); 133 } 134 135 136 137 /** 138 * {@inheritDoc} 139 */ 140 public AttributeTypeDescriptionAttributeSyntaxCfgClient createClientConfiguration( 141 ManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfgClient> impl) { 142 return new AttributeTypeDescriptionAttributeSyntaxCfgClientImpl(impl); 143 } 144 145 146 147 /** 148 * {@inheritDoc} 149 */ 150 public AttributeTypeDescriptionAttributeSyntaxCfg createServerConfiguration( 151 ServerManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfg> impl) { 152 return new AttributeTypeDescriptionAttributeSyntaxCfgServerImpl(impl); 153 } 154 155 156 157 /** 158 * {@inheritDoc} 159 */ 160 public Class<AttributeTypeDescriptionAttributeSyntaxCfg> getServerConfigurationClass() { 161 return AttributeTypeDescriptionAttributeSyntaxCfg.class; 162 } 163 164 165 166 /** 167 * Get the "enabled" property definition. 168 * <p> 169 * Indicates whether the Attribute Type Description Attribute Syntax 170 * is enabled. 171 * 172 * @return Returns the "enabled" property definition. 173 */ 174 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 175 return AttributeSyntaxCfgDefn.getInstance().getEnabledPropertyDefinition(); 176 } 177 178 179 180 /** 181 * Get the "java-class" property definition. 182 * <p> 183 * Specifies the fully-qualified name of the Java class that 184 * provides the Attribute Type Description Attribute Syntax 185 * implementation. 186 * 187 * @return Returns the "java-class" property definition. 188 */ 189 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 190 return PD_JAVA_CLASS; 191 } 192 193 194 195 /** 196 * Get the "strip-syntax-min-upper-bound" property definition. 197 * <p> 198 * Indicates whether the suggested minimum upper bound appended to 199 * an attribute's syntax OID in it's schema definition Attribute Type 200 * Description is stripped off. 201 * <p> 202 * When retrieving the server's schema, some APIs (JNDI) fail in 203 * their syntax lookup methods, because they do not parse this value 204 * correctly. This configuration option allows the server to be 205 * configured to provide schema definitions these APIs can parse 206 * correctly. 207 * 208 * @return Returns the "strip-syntax-min-upper-bound" property definition. 209 */ 210 public BooleanPropertyDefinition getStripSyntaxMinUpperBoundPropertyDefinition() { 211 return PD_STRIP_SYNTAX_MIN_UPPER_BOUND; 212 } 213 214 215 216 /** 217 * Managed object client implementation. 218 */ 219 private static class AttributeTypeDescriptionAttributeSyntaxCfgClientImpl implements 220 AttributeTypeDescriptionAttributeSyntaxCfgClient { 221 222 // Private implementation. 223 private ManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfgClient> impl; 224 225 226 227 // Private constructor. 228 private AttributeTypeDescriptionAttributeSyntaxCfgClientImpl( 229 ManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfgClient> impl) { 230 this.impl = impl; 231 } 232 233 234 235 /** 236 * {@inheritDoc} 237 */ 238 public Boolean isEnabled() { 239 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 240 } 241 242 243 244 /** 245 * {@inheritDoc} 246 */ 247 public void setEnabled(boolean value) { 248 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 249 } 250 251 252 253 /** 254 * {@inheritDoc} 255 */ 256 public String getJavaClass() { 257 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 258 } 259 260 261 262 /** 263 * {@inheritDoc} 264 */ 265 public void setJavaClass(String value) throws PropertyException { 266 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 267 } 268 269 270 271 /** 272 * {@inheritDoc} 273 */ 274 public boolean isStripSyntaxMinUpperBound() { 275 return impl.getPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundPropertyDefinition()); 276 } 277 278 279 280 /** 281 * {@inheritDoc} 282 */ 283 public void setStripSyntaxMinUpperBound(Boolean value) { 284 impl.setPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundPropertyDefinition(), value); 285 } 286 287 288 289 /** 290 * {@inheritDoc} 291 */ 292 public ManagedObjectDefinition<? extends AttributeTypeDescriptionAttributeSyntaxCfgClient, ? extends AttributeTypeDescriptionAttributeSyntaxCfg> definition() { 293 return INSTANCE; 294 } 295 296 297 298 /** 299 * {@inheritDoc} 300 */ 301 public PropertyProvider properties() { 302 return impl; 303 } 304 305 306 307 /** 308 * {@inheritDoc} 309 */ 310 public void commit() throws ManagedObjectAlreadyExistsException, 311 MissingMandatoryPropertiesException, ConcurrentModificationException, 312 OperationRejectedException, LdapException { 313 impl.commit(); 314 } 315 316 } 317 318 319 320 /** 321 * Managed object server implementation. 322 */ 323 private static class AttributeTypeDescriptionAttributeSyntaxCfgServerImpl implements 324 AttributeTypeDescriptionAttributeSyntaxCfg { 325 326 // Private implementation. 327 private ServerManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfg> impl; 328 329 // The value of the "enabled" property. 330 private final boolean pEnabled; 331 332 // The value of the "java-class" property. 333 private final String pJavaClass; 334 335 // The value of the "strip-syntax-min-upper-bound" property. 336 private final boolean pStripSyntaxMinUpperBound; 337 338 339 340 // Private constructor. 341 private AttributeTypeDescriptionAttributeSyntaxCfgServerImpl(ServerManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfg> impl) { 342 this.impl = impl; 343 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 344 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 345 this.pStripSyntaxMinUpperBound = impl.getPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundPropertyDefinition()); 346 } 347 348 349 350 /** 351 * {@inheritDoc} 352 */ 353 public void addAttributeTypeDescriptionChangeListener( 354 ConfigurationChangeListener<AttributeTypeDescriptionAttributeSyntaxCfg> listener) { 355 impl.registerChangeListener(listener); 356 } 357 358 359 360 /** 361 * {@inheritDoc} 362 */ 363 public void removeAttributeTypeDescriptionChangeListener( 364 ConfigurationChangeListener<AttributeTypeDescriptionAttributeSyntaxCfg> listener) { 365 impl.deregisterChangeListener(listener); 366 } 367 /** 368 * {@inheritDoc} 369 */ 370 public void addChangeListener( 371 ConfigurationChangeListener<AttributeSyntaxCfg> listener) { 372 impl.registerChangeListener(listener); 373 } 374 375 376 377 /** 378 * {@inheritDoc} 379 */ 380 public void removeChangeListener( 381 ConfigurationChangeListener<AttributeSyntaxCfg> listener) { 382 impl.deregisterChangeListener(listener); 383 } 384 385 386 387 /** 388 * {@inheritDoc} 389 */ 390 public boolean isEnabled() { 391 return pEnabled; 392 } 393 394 395 396 /** 397 * {@inheritDoc} 398 */ 399 public String getJavaClass() { 400 return pJavaClass; 401 } 402 403 404 405 /** 406 * {@inheritDoc} 407 */ 408 public boolean isStripSyntaxMinUpperBound() { 409 return pStripSyntaxMinUpperBound; 410 } 411 412 413 414 /** 415 * {@inheritDoc} 416 */ 417 public Class<? extends AttributeTypeDescriptionAttributeSyntaxCfg> configurationClass() { 418 return AttributeTypeDescriptionAttributeSyntaxCfg.class; 419 } 420 421 422 423 /** 424 * {@inheritDoc} 425 */ 426 public DN dn() { 427 return impl.getDN(); 428 } 429 430 } 431}