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