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 org.forgerock.opendj.config.AdministratorAction; 031import org.forgerock.opendj.config.client.ConcurrentModificationException; 032import org.forgerock.opendj.config.client.ManagedObject; 033import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException; 034import org.forgerock.opendj.config.client.OperationRejectedException; 035import org.forgerock.opendj.config.DefaultBehaviorProvider; 036import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider; 037import org.forgerock.opendj.config.DNPropertyDefinition; 038import org.forgerock.opendj.config.EnumPropertyDefinition; 039import org.forgerock.opendj.config.IntegerPropertyDefinition; 040import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException; 041import org.forgerock.opendj.config.ManagedObjectDefinition; 042import org.forgerock.opendj.config.PropertyException; 043import org.forgerock.opendj.config.PropertyOption; 044import org.forgerock.opendj.config.PropertyProvider; 045import org.forgerock.opendj.config.server.ConfigurationChangeListener; 046import org.forgerock.opendj.config.server.ServerManagedObject; 047import org.forgerock.opendj.config.StringPropertyDefinition; 048import org.forgerock.opendj.config.Tag; 049import org.forgerock.opendj.config.TopCfgDefn; 050import org.forgerock.opendj.config.UndefinedDefaultBehaviorProvider; 051import org.forgerock.opendj.ldap.DN; 052import org.forgerock.opendj.ldap.LdapException; 053import org.forgerock.opendj.server.config.client.LocalDBVLVIndexCfgClient; 054import org.forgerock.opendj.server.config.server.LocalDBVLVIndexCfg; 055 056 057 058/** 059 * An interface for querying the Local DB VLV Index managed object 060 * definition meta information. 061 * <p> 062 * Local DB VLV Indexes are used to store information about a specific 063 * search request that makes it possible to efficiently process them 064 * using the VLV control. 065 */ 066public final class LocalDBVLVIndexCfgDefn extends ManagedObjectDefinition<LocalDBVLVIndexCfgClient, LocalDBVLVIndexCfg> { 067 068 // The singleton configuration definition instance. 069 private static final LocalDBVLVIndexCfgDefn INSTANCE = new LocalDBVLVIndexCfgDefn(); 070 071 072 073 /** 074 * Defines the set of permissable values for the "scope" property. 075 * <p> 076 * Specifies the LDAP scope of the query that is being indexed. 077 */ 078 public static enum Scope { 079 080 /** 081 * Search the base object only. 082 */ 083 BASE_OBJECT("base-object"), 084 085 086 087 /** 088 * Search the immediate children of the base object but do not 089 * include any of their descendants or the base object itself. 090 */ 091 SINGLE_LEVEL("single-level"), 092 093 094 095 /** 096 * Search the entire subtree below the base object but do not 097 * include the base object itself. 098 */ 099 SUBORDINATE_SUBTREE("subordinate-subtree"), 100 101 102 103 /** 104 * Search the base object and the entire subtree below the base 105 * object. 106 */ 107 WHOLE_SUBTREE("whole-subtree"); 108 109 110 111 // String representation of the value. 112 private final String name; 113 114 115 116 // Private constructor. 117 private Scope(String name) { this.name = name; } 118 119 120 121 /** 122 * {@inheritDoc} 123 */ 124 public String toString() { return name; } 125 126 } 127 128 129 130 // The "base-dn" property definition. 131 private static final DNPropertyDefinition PD_BASE_DN; 132 133 134 135 // The "filter" property definition. 136 private static final StringPropertyDefinition PD_FILTER; 137 138 139 140 // The "max-block-size" property definition. 141 private static final IntegerPropertyDefinition PD_MAX_BLOCK_SIZE; 142 143 144 145 // The "name" property definition. 146 private static final StringPropertyDefinition PD_NAME; 147 148 149 150 // The "scope" property definition. 151 private static final EnumPropertyDefinition<Scope> PD_SCOPE; 152 153 154 155 // The "sort-order" property definition. 156 private static final StringPropertyDefinition PD_SORT_ORDER; 157 158 159 160 // Build the "base-dn" property definition. 161 static { 162 DNPropertyDefinition.Builder builder = DNPropertyDefinition.createBuilder(INSTANCE, "base-dn"); 163 builder.setOption(PropertyOption.MANDATORY); 164 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.OTHER, INSTANCE, "base-dn")); 165 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<DN>()); 166 PD_BASE_DN = builder.getInstance(); 167 INSTANCE.registerPropertyDefinition(PD_BASE_DN); 168 } 169 170 171 172 // Build the "filter" property definition. 173 static { 174 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "filter"); 175 builder.setOption(PropertyOption.MANDATORY); 176 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.OTHER, INSTANCE, "filter")); 177 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 178 builder.setPattern(".*", "STRING"); 179 PD_FILTER = builder.getInstance(); 180 INSTANCE.registerPropertyDefinition(PD_FILTER); 181 } 182 183 184 185 // Build the "max-block-size" property definition. 186 static { 187 IntegerPropertyDefinition.Builder builder = IntegerPropertyDefinition.createBuilder(INSTANCE, "max-block-size"); 188 builder.setOption(PropertyOption.READ_ONLY); 189 builder.setOption(PropertyOption.ADVANCED); 190 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "max-block-size")); 191 DefaultBehaviorProvider<Integer> provider = new DefinedDefaultBehaviorProvider<Integer>("4000"); 192 builder.setDefaultBehaviorProvider(provider); 193 PD_MAX_BLOCK_SIZE = builder.getInstance(); 194 INSTANCE.registerPropertyDefinition(PD_MAX_BLOCK_SIZE); 195 } 196 197 198 199 // Build the "name" property definition. 200 static { 201 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "name"); 202 builder.setOption(PropertyOption.READ_ONLY); 203 builder.setOption(PropertyOption.MANDATORY); 204 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "name")); 205 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 206 PD_NAME = builder.getInstance(); 207 INSTANCE.registerPropertyDefinition(PD_NAME); 208 } 209 210 211 212 // Build the "scope" property definition. 213 static { 214 EnumPropertyDefinition.Builder<Scope> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "scope"); 215 builder.setOption(PropertyOption.MANDATORY); 216 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.OTHER, INSTANCE, "scope")); 217 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<Scope>()); 218 builder.setEnumClass(Scope.class); 219 PD_SCOPE = builder.getInstance(); 220 INSTANCE.registerPropertyDefinition(PD_SCOPE); 221 } 222 223 224 225 // Build the "sort-order" property definition. 226 static { 227 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "sort-order"); 228 builder.setOption(PropertyOption.MANDATORY); 229 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.OTHER, INSTANCE, "sort-order")); 230 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 231 builder.setPattern(".*", "STRING"); 232 PD_SORT_ORDER = builder.getInstance(); 233 INSTANCE.registerPropertyDefinition(PD_SORT_ORDER); 234 } 235 236 237 238 // Register the tags associated with this managed object definition. 239 static { 240 INSTANCE.registerTag(Tag.valueOf("database")); 241 } 242 243 244 245 /** 246 * Get the Local DB VLV Index configuration definition singleton. 247 * 248 * @return Returns the Local DB VLV Index configuration definition 249 * singleton. 250 */ 251 public static LocalDBVLVIndexCfgDefn getInstance() { 252 return INSTANCE; 253 } 254 255 256 257 /** 258 * Private constructor. 259 */ 260 private LocalDBVLVIndexCfgDefn() { 261 super("local-db-vlv-index", TopCfgDefn.getInstance()); 262 } 263 264 265 266 /** 267 * {@inheritDoc} 268 */ 269 public LocalDBVLVIndexCfgClient createClientConfiguration( 270 ManagedObject<? extends LocalDBVLVIndexCfgClient> impl) { 271 return new LocalDBVLVIndexCfgClientImpl(impl); 272 } 273 274 275 276 /** 277 * {@inheritDoc} 278 */ 279 public LocalDBVLVIndexCfg createServerConfiguration( 280 ServerManagedObject<? extends LocalDBVLVIndexCfg> impl) { 281 return new LocalDBVLVIndexCfgServerImpl(impl); 282 } 283 284 285 286 /** 287 * {@inheritDoc} 288 */ 289 public Class<LocalDBVLVIndexCfg> getServerConfigurationClass() { 290 return LocalDBVLVIndexCfg.class; 291 } 292 293 294 295 /** 296 * Get the "base-dn" property definition. 297 * <p> 298 * Specifies the base DN used in the search query that is being 299 * indexed. 300 * 301 * @return Returns the "base-dn" property definition. 302 */ 303 public DNPropertyDefinition getBaseDNPropertyDefinition() { 304 return PD_BASE_DN; 305 } 306 307 308 309 /** 310 * Get the "filter" property definition. 311 * <p> 312 * Specifies the LDAP filter used in the query that is being 313 * indexed. 314 * 315 * @return Returns the "filter" property definition. 316 */ 317 public StringPropertyDefinition getFilterPropertyDefinition() { 318 return PD_FILTER; 319 } 320 321 322 323 /** 324 * Get the "max-block-size" property definition. 325 * <p> 326 * Specifies the number of entry IDs to store in a single sorted set 327 * before it must be split. 328 * 329 * @return Returns the "max-block-size" property definition. 330 */ 331 public IntegerPropertyDefinition getMaxBlockSizePropertyDefinition() { 332 return PD_MAX_BLOCK_SIZE; 333 } 334 335 336 337 /** 338 * Get the "name" property definition. 339 * <p> 340 * Specifies a unique name for this VLV index. 341 * 342 * @return Returns the "name" property definition. 343 */ 344 public StringPropertyDefinition getNamePropertyDefinition() { 345 return PD_NAME; 346 } 347 348 349 350 /** 351 * Get the "scope" property definition. 352 * <p> 353 * Specifies the LDAP scope of the query that is being indexed. 354 * 355 * @return Returns the "scope" property definition. 356 */ 357 public EnumPropertyDefinition<Scope> getScopePropertyDefinition() { 358 return PD_SCOPE; 359 } 360 361 362 363 /** 364 * Get the "sort-order" property definition. 365 * <p> 366 * Specifies the names of the attributes that are used to sort the 367 * entries for the query being indexed. 368 * <p> 369 * Multiple attributes can be used to determine the sort order by 370 * listing the attribute names from highest to lowest precedence. 371 * Optionally, + or - can be prefixed to the attribute name to sort 372 * the attribute in ascending order or descending order respectively. 373 * 374 * @return Returns the "sort-order" property definition. 375 */ 376 public StringPropertyDefinition getSortOrderPropertyDefinition() { 377 return PD_SORT_ORDER; 378 } 379 380 381 382 /** 383 * Managed object client implementation. 384 */ 385 private static class LocalDBVLVIndexCfgClientImpl implements 386 LocalDBVLVIndexCfgClient { 387 388 // Private implementation. 389 private ManagedObject<? extends LocalDBVLVIndexCfgClient> impl; 390 391 392 393 // Private constructor. 394 private LocalDBVLVIndexCfgClientImpl( 395 ManagedObject<? extends LocalDBVLVIndexCfgClient> impl) { 396 this.impl = impl; 397 } 398 399 400 401 /** 402 * {@inheritDoc} 403 */ 404 public DN getBaseDN() { 405 return impl.getPropertyValue(INSTANCE.getBaseDNPropertyDefinition()); 406 } 407 408 409 410 /** 411 * {@inheritDoc} 412 */ 413 public void setBaseDN(DN value) { 414 impl.setPropertyValue(INSTANCE.getBaseDNPropertyDefinition(), value); 415 } 416 417 418 419 /** 420 * {@inheritDoc} 421 */ 422 public String getFilter() { 423 return impl.getPropertyValue(INSTANCE.getFilterPropertyDefinition()); 424 } 425 426 427 428 /** 429 * {@inheritDoc} 430 */ 431 public void setFilter(String value) { 432 impl.setPropertyValue(INSTANCE.getFilterPropertyDefinition(), value); 433 } 434 435 436 437 /** 438 * {@inheritDoc} 439 */ 440 public int getMaxBlockSize() { 441 return impl.getPropertyValue(INSTANCE.getMaxBlockSizePropertyDefinition()); 442 } 443 444 445 446 /** 447 * {@inheritDoc} 448 */ 449 public void setMaxBlockSize(Integer value) throws PropertyException { 450 impl.setPropertyValue(INSTANCE.getMaxBlockSizePropertyDefinition(), value); 451 } 452 453 454 455 /** 456 * {@inheritDoc} 457 */ 458 public String getName() { 459 return impl.getPropertyValue(INSTANCE.getNamePropertyDefinition()); 460 } 461 462 463 464 /** 465 * {@inheritDoc} 466 */ 467 public void setName(String value) throws PropertyException { 468 impl.setPropertyValue(INSTANCE.getNamePropertyDefinition(), value); 469 } 470 471 472 473 /** 474 * {@inheritDoc} 475 */ 476 public Scope getScope() { 477 return impl.getPropertyValue(INSTANCE.getScopePropertyDefinition()); 478 } 479 480 481 482 /** 483 * {@inheritDoc} 484 */ 485 public void setScope(Scope value) { 486 impl.setPropertyValue(INSTANCE.getScopePropertyDefinition(), value); 487 } 488 489 490 491 /** 492 * {@inheritDoc} 493 */ 494 public String getSortOrder() { 495 return impl.getPropertyValue(INSTANCE.getSortOrderPropertyDefinition()); 496 } 497 498 499 500 /** 501 * {@inheritDoc} 502 */ 503 public void setSortOrder(String value) { 504 impl.setPropertyValue(INSTANCE.getSortOrderPropertyDefinition(), value); 505 } 506 507 508 509 /** 510 * {@inheritDoc} 511 */ 512 public ManagedObjectDefinition<? extends LocalDBVLVIndexCfgClient, ? extends LocalDBVLVIndexCfg> definition() { 513 return INSTANCE; 514 } 515 516 517 518 /** 519 * {@inheritDoc} 520 */ 521 public PropertyProvider properties() { 522 return impl; 523 } 524 525 526 527 /** 528 * {@inheritDoc} 529 */ 530 public void commit() throws ManagedObjectAlreadyExistsException, 531 MissingMandatoryPropertiesException, ConcurrentModificationException, 532 OperationRejectedException, LdapException { 533 impl.commit(); 534 } 535 536 } 537 538 539 540 /** 541 * Managed object server implementation. 542 */ 543 private static class LocalDBVLVIndexCfgServerImpl implements 544 LocalDBVLVIndexCfg { 545 546 // Private implementation. 547 private ServerManagedObject<? extends LocalDBVLVIndexCfg> impl; 548 549 // The value of the "base-dn" property. 550 private final DN pBaseDN; 551 552 // The value of the "filter" property. 553 private final String pFilter; 554 555 // The value of the "max-block-size" property. 556 private final int pMaxBlockSize; 557 558 // The value of the "name" property. 559 private final String pName; 560 561 // The value of the "scope" property. 562 private final Scope pScope; 563 564 // The value of the "sort-order" property. 565 private final String pSortOrder; 566 567 568 569 // Private constructor. 570 private LocalDBVLVIndexCfgServerImpl(ServerManagedObject<? extends LocalDBVLVIndexCfg> impl) { 571 this.impl = impl; 572 this.pBaseDN = impl.getPropertyValue(INSTANCE.getBaseDNPropertyDefinition()); 573 this.pFilter = impl.getPropertyValue(INSTANCE.getFilterPropertyDefinition()); 574 this.pMaxBlockSize = impl.getPropertyValue(INSTANCE.getMaxBlockSizePropertyDefinition()); 575 this.pName = impl.getPropertyValue(INSTANCE.getNamePropertyDefinition()); 576 this.pScope = impl.getPropertyValue(INSTANCE.getScopePropertyDefinition()); 577 this.pSortOrder = impl.getPropertyValue(INSTANCE.getSortOrderPropertyDefinition()); 578 } 579 580 581 582 /** 583 * {@inheritDoc} 584 */ 585 public void addChangeListener( 586 ConfigurationChangeListener<LocalDBVLVIndexCfg> listener) { 587 impl.registerChangeListener(listener); 588 } 589 590 591 592 /** 593 * {@inheritDoc} 594 */ 595 public void removeChangeListener( 596 ConfigurationChangeListener<LocalDBVLVIndexCfg> listener) { 597 impl.deregisterChangeListener(listener); 598 } 599 600 601 602 /** 603 * {@inheritDoc} 604 */ 605 public DN getBaseDN() { 606 return pBaseDN; 607 } 608 609 610 611 /** 612 * {@inheritDoc} 613 */ 614 public String getFilter() { 615 return pFilter; 616 } 617 618 619 620 /** 621 * {@inheritDoc} 622 */ 623 public int getMaxBlockSize() { 624 return pMaxBlockSize; 625 } 626 627 628 629 /** 630 * {@inheritDoc} 631 */ 632 public String getName() { 633 return pName; 634 } 635 636 637 638 /** 639 * {@inheritDoc} 640 */ 641 public Scope getScope() { 642 return pScope; 643 } 644 645 646 647 /** 648 * {@inheritDoc} 649 */ 650 public String getSortOrder() { 651 return pSortOrder; 652 } 653 654 655 656 /** 657 * {@inheritDoc} 658 */ 659 public Class<? extends LocalDBVLVIndexCfg> configurationClass() { 660 return LocalDBVLVIndexCfg.class; 661 } 662 663 664 665 /** 666 * {@inheritDoc} 667 */ 668 public DN dn() { 669 return impl.getDN(); 670 } 671 672 } 673}