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