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