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