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 /** {@inheritDoc} */ 138 public AttributeTypeDescriptionAttributeSyntaxCfgClient createClientConfiguration( 139 ManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfgClient> impl) { 140 return new AttributeTypeDescriptionAttributeSyntaxCfgClientImpl(impl); 141 } 142 143 144 145 /** {@inheritDoc} */ 146 public AttributeTypeDescriptionAttributeSyntaxCfg createServerConfiguration( 147 ServerManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfg> impl) { 148 return new AttributeTypeDescriptionAttributeSyntaxCfgServerImpl(impl); 149 } 150 151 152 153 /** {@inheritDoc} */ 154 public Class<AttributeTypeDescriptionAttributeSyntaxCfg> getServerConfigurationClass() { 155 return AttributeTypeDescriptionAttributeSyntaxCfg.class; 156 } 157 158 159 160 /** 161 * Get the "enabled" property definition. 162 * <p> 163 * Indicates whether the Attribute Type Description Attribute Syntax 164 * is enabled. 165 * 166 * @return Returns the "enabled" property definition. 167 */ 168 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 169 return AttributeSyntaxCfgDefn.getInstance().getEnabledPropertyDefinition(); 170 } 171 172 173 174 /** 175 * Get the "java-class" property definition. 176 * <p> 177 * Specifies the fully-qualified name of the Java class that 178 * provides the Attribute Type Description Attribute Syntax 179 * implementation. 180 * 181 * @return Returns the "java-class" property definition. 182 */ 183 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 184 return PD_JAVA_CLASS; 185 } 186 187 188 189 /** 190 * Get the "strip-syntax-min-upper-bound" property definition. 191 * <p> 192 * Indicates whether the suggested minimum upper bound appended to 193 * an attribute's syntax OID in it's schema definition Attribute Type 194 * Description is stripped off. 195 * <p> 196 * When retrieving the server's schema, some APIs (JNDI) fail in 197 * their syntax lookup methods, because they do not parse this value 198 * correctly. This configuration option allows the server to be 199 * configured to provide schema definitions these APIs can parse 200 * correctly. 201 * 202 * @return Returns the "strip-syntax-min-upper-bound" property definition. 203 */ 204 public BooleanPropertyDefinition getStripSyntaxMinUpperBoundPropertyDefinition() { 205 return PD_STRIP_SYNTAX_MIN_UPPER_BOUND; 206 } 207 208 209 210 /** 211 * Managed object client implementation. 212 */ 213 private static class AttributeTypeDescriptionAttributeSyntaxCfgClientImpl implements 214 AttributeTypeDescriptionAttributeSyntaxCfgClient { 215 216 /** Private implementation. */ 217 private ManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfgClient> impl; 218 219 220 221 /** Private constructor. */ 222 private AttributeTypeDescriptionAttributeSyntaxCfgClientImpl( 223 ManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfgClient> impl) { 224 this.impl = impl; 225 } 226 227 228 229 /** {@inheritDoc} */ 230 public Boolean isEnabled() { 231 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 232 } 233 234 235 236 /** {@inheritDoc} */ 237 public void setEnabled(boolean value) { 238 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 239 } 240 241 242 243 /** {@inheritDoc} */ 244 public String getJavaClass() { 245 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 246 } 247 248 249 250 /** {@inheritDoc} */ 251 public void setJavaClass(String value) throws PropertyException { 252 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 253 } 254 255 256 257 /** {@inheritDoc} */ 258 public boolean isStripSyntaxMinUpperBound() { 259 return impl.getPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundPropertyDefinition()); 260 } 261 262 263 264 /** {@inheritDoc} */ 265 public void setStripSyntaxMinUpperBound(Boolean value) { 266 impl.setPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundPropertyDefinition(), value); 267 } 268 269 270 271 /** {@inheritDoc} */ 272 public ManagedObjectDefinition<? extends AttributeTypeDescriptionAttributeSyntaxCfgClient, ? extends AttributeTypeDescriptionAttributeSyntaxCfg> definition() { 273 return INSTANCE; 274 } 275 276 277 278 /** {@inheritDoc} */ 279 public PropertyProvider properties() { 280 return impl; 281 } 282 283 284 285 /** {@inheritDoc} */ 286 public void commit() throws ManagedObjectAlreadyExistsException, 287 MissingMandatoryPropertiesException, ConcurrentModificationException, 288 OperationRejectedException, LdapException { 289 impl.commit(); 290 } 291 292 293 294 /** {@inheritDoc} */ 295 public String toString() { 296 return impl.toString(); 297 } 298 } 299 300 301 302 /** 303 * Managed object server implementation. 304 */ 305 private static class AttributeTypeDescriptionAttributeSyntaxCfgServerImpl implements 306 AttributeTypeDescriptionAttributeSyntaxCfg { 307 308 /** Private implementation. */ 309 private ServerManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfg> impl; 310 311 /** The value of the "enabled" property. */ 312 private final boolean pEnabled; 313 314 /** The value of the "java-class" property. */ 315 private final String pJavaClass; 316 317 /** The value of the "strip-syntax-min-upper-bound" property. */ 318 private final boolean pStripSyntaxMinUpperBound; 319 320 321 322 /** Private constructor. */ 323 private AttributeTypeDescriptionAttributeSyntaxCfgServerImpl(ServerManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfg> impl) { 324 this.impl = impl; 325 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 326 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 327 this.pStripSyntaxMinUpperBound = impl.getPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundPropertyDefinition()); 328 } 329 330 331 332 /** {@inheritDoc} */ 333 public void addAttributeTypeDescriptionChangeListener( 334 ConfigurationChangeListener<AttributeTypeDescriptionAttributeSyntaxCfg> listener) { 335 impl.registerChangeListener(listener); 336 } 337 338 339 340 /** {@inheritDoc} */ 341 public void removeAttributeTypeDescriptionChangeListener( 342 ConfigurationChangeListener<AttributeTypeDescriptionAttributeSyntaxCfg> listener) { 343 impl.deregisterChangeListener(listener); 344 } 345 /** {@inheritDoc} */ 346 public void addChangeListener( 347 ConfigurationChangeListener<AttributeSyntaxCfg> listener) { 348 impl.registerChangeListener(listener); 349 } 350 351 352 353 /** {@inheritDoc} */ 354 public void removeChangeListener( 355 ConfigurationChangeListener<AttributeSyntaxCfg> listener) { 356 impl.deregisterChangeListener(listener); 357 } 358 359 360 361 /** {@inheritDoc} */ 362 public boolean isEnabled() { 363 return pEnabled; 364 } 365 366 367 368 /** {@inheritDoc} */ 369 public String getJavaClass() { 370 return pJavaClass; 371 } 372 373 374 375 /** {@inheritDoc} */ 376 public boolean isStripSyntaxMinUpperBound() { 377 return pStripSyntaxMinUpperBound; 378 } 379 380 381 382 /** {@inheritDoc} */ 383 public Class<? extends AttributeTypeDescriptionAttributeSyntaxCfg> configurationClass() { 384 return AttributeTypeDescriptionAttributeSyntaxCfg.class; 385 } 386 387 388 389 /** {@inheritDoc} */ 390 public DN dn() { 391 return impl.getDN(); 392 } 393 394 395 396 /** {@inheritDoc} */ 397 public String toString() { 398 return impl.toString(); 399 } 400 } 401}