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