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