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