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.opends.server.admin.std.meta; 017 018 019 020import org.forgerock.opendj.ldap.DN; 021import org.opends.server.admin.AdministratorAction; 022import org.opends.server.admin.BooleanPropertyDefinition; 023import org.opends.server.admin.ClassPropertyDefinition; 024import org.opends.server.admin.client.AuthorizationException; 025import org.opends.server.admin.client.CommunicationException; 026import org.opends.server.admin.client.ConcurrentModificationException; 027import org.opends.server.admin.client.ManagedObject; 028import org.opends.server.admin.client.MissingMandatoryPropertiesException; 029import org.opends.server.admin.client.OperationRejectedException; 030import org.opends.server.admin.DefaultBehaviorProvider; 031import org.opends.server.admin.DefinedDefaultBehaviorProvider; 032import org.opends.server.admin.ManagedObjectAlreadyExistsException; 033import org.opends.server.admin.ManagedObjectDefinition; 034import org.opends.server.admin.PropertyException; 035import org.opends.server.admin.PropertyOption; 036import org.opends.server.admin.PropertyProvider; 037import org.opends.server.admin.server.ConfigurationChangeListener; 038import org.opends.server.admin.server.ServerManagedObject; 039import org.opends.server.admin.std.client.AttributeTypeDescriptionAttributeSyntaxCfgClient; 040import org.opends.server.admin.std.server.AttributeSyntaxCfg; 041import org.opends.server.admin.std.server.AttributeTypeDescriptionAttributeSyntaxCfg; 042import org.opends.server.admin.Tag; 043 044 045 046/** 047 * An interface for querying the Attribute Type Description Attribute 048 * Syntax managed object definition meta information. 049 * <p> 050 * Attribute Type Description Attribute Syntaxes describe the format 051 * of the directory schema attribute type definitions. 052 */ 053public final class AttributeTypeDescriptionAttributeSyntaxCfgDefn extends ManagedObjectDefinition<AttributeTypeDescriptionAttributeSyntaxCfgClient, AttributeTypeDescriptionAttributeSyntaxCfg> { 054 055 // The singleton configuration definition instance. 056 private static final AttributeTypeDescriptionAttributeSyntaxCfgDefn INSTANCE = new AttributeTypeDescriptionAttributeSyntaxCfgDefn(); 057 058 059 060 // The "java-class" property definition. 061 private static final ClassPropertyDefinition PD_JAVA_CLASS; 062 063 064 065 // The "strip-syntax-min-upper-bound" property definition. 066 private static final BooleanPropertyDefinition PD_STRIP_SYNTAX_MIN_UPPER_BOUND; 067 068 069 070 // Build the "java-class" property definition. 071 static { 072 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 073 builder.setOption(PropertyOption.READ_ONLY); 074 builder.setOption(PropertyOption.MANDATORY); 075 builder.setOption(PropertyOption.ADVANCED); 076 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class")); 077 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.schema.AttributeTypeSyntax"); 078 builder.setDefaultBehaviorProvider(provider); 079 builder.addInstanceOf("org.opends.server.api.AttributeSyntax"); 080 PD_JAVA_CLASS = builder.getInstance(); 081 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 082 } 083 084 085 086 // Build the "strip-syntax-min-upper-bound" property definition. 087 static { 088 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "strip-syntax-min-upper-bound"); 089 builder.setOption(PropertyOption.ADVANCED); 090 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "strip-syntax-min-upper-bound")); 091 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false"); 092 builder.setDefaultBehaviorProvider(provider); 093 PD_STRIP_SYNTAX_MIN_UPPER_BOUND = builder.getInstance(); 094 INSTANCE.registerPropertyDefinition(PD_STRIP_SYNTAX_MIN_UPPER_BOUND); 095 } 096 097 098 099 // Register the tags associated with this managed object definition. 100 static { 101 INSTANCE.registerTag(Tag.valueOf("core-server")); 102 } 103 104 105 106 /** 107 * Get the Attribute Type Description Attribute Syntax configuration 108 * definition singleton. 109 * 110 * @return Returns the Attribute Type Description Attribute Syntax 111 * configuration definition singleton. 112 */ 113 public static AttributeTypeDescriptionAttributeSyntaxCfgDefn getInstance() { 114 return INSTANCE; 115 } 116 117 118 119 /** 120 * Private constructor. 121 */ 122 private AttributeTypeDescriptionAttributeSyntaxCfgDefn() { 123 super("attribute-type-description-attribute-syntax", AttributeSyntaxCfgDefn.getInstance()); 124 } 125 126 127 128 /** 129 * {@inheritDoc} 130 */ 131 public AttributeTypeDescriptionAttributeSyntaxCfgClient createClientConfiguration( 132 ManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfgClient> impl) { 133 return new AttributeTypeDescriptionAttributeSyntaxCfgClientImpl(impl); 134 } 135 136 137 138 /** 139 * {@inheritDoc} 140 */ 141 public AttributeTypeDescriptionAttributeSyntaxCfg createServerConfiguration( 142 ServerManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfg> impl) { 143 return new AttributeTypeDescriptionAttributeSyntaxCfgServerImpl(impl); 144 } 145 146 147 148 /** 149 * {@inheritDoc} 150 */ 151 public Class<AttributeTypeDescriptionAttributeSyntaxCfg> getServerConfigurationClass() { 152 return AttributeTypeDescriptionAttributeSyntaxCfg.class; 153 } 154 155 156 157 /** 158 * Get the "enabled" property definition. 159 * <p> 160 * Indicates whether the Attribute Type Description Attribute Syntax 161 * is enabled. 162 * 163 * @return Returns the "enabled" property definition. 164 */ 165 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 166 return AttributeSyntaxCfgDefn.getInstance().getEnabledPropertyDefinition(); 167 } 168 169 170 171 /** 172 * Get the "java-class" property definition. 173 * <p> 174 * Specifies the fully-qualified name of the Java class that 175 * provides the Attribute Type Description Attribute Syntax 176 * implementation. 177 * 178 * @return Returns the "java-class" property definition. 179 */ 180 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 181 return PD_JAVA_CLASS; 182 } 183 184 185 186 /** 187 * Get the "strip-syntax-min-upper-bound" property definition. 188 * <p> 189 * Indicates whether the suggested minimum upper bound appended to 190 * an attribute's syntax OID in it's schema definition Attribute Type 191 * Description is stripped off. 192 * <p> 193 * When retrieving the server's schema, some APIs (JNDI) fail in 194 * their syntax lookup methods, because they do not parse this value 195 * correctly. This configuration option allows the server to be 196 * configured to provide schema definitions these APIs can parse 197 * correctly. 198 * 199 * @return Returns the "strip-syntax-min-upper-bound" property definition. 200 */ 201 public BooleanPropertyDefinition getStripSyntaxMinUpperBoundPropertyDefinition() { 202 return PD_STRIP_SYNTAX_MIN_UPPER_BOUND; 203 } 204 205 206 207 /** 208 * Managed object client implementation. 209 */ 210 private static class AttributeTypeDescriptionAttributeSyntaxCfgClientImpl implements 211 AttributeTypeDescriptionAttributeSyntaxCfgClient { 212 213 // Private implementation. 214 private ManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfgClient> impl; 215 216 217 218 // Private constructor. 219 private AttributeTypeDescriptionAttributeSyntaxCfgClientImpl( 220 ManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfgClient> 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 isStripSyntaxMinUpperBound() { 266 return impl.getPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundPropertyDefinition()); 267 } 268 269 270 271 /** 272 * {@inheritDoc} 273 */ 274 public void setStripSyntaxMinUpperBound(Boolean value) { 275 impl.setPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundPropertyDefinition(), value); 276 } 277 278 279 280 /** 281 * {@inheritDoc} 282 */ 283 public ManagedObjectDefinition<? extends AttributeTypeDescriptionAttributeSyntaxCfgClient, ? extends AttributeTypeDescriptionAttributeSyntaxCfg> 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 AttributeTypeDescriptionAttributeSyntaxCfgServerImpl implements 322 AttributeTypeDescriptionAttributeSyntaxCfg { 323 324 // Private implementation. 325 private ServerManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfg> 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 "strip-syntax-min-upper-bound" property. 334 private final boolean pStripSyntaxMinUpperBound; 335 336 337 338 // Private constructor. 339 private AttributeTypeDescriptionAttributeSyntaxCfgServerImpl(ServerManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfg> impl) { 340 this.impl = impl; 341 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 342 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 343 this.pStripSyntaxMinUpperBound = impl.getPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundPropertyDefinition()); 344 } 345 346 347 348 /** 349 * {@inheritDoc} 350 */ 351 public void addAttributeTypeDescriptionChangeListener( 352 ConfigurationChangeListener<AttributeTypeDescriptionAttributeSyntaxCfg> listener) { 353 impl.registerChangeListener(listener); 354 } 355 356 357 358 /** 359 * {@inheritDoc} 360 */ 361 public void removeAttributeTypeDescriptionChangeListener( 362 ConfigurationChangeListener<AttributeTypeDescriptionAttributeSyntaxCfg> 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 isStripSyntaxMinUpperBound() { 407 return pStripSyntaxMinUpperBound; 408 } 409 410 411 412 /** 413 * {@inheritDoc} 414 */ 415 public Class<? extends AttributeTypeDescriptionAttributeSyntaxCfg> configurationClass() { 416 return AttributeTypeDescriptionAttributeSyntaxCfg.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}