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