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 010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE 011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2008 Sun Microsystems, Inc. 026 */ 027 package org.opends.server.admin.std.meta; 028 029 030 031 import java.util.Collection; 032 import java.util.SortedSet; 033 import org.opends.server.admin.AdministratorAction; 034 import org.opends.server.admin.BooleanPropertyDefinition; 035 import org.opends.server.admin.ClassPropertyDefinition; 036 import org.opends.server.admin.client.AuthorizationException; 037 import org.opends.server.admin.client.CommunicationException; 038 import org.opends.server.admin.client.ConcurrentModificationException; 039 import org.opends.server.admin.client.ManagedObject; 040 import org.opends.server.admin.client.MissingMandatoryPropertiesException; 041 import org.opends.server.admin.client.OperationRejectedException; 042 import org.opends.server.admin.DefaultBehaviorProvider; 043 import org.opends.server.admin.DefinedDefaultBehaviorProvider; 044 import org.opends.server.admin.EnumPropertyDefinition; 045 import org.opends.server.admin.ManagedObjectAlreadyExistsException; 046 import org.opends.server.admin.ManagedObjectDefinition; 047 import org.opends.server.admin.PropertyOption; 048 import org.opends.server.admin.PropertyProvider; 049 import org.opends.server.admin.server.ConfigurationChangeListener; 050 import org.opends.server.admin.server.ServerManagedObject; 051 import org.opends.server.admin.std.client.EntryUUIDPluginCfgClient; 052 import org.opends.server.admin.std.meta.PluginCfgDefn.PluginType; 053 import org.opends.server.admin.std.server.EntryUUIDPluginCfg; 054 import org.opends.server.admin.std.server.PluginCfg; 055 import org.opends.server.admin.Tag; 056 import org.opends.server.types.DN; 057 058 059 060 /** 061 * An interface for querying the Entry UUID Plugin managed object 062 * definition meta information. 063 * <p> 064 * The Entry UUID Plugin generates values for the entryUUID 065 * operational attribute whenever an entry is added via protocol or 066 * imported from LDIF. 067 */ 068 public final class EntryUUIDPluginCfgDefn extends ManagedObjectDefinition<EntryUUIDPluginCfgClient, EntryUUIDPluginCfg> { 069 070 // The singleton configuration definition instance. 071 private static final EntryUUIDPluginCfgDefn INSTANCE = new EntryUUIDPluginCfgDefn(); 072 073 074 075 // The "java-class" property definition. 076 private static final ClassPropertyDefinition PD_JAVA_CLASS; 077 078 079 080 // The "plugin-type" property definition. 081 private static final EnumPropertyDefinition<PluginType> PD_PLUGIN_TYPE; 082 083 084 085 // Build the "java-class" property definition. 086 static { 087 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 088 builder.setOption(PropertyOption.MANDATORY); 089 builder.setOption(PropertyOption.ADVANCED); 090 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class")); 091 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.plugins.EntryUUIDPlugin"); 092 builder.setDefaultBehaviorProvider(provider); 093 builder.addInstanceOf("org.opends.server.api.plugin.DirectoryServerPlugin"); 094 PD_JAVA_CLASS = builder.getInstance(); 095 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 096 } 097 098 099 100 // Build the "plugin-type" property definition. 101 static { 102 EnumPropertyDefinition.Builder<PluginType> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "plugin-type"); 103 builder.setOption(PropertyOption.MULTI_VALUED); 104 builder.setOption(PropertyOption.MANDATORY); 105 builder.setOption(PropertyOption.ADVANCED); 106 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "plugin-type")); 107 DefaultBehaviorProvider<PluginType> provider = new DefinedDefaultBehaviorProvider<PluginType>("ldifimport", "preoperationadd"); 108 builder.setDefaultBehaviorProvider(provider); 109 builder.setEnumClass(PluginType.class); 110 PD_PLUGIN_TYPE = builder.getInstance(); 111 INSTANCE.registerPropertyDefinition(PD_PLUGIN_TYPE); 112 } 113 114 115 116 // Register the tags associated with this managed object definition. 117 static { 118 INSTANCE.registerTag(Tag.valueOf("core-server")); 119 } 120 121 122 123 /** 124 * Get the Entry UUID Plugin configuration definition singleton. 125 * 126 * @return Returns the Entry UUID Plugin configuration definition 127 * singleton. 128 */ 129 public static EntryUUIDPluginCfgDefn getInstance() { 130 return INSTANCE; 131 } 132 133 134 135 /** 136 * Private constructor. 137 */ 138 private EntryUUIDPluginCfgDefn() { 139 super("entry-uuid-plugin", PluginCfgDefn.getInstance()); 140 } 141 142 143 144 /** 145 * {@inheritDoc} 146 */ 147 public EntryUUIDPluginCfgClient createClientConfiguration( 148 ManagedObject<? extends EntryUUIDPluginCfgClient> impl) { 149 return new EntryUUIDPluginCfgClientImpl(impl); 150 } 151 152 153 154 /** 155 * {@inheritDoc} 156 */ 157 public EntryUUIDPluginCfg createServerConfiguration( 158 ServerManagedObject<? extends EntryUUIDPluginCfg> impl) { 159 return new EntryUUIDPluginCfgServerImpl(impl); 160 } 161 162 163 164 /** 165 * {@inheritDoc} 166 */ 167 public Class<EntryUUIDPluginCfg> getServerConfigurationClass() { 168 return EntryUUIDPluginCfg.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 EntryUUIDPluginCfgClientImpl implements 236 EntryUUIDPluginCfgClient { 237 238 // Private implementation. 239 private ManagedObject<? extends EntryUUIDPluginCfgClient> impl; 240 241 242 243 // Private constructor. 244 private EntryUUIDPluginCfgClientImpl( 245 ManagedObject<? extends EntryUUIDPluginCfgClient> 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 EntryUUIDPluginCfgClient, ? extends EntryUUIDPluginCfg> 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 354 355 /** 356 * Managed object server implementation. 357 */ 358 private static class EntryUUIDPluginCfgServerImpl implements 359 EntryUUIDPluginCfg { 360 361 // Private implementation. 362 private ServerManagedObject<? extends EntryUUIDPluginCfg> impl; 363 364 // The value of the "enabled" property. 365 private final boolean pEnabled; 366 367 // The value of the "invoke-for-internal-operations" property. 368 private final boolean pInvokeForInternalOperations; 369 370 // The value of the "java-class" property. 371 private final String pJavaClass; 372 373 // The value of the "plugin-type" property. 374 private final SortedSet<PluginType> pPluginType; 375 376 377 378 // Private constructor. 379 private EntryUUIDPluginCfgServerImpl(ServerManagedObject<? extends EntryUUIDPluginCfg> impl) { 380 this.impl = impl; 381 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 382 this.pInvokeForInternalOperations = impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition()); 383 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 384 this.pPluginType = impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition()); 385 } 386 387 388 389 /** 390 * {@inheritDoc} 391 */ 392 public void addEntryUUIDChangeListener( 393 ConfigurationChangeListener<EntryUUIDPluginCfg> listener) { 394 impl.registerChangeListener(listener); 395 } 396 397 398 399 /** 400 * {@inheritDoc} 401 */ 402 public void removeEntryUUIDChangeListener( 403 ConfigurationChangeListener<EntryUUIDPluginCfg> listener) { 404 impl.deregisterChangeListener(listener); 405 } 406 /** 407 * {@inheritDoc} 408 */ 409 public void addChangeListener( 410 ConfigurationChangeListener<PluginCfg> listener) { 411 impl.registerChangeListener(listener); 412 } 413 414 415 416 /** 417 * {@inheritDoc} 418 */ 419 public void removeChangeListener( 420 ConfigurationChangeListener<PluginCfg> listener) { 421 impl.deregisterChangeListener(listener); 422 } 423 424 425 426 /** 427 * {@inheritDoc} 428 */ 429 public boolean isEnabled() { 430 return pEnabled; 431 } 432 433 434 435 /** 436 * {@inheritDoc} 437 */ 438 public boolean isInvokeForInternalOperations() { 439 return pInvokeForInternalOperations; 440 } 441 442 443 444 /** 445 * {@inheritDoc} 446 */ 447 public String getJavaClass() { 448 return pJavaClass; 449 } 450 451 452 453 /** 454 * {@inheritDoc} 455 */ 456 public SortedSet<PluginType> getPluginType() { 457 return pPluginType; 458 } 459 460 461 462 /** 463 * {@inheritDoc} 464 */ 465 public Class<? extends EntryUUIDPluginCfg> configurationClass() { 466 return EntryUUIDPluginCfg.class; 467 } 468 469 470 471 /** 472 * {@inheritDoc} 473 */ 474 public DN dn() { 475 return impl.getDN(); 476 } 477 478 } 479 }