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