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.forgerock.opendj.server.config.meta; 027 028 029 030import org.forgerock.opendj.config.AdministratorAction; 031import org.forgerock.opendj.config.BooleanPropertyDefinition; 032import org.forgerock.opendj.config.ClassPropertyDefinition; 033import org.forgerock.opendj.config.client.ConcurrentModificationException; 034import org.forgerock.opendj.config.client.ManagedObject; 035import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException; 036import org.forgerock.opendj.config.client.OperationRejectedException; 037import org.forgerock.opendj.config.DefaultBehaviorProvider; 038import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider; 039import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException; 040import org.forgerock.opendj.config.ManagedObjectDefinition; 041import org.forgerock.opendj.config.PropertyException; 042import org.forgerock.opendj.config.PropertyOption; 043import org.forgerock.opendj.config.PropertyProvider; 044import org.forgerock.opendj.config.server.ConfigurationChangeListener; 045import org.forgerock.opendj.config.server.ServerManagedObject; 046import org.forgerock.opendj.config.Tag; 047import org.forgerock.opendj.ldap.DN; 048import org.forgerock.opendj.ldap.LdapException; 049import org.forgerock.opendj.server.config.client.TelephoneNumberAttributeSyntaxCfgClient; 050import org.forgerock.opendj.server.config.server.AttributeSyntaxCfg; 051import org.forgerock.opendj.server.config.server.TelephoneNumberAttributeSyntaxCfg; 052 053 054 055/** 056 * An interface for querying the Telephone Number Attribute Syntax 057 * managed object definition meta information. 058 * <p> 059 * Telephone Number Attribute Syntaxes define an attribute syntax for 060 * storing telephone number information. 061 */ 062public final class TelephoneNumberAttributeSyntaxCfgDefn extends ManagedObjectDefinition<TelephoneNumberAttributeSyntaxCfgClient, TelephoneNumberAttributeSyntaxCfg> { 063 064 /** The singleton configuration definition instance. */ 065 private static final TelephoneNumberAttributeSyntaxCfgDefn INSTANCE = new TelephoneNumberAttributeSyntaxCfgDefn(); 066 067 068 069 /** The "java-class" property definition. */ 070 private static final ClassPropertyDefinition PD_JAVA_CLASS; 071 072 073 074 /** The "strict-format" property definition. */ 075 private static final BooleanPropertyDefinition PD_STRICT_FORMAT; 076 077 078 079 /** Build the "java-class" property definition. */ 080 static { 081 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 082 builder.setOption(PropertyOption.READ_ONLY); 083 builder.setOption(PropertyOption.MANDATORY); 084 builder.setOption(PropertyOption.ADVANCED); 085 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class")); 086 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.schema.TelephoneNumberSyntax"); 087 builder.setDefaultBehaviorProvider(provider); 088 builder.addInstanceOf("org.opends.server.api.AttributeSyntax"); 089 PD_JAVA_CLASS = builder.getInstance(); 090 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 091 } 092 093 094 095 /** Build the "strict-format" property definition. */ 096 static { 097 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "strict-format"); 098 builder.setOption(PropertyOption.ADVANCED); 099 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "strict-format")); 100 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false"); 101 builder.setDefaultBehaviorProvider(provider); 102 PD_STRICT_FORMAT = builder.getInstance(); 103 INSTANCE.registerPropertyDefinition(PD_STRICT_FORMAT); 104 } 105 106 107 108 // Register the tags associated with this managed object definition. 109 static { 110 INSTANCE.registerTag(Tag.valueOf("core-server")); 111 } 112 113 114 115 /** 116 * Get the Telephone Number Attribute Syntax configuration 117 * definition singleton. 118 * 119 * @return Returns the Telephone Number Attribute Syntax 120 * configuration definition singleton. 121 */ 122 public static TelephoneNumberAttributeSyntaxCfgDefn getInstance() { 123 return INSTANCE; 124 } 125 126 127 128 /** 129 * Private constructor. 130 */ 131 private TelephoneNumberAttributeSyntaxCfgDefn() { 132 super("telephone-number-attribute-syntax", AttributeSyntaxCfgDefn.getInstance()); 133 } 134 135 136 137 /** {@inheritDoc} */ 138 public TelephoneNumberAttributeSyntaxCfgClient createClientConfiguration( 139 ManagedObject<? extends TelephoneNumberAttributeSyntaxCfgClient> impl) { 140 return new TelephoneNumberAttributeSyntaxCfgClientImpl(impl); 141 } 142 143 144 145 /** {@inheritDoc} */ 146 public TelephoneNumberAttributeSyntaxCfg createServerConfiguration( 147 ServerManagedObject<? extends TelephoneNumberAttributeSyntaxCfg> impl) { 148 return new TelephoneNumberAttributeSyntaxCfgServerImpl(impl); 149 } 150 151 152 153 /** {@inheritDoc} */ 154 public Class<TelephoneNumberAttributeSyntaxCfg> getServerConfigurationClass() { 155 return TelephoneNumberAttributeSyntaxCfg.class; 156 } 157 158 159 160 /** 161 * Get the "enabled" property definition. 162 * <p> 163 * Indicates whether the Telephone Number Attribute Syntax is 164 * enabled. 165 * 166 * @return Returns the "enabled" property definition. 167 */ 168 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 169 return AttributeSyntaxCfgDefn.getInstance().getEnabledPropertyDefinition(); 170 } 171 172 173 174 /** 175 * Get the "java-class" property definition. 176 * <p> 177 * Specifies the fully-qualified name of the Java class that 178 * provides the Telephone Number Attribute Syntax implementation. 179 * 180 * @return Returns the "java-class" property definition. 181 */ 182 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 183 return PD_JAVA_CLASS; 184 } 185 186 187 188 /** 189 * Get the "strict-format" property definition. 190 * <p> 191 * Indicates whether to require telephone number values to strictly 192 * comply with the standard definition for this syntax. 193 * 194 * @return Returns the "strict-format" property definition. 195 */ 196 public BooleanPropertyDefinition getStrictFormatPropertyDefinition() { 197 return PD_STRICT_FORMAT; 198 } 199 200 201 202 /** 203 * Managed object client implementation. 204 */ 205 private static class TelephoneNumberAttributeSyntaxCfgClientImpl implements 206 TelephoneNumberAttributeSyntaxCfgClient { 207 208 /** Private implementation. */ 209 private ManagedObject<? extends TelephoneNumberAttributeSyntaxCfgClient> impl; 210 211 212 213 /** Private constructor. */ 214 private TelephoneNumberAttributeSyntaxCfgClientImpl( 215 ManagedObject<? extends TelephoneNumberAttributeSyntaxCfgClient> impl) { 216 this.impl = impl; 217 } 218 219 220 221 /** {@inheritDoc} */ 222 public Boolean isEnabled() { 223 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 224 } 225 226 227 228 /** {@inheritDoc} */ 229 public void setEnabled(boolean value) { 230 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 231 } 232 233 234 235 /** {@inheritDoc} */ 236 public String getJavaClass() { 237 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 238 } 239 240 241 242 /** {@inheritDoc} */ 243 public void setJavaClass(String value) throws PropertyException { 244 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 245 } 246 247 248 249 /** {@inheritDoc} */ 250 public boolean isStrictFormat() { 251 return impl.getPropertyValue(INSTANCE.getStrictFormatPropertyDefinition()); 252 } 253 254 255 256 /** {@inheritDoc} */ 257 public void setStrictFormat(Boolean value) { 258 impl.setPropertyValue(INSTANCE.getStrictFormatPropertyDefinition(), value); 259 } 260 261 262 263 /** {@inheritDoc} */ 264 public ManagedObjectDefinition<? extends TelephoneNumberAttributeSyntaxCfgClient, ? extends TelephoneNumberAttributeSyntaxCfg> definition() { 265 return INSTANCE; 266 } 267 268 269 270 /** {@inheritDoc} */ 271 public PropertyProvider properties() { 272 return impl; 273 } 274 275 276 277 /** {@inheritDoc} */ 278 public void commit() throws ManagedObjectAlreadyExistsException, 279 MissingMandatoryPropertiesException, ConcurrentModificationException, 280 OperationRejectedException, LdapException { 281 impl.commit(); 282 } 283 284 285 286 /** {@inheritDoc} */ 287 public String toString() { 288 return impl.toString(); 289 } 290 } 291 292 293 294 /** 295 * Managed object server implementation. 296 */ 297 private static class TelephoneNumberAttributeSyntaxCfgServerImpl implements 298 TelephoneNumberAttributeSyntaxCfg { 299 300 /** Private implementation. */ 301 private ServerManagedObject<? extends TelephoneNumberAttributeSyntaxCfg> impl; 302 303 /** The value of the "enabled" property. */ 304 private final boolean pEnabled; 305 306 /** The value of the "java-class" property. */ 307 private final String pJavaClass; 308 309 /** The value of the "strict-format" property. */ 310 private final boolean pStrictFormat; 311 312 313 314 /** Private constructor. */ 315 private TelephoneNumberAttributeSyntaxCfgServerImpl(ServerManagedObject<? extends TelephoneNumberAttributeSyntaxCfg> impl) { 316 this.impl = impl; 317 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 318 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 319 this.pStrictFormat = impl.getPropertyValue(INSTANCE.getStrictFormatPropertyDefinition()); 320 } 321 322 323 324 /** {@inheritDoc} */ 325 public void addTelephoneNumberChangeListener( 326 ConfigurationChangeListener<TelephoneNumberAttributeSyntaxCfg> listener) { 327 impl.registerChangeListener(listener); 328 } 329 330 331 332 /** {@inheritDoc} */ 333 public void removeTelephoneNumberChangeListener( 334 ConfigurationChangeListener<TelephoneNumberAttributeSyntaxCfg> listener) { 335 impl.deregisterChangeListener(listener); 336 } 337 /** {@inheritDoc} */ 338 public void addChangeListener( 339 ConfigurationChangeListener<AttributeSyntaxCfg> listener) { 340 impl.registerChangeListener(listener); 341 } 342 343 344 345 /** {@inheritDoc} */ 346 public void removeChangeListener( 347 ConfigurationChangeListener<AttributeSyntaxCfg> listener) { 348 impl.deregisterChangeListener(listener); 349 } 350 351 352 353 /** {@inheritDoc} */ 354 public boolean isEnabled() { 355 return pEnabled; 356 } 357 358 359 360 /** {@inheritDoc} */ 361 public String getJavaClass() { 362 return pJavaClass; 363 } 364 365 366 367 /** {@inheritDoc} */ 368 public boolean isStrictFormat() { 369 return pStrictFormat; 370 } 371 372 373 374 /** {@inheritDoc} */ 375 public Class<? extends TelephoneNumberAttributeSyntaxCfg> configurationClass() { 376 return TelephoneNumberAttributeSyntaxCfg.class; 377 } 378 379 380 381 /** {@inheritDoc} */ 382 public DN dn() { 383 return impl.getDN(); 384 } 385 386 387 388 /** {@inheritDoc} */ 389 public String toString() { 390 return impl.toString(); 391 } 392 } 393}