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.AliasDefaultBehaviorProvider; 035 import org.opends.server.admin.AttributeTypePropertyDefinition; 036 import org.opends.server.admin.BooleanPropertyDefinition; 037 import org.opends.server.admin.ClassPropertyDefinition; 038 import org.opends.server.admin.client.AuthorizationException; 039 import org.opends.server.admin.client.CommunicationException; 040 import org.opends.server.admin.client.ConcurrentModificationException; 041 import org.opends.server.admin.client.ManagedObject; 042 import org.opends.server.admin.client.MissingMandatoryPropertiesException; 043 import org.opends.server.admin.client.OperationRejectedException; 044 import org.opends.server.admin.DefaultBehaviorProvider; 045 import org.opends.server.admin.DefinedDefaultBehaviorProvider; 046 import org.opends.server.admin.DNPropertyDefinition; 047 import org.opends.server.admin.DurationPropertyDefinition; 048 import org.opends.server.admin.EnumPropertyDefinition; 049 import org.opends.server.admin.ManagedObjectAlreadyExistsException; 050 import org.opends.server.admin.ManagedObjectDefinition; 051 import org.opends.server.admin.PropertyOption; 052 import org.opends.server.admin.PropertyProvider; 053 import org.opends.server.admin.server.ConfigurationChangeListener; 054 import org.opends.server.admin.server.ServerManagedObject; 055 import org.opends.server.admin.std.client.ReferentialIntegrityPluginCfgClient; 056 import org.opends.server.admin.std.meta.PluginCfgDefn.PluginType; 057 import org.opends.server.admin.std.server.PluginCfg; 058 import org.opends.server.admin.std.server.ReferentialIntegrityPluginCfg; 059 import org.opends.server.admin.StringPropertyDefinition; 060 import org.opends.server.admin.Tag; 061 import org.opends.server.admin.UndefinedDefaultBehaviorProvider; 062 import org.opends.server.types.AttributeType; 063 import org.opends.server.types.DN; 064 065 066 067 /** 068 * An interface for querying the Referential Integrity Plugin managed 069 * object definition meta information. 070 * <p> 071 * The Referential Integrity Plugin maintains referential integrity 072 * for DN valued attributes. 073 */ 074 public final class ReferentialIntegrityPluginCfgDefn extends ManagedObjectDefinition<ReferentialIntegrityPluginCfgClient, ReferentialIntegrityPluginCfg> { 075 076 // The singleton configuration definition instance. 077 private static final ReferentialIntegrityPluginCfgDefn INSTANCE = new ReferentialIntegrityPluginCfgDefn(); 078 079 080 081 // The "attribute-type" property definition. 082 private static final AttributeTypePropertyDefinition PD_ATTRIBUTE_TYPE; 083 084 085 086 // The "base-dn" property definition. 087 private static final DNPropertyDefinition PD_BASE_DN; 088 089 090 091 // The "java-class" property definition. 092 private static final ClassPropertyDefinition PD_JAVA_CLASS; 093 094 095 096 // The "log-file" property definition. 097 private static final StringPropertyDefinition PD_LOG_FILE; 098 099 100 101 // The "plugin-type" property definition. 102 private static final EnumPropertyDefinition<PluginType> PD_PLUGIN_TYPE; 103 104 105 106 // The "update-interval" property definition. 107 private static final DurationPropertyDefinition PD_UPDATE_INTERVAL; 108 109 110 111 // Build the "attribute-type" property definition. 112 static { 113 AttributeTypePropertyDefinition.Builder builder = AttributeTypePropertyDefinition.createBuilder(INSTANCE, "attribute-type"); 114 builder.setOption(PropertyOption.MULTI_VALUED); 115 builder.setOption(PropertyOption.MANDATORY); 116 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "attribute-type")); 117 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<AttributeType>()); 118 PD_ATTRIBUTE_TYPE = builder.getInstance(); 119 INSTANCE.registerPropertyDefinition(PD_ATTRIBUTE_TYPE); 120 } 121 122 123 124 // Build the "base-dn" property definition. 125 static { 126 DNPropertyDefinition.Builder builder = DNPropertyDefinition.createBuilder(INSTANCE, "base-dn"); 127 builder.setOption(PropertyOption.MULTI_VALUED); 128 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "base-dn")); 129 builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<DN>(INSTANCE, "base-dn")); 130 PD_BASE_DN = builder.getInstance(); 131 INSTANCE.registerPropertyDefinition(PD_BASE_DN); 132 } 133 134 135 136 // Build the "java-class" property definition. 137 static { 138 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 139 builder.setOption(PropertyOption.MANDATORY); 140 builder.setOption(PropertyOption.ADVANCED); 141 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class")); 142 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.plugins.ReferentialIntegrityPlugin"); 143 builder.setDefaultBehaviorProvider(provider); 144 builder.addInstanceOf("org.opends.server.api.plugin.DirectoryServerPlugin"); 145 PD_JAVA_CLASS = builder.getInstance(); 146 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 147 } 148 149 150 151 // Build the "log-file" property definition. 152 static { 153 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "log-file"); 154 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "log-file")); 155 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("logs/referint"); 156 builder.setDefaultBehaviorProvider(provider); 157 builder.setPattern(".*", "FILE"); 158 PD_LOG_FILE = builder.getInstance(); 159 INSTANCE.registerPropertyDefinition(PD_LOG_FILE); 160 } 161 162 163 164 // Build the "plugin-type" property definition. 165 static { 166 EnumPropertyDefinition.Builder<PluginType> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "plugin-type"); 167 builder.setOption(PropertyOption.MULTI_VALUED); 168 builder.setOption(PropertyOption.MANDATORY); 169 builder.setOption(PropertyOption.ADVANCED); 170 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "plugin-type")); 171 DefaultBehaviorProvider<PluginType> provider = new DefinedDefaultBehaviorProvider<PluginType>("postoperationdelete", "postoperationmodifydn", "subordinatemodifydn"); 172 builder.setDefaultBehaviorProvider(provider); 173 builder.setEnumClass(PluginType.class); 174 PD_PLUGIN_TYPE = builder.getInstance(); 175 INSTANCE.registerPropertyDefinition(PD_PLUGIN_TYPE); 176 } 177 178 179 180 // Build the "update-interval" property definition. 181 static { 182 DurationPropertyDefinition.Builder builder = DurationPropertyDefinition.createBuilder(INSTANCE, "update-interval"); 183 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "update-interval")); 184 DefaultBehaviorProvider<Long> provider = new DefinedDefaultBehaviorProvider<Long>("0 seconds"); 185 builder.setDefaultBehaviorProvider(provider); 186 builder.setAllowUnlimited(false); 187 builder.setBaseUnit("s"); 188 PD_UPDATE_INTERVAL = builder.getInstance(); 189 INSTANCE.registerPropertyDefinition(PD_UPDATE_INTERVAL); 190 } 191 192 193 194 // Register the tags associated with this managed object definition. 195 static { 196 INSTANCE.registerTag(Tag.valueOf("core-server")); 197 } 198 199 200 201 /** 202 * Get the Referential Integrity Plugin configuration definition 203 * singleton. 204 * 205 * @return Returns the Referential Integrity Plugin configuration 206 * definition singleton. 207 */ 208 public static ReferentialIntegrityPluginCfgDefn getInstance() { 209 return INSTANCE; 210 } 211 212 213 214 /** 215 * Private constructor. 216 */ 217 private ReferentialIntegrityPluginCfgDefn() { 218 super("referential-integrity-plugin", PluginCfgDefn.getInstance()); 219 } 220 221 222 223 /** 224 * {@inheritDoc} 225 */ 226 public ReferentialIntegrityPluginCfgClient createClientConfiguration( 227 ManagedObject<? extends ReferentialIntegrityPluginCfgClient> impl) { 228 return new ReferentialIntegrityPluginCfgClientImpl(impl); 229 } 230 231 232 233 /** 234 * {@inheritDoc} 235 */ 236 public ReferentialIntegrityPluginCfg createServerConfiguration( 237 ServerManagedObject<? extends ReferentialIntegrityPluginCfg> impl) { 238 return new ReferentialIntegrityPluginCfgServerImpl(impl); 239 } 240 241 242 243 /** 244 * {@inheritDoc} 245 */ 246 public Class<ReferentialIntegrityPluginCfg> getServerConfigurationClass() { 247 return ReferentialIntegrityPluginCfg.class; 248 } 249 250 251 252 /** 253 * Get the "attribute-type" property definition. 254 * <p> 255 * Specifies the attribute types for which referential integrity is 256 * to be maintained. 257 * <p> 258 * At least one attribute type must be specified, and the syntax of 259 * any attributes must be either a distinguished name 260 * (1.3.6.1.4.1.1466.115.121.1.12) or name and optional UID 261 * (1.3.6.1.4.1.1466.115.121.1.34). 262 * 263 * @return Returns the "attribute-type" property definition. 264 */ 265 public AttributeTypePropertyDefinition getAttributeTypePropertyDefinition() { 266 return PD_ATTRIBUTE_TYPE; 267 } 268 269 270 271 /** 272 * Get the "base-dn" property definition. 273 * <p> 274 * Specifies the base DN that limits the scope within which 275 * referential integrity is maintained. 276 * 277 * @return Returns the "base-dn" property definition. 278 */ 279 public DNPropertyDefinition getBaseDNPropertyDefinition() { 280 return PD_BASE_DN; 281 } 282 283 284 285 /** 286 * Get the "enabled" property definition. 287 * <p> 288 * Indicates whether the plug-in is enabled for use. 289 * 290 * @return Returns the "enabled" property definition. 291 */ 292 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 293 return PluginCfgDefn.getInstance().getEnabledPropertyDefinition(); 294 } 295 296 297 298 /** 299 * Get the "invoke-for-internal-operations" property definition. 300 * <p> 301 * Indicates whether the plug-in should be invoked for internal 302 * operations. 303 * <p> 304 * Any plug-in that can be invoked for internal operations must 305 * ensure that it does not create any new internal operatons that can 306 * cause the same plug-in to be re-invoked. 307 * 308 * @return Returns the "invoke-for-internal-operations" property definition. 309 */ 310 public BooleanPropertyDefinition getInvokeForInternalOperationsPropertyDefinition() { 311 return PluginCfgDefn.getInstance().getInvokeForInternalOperationsPropertyDefinition(); 312 } 313 314 315 316 /** 317 * Get the "java-class" property definition. 318 * <p> 319 * Specifies the fully-qualified name of the Java class that 320 * provides the plug-in implementation. 321 * 322 * @return Returns the "java-class" property definition. 323 */ 324 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 325 return PD_JAVA_CLASS; 326 } 327 328 329 330 /** 331 * Get the "log-file" property definition. 332 * <p> 333 * Specifies the log file location where the update records are 334 * written when the plug-in is in background-mode processing. 335 * <p> 336 * The default location is the logs directory of the server 337 * instance, using the file name "referint". 338 * 339 * @return Returns the "log-file" property definition. 340 */ 341 public StringPropertyDefinition getLogFilePropertyDefinition() { 342 return PD_LOG_FILE; 343 } 344 345 346 347 /** 348 * Get the "plugin-type" property definition. 349 * <p> 350 * Specifies the set of plug-in types for the plug-in, which 351 * specifies the times at which the plug-in is invoked. 352 * 353 * @return Returns the "plugin-type" property definition. 354 */ 355 public EnumPropertyDefinition<PluginType> getPluginTypePropertyDefinition() { 356 return PD_PLUGIN_TYPE; 357 } 358 359 360 361 /** 362 * Get the "update-interval" property definition. 363 * <p> 364 * Specifies the interval in seconds when referential integrity 365 * updates are made. 366 * <p> 367 * If this value is 0, then the updates are made synchronously in 368 * the foreground. 369 * 370 * @return Returns the "update-interval" property definition. 371 */ 372 public DurationPropertyDefinition getUpdateIntervalPropertyDefinition() { 373 return PD_UPDATE_INTERVAL; 374 } 375 376 377 378 /** 379 * Managed object client implementation. 380 */ 381 private static class ReferentialIntegrityPluginCfgClientImpl implements 382 ReferentialIntegrityPluginCfgClient { 383 384 // Private implementation. 385 private ManagedObject<? extends ReferentialIntegrityPluginCfgClient> impl; 386 387 388 389 // Private constructor. 390 private ReferentialIntegrityPluginCfgClientImpl( 391 ManagedObject<? extends ReferentialIntegrityPluginCfgClient> impl) { 392 this.impl = impl; 393 } 394 395 396 397 /** 398 * {@inheritDoc} 399 */ 400 public SortedSet<AttributeType> getAttributeType() { 401 return impl.getPropertyValues(INSTANCE.getAttributeTypePropertyDefinition()); 402 } 403 404 405 406 /** 407 * {@inheritDoc} 408 */ 409 public void setAttributeType(Collection<AttributeType> values) { 410 impl.setPropertyValues(INSTANCE.getAttributeTypePropertyDefinition(), values); 411 } 412 413 414 415 /** 416 * {@inheritDoc} 417 */ 418 public SortedSet<DN> getBaseDN() { 419 return impl.getPropertyValues(INSTANCE.getBaseDNPropertyDefinition()); 420 } 421 422 423 424 /** 425 * {@inheritDoc} 426 */ 427 public void setBaseDN(Collection<DN> values) { 428 impl.setPropertyValues(INSTANCE.getBaseDNPropertyDefinition(), values); 429 } 430 431 432 433 /** 434 * {@inheritDoc} 435 */ 436 public Boolean isEnabled() { 437 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 438 } 439 440 441 442 /** 443 * {@inheritDoc} 444 */ 445 public void setEnabled(boolean value) { 446 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 447 } 448 449 450 451 /** 452 * {@inheritDoc} 453 */ 454 public boolean isInvokeForInternalOperations() { 455 return impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition()); 456 } 457 458 459 460 /** 461 * {@inheritDoc} 462 */ 463 public void setInvokeForInternalOperations(Boolean value) { 464 impl.setPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition(), value); 465 } 466 467 468 469 /** 470 * {@inheritDoc} 471 */ 472 public String getJavaClass() { 473 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 474 } 475 476 477 478 /** 479 * {@inheritDoc} 480 */ 481 public void setJavaClass(String value) { 482 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 483 } 484 485 486 487 /** 488 * {@inheritDoc} 489 */ 490 public String getLogFile() { 491 return impl.getPropertyValue(INSTANCE.getLogFilePropertyDefinition()); 492 } 493 494 495 496 /** 497 * {@inheritDoc} 498 */ 499 public void setLogFile(String value) { 500 impl.setPropertyValue(INSTANCE.getLogFilePropertyDefinition(), value); 501 } 502 503 504 505 /** 506 * {@inheritDoc} 507 */ 508 public SortedSet<PluginType> getPluginType() { 509 return impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition()); 510 } 511 512 513 514 /** 515 * {@inheritDoc} 516 */ 517 public void setPluginType(Collection<PluginType> values) { 518 impl.setPropertyValues(INSTANCE.getPluginTypePropertyDefinition(), values); 519 } 520 521 522 523 /** 524 * {@inheritDoc} 525 */ 526 public long getUpdateInterval() { 527 return impl.getPropertyValue(INSTANCE.getUpdateIntervalPropertyDefinition()); 528 } 529 530 531 532 /** 533 * {@inheritDoc} 534 */ 535 public void setUpdateInterval(Long value) { 536 impl.setPropertyValue(INSTANCE.getUpdateIntervalPropertyDefinition(), value); 537 } 538 539 540 541 /** 542 * {@inheritDoc} 543 */ 544 public ManagedObjectDefinition<? extends ReferentialIntegrityPluginCfgClient, ? extends ReferentialIntegrityPluginCfg> definition() { 545 return INSTANCE; 546 } 547 548 549 550 /** 551 * {@inheritDoc} 552 */ 553 public PropertyProvider properties() { 554 return impl; 555 } 556 557 558 559 /** 560 * {@inheritDoc} 561 */ 562 public void commit() throws ManagedObjectAlreadyExistsException, 563 MissingMandatoryPropertiesException, ConcurrentModificationException, 564 OperationRejectedException, AuthorizationException, 565 CommunicationException { 566 impl.commit(); 567 } 568 569 } 570 571 572 573 /** 574 * Managed object server implementation. 575 */ 576 private static class ReferentialIntegrityPluginCfgServerImpl implements 577 ReferentialIntegrityPluginCfg { 578 579 // Private implementation. 580 private ServerManagedObject<? extends ReferentialIntegrityPluginCfg> impl; 581 582 // The value of the "attribute-type" property. 583 private final SortedSet<AttributeType> pAttributeType; 584 585 // The value of the "base-dn" property. 586 private final SortedSet<DN> pBaseDN; 587 588 // The value of the "enabled" property. 589 private final boolean pEnabled; 590 591 // The value of the "invoke-for-internal-operations" property. 592 private final boolean pInvokeForInternalOperations; 593 594 // The value of the "java-class" property. 595 private final String pJavaClass; 596 597 // The value of the "log-file" property. 598 private final String pLogFile; 599 600 // The value of the "plugin-type" property. 601 private final SortedSet<PluginType> pPluginType; 602 603 // The value of the "update-interval" property. 604 private final long pUpdateInterval; 605 606 607 608 // Private constructor. 609 private ReferentialIntegrityPluginCfgServerImpl(ServerManagedObject<? extends ReferentialIntegrityPluginCfg> impl) { 610 this.impl = impl; 611 this.pAttributeType = impl.getPropertyValues(INSTANCE.getAttributeTypePropertyDefinition()); 612 this.pBaseDN = impl.getPropertyValues(INSTANCE.getBaseDNPropertyDefinition()); 613 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 614 this.pInvokeForInternalOperations = impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition()); 615 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 616 this.pLogFile = impl.getPropertyValue(INSTANCE.getLogFilePropertyDefinition()); 617 this.pPluginType = impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition()); 618 this.pUpdateInterval = impl.getPropertyValue(INSTANCE.getUpdateIntervalPropertyDefinition()); 619 } 620 621 622 623 /** 624 * {@inheritDoc} 625 */ 626 public void addReferentialIntegrityChangeListener( 627 ConfigurationChangeListener<ReferentialIntegrityPluginCfg> listener) { 628 impl.registerChangeListener(listener); 629 } 630 631 632 633 /** 634 * {@inheritDoc} 635 */ 636 public void removeReferentialIntegrityChangeListener( 637 ConfigurationChangeListener<ReferentialIntegrityPluginCfg> listener) { 638 impl.deregisterChangeListener(listener); 639 } 640 /** 641 * {@inheritDoc} 642 */ 643 public void addChangeListener( 644 ConfigurationChangeListener<PluginCfg> listener) { 645 impl.registerChangeListener(listener); 646 } 647 648 649 650 /** 651 * {@inheritDoc} 652 */ 653 public void removeChangeListener( 654 ConfigurationChangeListener<PluginCfg> listener) { 655 impl.deregisterChangeListener(listener); 656 } 657 658 659 660 /** 661 * {@inheritDoc} 662 */ 663 public SortedSet<AttributeType> getAttributeType() { 664 return pAttributeType; 665 } 666 667 668 669 /** 670 * {@inheritDoc} 671 */ 672 public SortedSet<DN> getBaseDN() { 673 return pBaseDN; 674 } 675 676 677 678 /** 679 * {@inheritDoc} 680 */ 681 public boolean isEnabled() { 682 return pEnabled; 683 } 684 685 686 687 /** 688 * {@inheritDoc} 689 */ 690 public boolean isInvokeForInternalOperations() { 691 return pInvokeForInternalOperations; 692 } 693 694 695 696 /** 697 * {@inheritDoc} 698 */ 699 public String getJavaClass() { 700 return pJavaClass; 701 } 702 703 704 705 /** 706 * {@inheritDoc} 707 */ 708 public String getLogFile() { 709 return pLogFile; 710 } 711 712 713 714 /** 715 * {@inheritDoc} 716 */ 717 public SortedSet<PluginType> getPluginType() { 718 return pPluginType; 719 } 720 721 722 723 /** 724 * {@inheritDoc} 725 */ 726 public long getUpdateInterval() { 727 return pUpdateInterval; 728 } 729 730 731 732 /** 733 * {@inheritDoc} 734 */ 735 public Class<? extends ReferentialIntegrityPluginCfg> configurationClass() { 736 return ReferentialIntegrityPluginCfg.class; 737 } 738 739 740 741 /** 742 * {@inheritDoc} 743 */ 744 public DN dn() { 745 return impl.getDN(); 746 } 747 748 } 749 }