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.AttributeTypePropertyDefinition; 034import org.forgerock.opendj.config.BooleanPropertyDefinition; 035import org.forgerock.opendj.config.ClassPropertyDefinition; 036import org.forgerock.opendj.config.client.ConcurrentModificationException; 037import org.forgerock.opendj.config.client.ManagedObject; 038import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException; 039import org.forgerock.opendj.config.client.OperationRejectedException; 040import org.forgerock.opendj.config.DefaultBehaviorProvider; 041import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider; 042import org.forgerock.opendj.config.DNPropertyDefinition; 043import org.forgerock.opendj.config.EnumPropertyDefinition; 044import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException; 045import org.forgerock.opendj.config.ManagedObjectDefinition; 046import org.forgerock.opendj.config.PropertyOption; 047import org.forgerock.opendj.config.PropertyProvider; 048import org.forgerock.opendj.config.server.ConfigurationChangeListener; 049import org.forgerock.opendj.config.server.ServerManagedObject; 050import org.forgerock.opendj.config.StringPropertyDefinition; 051import org.forgerock.opendj.config.Tag; 052import org.forgerock.opendj.ldap.DN; 053import org.forgerock.opendj.ldap.LdapException; 054import org.forgerock.opendj.ldap.schema.AttributeType; 055import org.forgerock.opendj.server.config.client.HasSubordinatesVirtualAttributeCfgClient; 056import org.forgerock.opendj.server.config.meta.VirtualAttributeCfgDefn.ConflictBehavior; 057import org.forgerock.opendj.server.config.meta.VirtualAttributeCfgDefn.Scope; 058import org.forgerock.opendj.server.config.server.HasSubordinatesVirtualAttributeCfg; 059import org.forgerock.opendj.server.config.server.VirtualAttributeCfg; 060 061 062 063/** 064 * An interface for querying the Has Subordinates Virtual Attribute 065 * managed object definition meta information. 066 * <p> 067 * The Has Subordinates Virtual Attribute generates a virtual 068 * attribute that indicates whether the entry has any subordinate 069 * entries. 070 */ 071public final class HasSubordinatesVirtualAttributeCfgDefn extends ManagedObjectDefinition<HasSubordinatesVirtualAttributeCfgClient, HasSubordinatesVirtualAttributeCfg> { 072 073 // The singleton configuration definition instance. 074 private static final HasSubordinatesVirtualAttributeCfgDefn INSTANCE = new HasSubordinatesVirtualAttributeCfgDefn(); 075 076 077 078 // The "attribute-type" property definition. 079 private static final AttributeTypePropertyDefinition PD_ATTRIBUTE_TYPE; 080 081 082 083 // The "conflict-behavior" property definition. 084 private static final EnumPropertyDefinition<ConflictBehavior> PD_CONFLICT_BEHAVIOR; 085 086 087 088 // The "java-class" property definition. 089 private static final ClassPropertyDefinition PD_JAVA_CLASS; 090 091 092 093 // Build the "attribute-type" property definition. 094 static { 095 AttributeTypePropertyDefinition.Builder builder = AttributeTypePropertyDefinition.createBuilder(INSTANCE, "attribute-type"); 096 builder.setOption(PropertyOption.MANDATORY); 097 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "attribute-type")); 098 DefaultBehaviorProvider<AttributeType> provider = new DefinedDefaultBehaviorProvider<AttributeType>("hasSubordinates"); 099 builder.setDefaultBehaviorProvider(provider); 100 PD_ATTRIBUTE_TYPE = builder.getInstance(); 101 INSTANCE.registerPropertyDefinition(PD_ATTRIBUTE_TYPE); 102 } 103 104 105 106 // Build the "conflict-behavior" property definition. 107 static { 108 EnumPropertyDefinition.Builder<ConflictBehavior> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "conflict-behavior"); 109 builder.setOption(PropertyOption.ADVANCED); 110 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "conflict-behavior")); 111 DefaultBehaviorProvider<ConflictBehavior> provider = new DefinedDefaultBehaviorProvider<ConflictBehavior>("virtual-overrides-real"); 112 builder.setDefaultBehaviorProvider(provider); 113 builder.setEnumClass(ConflictBehavior.class); 114 PD_CONFLICT_BEHAVIOR = builder.getInstance(); 115 INSTANCE.registerPropertyDefinition(PD_CONFLICT_BEHAVIOR); 116 } 117 118 119 120 // Build the "java-class" property definition. 121 static { 122 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 123 builder.setOption(PropertyOption.MANDATORY); 124 builder.setOption(PropertyOption.ADVANCED); 125 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class")); 126 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.HasSubordinatesVirtualAttributeProvider"); 127 builder.setDefaultBehaviorProvider(provider); 128 builder.addInstanceOf("org.opends.server.api.VirtualAttributeProvider"); 129 PD_JAVA_CLASS = builder.getInstance(); 130 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 131 } 132 133 134 135 // Register the tags associated with this managed object definition. 136 static { 137 INSTANCE.registerTag(Tag.valueOf("core-server")); 138 } 139 140 141 142 /** 143 * Get the Has Subordinates Virtual Attribute configuration 144 * definition singleton. 145 * 146 * @return Returns the Has Subordinates Virtual Attribute 147 * configuration definition singleton. 148 */ 149 public static HasSubordinatesVirtualAttributeCfgDefn getInstance() { 150 return INSTANCE; 151 } 152 153 154 155 /** 156 * Private constructor. 157 */ 158 private HasSubordinatesVirtualAttributeCfgDefn() { 159 super("has-subordinates-virtual-attribute", VirtualAttributeCfgDefn.getInstance()); 160 } 161 162 163 164 /** 165 * {@inheritDoc} 166 */ 167 public HasSubordinatesVirtualAttributeCfgClient createClientConfiguration( 168 ManagedObject<? extends HasSubordinatesVirtualAttributeCfgClient> impl) { 169 return new HasSubordinatesVirtualAttributeCfgClientImpl(impl); 170 } 171 172 173 174 /** 175 * {@inheritDoc} 176 */ 177 public HasSubordinatesVirtualAttributeCfg createServerConfiguration( 178 ServerManagedObject<? extends HasSubordinatesVirtualAttributeCfg> impl) { 179 return new HasSubordinatesVirtualAttributeCfgServerImpl(impl); 180 } 181 182 183 184 /** 185 * {@inheritDoc} 186 */ 187 public Class<HasSubordinatesVirtualAttributeCfg> getServerConfigurationClass() { 188 return HasSubordinatesVirtualAttributeCfg.class; 189 } 190 191 192 193 /** 194 * Get the "attribute-type" property definition. 195 * <p> 196 * Specifies the attribute type for the attribute whose values are 197 * to be dynamically assigned by the virtual attribute. 198 * 199 * @return Returns the "attribute-type" property definition. 200 */ 201 public AttributeTypePropertyDefinition getAttributeTypePropertyDefinition() { 202 return PD_ATTRIBUTE_TYPE; 203 } 204 205 206 207 /** 208 * Get the "base-dn" property definition. 209 * <p> 210 * Specifies the base DNs for the branches containing entries that 211 * are eligible to use this virtual attribute. 212 * <p> 213 * If no values are given, then the server generates virtual 214 * attributes anywhere in the server. 215 * 216 * @return Returns the "base-dn" property definition. 217 */ 218 public DNPropertyDefinition getBaseDNPropertyDefinition() { 219 return VirtualAttributeCfgDefn.getInstance().getBaseDNPropertyDefinition(); 220 } 221 222 223 224 /** 225 * Get the "conflict-behavior" property definition. 226 * <p> 227 * Specifies the behavior that the server is to exhibit for entries 228 * that already contain one or more real values for the associated 229 * attribute. 230 * 231 * @return Returns the "conflict-behavior" property definition. 232 */ 233 public EnumPropertyDefinition<ConflictBehavior> getConflictBehaviorPropertyDefinition() { 234 return PD_CONFLICT_BEHAVIOR; 235 } 236 237 238 239 /** 240 * Get the "enabled" property definition. 241 * <p> 242 * Indicates whether the Has Subordinates Virtual Attribute is 243 * enabled for use. 244 * 245 * @return Returns the "enabled" property definition. 246 */ 247 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 248 return VirtualAttributeCfgDefn.getInstance().getEnabledPropertyDefinition(); 249 } 250 251 252 253 /** 254 * Get the "filter" property definition. 255 * <p> 256 * Specifies the search filters to be applied against entries to 257 * determine if the virtual attribute is to be generated for those 258 * entries. 259 * <p> 260 * If no values are given, then any entry is eligible to have the 261 * value generated. If one or more filters are specified, then only 262 * entries that match at least one of those filters are allowed to 263 * have the virtual attribute. 264 * 265 * @return Returns the "filter" property definition. 266 */ 267 public StringPropertyDefinition getFilterPropertyDefinition() { 268 return VirtualAttributeCfgDefn.getInstance().getFilterPropertyDefinition(); 269 } 270 271 272 273 /** 274 * Get the "group-dn" property definition. 275 * <p> 276 * Specifies the DNs of the groups whose members can be eligible to 277 * use this virtual attribute. 278 * <p> 279 * If no values are given, then group membership is not taken into 280 * account when generating the virtual attribute. If one or more 281 * group DNs are specified, then only members of those groups are 282 * allowed to have the virtual attribute. 283 * 284 * @return Returns the "group-dn" property definition. 285 */ 286 public DNPropertyDefinition getGroupDNPropertyDefinition() { 287 return VirtualAttributeCfgDefn.getInstance().getGroupDNPropertyDefinition(); 288 } 289 290 291 292 /** 293 * Get the "java-class" property definition. 294 * <p> 295 * Specifies the fully-qualified name of the virtual attribute 296 * provider class that generates the attribute values. 297 * 298 * @return Returns the "java-class" property definition. 299 */ 300 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 301 return PD_JAVA_CLASS; 302 } 303 304 305 306 /** 307 * Get the "scope" property definition. 308 * <p> 309 * Specifies the LDAP scope associated with base DNs for entries 310 * that are eligible to use this virtual attribute. 311 * 312 * @return Returns the "scope" property definition. 313 */ 314 public EnumPropertyDefinition<Scope> getScopePropertyDefinition() { 315 return VirtualAttributeCfgDefn.getInstance().getScopePropertyDefinition(); 316 } 317 318 319 320 /** 321 * Managed object client implementation. 322 */ 323 private static class HasSubordinatesVirtualAttributeCfgClientImpl implements 324 HasSubordinatesVirtualAttributeCfgClient { 325 326 // Private implementation. 327 private ManagedObject<? extends HasSubordinatesVirtualAttributeCfgClient> impl; 328 329 330 331 // Private constructor. 332 private HasSubordinatesVirtualAttributeCfgClientImpl( 333 ManagedObject<? extends HasSubordinatesVirtualAttributeCfgClient> impl) { 334 this.impl = impl; 335 } 336 337 338 339 /** 340 * {@inheritDoc} 341 */ 342 public AttributeType getAttributeType() { 343 return impl.getPropertyValue(INSTANCE.getAttributeTypePropertyDefinition()); 344 } 345 346 347 348 /** 349 * {@inheritDoc} 350 */ 351 public void setAttributeType(AttributeType value) { 352 impl.setPropertyValue(INSTANCE.getAttributeTypePropertyDefinition(), value); 353 } 354 355 356 357 /** 358 * {@inheritDoc} 359 */ 360 public SortedSet<DN> getBaseDN() { 361 return impl.getPropertyValues(INSTANCE.getBaseDNPropertyDefinition()); 362 } 363 364 365 366 /** 367 * {@inheritDoc} 368 */ 369 public void setBaseDN(Collection<DN> values) { 370 impl.setPropertyValues(INSTANCE.getBaseDNPropertyDefinition(), values); 371 } 372 373 374 375 /** 376 * {@inheritDoc} 377 */ 378 public ConflictBehavior getConflictBehavior() { 379 return impl.getPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition()); 380 } 381 382 383 384 /** 385 * {@inheritDoc} 386 */ 387 public void setConflictBehavior(ConflictBehavior value) { 388 impl.setPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition(), value); 389 } 390 391 392 393 /** 394 * {@inheritDoc} 395 */ 396 public Boolean isEnabled() { 397 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 398 } 399 400 401 402 /** 403 * {@inheritDoc} 404 */ 405 public void setEnabled(boolean value) { 406 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 407 } 408 409 410 411 /** 412 * {@inheritDoc} 413 */ 414 public SortedSet<String> getFilter() { 415 return impl.getPropertyValues(INSTANCE.getFilterPropertyDefinition()); 416 } 417 418 419 420 /** 421 * {@inheritDoc} 422 */ 423 public void setFilter(Collection<String> values) { 424 impl.setPropertyValues(INSTANCE.getFilterPropertyDefinition(), values); 425 } 426 427 428 429 /** 430 * {@inheritDoc} 431 */ 432 public SortedSet<DN> getGroupDN() { 433 return impl.getPropertyValues(INSTANCE.getGroupDNPropertyDefinition()); 434 } 435 436 437 438 /** 439 * {@inheritDoc} 440 */ 441 public void setGroupDN(Collection<DN> values) { 442 impl.setPropertyValues(INSTANCE.getGroupDNPropertyDefinition(), values); 443 } 444 445 446 447 /** 448 * {@inheritDoc} 449 */ 450 public String getJavaClass() { 451 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 452 } 453 454 455 456 /** 457 * {@inheritDoc} 458 */ 459 public void setJavaClass(String value) { 460 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 461 } 462 463 464 465 /** 466 * {@inheritDoc} 467 */ 468 public Scope getScope() { 469 return impl.getPropertyValue(INSTANCE.getScopePropertyDefinition()); 470 } 471 472 473 474 /** 475 * {@inheritDoc} 476 */ 477 public void setScope(Scope value) { 478 impl.setPropertyValue(INSTANCE.getScopePropertyDefinition(), value); 479 } 480 481 482 483 /** 484 * {@inheritDoc} 485 */ 486 public ManagedObjectDefinition<? extends HasSubordinatesVirtualAttributeCfgClient, ? extends HasSubordinatesVirtualAttributeCfg> definition() { 487 return INSTANCE; 488 } 489 490 491 492 /** 493 * {@inheritDoc} 494 */ 495 public PropertyProvider properties() { 496 return impl; 497 } 498 499 500 501 /** 502 * {@inheritDoc} 503 */ 504 public void commit() throws ManagedObjectAlreadyExistsException, 505 MissingMandatoryPropertiesException, ConcurrentModificationException, 506 OperationRejectedException, LdapException { 507 impl.commit(); 508 } 509 510 } 511 512 513 514 /** 515 * Managed object server implementation. 516 */ 517 private static class HasSubordinatesVirtualAttributeCfgServerImpl implements 518 HasSubordinatesVirtualAttributeCfg { 519 520 // Private implementation. 521 private ServerManagedObject<? extends HasSubordinatesVirtualAttributeCfg> impl; 522 523 // The value of the "attribute-type" property. 524 private final AttributeType pAttributeType; 525 526 // The value of the "base-dn" property. 527 private final SortedSet<DN> pBaseDN; 528 529 // The value of the "conflict-behavior" property. 530 private final ConflictBehavior pConflictBehavior; 531 532 // The value of the "enabled" property. 533 private final boolean pEnabled; 534 535 // The value of the "filter" property. 536 private final SortedSet<String> pFilter; 537 538 // The value of the "group-dn" property. 539 private final SortedSet<DN> pGroupDN; 540 541 // The value of the "java-class" property. 542 private final String pJavaClass; 543 544 // The value of the "scope" property. 545 private final Scope pScope; 546 547 548 549 // Private constructor. 550 private HasSubordinatesVirtualAttributeCfgServerImpl(ServerManagedObject<? extends HasSubordinatesVirtualAttributeCfg> impl) { 551 this.impl = impl; 552 this.pAttributeType = impl.getPropertyValue(INSTANCE.getAttributeTypePropertyDefinition()); 553 this.pBaseDN = impl.getPropertyValues(INSTANCE.getBaseDNPropertyDefinition()); 554 this.pConflictBehavior = impl.getPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition()); 555 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 556 this.pFilter = impl.getPropertyValues(INSTANCE.getFilterPropertyDefinition()); 557 this.pGroupDN = impl.getPropertyValues(INSTANCE.getGroupDNPropertyDefinition()); 558 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 559 this.pScope = impl.getPropertyValue(INSTANCE.getScopePropertyDefinition()); 560 } 561 562 563 564 /** 565 * {@inheritDoc} 566 */ 567 public void addHasSubordinatesChangeListener( 568 ConfigurationChangeListener<HasSubordinatesVirtualAttributeCfg> listener) { 569 impl.registerChangeListener(listener); 570 } 571 572 573 574 /** 575 * {@inheritDoc} 576 */ 577 public void removeHasSubordinatesChangeListener( 578 ConfigurationChangeListener<HasSubordinatesVirtualAttributeCfg> listener) { 579 impl.deregisterChangeListener(listener); 580 } 581 /** 582 * {@inheritDoc} 583 */ 584 public void addChangeListener( 585 ConfigurationChangeListener<VirtualAttributeCfg> listener) { 586 impl.registerChangeListener(listener); 587 } 588 589 590 591 /** 592 * {@inheritDoc} 593 */ 594 public void removeChangeListener( 595 ConfigurationChangeListener<VirtualAttributeCfg> listener) { 596 impl.deregisterChangeListener(listener); 597 } 598 599 600 601 /** 602 * {@inheritDoc} 603 */ 604 public AttributeType getAttributeType() { 605 return pAttributeType; 606 } 607 608 609 610 /** 611 * {@inheritDoc} 612 */ 613 public SortedSet<DN> getBaseDN() { 614 return pBaseDN; 615 } 616 617 618 619 /** 620 * {@inheritDoc} 621 */ 622 public ConflictBehavior getConflictBehavior() { 623 return pConflictBehavior; 624 } 625 626 627 628 /** 629 * {@inheritDoc} 630 */ 631 public boolean isEnabled() { 632 return pEnabled; 633 } 634 635 636 637 /** 638 * {@inheritDoc} 639 */ 640 public SortedSet<String> getFilter() { 641 return pFilter; 642 } 643 644 645 646 /** 647 * {@inheritDoc} 648 */ 649 public SortedSet<DN> getGroupDN() { 650 return pGroupDN; 651 } 652 653 654 655 /** 656 * {@inheritDoc} 657 */ 658 public String getJavaClass() { 659 return pJavaClass; 660 } 661 662 663 664 /** 665 * {@inheritDoc} 666 */ 667 public Scope getScope() { 668 return pScope; 669 } 670 671 672 673 /** 674 * {@inheritDoc} 675 */ 676 public Class<? extends HasSubordinatesVirtualAttributeCfg> configurationClass() { 677 return HasSubordinatesVirtualAttributeCfg.class; 678 } 679 680 681 682 /** 683 * {@inheritDoc} 684 */ 685 public DN dn() { 686 return impl.getDN(); 687 } 688 689 } 690}