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.BooleanPropertyDefinition;
033import org.opends.server.admin.ClassPropertyDefinition;
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.EnumPropertyDefinition;
041import org.opends.server.admin.ManagedObjectAlreadyExistsException;
042import org.opends.server.admin.ManagedObjectDefinition;
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.FractionalLDIFImportPluginCfgClient;
047import org.opends.server.admin.std.meta.PluginCfgDefn.PluginType;
048import org.opends.server.admin.std.server.FractionalLDIFImportPluginCfg;
049import org.opends.server.admin.std.server.PluginCfg;
050import org.opends.server.admin.Tag;
051import org.opends.server.types.DN;
052
053
054
055/**
056 * An interface for querying the Fractional LDIF Import Plugin managed
057 * object definition meta information.
058 * <p>
059 * The Fractional LDIF Import Plugin is used internally by the
060 * replication plugin to support fractional replication.
061 */
062public final class FractionalLDIFImportPluginCfgDefn extends ManagedObjectDefinition<FractionalLDIFImportPluginCfgClient, FractionalLDIFImportPluginCfg> {
063
064  // The singleton configuration definition instance.
065  private static final FractionalLDIFImportPluginCfgDefn INSTANCE = new FractionalLDIFImportPluginCfgDefn();
066
067
068
069  // Register the tags associated with this managed object definition.
070  static {
071    INSTANCE.registerTag(Tag.valueOf("core-server"));
072  }
073
074
075
076  /**
077   * Get the Fractional LDIF Import Plugin configuration definition
078   * singleton.
079   *
080   * @return Returns the Fractional LDIF Import Plugin configuration
081   *         definition singleton.
082   */
083  public static FractionalLDIFImportPluginCfgDefn getInstance() {
084    return INSTANCE;
085  }
086
087
088
089  /**
090   * Private constructor.
091   */
092  private FractionalLDIFImportPluginCfgDefn() {
093    super("fractional-ldif-import-plugin", PluginCfgDefn.getInstance());
094  }
095
096
097
098  /**
099   * {@inheritDoc}
100   */
101  public FractionalLDIFImportPluginCfgClient createClientConfiguration(
102      ManagedObject<? extends FractionalLDIFImportPluginCfgClient> impl) {
103    return new FractionalLDIFImportPluginCfgClientImpl(impl);
104  }
105
106
107
108  /**
109   * {@inheritDoc}
110   */
111  public FractionalLDIFImportPluginCfg createServerConfiguration(
112      ServerManagedObject<? extends FractionalLDIFImportPluginCfg> impl) {
113    return new FractionalLDIFImportPluginCfgServerImpl(impl);
114  }
115
116
117
118  /**
119   * {@inheritDoc}
120   */
121  public Class<FractionalLDIFImportPluginCfg> getServerConfigurationClass() {
122    return FractionalLDIFImportPluginCfg.class;
123  }
124
125
126
127  /**
128   * Get the "enabled" property definition.
129   * <p>
130   * Indicates whether the plug-in is enabled for use.
131   *
132   * @return Returns the "enabled" property definition.
133   */
134  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
135    return PluginCfgDefn.getInstance().getEnabledPropertyDefinition();
136  }
137
138
139
140  /**
141   * Get the "invoke-for-internal-operations" property definition.
142   * <p>
143   * Indicates whether the plug-in should be invoked for internal
144   * operations.
145   * <p>
146   * Any plug-in that can be invoked for internal operations must
147   * ensure that it does not create any new internal operatons that can
148   * cause the same plug-in to be re-invoked.
149   *
150   * @return Returns the "invoke-for-internal-operations" property definition.
151   */
152  public BooleanPropertyDefinition getInvokeForInternalOperationsPropertyDefinition() {
153    return PluginCfgDefn.getInstance().getInvokeForInternalOperationsPropertyDefinition();
154  }
155
156
157
158  /**
159   * Get the "java-class" property definition.
160   * <p>
161   * Specifies the fully-qualified name of the Java class that
162   * provides the plug-in implementation.
163   *
164   * @return Returns the "java-class" property definition.
165   */
166  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
167    return PluginCfgDefn.getInstance().getJavaClassPropertyDefinition();
168  }
169
170
171
172  /**
173   * Get the "plugin-type" property definition.
174   * <p>
175   * Specifies the set of plug-in types for the plug-in, which
176   * specifies the times at which the plug-in is invoked.
177   *
178   * @return Returns the "plugin-type" property definition.
179   */
180  public EnumPropertyDefinition<PluginType> getPluginTypePropertyDefinition() {
181    return PluginCfgDefn.getInstance().getPluginTypePropertyDefinition();
182  }
183
184
185
186  /**
187   * Managed object client implementation.
188   */
189  private static class FractionalLDIFImportPluginCfgClientImpl implements
190    FractionalLDIFImportPluginCfgClient {
191
192    // Private implementation.
193    private ManagedObject<? extends FractionalLDIFImportPluginCfgClient> impl;
194
195
196
197    // Private constructor.
198    private FractionalLDIFImportPluginCfgClientImpl(
199        ManagedObject<? extends FractionalLDIFImportPluginCfgClient> impl) {
200      this.impl = impl;
201    }
202
203
204
205    /**
206     * {@inheritDoc}
207     */
208    public Boolean isEnabled() {
209      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
210    }
211
212
213
214    /**
215     * {@inheritDoc}
216     */
217    public void setEnabled(boolean value) {
218      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
219    }
220
221
222
223    /**
224     * {@inheritDoc}
225     */
226    public boolean isInvokeForInternalOperations() {
227      return impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition());
228    }
229
230
231
232    /**
233     * {@inheritDoc}
234     */
235    public void setInvokeForInternalOperations(Boolean value) {
236      impl.setPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition(), value);
237    }
238
239
240
241    /**
242     * {@inheritDoc}
243     */
244    public String getJavaClass() {
245      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
246    }
247
248
249
250    /**
251     * {@inheritDoc}
252     */
253    public void setJavaClass(String value) {
254      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
255    }
256
257
258
259    /**
260     * {@inheritDoc}
261     */
262    public SortedSet<PluginType> getPluginType() {
263      return impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition());
264    }
265
266
267
268    /**
269     * {@inheritDoc}
270     */
271    public void setPluginType(Collection<PluginType> values) {
272      impl.setPropertyValues(INSTANCE.getPluginTypePropertyDefinition(), values);
273    }
274
275
276
277    /**
278     * {@inheritDoc}
279     */
280    public ManagedObjectDefinition<? extends FractionalLDIFImportPluginCfgClient, ? extends FractionalLDIFImportPluginCfg> definition() {
281      return INSTANCE;
282    }
283
284
285
286    /**
287     * {@inheritDoc}
288     */
289    public PropertyProvider properties() {
290      return impl;
291    }
292
293
294
295    /**
296     * {@inheritDoc}
297     */
298    public void commit() throws ManagedObjectAlreadyExistsException,
299        MissingMandatoryPropertiesException, ConcurrentModificationException,
300        OperationRejectedException, AuthorizationException,
301        CommunicationException {
302      impl.commit();
303    }
304
305
306
307    /** {@inheritDoc} */
308    public String toString() {
309      return impl.toString();
310    }
311  }
312
313
314
315  /**
316   * Managed object server implementation.
317   */
318  private static class FractionalLDIFImportPluginCfgServerImpl implements
319    FractionalLDIFImportPluginCfg {
320
321    // Private implementation.
322    private ServerManagedObject<? extends FractionalLDIFImportPluginCfg> impl;
323
324    // The value of the "enabled" property.
325    private final boolean pEnabled;
326
327    // The value of the "invoke-for-internal-operations" property.
328    private final boolean pInvokeForInternalOperations;
329
330    // The value of the "java-class" property.
331    private final String pJavaClass;
332
333    // The value of the "plugin-type" property.
334    private final SortedSet<PluginType> pPluginType;
335
336
337
338    // Private constructor.
339    private FractionalLDIFImportPluginCfgServerImpl(ServerManagedObject<? extends FractionalLDIFImportPluginCfg> impl) {
340      this.impl = impl;
341      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
342      this.pInvokeForInternalOperations = impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition());
343      this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
344      this.pPluginType = impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition());
345    }
346
347
348
349    /**
350     * {@inheritDoc}
351     */
352    public void addFractionalLDIFImportChangeListener(
353        ConfigurationChangeListener<FractionalLDIFImportPluginCfg> listener) {
354      impl.registerChangeListener(listener);
355    }
356
357
358
359    /**
360     * {@inheritDoc}
361     */
362    public void removeFractionalLDIFImportChangeListener(
363        ConfigurationChangeListener<FractionalLDIFImportPluginCfg> listener) {
364      impl.deregisterChangeListener(listener);
365    }
366    /**
367     * {@inheritDoc}
368     */
369    public void addChangeListener(
370        ConfigurationChangeListener<PluginCfg> listener) {
371      impl.registerChangeListener(listener);
372    }
373
374
375
376    /**
377     * {@inheritDoc}
378     */
379    public void removeChangeListener(
380        ConfigurationChangeListener<PluginCfg> listener) {
381      impl.deregisterChangeListener(listener);
382    }
383
384
385
386    /**
387     * {@inheritDoc}
388     */
389    public boolean isEnabled() {
390      return pEnabled;
391    }
392
393
394
395    /**
396     * {@inheritDoc}
397     */
398    public boolean isInvokeForInternalOperations() {
399      return pInvokeForInternalOperations;
400    }
401
402
403
404    /**
405     * {@inheritDoc}
406     */
407    public String getJavaClass() {
408      return pJavaClass;
409    }
410
411
412
413    /**
414     * {@inheritDoc}
415     */
416    public SortedSet<PluginType> getPluginType() {
417      return pPluginType;
418    }
419
420
421
422    /**
423     * {@inheritDoc}
424     */
425    public Class<? extends FractionalLDIFImportPluginCfg> configurationClass() {
426      return FractionalLDIFImportPluginCfg.class;
427    }
428
429
430
431    /**
432     * {@inheritDoc}
433     */
434    public DN dn() {
435      return impl.getDN();
436    }
437
438
439
440    /** {@inheritDoc} */
441    public String toString() {
442      return impl.toString();
443    }
444  }
445}