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 org.forgerock.opendj.config.server.ConfigException;
022import org.forgerock.opendj.ldap.DN;
023import org.opends.server.admin.AdministratorAction;
024import org.opends.server.admin.BooleanPropertyDefinition;
025import org.opends.server.admin.ClassPropertyDefinition;
026import org.opends.server.admin.client.AuthorizationException;
027import org.opends.server.admin.client.CommunicationException;
028import org.opends.server.admin.client.ConcurrentModificationException;
029import org.opends.server.admin.client.IllegalManagedObjectNameException;
030import org.opends.server.admin.client.ManagedObject;
031import org.opends.server.admin.client.ManagedObjectDecodingException;
032import org.opends.server.admin.client.MissingMandatoryPropertiesException;
033import org.opends.server.admin.client.OperationRejectedException;
034import org.opends.server.admin.DefaultBehaviorProvider;
035import org.opends.server.admin.DefinedDefaultBehaviorProvider;
036import org.opends.server.admin.DefinitionDecodingException;
037import org.opends.server.admin.EnumPropertyDefinition;
038import org.opends.server.admin.InstantiableRelationDefinition;
039import org.opends.server.admin.ManagedObjectAlreadyExistsException;
040import org.opends.server.admin.ManagedObjectDefinition;
041import org.opends.server.admin.ManagedObjectNotFoundException;
042import org.opends.server.admin.PropertyException;
043import org.opends.server.admin.PropertyOption;
044import org.opends.server.admin.PropertyProvider;
045import org.opends.server.admin.server.ConfigurationAddListener;
046import org.opends.server.admin.server.ConfigurationChangeListener;
047import org.opends.server.admin.server.ConfigurationDeleteListener;
048import org.opends.server.admin.server.ServerManagedObject;
049import org.opends.server.admin.std.client.AccessLogFilteringCriteriaCfgClient;
050import org.opends.server.admin.std.client.AccessLogPublisherCfgClient;
051import org.opends.server.admin.std.server.AccessLogFilteringCriteriaCfg;
052import org.opends.server.admin.std.server.AccessLogPublisherCfg;
053import org.opends.server.admin.std.server.LogPublisherCfg;
054import org.opends.server.admin.Tag;
055
056
057
058/**
059 * An interface for querying the Access Log Publisher managed object
060 * definition meta information.
061 * <p>
062 * Access Log Publishers are responsible for distributing access log
063 * messages from the access logger to a destination.
064 */
065public final class AccessLogPublisherCfgDefn extends ManagedObjectDefinition<AccessLogPublisherCfgClient, AccessLogPublisherCfg> {
066
067  // The singleton configuration definition instance.
068  private static final AccessLogPublisherCfgDefn INSTANCE = new AccessLogPublisherCfgDefn();
069
070
071
072  /**
073   * Defines the set of permissable values for the "filtering-policy" property.
074   * <p>
075   * Specifies how filtering criteria should be applied to log
076   * records.
077   */
078  public static enum FilteringPolicy {
079
080    /**
081     * Records must not match any of the filtering criteria in order
082     * to be logged.
083     */
084    EXCLUSIVE("exclusive"),
085
086
087
088    /**
089     * Records must match at least one of the filtering criteria in
090     * order to be logged.
091     */
092    INCLUSIVE("inclusive"),
093
094
095
096    /**
097     * No filtering will be performed, and all records will be logged.
098     */
099    NO_FILTERING("no-filtering");
100
101
102
103    // String representation of the value.
104    private final String name;
105
106
107
108    // Private constructor.
109    private FilteringPolicy(String name) { this.name = name; }
110
111
112
113    /**
114     * {@inheritDoc}
115     */
116    public String toString() { return name; }
117
118  }
119
120
121
122  // The "filtering-policy" property definition.
123  private static final EnumPropertyDefinition<FilteringPolicy> PD_FILTERING_POLICY;
124
125
126
127  // The "java-class" property definition.
128  private static final ClassPropertyDefinition PD_JAVA_CLASS;
129
130
131
132  // The "suppress-internal-operations" property definition.
133  private static final BooleanPropertyDefinition PD_SUPPRESS_INTERNAL_OPERATIONS;
134
135
136
137  // The "suppress-synchronization-operations" property definition.
138  private static final BooleanPropertyDefinition PD_SUPPRESS_SYNCHRONIZATION_OPERATIONS;
139
140
141
142  // The "access-log-filtering-criteria" relation definition.
143  private static final InstantiableRelationDefinition<AccessLogFilteringCriteriaCfgClient, AccessLogFilteringCriteriaCfg> RD_ACCESS_LOG_FILTERING_CRITERIA;
144
145
146
147  // Build the "filtering-policy" property definition.
148  static {
149      EnumPropertyDefinition.Builder<FilteringPolicy> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "filtering-policy");
150      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "filtering-policy"));
151      DefaultBehaviorProvider<FilteringPolicy> provider = new DefinedDefaultBehaviorProvider<FilteringPolicy>("no-filtering");
152      builder.setDefaultBehaviorProvider(provider);
153      builder.setEnumClass(FilteringPolicy.class);
154      PD_FILTERING_POLICY = builder.getInstance();
155      INSTANCE.registerPropertyDefinition(PD_FILTERING_POLICY);
156  }
157
158
159
160  // Build the "java-class" property definition.
161  static {
162      ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
163      builder.setOption(PropertyOption.MANDATORY);
164      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class"));
165      DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.loggers.AccessLogPublisher");
166      builder.setDefaultBehaviorProvider(provider);
167      builder.addInstanceOf("org.opends.server.loggers.LogPublisher");
168      PD_JAVA_CLASS = builder.getInstance();
169      INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
170  }
171
172
173
174  // Build the "suppress-internal-operations" property definition.
175  static {
176      BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "suppress-internal-operations");
177      builder.setOption(PropertyOption.ADVANCED);
178      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "suppress-internal-operations"));
179      DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("true");
180      builder.setDefaultBehaviorProvider(provider);
181      PD_SUPPRESS_INTERNAL_OPERATIONS = builder.getInstance();
182      INSTANCE.registerPropertyDefinition(PD_SUPPRESS_INTERNAL_OPERATIONS);
183  }
184
185
186
187  // Build the "suppress-synchronization-operations" property definition.
188  static {
189      BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "suppress-synchronization-operations");
190      builder.setOption(PropertyOption.ADVANCED);
191      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "suppress-synchronization-operations"));
192      DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false");
193      builder.setDefaultBehaviorProvider(provider);
194      PD_SUPPRESS_SYNCHRONIZATION_OPERATIONS = builder.getInstance();
195      INSTANCE.registerPropertyDefinition(PD_SUPPRESS_SYNCHRONIZATION_OPERATIONS);
196  }
197
198
199
200  // Build the "access-log-filtering-criteria" relation definition.
201  static {
202    InstantiableRelationDefinition.Builder<AccessLogFilteringCriteriaCfgClient, AccessLogFilteringCriteriaCfg> builder =
203      new InstantiableRelationDefinition.Builder<AccessLogFilteringCriteriaCfgClient, AccessLogFilteringCriteriaCfg>(INSTANCE, "access-log-filtering-criteria", "access-log-filtering-criteria", AccessLogFilteringCriteriaCfgDefn.getInstance());
204    RD_ACCESS_LOG_FILTERING_CRITERIA = builder.getInstance();
205    INSTANCE.registerRelationDefinition(RD_ACCESS_LOG_FILTERING_CRITERIA);
206  }
207
208
209
210  // Register the tags associated with this managed object definition.
211  static {
212    INSTANCE.registerTag(Tag.valueOf("logging"));
213  }
214
215
216
217  /**
218   * Get the Access Log Publisher configuration definition singleton.
219   *
220   * @return Returns the Access Log Publisher configuration definition
221   *         singleton.
222   */
223  public static AccessLogPublisherCfgDefn getInstance() {
224    return INSTANCE;
225  }
226
227
228
229  /**
230   * Private constructor.
231   */
232  private AccessLogPublisherCfgDefn() {
233    super("access-log-publisher", LogPublisherCfgDefn.getInstance());
234  }
235
236
237
238  /**
239   * {@inheritDoc}
240   */
241  public AccessLogPublisherCfgClient createClientConfiguration(
242      ManagedObject<? extends AccessLogPublisherCfgClient> impl) {
243    return new AccessLogPublisherCfgClientImpl(impl);
244  }
245
246
247
248  /**
249   * {@inheritDoc}
250   */
251  public AccessLogPublisherCfg createServerConfiguration(
252      ServerManagedObject<? extends AccessLogPublisherCfg> impl) {
253    return new AccessLogPublisherCfgServerImpl(impl);
254  }
255
256
257
258  /**
259   * {@inheritDoc}
260   */
261  public Class<AccessLogPublisherCfg> getServerConfigurationClass() {
262    return AccessLogPublisherCfg.class;
263  }
264
265
266
267  /**
268   * Get the "enabled" property definition.
269   * <p>
270   * Indicates whether the Access Log Publisher is enabled for use.
271   *
272   * @return Returns the "enabled" property definition.
273   */
274  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
275    return LogPublisherCfgDefn.getInstance().getEnabledPropertyDefinition();
276  }
277
278
279
280  /**
281   * Get the "filtering-policy" property definition.
282   * <p>
283   * Specifies how filtering criteria should be applied to log
284   * records.
285   *
286   * @return Returns the "filtering-policy" property definition.
287   */
288  public EnumPropertyDefinition<FilteringPolicy> getFilteringPolicyPropertyDefinition() {
289    return PD_FILTERING_POLICY;
290  }
291
292
293
294  /**
295   * Get the "java-class" property definition.
296   * <p>
297   * The fully-qualified name of the Java class that provides the
298   * Access Log Publisher implementation.
299   *
300   * @return Returns the "java-class" property definition.
301   */
302  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
303    return PD_JAVA_CLASS;
304  }
305
306
307
308  /**
309   * Get the "suppress-internal-operations" property definition.
310   * <p>
311   * Indicates whether internal operations (for example, operations
312   * that are initiated by plugins) should be logged along with the
313   * operations that are requested by users.
314   *
315   * @return Returns the "suppress-internal-operations" property definition.
316   */
317  public BooleanPropertyDefinition getSuppressInternalOperationsPropertyDefinition() {
318    return PD_SUPPRESS_INTERNAL_OPERATIONS;
319  }
320
321
322
323  /**
324   * Get the "suppress-synchronization-operations" property definition.
325   * <p>
326   * Indicates whether access messages that are generated by
327   * synchronization operations should be suppressed.
328   *
329   * @return Returns the "suppress-synchronization-operations" property definition.
330   */
331  public BooleanPropertyDefinition getSuppressSynchronizationOperationsPropertyDefinition() {
332    return PD_SUPPRESS_SYNCHRONIZATION_OPERATIONS;
333  }
334
335
336
337  /**
338   * Get the "access-log-filtering-criteria" relation definition.
339   *
340   * @return Returns the "access-log-filtering-criteria" relation definition.
341   */
342  public InstantiableRelationDefinition<AccessLogFilteringCriteriaCfgClient,AccessLogFilteringCriteriaCfg> getAccessLogFilteringCriteriaRelationDefinition() {
343    return RD_ACCESS_LOG_FILTERING_CRITERIA;
344  }
345
346
347
348  /**
349   * Managed object client implementation.
350   */
351  private static class AccessLogPublisherCfgClientImpl implements
352    AccessLogPublisherCfgClient {
353
354    // Private implementation.
355    private ManagedObject<? extends AccessLogPublisherCfgClient> impl;
356
357
358
359    // Private constructor.
360    private AccessLogPublisherCfgClientImpl(
361        ManagedObject<? extends AccessLogPublisherCfgClient> impl) {
362      this.impl = impl;
363    }
364
365
366
367    /**
368     * {@inheritDoc}
369     */
370    public Boolean isEnabled() {
371      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
372    }
373
374
375
376    /**
377     * {@inheritDoc}
378     */
379    public void setEnabled(boolean value) {
380      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
381    }
382
383
384
385    /**
386     * {@inheritDoc}
387     */
388    public FilteringPolicy getFilteringPolicy() {
389      return impl.getPropertyValue(INSTANCE.getFilteringPolicyPropertyDefinition());
390    }
391
392
393
394    /**
395     * {@inheritDoc}
396     */
397    public void setFilteringPolicy(FilteringPolicy value) {
398      impl.setPropertyValue(INSTANCE.getFilteringPolicyPropertyDefinition(), value);
399    }
400
401
402
403    /**
404     * {@inheritDoc}
405     */
406    public String getJavaClass() {
407      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
408    }
409
410
411
412    /**
413     * {@inheritDoc}
414     */
415    public void setJavaClass(String value) {
416      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
417    }
418
419
420
421    /**
422     * {@inheritDoc}
423     */
424    public boolean isSuppressInternalOperations() {
425      return impl.getPropertyValue(INSTANCE.getSuppressInternalOperationsPropertyDefinition());
426    }
427
428
429
430    /**
431     * {@inheritDoc}
432     */
433    public void setSuppressInternalOperations(Boolean value) {
434      impl.setPropertyValue(INSTANCE.getSuppressInternalOperationsPropertyDefinition(), value);
435    }
436
437
438
439    /**
440     * {@inheritDoc}
441     */
442    public boolean isSuppressSynchronizationOperations() {
443      return impl.getPropertyValue(INSTANCE.getSuppressSynchronizationOperationsPropertyDefinition());
444    }
445
446
447
448    /**
449     * {@inheritDoc}
450     */
451    public void setSuppressSynchronizationOperations(Boolean value) {
452      impl.setPropertyValue(INSTANCE.getSuppressSynchronizationOperationsPropertyDefinition(), value);
453    }
454
455
456
457    /**
458     * {@inheritDoc}
459     */
460    public String[] listAccessLogFilteringCriteria() throws ConcurrentModificationException,
461        AuthorizationException, CommunicationException {
462      return impl.listChildren(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition());
463    }
464
465
466
467    /**
468     * {@inheritDoc}
469     */
470    public AccessLogFilteringCriteriaCfgClient getAccessLogFilteringCriteria(String name)
471        throws DefinitionDecodingException, ManagedObjectDecodingException,
472        ManagedObjectNotFoundException, ConcurrentModificationException,
473        AuthorizationException, CommunicationException {
474      return impl.getChild(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition(), name).getConfiguration();
475    }
476
477
478
479    /**
480     * {@inheritDoc}
481     */
482    public <M extends AccessLogFilteringCriteriaCfgClient> M createAccessLogFilteringCriteria(
483        ManagedObjectDefinition<M, ? extends AccessLogFilteringCriteriaCfg> d, String name, Collection<PropertyException> exceptions) throws IllegalManagedObjectNameException {
484      return impl.createChild(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition(), d, name, exceptions).getConfiguration();
485    }
486
487
488
489    /**
490     * {@inheritDoc}
491     */
492    public void removeAccessLogFilteringCriteria(String name)
493        throws ManagedObjectNotFoundException, ConcurrentModificationException,
494        OperationRejectedException, AuthorizationException, CommunicationException {
495      impl.removeChild(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition(), name);
496    }
497
498
499
500    /**
501     * {@inheritDoc}
502     */
503    public ManagedObjectDefinition<? extends AccessLogPublisherCfgClient, ? extends AccessLogPublisherCfg> definition() {
504      return INSTANCE;
505    }
506
507
508
509    /**
510     * {@inheritDoc}
511     */
512    public PropertyProvider properties() {
513      return impl;
514    }
515
516
517
518    /**
519     * {@inheritDoc}
520     */
521    public void commit() throws ManagedObjectAlreadyExistsException,
522        MissingMandatoryPropertiesException, ConcurrentModificationException,
523        OperationRejectedException, AuthorizationException,
524        CommunicationException {
525      impl.commit();
526    }
527
528
529
530    /** {@inheritDoc} */
531    public String toString() {
532      return impl.toString();
533    }
534  }
535
536
537
538  /**
539   * Managed object server implementation.
540   */
541  private static class AccessLogPublisherCfgServerImpl implements
542    AccessLogPublisherCfg {
543
544    // Private implementation.
545    private ServerManagedObject<? extends AccessLogPublisherCfg> impl;
546
547    // The value of the "enabled" property.
548    private final boolean pEnabled;
549
550    // The value of the "filtering-policy" property.
551    private final FilteringPolicy pFilteringPolicy;
552
553    // The value of the "java-class" property.
554    private final String pJavaClass;
555
556    // The value of the "suppress-internal-operations" property.
557    private final boolean pSuppressInternalOperations;
558
559    // The value of the "suppress-synchronization-operations" property.
560    private final boolean pSuppressSynchronizationOperations;
561
562
563
564    // Private constructor.
565    private AccessLogPublisherCfgServerImpl(ServerManagedObject<? extends AccessLogPublisherCfg> impl) {
566      this.impl = impl;
567      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
568      this.pFilteringPolicy = impl.getPropertyValue(INSTANCE.getFilteringPolicyPropertyDefinition());
569      this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
570      this.pSuppressInternalOperations = impl.getPropertyValue(INSTANCE.getSuppressInternalOperationsPropertyDefinition());
571      this.pSuppressSynchronizationOperations = impl.getPropertyValue(INSTANCE.getSuppressSynchronizationOperationsPropertyDefinition());
572    }
573
574
575
576    /**
577     * {@inheritDoc}
578     */
579    public void addAccessChangeListener(
580        ConfigurationChangeListener<AccessLogPublisherCfg> listener) {
581      impl.registerChangeListener(listener);
582    }
583
584
585
586    /**
587     * {@inheritDoc}
588     */
589    public void removeAccessChangeListener(
590        ConfigurationChangeListener<AccessLogPublisherCfg> listener) {
591      impl.deregisterChangeListener(listener);
592    }
593    /**
594     * {@inheritDoc}
595     */
596    public void addChangeListener(
597        ConfigurationChangeListener<LogPublisherCfg> listener) {
598      impl.registerChangeListener(listener);
599    }
600
601
602
603    /**
604     * {@inheritDoc}
605     */
606    public void removeChangeListener(
607        ConfigurationChangeListener<LogPublisherCfg> listener) {
608      impl.deregisterChangeListener(listener);
609    }
610
611
612
613    /**
614     * {@inheritDoc}
615     */
616    public boolean isEnabled() {
617      return pEnabled;
618    }
619
620
621
622    /**
623     * {@inheritDoc}
624     */
625    public FilteringPolicy getFilteringPolicy() {
626      return pFilteringPolicy;
627    }
628
629
630
631    /**
632     * {@inheritDoc}
633     */
634    public String getJavaClass() {
635      return pJavaClass;
636    }
637
638
639
640    /**
641     * {@inheritDoc}
642     */
643    public boolean isSuppressInternalOperations() {
644      return pSuppressInternalOperations;
645    }
646
647
648
649    /**
650     * {@inheritDoc}
651     */
652    public boolean isSuppressSynchronizationOperations() {
653      return pSuppressSynchronizationOperations;
654    }
655
656
657
658    /**
659     * {@inheritDoc}
660     */
661    public String[] listAccessLogFilteringCriteria() {
662      return impl.listChildren(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition());
663    }
664
665
666
667    /**
668     * {@inheritDoc}
669     */
670    public AccessLogFilteringCriteriaCfg getAccessLogFilteringCriteria(String name) throws ConfigException {
671      return impl.getChild(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition(), name).getConfiguration();
672    }
673
674
675
676    /**
677     * {@inheritDoc}
678     */
679    public void addAccessLogFilteringCriteriaAddListener(
680        ConfigurationAddListener<AccessLogFilteringCriteriaCfg> listener) throws ConfigException {
681      impl.registerAddListener(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition(), listener);
682    }
683
684
685
686    /**
687     * {@inheritDoc}
688     */
689    public void removeAccessLogFilteringCriteriaAddListener(
690        ConfigurationAddListener<AccessLogFilteringCriteriaCfg> listener) {
691      impl.deregisterAddListener(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition(), listener);
692    }
693
694
695
696    /**
697     * {@inheritDoc}
698     */
699    public void addAccessLogFilteringCriteriaDeleteListener(
700        ConfigurationDeleteListener<AccessLogFilteringCriteriaCfg> listener) throws ConfigException {
701      impl.registerDeleteListener(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition(), listener);
702    }
703
704
705
706    /**
707     * {@inheritDoc}
708     */
709    public void removeAccessLogFilteringCriteriaDeleteListener(
710        ConfigurationDeleteListener<AccessLogFilteringCriteriaCfg> listener) {
711      impl.deregisterDeleteListener(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition(), listener);
712    }
713
714
715
716    /**
717     * {@inheritDoc}
718     */
719    public Class<? extends AccessLogPublisherCfg> configurationClass() {
720      return AccessLogPublisherCfg.class;
721    }
722
723
724
725    /**
726     * {@inheritDoc}
727     */
728    public DN dn() {
729      return impl.getDN();
730    }
731
732
733
734    /** {@inheritDoc} */
735    public String toString() {
736      return impl.toString();
737    }
738  }
739}