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