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