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