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.StructuralObjectClassVirtualAttributeCfgClient; 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.StructuralObjectClassVirtualAttributeCfg; 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 Structural Object Class Virtual 066 * Attribute managed object definition meta information. 067 * <p> 068 * The Structural Object Class Virtual Attribute generates a virtual 069 * attribute that specifies the structural object class with the schema 070 * definitions in effect for the entry. This attribute is defined in 071 * RFC 4512. 072 */ 073public final class StructuralObjectClassVirtualAttributeCfgDefn extends ManagedObjectDefinition<StructuralObjectClassVirtualAttributeCfgClient, StructuralObjectClassVirtualAttributeCfg> { 074 075 // The singleton configuration definition instance. 076 private static final StructuralObjectClassVirtualAttributeCfgDefn INSTANCE = new StructuralObjectClassVirtualAttributeCfgDefn(); 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>("structuralObjectClass"); 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.StructuralObjectClassVirtualAttributeProvider"); 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 Structural Object Class Virtual Attribute configuration 146 * definition singleton. 147 * 148 * @return Returns the Structural Object Class Virtual Attribute 149 * configuration definition singleton. 150 */ 151 public static StructuralObjectClassVirtualAttributeCfgDefn getInstance() { 152 return INSTANCE; 153 } 154 155 156 157 /** 158 * Private constructor. 159 */ 160 private StructuralObjectClassVirtualAttributeCfgDefn() { 161 super("structural-object-class-virtual-attribute", VirtualAttributeCfgDefn.getInstance()); 162 } 163 164 165 166 /** 167 * {@inheritDoc} 168 */ 169 public StructuralObjectClassVirtualAttributeCfgClient createClientConfiguration( 170 ManagedObject<? extends StructuralObjectClassVirtualAttributeCfgClient> impl) { 171 return new StructuralObjectClassVirtualAttributeCfgClientImpl(impl); 172 } 173 174 175 176 /** 177 * {@inheritDoc} 178 */ 179 public StructuralObjectClassVirtualAttributeCfg createServerConfiguration( 180 ServerManagedObject<? extends StructuralObjectClassVirtualAttributeCfg> impl) { 181 return new StructuralObjectClassVirtualAttributeCfgServerImpl(impl); 182 } 183 184 185 186 /** 187 * {@inheritDoc} 188 */ 189 public Class<StructuralObjectClassVirtualAttributeCfg> getServerConfigurationClass() { 190 return StructuralObjectClassVirtualAttributeCfg.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 Structural Object Class Virtual Attribute 245 * is 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 StructuralObjectClassVirtualAttributeCfgClientImpl implements 326 StructuralObjectClassVirtualAttributeCfgClient { 327 328 // Private implementation. 329 private ManagedObject<? extends StructuralObjectClassVirtualAttributeCfgClient> impl; 330 331 332 333 // Private constructor. 334 private StructuralObjectClassVirtualAttributeCfgClientImpl( 335 ManagedObject<? extends StructuralObjectClassVirtualAttributeCfgClient> 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 StructuralObjectClassVirtualAttributeCfgClient, ? extends StructuralObjectClassVirtualAttributeCfg> 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 /** {@inheritDoc} */ 516 public String toString() { 517 return impl.toString(); 518 } 519 } 520 521 522 523 /** 524 * Managed object server implementation. 525 */ 526 private static class StructuralObjectClassVirtualAttributeCfgServerImpl implements 527 StructuralObjectClassVirtualAttributeCfg { 528 529 // Private implementation. 530 private ServerManagedObject<? extends StructuralObjectClassVirtualAttributeCfg> impl; 531 532 // The value of the "attribute-type" property. 533 private final AttributeType pAttributeType; 534 535 // The value of the "base-dn" property. 536 private final SortedSet<DN> pBaseDN; 537 538 // The value of the "conflict-behavior" property. 539 private final ConflictBehavior pConflictBehavior; 540 541 // The value of the "enabled" property. 542 private final boolean pEnabled; 543 544 // The value of the "filter" property. 545 private final SortedSet<String> pFilter; 546 547 // The value of the "group-dn" property. 548 private final SortedSet<DN> pGroupDN; 549 550 // The value of the "java-class" property. 551 private final String pJavaClass; 552 553 // The value of the "scope" property. 554 private final Scope pScope; 555 556 557 558 // Private constructor. 559 private StructuralObjectClassVirtualAttributeCfgServerImpl(ServerManagedObject<? extends StructuralObjectClassVirtualAttributeCfg> impl) { 560 this.impl = impl; 561 this.pAttributeType = impl.getPropertyValue(INSTANCE.getAttributeTypePropertyDefinition()); 562 this.pBaseDN = impl.getPropertyValues(INSTANCE.getBaseDNPropertyDefinition()); 563 this.pConflictBehavior = impl.getPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition()); 564 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 565 this.pFilter = impl.getPropertyValues(INSTANCE.getFilterPropertyDefinition()); 566 this.pGroupDN = impl.getPropertyValues(INSTANCE.getGroupDNPropertyDefinition()); 567 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 568 this.pScope = impl.getPropertyValue(INSTANCE.getScopePropertyDefinition()); 569 } 570 571 572 573 /** 574 * {@inheritDoc} 575 */ 576 public void addStructuralObjectClassChangeListener( 577 ConfigurationChangeListener<StructuralObjectClassVirtualAttributeCfg> listener) { 578 impl.registerChangeListener(listener); 579 } 580 581 582 583 /** 584 * {@inheritDoc} 585 */ 586 public void removeStructuralObjectClassChangeListener( 587 ConfigurationChangeListener<StructuralObjectClassVirtualAttributeCfg> listener) { 588 impl.deregisterChangeListener(listener); 589 } 590 /** 591 * {@inheritDoc} 592 */ 593 public void addChangeListener( 594 ConfigurationChangeListener<VirtualAttributeCfg> listener) { 595 impl.registerChangeListener(listener); 596 } 597 598 599 600 /** 601 * {@inheritDoc} 602 */ 603 public void removeChangeListener( 604 ConfigurationChangeListener<VirtualAttributeCfg> listener) { 605 impl.deregisterChangeListener(listener); 606 } 607 608 609 610 /** 611 * {@inheritDoc} 612 */ 613 public AttributeType getAttributeType() { 614 return pAttributeType; 615 } 616 617 618 619 /** 620 * {@inheritDoc} 621 */ 622 public SortedSet<DN> getBaseDN() { 623 return pBaseDN; 624 } 625 626 627 628 /** 629 * {@inheritDoc} 630 */ 631 public ConflictBehavior getConflictBehavior() { 632 return pConflictBehavior; 633 } 634 635 636 637 /** 638 * {@inheritDoc} 639 */ 640 public boolean isEnabled() { 641 return pEnabled; 642 } 643 644 645 646 /** 647 * {@inheritDoc} 648 */ 649 public SortedSet<String> getFilter() { 650 return pFilter; 651 } 652 653 654 655 /** 656 * {@inheritDoc} 657 */ 658 public SortedSet<DN> getGroupDN() { 659 return pGroupDN; 660 } 661 662 663 664 /** 665 * {@inheritDoc} 666 */ 667 public String getJavaClass() { 668 return pJavaClass; 669 } 670 671 672 673 /** 674 * {@inheritDoc} 675 */ 676 public Scope getScope() { 677 return pScope; 678 } 679 680 681 682 /** 683 * {@inheritDoc} 684 */ 685 public Class<? extends StructuralObjectClassVirtualAttributeCfg> configurationClass() { 686 return StructuralObjectClassVirtualAttributeCfg.class; 687 } 688 689 690 691 /** 692 * {@inheritDoc} 693 */ 694 public DN dn() { 695 return impl.getDN(); 696 } 697 698 699 700 /** {@inheritDoc} */ 701 public String toString() { 702 return impl.toString(); 703 } 704 } 705}