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.DirectoryStringAttributeSyntaxCfgClient; 040import org.opends.server.admin.std.server.AttributeSyntaxCfg; 041import org.opends.server.admin.std.server.DirectoryStringAttributeSyntaxCfg; 042import org.opends.server.admin.Tag; 043 044 045 046/** 047 * An interface for querying the Directory String Attribute Syntax 048 * managed object definition meta information. 049 * <p> 050 * The Directory String Attribute Syntax defines an attribute syntax 051 * for storing arbitrary string (and sometimes binary) data. 052 */ 053public final class DirectoryStringAttributeSyntaxCfgDefn extends ManagedObjectDefinition<DirectoryStringAttributeSyntaxCfgClient, DirectoryStringAttributeSyntaxCfg> { 054 055 // The singleton configuration definition instance. 056 private static final DirectoryStringAttributeSyntaxCfgDefn INSTANCE = new DirectoryStringAttributeSyntaxCfgDefn(); 057 058 059 060 // The "allow-zero-length-values" property definition. 061 private static final BooleanPropertyDefinition PD_ALLOW_ZERO_LENGTH_VALUES; 062 063 064 065 // The "java-class" property definition. 066 private static final ClassPropertyDefinition PD_JAVA_CLASS; 067 068 069 070 // Build the "allow-zero-length-values" property definition. 071 static { 072 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "allow-zero-length-values"); 073 builder.setOption(PropertyOption.ADVANCED); 074 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "allow-zero-length-values")); 075 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false"); 076 builder.setDefaultBehaviorProvider(provider); 077 PD_ALLOW_ZERO_LENGTH_VALUES = builder.getInstance(); 078 INSTANCE.registerPropertyDefinition(PD_ALLOW_ZERO_LENGTH_VALUES); 079 } 080 081 082 083 // Build the "java-class" property definition. 084 static { 085 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 086 builder.setOption(PropertyOption.READ_ONLY); 087 builder.setOption(PropertyOption.MANDATORY); 088 builder.setOption(PropertyOption.ADVANCED); 089 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class")); 090 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.schema.DirectoryStringSyntax"); 091 builder.setDefaultBehaviorProvider(provider); 092 builder.addInstanceOf("org.opends.server.api.AttributeSyntax"); 093 PD_JAVA_CLASS = builder.getInstance(); 094 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 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 Directory String Attribute Syntax configuration 108 * definition singleton. 109 * 110 * @return Returns the Directory String Attribute Syntax 111 * configuration definition singleton. 112 */ 113 public static DirectoryStringAttributeSyntaxCfgDefn getInstance() { 114 return INSTANCE; 115 } 116 117 118 119 /** 120 * Private constructor. 121 */ 122 private DirectoryStringAttributeSyntaxCfgDefn() { 123 super("directory-string-attribute-syntax", AttributeSyntaxCfgDefn.getInstance()); 124 } 125 126 127 128 /** 129 * {@inheritDoc} 130 */ 131 public DirectoryStringAttributeSyntaxCfgClient createClientConfiguration( 132 ManagedObject<? extends DirectoryStringAttributeSyntaxCfgClient> impl) { 133 return new DirectoryStringAttributeSyntaxCfgClientImpl(impl); 134 } 135 136 137 138 /** 139 * {@inheritDoc} 140 */ 141 public DirectoryStringAttributeSyntaxCfg createServerConfiguration( 142 ServerManagedObject<? extends DirectoryStringAttributeSyntaxCfg> impl) { 143 return new DirectoryStringAttributeSyntaxCfgServerImpl(impl); 144 } 145 146 147 148 /** 149 * {@inheritDoc} 150 */ 151 public Class<DirectoryStringAttributeSyntaxCfg> getServerConfigurationClass() { 152 return DirectoryStringAttributeSyntaxCfg.class; 153 } 154 155 156 157 /** 158 * Get the "allow-zero-length-values" property definition. 159 * <p> 160 * Indicates whether zero-length (that is, an empty string) values 161 * are allowed. 162 * <p> 163 * This is technically not allowed by the revised LDAPv3 164 * specification, but some environments may require it for backward 165 * compatibility with servers that do allow it. 166 * 167 * @return Returns the "allow-zero-length-values" property definition. 168 */ 169 public BooleanPropertyDefinition getAllowZeroLengthValuesPropertyDefinition() { 170 return PD_ALLOW_ZERO_LENGTH_VALUES; 171 } 172 173 174 175 /** 176 * Get the "enabled" property definition. 177 * <p> 178 * Indicates whether the Directory String Attribute Syntax is 179 * enabled. 180 * 181 * @return Returns the "enabled" property definition. 182 */ 183 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 184 return AttributeSyntaxCfgDefn.getInstance().getEnabledPropertyDefinition(); 185 } 186 187 188 189 /** 190 * Get the "java-class" property definition. 191 * <p> 192 * Specifies the fully-qualified name of the Java class that 193 * provides the Directory String Attribute Syntax implementation. 194 * 195 * @return Returns the "java-class" property definition. 196 */ 197 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 198 return PD_JAVA_CLASS; 199 } 200 201 202 203 /** 204 * Managed object client implementation. 205 */ 206 private static class DirectoryStringAttributeSyntaxCfgClientImpl implements 207 DirectoryStringAttributeSyntaxCfgClient { 208 209 // Private implementation. 210 private ManagedObject<? extends DirectoryStringAttributeSyntaxCfgClient> impl; 211 212 213 214 // Private constructor. 215 private DirectoryStringAttributeSyntaxCfgClientImpl( 216 ManagedObject<? extends DirectoryStringAttributeSyntaxCfgClient> impl) { 217 this.impl = impl; 218 } 219 220 221 222 /** 223 * {@inheritDoc} 224 */ 225 public boolean isAllowZeroLengthValues() { 226 return impl.getPropertyValue(INSTANCE.getAllowZeroLengthValuesPropertyDefinition()); 227 } 228 229 230 231 /** 232 * {@inheritDoc} 233 */ 234 public void setAllowZeroLengthValues(Boolean value) { 235 impl.setPropertyValue(INSTANCE.getAllowZeroLengthValuesPropertyDefinition(), value); 236 } 237 238 239 240 /** 241 * {@inheritDoc} 242 */ 243 public Boolean isEnabled() { 244 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 245 } 246 247 248 249 /** 250 * {@inheritDoc} 251 */ 252 public void setEnabled(boolean value) { 253 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 254 } 255 256 257 258 /** 259 * {@inheritDoc} 260 */ 261 public String getJavaClass() { 262 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 263 } 264 265 266 267 /** 268 * {@inheritDoc} 269 */ 270 public void setJavaClass(String value) throws PropertyException { 271 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 272 } 273 274 275 276 /** 277 * {@inheritDoc} 278 */ 279 public ManagedObjectDefinition<? extends DirectoryStringAttributeSyntaxCfgClient, ? extends DirectoryStringAttributeSyntaxCfg> definition() { 280 return INSTANCE; 281 } 282 283 284 285 /** 286 * {@inheritDoc} 287 */ 288 public PropertyProvider properties() { 289 return impl; 290 } 291 292 293 294 /** 295 * {@inheritDoc} 296 */ 297 public void commit() throws ManagedObjectAlreadyExistsException, 298 MissingMandatoryPropertiesException, ConcurrentModificationException, 299 OperationRejectedException, AuthorizationException, 300 CommunicationException { 301 impl.commit(); 302 } 303 304 305 306 /** {@inheritDoc} */ 307 public String toString() { 308 return impl.toString(); 309 } 310 } 311 312 313 314 /** 315 * Managed object server implementation. 316 */ 317 private static class DirectoryStringAttributeSyntaxCfgServerImpl implements 318 DirectoryStringAttributeSyntaxCfg { 319 320 // Private implementation. 321 private ServerManagedObject<? extends DirectoryStringAttributeSyntaxCfg> impl; 322 323 // The value of the "allow-zero-length-values" property. 324 private final boolean pAllowZeroLengthValues; 325 326 // The value of the "enabled" property. 327 private final boolean pEnabled; 328 329 // The value of the "java-class" property. 330 private final String pJavaClass; 331 332 333 334 // Private constructor. 335 private DirectoryStringAttributeSyntaxCfgServerImpl(ServerManagedObject<? extends DirectoryStringAttributeSyntaxCfg> impl) { 336 this.impl = impl; 337 this.pAllowZeroLengthValues = impl.getPropertyValue(INSTANCE.getAllowZeroLengthValuesPropertyDefinition()); 338 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 339 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 340 } 341 342 343 344 /** 345 * {@inheritDoc} 346 */ 347 public void addDirectoryStringChangeListener( 348 ConfigurationChangeListener<DirectoryStringAttributeSyntaxCfg> listener) { 349 impl.registerChangeListener(listener); 350 } 351 352 353 354 /** 355 * {@inheritDoc} 356 */ 357 public void removeDirectoryStringChangeListener( 358 ConfigurationChangeListener<DirectoryStringAttributeSyntaxCfg> listener) { 359 impl.deregisterChangeListener(listener); 360 } 361 /** 362 * {@inheritDoc} 363 */ 364 public void addChangeListener( 365 ConfigurationChangeListener<AttributeSyntaxCfg> listener) { 366 impl.registerChangeListener(listener); 367 } 368 369 370 371 /** 372 * {@inheritDoc} 373 */ 374 public void removeChangeListener( 375 ConfigurationChangeListener<AttributeSyntaxCfg> listener) { 376 impl.deregisterChangeListener(listener); 377 } 378 379 380 381 /** 382 * {@inheritDoc} 383 */ 384 public boolean isAllowZeroLengthValues() { 385 return pAllowZeroLengthValues; 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 Class<? extends DirectoryStringAttributeSyntaxCfg> configurationClass() { 412 return DirectoryStringAttributeSyntaxCfg.class; 413 } 414 415 416 417 /** 418 * {@inheritDoc} 419 */ 420 public DN dn() { 421 return impl.getDN(); 422 } 423 424 425 426 /** {@inheritDoc} */ 427 public String toString() { 428 return impl.toString(); 429 } 430 } 431}