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 java.util.Collection;
031import java.util.SortedSet;
032import org.opends.server.admin.AdministratorAction;
033import org.opends.server.admin.BooleanPropertyDefinition;
034import org.opends.server.admin.client.AuthorizationException;
035import org.opends.server.admin.client.CommunicationException;
036import org.opends.server.admin.client.ConcurrentModificationException;
037import org.opends.server.admin.client.ManagedObject;
038import org.opends.server.admin.client.MissingMandatoryPropertiesException;
039import org.opends.server.admin.client.OperationRejectedException;
040import org.opends.server.admin.ManagedObjectAlreadyExistsException;
041import org.opends.server.admin.ManagedObjectDefinition;
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.ExternalChangelogDomainCfgClient;
047import org.opends.server.admin.std.server.ExternalChangelogDomainCfg;
048import org.opends.server.admin.StringPropertyDefinition;
049import org.opends.server.admin.TopCfgDefn;
050import org.opends.server.admin.UndefinedDefaultBehaviorProvider;
051import org.opends.server.types.DN;
052
053
054
055/**
056 * An interface for querying the External Changelog Domain managed
057 * object definition meta information.
058 * <p>
059 * The External Changelog Domain provides configuration of the
060 * external changelog for the replication domain.
061 */
062public final class ExternalChangelogDomainCfgDefn extends ManagedObjectDefinition<ExternalChangelogDomainCfgClient, ExternalChangelogDomainCfg> {
063
064  // The singleton configuration definition instance.
065  private static final ExternalChangelogDomainCfgDefn INSTANCE = new ExternalChangelogDomainCfgDefn();
066
067
068
069  // The "ecl-include" property definition.
070  private static final StringPropertyDefinition PD_ECL_INCLUDE;
071
072
073
074  // The "ecl-include-for-deletes" property definition.
075  private static final StringPropertyDefinition PD_ECL_INCLUDE_FOR_DELETES;
076
077
078
079  // The "enabled" property definition.
080  private static final BooleanPropertyDefinition PD_ENABLED;
081
082
083
084  // Build the "ecl-include" property definition.
085  static {
086      StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "ecl-include");
087      builder.setOption(PropertyOption.MULTI_VALUED);
088      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "ecl-include"));
089      builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>());
090      PD_ECL_INCLUDE = builder.getInstance();
091      INSTANCE.registerPropertyDefinition(PD_ECL_INCLUDE);
092  }
093
094
095
096  // Build the "ecl-include-for-deletes" property definition.
097  static {
098      StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "ecl-include-for-deletes");
099      builder.setOption(PropertyOption.MULTI_VALUED);
100      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "ecl-include-for-deletes"));
101      builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>());
102      PD_ECL_INCLUDE_FOR_DELETES = builder.getInstance();
103      INSTANCE.registerPropertyDefinition(PD_ECL_INCLUDE_FOR_DELETES);
104  }
105
106
107
108  // Build the "enabled" property definition.
109  static {
110      BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "enabled");
111      builder.setOption(PropertyOption.MANDATORY);
112      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "enabled"));
113      builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<Boolean>());
114      PD_ENABLED = builder.getInstance();
115      INSTANCE.registerPropertyDefinition(PD_ENABLED);
116  }
117
118
119
120  /**
121   * Get the External Changelog Domain configuration definition
122   * singleton.
123   *
124   * @return Returns the External Changelog Domain configuration
125   *         definition singleton.
126   */
127  public static ExternalChangelogDomainCfgDefn getInstance() {
128    return INSTANCE;
129  }
130
131
132
133  /**
134   * Private constructor.
135   */
136  private ExternalChangelogDomainCfgDefn() {
137    super("external-changelog-domain", TopCfgDefn.getInstance());
138  }
139
140
141
142  /**
143   * {@inheritDoc}
144   */
145  public ExternalChangelogDomainCfgClient createClientConfiguration(
146      ManagedObject<? extends ExternalChangelogDomainCfgClient> impl) {
147    return new ExternalChangelogDomainCfgClientImpl(impl);
148  }
149
150
151
152  /**
153   * {@inheritDoc}
154   */
155  public ExternalChangelogDomainCfg createServerConfiguration(
156      ServerManagedObject<? extends ExternalChangelogDomainCfg> impl) {
157    return new ExternalChangelogDomainCfgServerImpl(impl);
158  }
159
160
161
162  /**
163   * {@inheritDoc}
164   */
165  public Class<ExternalChangelogDomainCfg> getServerConfigurationClass() {
166    return ExternalChangelogDomainCfg.class;
167  }
168
169
170
171  /**
172   * Get the "ecl-include" property definition.
173   * <p>
174   * Specifies a list of attributes which should be published with
175   * every change log entry, regardless of whether or not the attribute
176   * itself has changed.
177   * <p>
178   * The list of attributes may include wild cards such as "*" and "+"
179   * as well as object class references prefixed with an ampersand, for
180   * example "@person". The included attributes will be published using
181   * the "includedAttributes" operational attribute as a single LDIF
182   * value rather like the "changes" attribute. For modify and modifyDN
183   * operations the included attributes will be taken from the entry
184   * before any changes were applied.
185   *
186   * @return Returns the "ecl-include" property definition.
187   */
188  public StringPropertyDefinition getECLIncludePropertyDefinition() {
189    return PD_ECL_INCLUDE;
190  }
191
192
193
194  /**
195   * Get the "ecl-include-for-deletes" property definition.
196   * <p>
197   * Specifies a list of attributes which should be published with
198   * every delete operation change log entry, in addition to those
199   * specified by the "ecl-include" property.
200   * <p>
201   * This property provides a means for applications to archive
202   * entries after they have been deleted. See the description of the
203   * "ecl-include" property for further information about how the
204   * included attributes are published.
205   *
206   * @return Returns the "ecl-include-for-deletes" property definition.
207   */
208  public StringPropertyDefinition getECLIncludeForDeletesPropertyDefinition() {
209    return PD_ECL_INCLUDE_FOR_DELETES;
210  }
211
212
213
214  /**
215   * Get the "enabled" property definition.
216   * <p>
217   * Indicates whether the External Changelog Domain is enabled. To
218   * enable computing the change numbers, set the Replication Server's
219   * "ds-cfg-compute-change-number" property to true.
220   *
221   * @return Returns the "enabled" property definition.
222   */
223  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
224    return PD_ENABLED;
225  }
226
227
228
229  /**
230   * Managed object client implementation.
231   */
232  private static class ExternalChangelogDomainCfgClientImpl implements
233    ExternalChangelogDomainCfgClient {
234
235    // Private implementation.
236    private ManagedObject<? extends ExternalChangelogDomainCfgClient> impl;
237
238
239
240    // Private constructor.
241    private ExternalChangelogDomainCfgClientImpl(
242        ManagedObject<? extends ExternalChangelogDomainCfgClient> impl) {
243      this.impl = impl;
244    }
245
246
247
248    /**
249     * {@inheritDoc}
250     */
251    public SortedSet<String> getECLInclude() {
252      return impl.getPropertyValues(INSTANCE.getECLIncludePropertyDefinition());
253    }
254
255
256
257    /**
258     * {@inheritDoc}
259     */
260    public void setECLInclude(Collection<String> values) {
261      impl.setPropertyValues(INSTANCE.getECLIncludePropertyDefinition(), values);
262    }
263
264
265
266    /**
267     * {@inheritDoc}
268     */
269    public SortedSet<String> getECLIncludeForDeletes() {
270      return impl.getPropertyValues(INSTANCE.getECLIncludeForDeletesPropertyDefinition());
271    }
272
273
274
275    /**
276     * {@inheritDoc}
277     */
278    public void setECLIncludeForDeletes(Collection<String> values) {
279      impl.setPropertyValues(INSTANCE.getECLIncludeForDeletesPropertyDefinition(), values);
280    }
281
282
283
284    /**
285     * {@inheritDoc}
286     */
287    public Boolean isEnabled() {
288      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
289    }
290
291
292
293    /**
294     * {@inheritDoc}
295     */
296    public void setEnabled(boolean value) {
297      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
298    }
299
300
301
302    /**
303     * {@inheritDoc}
304     */
305    public ManagedObjectDefinition<? extends ExternalChangelogDomainCfgClient, ? extends ExternalChangelogDomainCfg> definition() {
306      return INSTANCE;
307    }
308
309
310
311    /**
312     * {@inheritDoc}
313     */
314    public PropertyProvider properties() {
315      return impl;
316    }
317
318
319
320    /**
321     * {@inheritDoc}
322     */
323    public void commit() throws ManagedObjectAlreadyExistsException,
324        MissingMandatoryPropertiesException, ConcurrentModificationException,
325        OperationRejectedException, AuthorizationException,
326        CommunicationException {
327      impl.commit();
328    }
329
330
331
332    /** {@inheritDoc} */
333    public String toString() {
334      return impl.toString();
335    }
336  }
337
338
339
340  /**
341   * Managed object server implementation.
342   */
343  private static class ExternalChangelogDomainCfgServerImpl implements
344    ExternalChangelogDomainCfg {
345
346    // Private implementation.
347    private ServerManagedObject<? extends ExternalChangelogDomainCfg> impl;
348
349    // The value of the "ecl-include" property.
350    private final SortedSet<String> pECLInclude;
351
352    // The value of the "ecl-include-for-deletes" property.
353    private final SortedSet<String> pECLIncludeForDeletes;
354
355    // The value of the "enabled" property.
356    private final boolean pEnabled;
357
358
359
360    // Private constructor.
361    private ExternalChangelogDomainCfgServerImpl(ServerManagedObject<? extends ExternalChangelogDomainCfg> impl) {
362      this.impl = impl;
363      this.pECLInclude = impl.getPropertyValues(INSTANCE.getECLIncludePropertyDefinition());
364      this.pECLIncludeForDeletes = impl.getPropertyValues(INSTANCE.getECLIncludeForDeletesPropertyDefinition());
365      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
366    }
367
368
369
370    /**
371     * {@inheritDoc}
372     */
373    public void addChangeListener(
374        ConfigurationChangeListener<ExternalChangelogDomainCfg> listener) {
375      impl.registerChangeListener(listener);
376    }
377
378
379
380    /**
381     * {@inheritDoc}
382     */
383    public void removeChangeListener(
384        ConfigurationChangeListener<ExternalChangelogDomainCfg> listener) {
385      impl.deregisterChangeListener(listener);
386    }
387
388
389
390    /**
391     * {@inheritDoc}
392     */
393    public SortedSet<String> getECLInclude() {
394      return pECLInclude;
395    }
396
397
398
399    /**
400     * {@inheritDoc}
401     */
402    public SortedSet<String> getECLIncludeForDeletes() {
403      return pECLIncludeForDeletes;
404    }
405
406
407
408    /**
409     * {@inheritDoc}
410     */
411    public boolean isEnabled() {
412      return pEnabled;
413    }
414
415
416
417    /**
418     * {@inheritDoc}
419     */
420    public Class<? extends ExternalChangelogDomainCfg> configurationClass() {
421      return ExternalChangelogDomainCfg.class;
422    }
423
424
425
426    /**
427     * {@inheritDoc}
428     */
429    public DN dn() {
430      return impl.getDN();
431    }
432
433
434
435    /** {@inheritDoc} */
436    public String toString() {
437      return impl.toString();
438    }
439  }
440}