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