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