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