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 java.util.Collection; 031import java.util.SortedSet; 032import org.forgerock.opendj.config.AdministratorAction; 033import org.forgerock.opendj.config.BooleanPropertyDefinition; 034import org.forgerock.opendj.config.ClassPropertyDefinition; 035import org.forgerock.opendj.config.client.ConcurrentModificationException; 036import org.forgerock.opendj.config.client.ManagedObject; 037import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException; 038import org.forgerock.opendj.config.client.OperationRejectedException; 039import org.forgerock.opendj.config.DefaultBehaviorProvider; 040import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider; 041import org.forgerock.opendj.config.EnumPropertyDefinition; 042import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException; 043import org.forgerock.opendj.config.ManagedObjectDefinition; 044import org.forgerock.opendj.config.PropertyOption; 045import org.forgerock.opendj.config.PropertyProvider; 046import org.forgerock.opendj.config.server.ConfigurationChangeListener; 047import org.forgerock.opendj.config.server.ServerManagedObject; 048import org.forgerock.opendj.config.Tag; 049import org.forgerock.opendj.ldap.DN; 050import org.forgerock.opendj.ldap.LdapException; 051import org.forgerock.opendj.server.config.client.LDAPAttributeDescriptionListPluginCfgClient; 052import org.forgerock.opendj.server.config.meta.PluginCfgDefn.PluginType; 053import org.forgerock.opendj.server.config.server.LDAPAttributeDescriptionListPluginCfg; 054import org.forgerock.opendj.server.config.server.PluginCfg; 055 056 057 058/** 059 * An interface for querying the LDAP Attribute Description List 060 * Plugin managed object definition meta information. 061 * <p> 062 * The LDAP Attribute Description List Plugin provides the ability for 063 * clients to include an attribute list in a search request that names 064 * object classes instead of (or in addition to) attributes. 065 */ 066public final class LDAPAttributeDescriptionListPluginCfgDefn extends ManagedObjectDefinition<LDAPAttributeDescriptionListPluginCfgClient, LDAPAttributeDescriptionListPluginCfg> { 067 068 // The singleton configuration definition instance. 069 private static final LDAPAttributeDescriptionListPluginCfgDefn INSTANCE = new LDAPAttributeDescriptionListPluginCfgDefn(); 070 071 072 073 // The "java-class" property definition. 074 private static final ClassPropertyDefinition PD_JAVA_CLASS; 075 076 077 078 // The "plugin-type" property definition. 079 private static final EnumPropertyDefinition<PluginType> PD_PLUGIN_TYPE; 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.MANDATORY); 087 builder.setOption(PropertyOption.ADVANCED); 088 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class")); 089 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.plugins.LDAPADListPlugin"); 090 builder.setDefaultBehaviorProvider(provider); 091 builder.addInstanceOf("org.opends.server.api.plugin.DirectoryServerPlugin"); 092 PD_JAVA_CLASS = builder.getInstance(); 093 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 094 } 095 096 097 098 // Build the "plugin-type" property definition. 099 static { 100 EnumPropertyDefinition.Builder<PluginType> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "plugin-type"); 101 builder.setOption(PropertyOption.MULTI_VALUED); 102 builder.setOption(PropertyOption.MANDATORY); 103 builder.setOption(PropertyOption.ADVANCED); 104 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "plugin-type")); 105 DefaultBehaviorProvider<PluginType> provider = new DefinedDefaultBehaviorProvider<PluginType>("preparsesearch"); 106 builder.setDefaultBehaviorProvider(provider); 107 builder.setEnumClass(PluginType.class); 108 PD_PLUGIN_TYPE = builder.getInstance(); 109 INSTANCE.registerPropertyDefinition(PD_PLUGIN_TYPE); 110 } 111 112 113 114 // Register the tags associated with this managed object definition. 115 static { 116 INSTANCE.registerTag(Tag.valueOf("core-server")); 117 } 118 119 120 121 /** 122 * Get the LDAP Attribute Description List Plugin configuration 123 * definition singleton. 124 * 125 * @return Returns the LDAP Attribute Description List Plugin 126 * configuration definition singleton. 127 */ 128 public static LDAPAttributeDescriptionListPluginCfgDefn getInstance() { 129 return INSTANCE; 130 } 131 132 133 134 /** 135 * Private constructor. 136 */ 137 private LDAPAttributeDescriptionListPluginCfgDefn() { 138 super("ldap-attribute-description-list-plugin", PluginCfgDefn.getInstance()); 139 } 140 141 142 143 /** 144 * {@inheritDoc} 145 */ 146 public LDAPAttributeDescriptionListPluginCfgClient createClientConfiguration( 147 ManagedObject<? extends LDAPAttributeDescriptionListPluginCfgClient> impl) { 148 return new LDAPAttributeDescriptionListPluginCfgClientImpl(impl); 149 } 150 151 152 153 /** 154 * {@inheritDoc} 155 */ 156 public LDAPAttributeDescriptionListPluginCfg createServerConfiguration( 157 ServerManagedObject<? extends LDAPAttributeDescriptionListPluginCfg> impl) { 158 return new LDAPAttributeDescriptionListPluginCfgServerImpl(impl); 159 } 160 161 162 163 /** 164 * {@inheritDoc} 165 */ 166 public Class<LDAPAttributeDescriptionListPluginCfg> getServerConfigurationClass() { 167 return LDAPAttributeDescriptionListPluginCfg.class; 168 } 169 170 171 172 /** 173 * Get the "enabled" property definition. 174 * <p> 175 * Indicates whether the plug-in is enabled for use. 176 * 177 * @return Returns the "enabled" property definition. 178 */ 179 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 180 return PluginCfgDefn.getInstance().getEnabledPropertyDefinition(); 181 } 182 183 184 185 /** 186 * Get the "invoke-for-internal-operations" property definition. 187 * <p> 188 * Indicates whether the plug-in should be invoked for internal 189 * operations. 190 * <p> 191 * Any plug-in that can be invoked for internal operations must 192 * ensure that it does not create any new internal operatons that can 193 * cause the same plug-in to be re-invoked. 194 * 195 * @return Returns the "invoke-for-internal-operations" property definition. 196 */ 197 public BooleanPropertyDefinition getInvokeForInternalOperationsPropertyDefinition() { 198 return PluginCfgDefn.getInstance().getInvokeForInternalOperationsPropertyDefinition(); 199 } 200 201 202 203 /** 204 * Get the "java-class" property definition. 205 * <p> 206 * Specifies the fully-qualified name of the Java class that 207 * provides the plug-in implementation. 208 * 209 * @return Returns the "java-class" property definition. 210 */ 211 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 212 return PD_JAVA_CLASS; 213 } 214 215 216 217 /** 218 * Get the "plugin-type" property definition. 219 * <p> 220 * Specifies the set of plug-in types for the plug-in, which 221 * specifies the times at which the plug-in is invoked. 222 * 223 * @return Returns the "plugin-type" property definition. 224 */ 225 public EnumPropertyDefinition<PluginType> getPluginTypePropertyDefinition() { 226 return PD_PLUGIN_TYPE; 227 } 228 229 230 231 /** 232 * Managed object client implementation. 233 */ 234 private static class LDAPAttributeDescriptionListPluginCfgClientImpl implements 235 LDAPAttributeDescriptionListPluginCfgClient { 236 237 // Private implementation. 238 private ManagedObject<? extends LDAPAttributeDescriptionListPluginCfgClient> impl; 239 240 241 242 // Private constructor. 243 private LDAPAttributeDescriptionListPluginCfgClientImpl( 244 ManagedObject<? extends LDAPAttributeDescriptionListPluginCfgClient> impl) { 245 this.impl = impl; 246 } 247 248 249 250 /** 251 * {@inheritDoc} 252 */ 253 public Boolean isEnabled() { 254 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 255 } 256 257 258 259 /** 260 * {@inheritDoc} 261 */ 262 public void setEnabled(boolean value) { 263 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 264 } 265 266 267 268 /** 269 * {@inheritDoc} 270 */ 271 public boolean isInvokeForInternalOperations() { 272 return impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition()); 273 } 274 275 276 277 /** 278 * {@inheritDoc} 279 */ 280 public void setInvokeForInternalOperations(Boolean value) { 281 impl.setPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition(), value); 282 } 283 284 285 286 /** 287 * {@inheritDoc} 288 */ 289 public String getJavaClass() { 290 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 291 } 292 293 294 295 /** 296 * {@inheritDoc} 297 */ 298 public void setJavaClass(String value) { 299 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 300 } 301 302 303 304 /** 305 * {@inheritDoc} 306 */ 307 public SortedSet<PluginType> getPluginType() { 308 return impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition()); 309 } 310 311 312 313 /** 314 * {@inheritDoc} 315 */ 316 public void setPluginType(Collection<PluginType> values) { 317 impl.setPropertyValues(INSTANCE.getPluginTypePropertyDefinition(), values); 318 } 319 320 321 322 /** 323 * {@inheritDoc} 324 */ 325 public ManagedObjectDefinition<? extends LDAPAttributeDescriptionListPluginCfgClient, ? extends LDAPAttributeDescriptionListPluginCfg> definition() { 326 return INSTANCE; 327 } 328 329 330 331 /** 332 * {@inheritDoc} 333 */ 334 public PropertyProvider properties() { 335 return impl; 336 } 337 338 339 340 /** 341 * {@inheritDoc} 342 */ 343 public void commit() throws ManagedObjectAlreadyExistsException, 344 MissingMandatoryPropertiesException, ConcurrentModificationException, 345 OperationRejectedException, LdapException { 346 impl.commit(); 347 } 348 349 } 350 351 352 353 /** 354 * Managed object server implementation. 355 */ 356 private static class LDAPAttributeDescriptionListPluginCfgServerImpl implements 357 LDAPAttributeDescriptionListPluginCfg { 358 359 // Private implementation. 360 private ServerManagedObject<? extends LDAPAttributeDescriptionListPluginCfg> impl; 361 362 // The value of the "enabled" property. 363 private final boolean pEnabled; 364 365 // The value of the "invoke-for-internal-operations" property. 366 private final boolean pInvokeForInternalOperations; 367 368 // The value of the "java-class" property. 369 private final String pJavaClass; 370 371 // The value of the "plugin-type" property. 372 private final SortedSet<PluginType> pPluginType; 373 374 375 376 // Private constructor. 377 private LDAPAttributeDescriptionListPluginCfgServerImpl(ServerManagedObject<? extends LDAPAttributeDescriptionListPluginCfg> impl) { 378 this.impl = impl; 379 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 380 this.pInvokeForInternalOperations = impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition()); 381 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 382 this.pPluginType = impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition()); 383 } 384 385 386 387 /** 388 * {@inheritDoc} 389 */ 390 public void addLDAPAttributeDescriptionListChangeListener( 391 ConfigurationChangeListener<LDAPAttributeDescriptionListPluginCfg> listener) { 392 impl.registerChangeListener(listener); 393 } 394 395 396 397 /** 398 * {@inheritDoc} 399 */ 400 public void removeLDAPAttributeDescriptionListChangeListener( 401 ConfigurationChangeListener<LDAPAttributeDescriptionListPluginCfg> listener) { 402 impl.deregisterChangeListener(listener); 403 } 404 /** 405 * {@inheritDoc} 406 */ 407 public void addChangeListener( 408 ConfigurationChangeListener<PluginCfg> listener) { 409 impl.registerChangeListener(listener); 410 } 411 412 413 414 /** 415 * {@inheritDoc} 416 */ 417 public void removeChangeListener( 418 ConfigurationChangeListener<PluginCfg> listener) { 419 impl.deregisterChangeListener(listener); 420 } 421 422 423 424 /** 425 * {@inheritDoc} 426 */ 427 public boolean isEnabled() { 428 return pEnabled; 429 } 430 431 432 433 /** 434 * {@inheritDoc} 435 */ 436 public boolean isInvokeForInternalOperations() { 437 return pInvokeForInternalOperations; 438 } 439 440 441 442 /** 443 * {@inheritDoc} 444 */ 445 public String getJavaClass() { 446 return pJavaClass; 447 } 448 449 450 451 /** 452 * {@inheritDoc} 453 */ 454 public SortedSet<PluginType> getPluginType() { 455 return pPluginType; 456 } 457 458 459 460 /** 461 * {@inheritDoc} 462 */ 463 public Class<? extends LDAPAttributeDescriptionListPluginCfg> configurationClass() { 464 return LDAPAttributeDescriptionListPluginCfg.class; 465 } 466 467 468 469 /** 470 * {@inheritDoc} 471 */ 472 public DN dn() { 473 return impl.getDN(); 474 } 475 476 } 477}