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 010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE 011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2008 Sun Microsystems, Inc. 026 */ 027 package org.opends.server.admin.std.meta; 028 029 030 031 import org.opends.server.admin.AdministratorAction; 032 import org.opends.server.admin.BooleanPropertyDefinition; 033 import org.opends.server.admin.ClassPropertyDefinition; 034 import org.opends.server.admin.client.AuthorizationException; 035 import org.opends.server.admin.client.CommunicationException; 036 import org.opends.server.admin.client.ConcurrentModificationException; 037 import org.opends.server.admin.client.ManagedObject; 038 import org.opends.server.admin.client.MissingMandatoryPropertiesException; 039 import org.opends.server.admin.client.OperationRejectedException; 040 import org.opends.server.admin.DefaultBehaviorProvider; 041 import org.opends.server.admin.DefinedDefaultBehaviorProvider; 042 import org.opends.server.admin.ManagedObjectAlreadyExistsException; 043 import org.opends.server.admin.ManagedObjectDefinition; 044 import org.opends.server.admin.PropertyIsReadOnlyException; 045 import org.opends.server.admin.PropertyOption; 046 import org.opends.server.admin.PropertyProvider; 047 import org.opends.server.admin.server.ConfigurationChangeListener; 048 import org.opends.server.admin.server.ServerManagedObject; 049 import org.opends.server.admin.std.client.AttributeTypeDescriptionAttributeSyntaxCfgClient; 050 import org.opends.server.admin.std.server.AttributeSyntaxCfg; 051 import org.opends.server.admin.std.server.AttributeTypeDescriptionAttributeSyntaxCfg; 052 import org.opends.server.admin.Tag; 053 import org.opends.server.types.DN; 054 055 056 057 /** 058 * An interface for querying the Attribute Type Description Attribute 059 * Syntax managed object definition meta information. 060 * <p> 061 * Attribute Type Description Attribute Syntaxes describe the format 062 * of the directory schema attribute type definitions. 063 */ 064 public final class AttributeTypeDescriptionAttributeSyntaxCfgDefn extends ManagedObjectDefinition<AttributeTypeDescriptionAttributeSyntaxCfgClient, AttributeTypeDescriptionAttributeSyntaxCfg> { 065 066 // The singleton configuration definition instance. 067 private static final AttributeTypeDescriptionAttributeSyntaxCfgDefn INSTANCE = new AttributeTypeDescriptionAttributeSyntaxCfgDefn(); 068 069 070 071 // The "java-class" property definition. 072 private static final ClassPropertyDefinition PD_JAVA_CLASS; 073 074 075 076 // The "strip-syntax-min-upper-bound" property definition. 077 private static final BooleanPropertyDefinition PD_STRIP_SYNTAX_MIN_UPPER_BOUND; 078 079 080 081 // Build the "java-class" property definition. 082 static { 083 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 084 builder.setOption(PropertyOption.READ_ONLY); 085 builder.setOption(PropertyOption.MANDATORY); 086 builder.setOption(PropertyOption.ADVANCED); 087 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class")); 088 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.schema.AttributeTypeSyntax"); 089 builder.setDefaultBehaviorProvider(provider); 090 builder.addInstanceOf("org.opends.server.api.AttributeSyntax"); 091 PD_JAVA_CLASS = builder.getInstance(); 092 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 093 } 094 095 096 097 // Build the "strip-syntax-min-upper-bound" property definition. 098 static { 099 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "strip-syntax-min-upper-bound"); 100 builder.setOption(PropertyOption.ADVANCED); 101 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "strip-syntax-min-upper-bound")); 102 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false"); 103 builder.setDefaultBehaviorProvider(provider); 104 PD_STRIP_SYNTAX_MIN_UPPER_BOUND = builder.getInstance(); 105 INSTANCE.registerPropertyDefinition(PD_STRIP_SYNTAX_MIN_UPPER_BOUND); 106 } 107 108 109 110 // Register the tags associated with this managed object definition. 111 static { 112 INSTANCE.registerTag(Tag.valueOf("core-server")); 113 } 114 115 116 117 /** 118 * Get the Attribute Type Description Attribute Syntax configuration 119 * definition singleton. 120 * 121 * @return Returns the Attribute Type Description Attribute Syntax 122 * configuration definition singleton. 123 */ 124 public static AttributeTypeDescriptionAttributeSyntaxCfgDefn getInstance() { 125 return INSTANCE; 126 } 127 128 129 130 /** 131 * Private constructor. 132 */ 133 private AttributeTypeDescriptionAttributeSyntaxCfgDefn() { 134 super("attribute-type-description-attribute-syntax", AttributeSyntaxCfgDefn.getInstance()); 135 } 136 137 138 139 /** 140 * {@inheritDoc} 141 */ 142 public AttributeTypeDescriptionAttributeSyntaxCfgClient createClientConfiguration( 143 ManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfgClient> impl) { 144 return new AttributeTypeDescriptionAttributeSyntaxCfgClientImpl(impl); 145 } 146 147 148 149 /** 150 * {@inheritDoc} 151 */ 152 public AttributeTypeDescriptionAttributeSyntaxCfg createServerConfiguration( 153 ServerManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfg> impl) { 154 return new AttributeTypeDescriptionAttributeSyntaxCfgServerImpl(impl); 155 } 156 157 158 159 /** 160 * {@inheritDoc} 161 */ 162 public Class<AttributeTypeDescriptionAttributeSyntaxCfg> getServerConfigurationClass() { 163 return AttributeTypeDescriptionAttributeSyntaxCfg.class; 164 } 165 166 167 168 /** 169 * Get the "enabled" property definition. 170 * <p> 171 * Indicates whether the Attribute Type Description Attribute Syntax 172 * is enabled. 173 * 174 * @return Returns the "enabled" property definition. 175 */ 176 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 177 return AttributeSyntaxCfgDefn.getInstance().getEnabledPropertyDefinition(); 178 } 179 180 181 182 /** 183 * Get the "java-class" property definition. 184 * <p> 185 * Specifies the fully-qualified name of the Java class that 186 * provides the Attribute Type Description Attribute Syntax 187 * implementation. 188 * 189 * @return Returns the "java-class" property definition. 190 */ 191 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 192 return PD_JAVA_CLASS; 193 } 194 195 196 197 /** 198 * Get the "strip-syntax-min-upper-bound" property definition. 199 * <p> 200 * Indicates whether the suggested minimum upper bound appended to 201 * an attribute's syntax OID in it's schema definition Attribute Type 202 * Description is stripped off. 203 * <p> 204 * When retrieving the server's schema, some APIs (JNDI) fail in 205 * their syntax lookup methods, because they do not parse this value 206 * correctly. This configuration option allows the server to be 207 * configured to provide schema definitions these APIs can parse 208 * correctly. 209 * 210 * @return Returns the "strip-syntax-min-upper-bound" property definition. 211 */ 212 public BooleanPropertyDefinition getStripSyntaxMinUpperBoundPropertyDefinition() { 213 return PD_STRIP_SYNTAX_MIN_UPPER_BOUND; 214 } 215 216 217 218 /** 219 * Managed object client implementation. 220 */ 221 private static class AttributeTypeDescriptionAttributeSyntaxCfgClientImpl implements 222 AttributeTypeDescriptionAttributeSyntaxCfgClient { 223 224 // Private implementation. 225 private ManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfgClient> impl; 226 227 228 229 // Private constructor. 230 private AttributeTypeDescriptionAttributeSyntaxCfgClientImpl( 231 ManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfgClient> impl) { 232 this.impl = impl; 233 } 234 235 236 237 /** 238 * {@inheritDoc} 239 */ 240 public Boolean isEnabled() { 241 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 242 } 243 244 245 246 /** 247 * {@inheritDoc} 248 */ 249 public void setEnabled(boolean value) { 250 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 251 } 252 253 254 255 /** 256 * {@inheritDoc} 257 */ 258 public String getJavaClass() { 259 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 260 } 261 262 263 264 /** 265 * {@inheritDoc} 266 */ 267 public void setJavaClass(String value) throws PropertyIsReadOnlyException { 268 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 269 } 270 271 272 273 /** 274 * {@inheritDoc} 275 */ 276 public boolean isStripSyntaxMinUpperBound() { 277 return impl.getPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundPropertyDefinition()); 278 } 279 280 281 282 /** 283 * {@inheritDoc} 284 */ 285 public void setStripSyntaxMinUpperBound(Boolean value) { 286 impl.setPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundPropertyDefinition(), value); 287 } 288 289 290 291 /** 292 * {@inheritDoc} 293 */ 294 public ManagedObjectDefinition<? extends AttributeTypeDescriptionAttributeSyntaxCfgClient, ? extends AttributeTypeDescriptionAttributeSyntaxCfg> definition() { 295 return INSTANCE; 296 } 297 298 299 300 /** 301 * {@inheritDoc} 302 */ 303 public PropertyProvider properties() { 304 return impl; 305 } 306 307 308 309 /** 310 * {@inheritDoc} 311 */ 312 public void commit() throws ManagedObjectAlreadyExistsException, 313 MissingMandatoryPropertiesException, ConcurrentModificationException, 314 OperationRejectedException, AuthorizationException, 315 CommunicationException { 316 impl.commit(); 317 } 318 319 } 320 321 322 323 /** 324 * Managed object server implementation. 325 */ 326 private static class AttributeTypeDescriptionAttributeSyntaxCfgServerImpl implements 327 AttributeTypeDescriptionAttributeSyntaxCfg { 328 329 // Private implementation. 330 private ServerManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfg> impl; 331 332 // The value of the "enabled" property. 333 private final boolean pEnabled; 334 335 // The value of the "java-class" property. 336 private final String pJavaClass; 337 338 // The value of the "strip-syntax-min-upper-bound" property. 339 private final boolean pStripSyntaxMinUpperBound; 340 341 342 343 // Private constructor. 344 private AttributeTypeDescriptionAttributeSyntaxCfgServerImpl(ServerManagedObject<? extends AttributeTypeDescriptionAttributeSyntaxCfg> impl) { 345 this.impl = impl; 346 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 347 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 348 this.pStripSyntaxMinUpperBound = impl.getPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundPropertyDefinition()); 349 } 350 351 352 353 /** 354 * {@inheritDoc} 355 */ 356 public void addAttributeTypeDescriptionChangeListener( 357 ConfigurationChangeListener<AttributeTypeDescriptionAttributeSyntaxCfg> listener) { 358 impl.registerChangeListener(listener); 359 } 360 361 362 363 /** 364 * {@inheritDoc} 365 */ 366 public void removeAttributeTypeDescriptionChangeListener( 367 ConfigurationChangeListener<AttributeTypeDescriptionAttributeSyntaxCfg> listener) { 368 impl.deregisterChangeListener(listener); 369 } 370 /** 371 * {@inheritDoc} 372 */ 373 public void addChangeListener( 374 ConfigurationChangeListener<AttributeSyntaxCfg> listener) { 375 impl.registerChangeListener(listener); 376 } 377 378 379 380 /** 381 * {@inheritDoc} 382 */ 383 public void removeChangeListener( 384 ConfigurationChangeListener<AttributeSyntaxCfg> listener) { 385 impl.deregisterChangeListener(listener); 386 } 387 388 389 390 /** 391 * {@inheritDoc} 392 */ 393 public boolean isEnabled() { 394 return pEnabled; 395 } 396 397 398 399 /** 400 * {@inheritDoc} 401 */ 402 public String getJavaClass() { 403 return pJavaClass; 404 } 405 406 407 408 /** 409 * {@inheritDoc} 410 */ 411 public boolean isStripSyntaxMinUpperBound() { 412 return pStripSyntaxMinUpperBound; 413 } 414 415 416 417 /** 418 * {@inheritDoc} 419 */ 420 public Class<? extends AttributeTypeDescriptionAttributeSyntaxCfg> configurationClass() { 421 return AttributeTypeDescriptionAttributeSyntaxCfg.class; 422 } 423 424 425 426 /** 427 * {@inheritDoc} 428 */ 429 public DN dn() { 430 return impl.getDN(); 431 } 432 433 } 434 }