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