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