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 010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE 011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2008 Sun Microsystems, Inc. 026 */ 027 package org.opends.server.admin.std.meta; 028 029 030 031 import org.opends.server.admin.AdministratorAction; 032 import org.opends.server.admin.BooleanPropertyDefinition; 033 import org.opends.server.admin.ClassPropertyDefinition; 034 import org.opends.server.admin.client.AuthorizationException; 035 import org.opends.server.admin.client.CommunicationException; 036 import org.opends.server.admin.client.ConcurrentModificationException; 037 import org.opends.server.admin.client.ManagedObject; 038 import org.opends.server.admin.client.MissingMandatoryPropertiesException; 039 import org.opends.server.admin.client.OperationRejectedException; 040 import org.opends.server.admin.DefaultBehaviorProvider; 041 import org.opends.server.admin.DefinedDefaultBehaviorProvider; 042 import org.opends.server.admin.ManagedObjectAlreadyExistsException; 043 import org.opends.server.admin.ManagedObjectDefinition; 044 import org.opends.server.admin.PropertyOption; 045 import org.opends.server.admin.PropertyProvider; 046 import org.opends.server.admin.server.ConfigurationChangeListener; 047 import org.opends.server.admin.server.ServerManagedObject; 048 import org.opends.server.admin.std.client.AccessLogPublisherCfgClient; 049 import org.opends.server.admin.std.server.AccessLogPublisherCfg; 050 import org.opends.server.admin.std.server.LogPublisherCfg; 051 import org.opends.server.admin.Tag; 052 import org.opends.server.admin.UndefinedDefaultBehaviorProvider; 053 import org.opends.server.types.DN; 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 */ 064 public 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 // The "java-class" property definition. 072 private static final ClassPropertyDefinition PD_JAVA_CLASS; 073 074 075 076 // The "suppress-internal-operations" property definition. 077 private static final BooleanPropertyDefinition PD_SUPPRESS_INTERNAL_OPERATIONS; 078 079 080 081 // The "suppress-synchronization-operations" property definition. 082 private static final BooleanPropertyDefinition PD_SUPPRESS_SYNCHRONIZATION_OPERATIONS; 083 084 085 086 // Build the "java-class" property definition. 087 static { 088 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 089 builder.setOption(PropertyOption.MANDATORY); 090 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class")); 091 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 092 builder.addInstanceOf("org.opends.server.api.AccessLogPublisher"); 093 PD_JAVA_CLASS = builder.getInstance(); 094 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 095 } 096 097 098 099 // Build the "suppress-internal-operations" property definition. 100 static { 101 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "suppress-internal-operations"); 102 builder.setOption(PropertyOption.ADVANCED); 103 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "suppress-internal-operations")); 104 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("true"); 105 builder.setDefaultBehaviorProvider(provider); 106 PD_SUPPRESS_INTERNAL_OPERATIONS = builder.getInstance(); 107 INSTANCE.registerPropertyDefinition(PD_SUPPRESS_INTERNAL_OPERATIONS); 108 } 109 110 111 112 // Build the "suppress-synchronization-operations" property definition. 113 static { 114 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "suppress-synchronization-operations"); 115 builder.setOption(PropertyOption.ADVANCED); 116 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "suppress-synchronization-operations")); 117 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false"); 118 builder.setDefaultBehaviorProvider(provider); 119 PD_SUPPRESS_SYNCHRONIZATION_OPERATIONS = builder.getInstance(); 120 INSTANCE.registerPropertyDefinition(PD_SUPPRESS_SYNCHRONIZATION_OPERATIONS); 121 } 122 123 124 125 // Register the tags associated with this managed object definition. 126 static { 127 INSTANCE.registerTag(Tag.valueOf("logging")); 128 } 129 130 131 132 /** 133 * Get the Access Log Publisher configuration definition singleton. 134 * 135 * @return Returns the Access Log Publisher configuration definition 136 * singleton. 137 */ 138 public static AccessLogPublisherCfgDefn getInstance() { 139 return INSTANCE; 140 } 141 142 143 144 /** 145 * Private constructor. 146 */ 147 private AccessLogPublisherCfgDefn() { 148 super("access-log-publisher", LogPublisherCfgDefn.getInstance()); 149 } 150 151 152 153 /** 154 * {@inheritDoc} 155 */ 156 public AccessLogPublisherCfgClient createClientConfiguration( 157 ManagedObject<? extends AccessLogPublisherCfgClient> impl) { 158 return new AccessLogPublisherCfgClientImpl(impl); 159 } 160 161 162 163 /** 164 * {@inheritDoc} 165 */ 166 public AccessLogPublisherCfg createServerConfiguration( 167 ServerManagedObject<? extends AccessLogPublisherCfg> impl) { 168 return new AccessLogPublisherCfgServerImpl(impl); 169 } 170 171 172 173 /** 174 * {@inheritDoc} 175 */ 176 public Class<AccessLogPublisherCfg> getServerConfigurationClass() { 177 return AccessLogPublisherCfg.class; 178 } 179 180 181 182 /** 183 * Get the "enabled" property definition. 184 * <p> 185 * Indicates whether the Access Log Publisher is enabled for use. 186 * 187 * @return Returns the "enabled" property definition. 188 */ 189 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 190 return LogPublisherCfgDefn.getInstance().getEnabledPropertyDefinition(); 191 } 192 193 194 195 /** 196 * Get the "java-class" property definition. 197 * <p> 198 * The fully-qualified name of the Java class that provides the 199 * Access Log Publisher implementation. 200 * 201 * @return Returns the "java-class" property definition. 202 */ 203 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 204 return PD_JAVA_CLASS; 205 } 206 207 208 209 /** 210 * Get the "suppress-internal-operations" property definition. 211 * <p> 212 * Indicates whether internal operations (for example, operations 213 * that are initiated by plugins) should be logged along with the 214 * operations that are requested by users. 215 * 216 * @return Returns the "suppress-internal-operations" property definition. 217 */ 218 public BooleanPropertyDefinition getSuppressInternalOperationsPropertyDefinition() { 219 return PD_SUPPRESS_INTERNAL_OPERATIONS; 220 } 221 222 223 224 /** 225 * Get the "suppress-synchronization-operations" property definition. 226 * <p> 227 * Indicates whether access messages that are generated by 228 * synchronization operations should be suppressed. 229 * 230 * @return Returns the "suppress-synchronization-operations" property definition. 231 */ 232 public BooleanPropertyDefinition getSuppressSynchronizationOperationsPropertyDefinition() { 233 return PD_SUPPRESS_SYNCHRONIZATION_OPERATIONS; 234 } 235 236 237 238 /** 239 * Managed object client implementation. 240 */ 241 private static class AccessLogPublisherCfgClientImpl implements 242 AccessLogPublisherCfgClient { 243 244 // Private implementation. 245 private ManagedObject<? extends AccessLogPublisherCfgClient> impl; 246 247 248 249 // Private constructor. 250 private AccessLogPublisherCfgClientImpl( 251 ManagedObject<? extends AccessLogPublisherCfgClient> impl) { 252 this.impl = impl; 253 } 254 255 256 257 /** 258 * {@inheritDoc} 259 */ 260 public Boolean isEnabled() { 261 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 262 } 263 264 265 266 /** 267 * {@inheritDoc} 268 */ 269 public void setEnabled(boolean value) { 270 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 271 } 272 273 274 275 /** 276 * {@inheritDoc} 277 */ 278 public String getJavaClass() { 279 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 280 } 281 282 283 284 /** 285 * {@inheritDoc} 286 */ 287 public void setJavaClass(String value) { 288 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 289 } 290 291 292 293 /** 294 * {@inheritDoc} 295 */ 296 public boolean isSuppressInternalOperations() { 297 return impl.getPropertyValue(INSTANCE.getSuppressInternalOperationsPropertyDefinition()); 298 } 299 300 301 302 /** 303 * {@inheritDoc} 304 */ 305 public void setSuppressInternalOperations(Boolean value) { 306 impl.setPropertyValue(INSTANCE.getSuppressInternalOperationsPropertyDefinition(), value); 307 } 308 309 310 311 /** 312 * {@inheritDoc} 313 */ 314 public boolean isSuppressSynchronizationOperations() { 315 return impl.getPropertyValue(INSTANCE.getSuppressSynchronizationOperationsPropertyDefinition()); 316 } 317 318 319 320 /** 321 * {@inheritDoc} 322 */ 323 public void setSuppressSynchronizationOperations(Boolean value) { 324 impl.setPropertyValue(INSTANCE.getSuppressSynchronizationOperationsPropertyDefinition(), value); 325 } 326 327 328 329 /** 330 * {@inheritDoc} 331 */ 332 public ManagedObjectDefinition<? extends AccessLogPublisherCfgClient, ? extends AccessLogPublisherCfg> definition() { 333 return INSTANCE; 334 } 335 336 337 338 /** 339 * {@inheritDoc} 340 */ 341 public PropertyProvider properties() { 342 return impl; 343 } 344 345 346 347 /** 348 * {@inheritDoc} 349 */ 350 public void commit() throws ManagedObjectAlreadyExistsException, 351 MissingMandatoryPropertiesException, ConcurrentModificationException, 352 OperationRejectedException, AuthorizationException, 353 CommunicationException { 354 impl.commit(); 355 } 356 357 } 358 359 360 361 /** 362 * Managed object server implementation. 363 */ 364 private static class AccessLogPublisherCfgServerImpl implements 365 AccessLogPublisherCfg { 366 367 // Private implementation. 368 private ServerManagedObject<? extends AccessLogPublisherCfg> impl; 369 370 // The value of the "enabled" property. 371 private final boolean pEnabled; 372 373 // The value of the "java-class" property. 374 private final String pJavaClass; 375 376 // The value of the "suppress-internal-operations" property. 377 private final boolean pSuppressInternalOperations; 378 379 // The value of the "suppress-synchronization-operations" property. 380 private final boolean pSuppressSynchronizationOperations; 381 382 383 384 // Private constructor. 385 private AccessLogPublisherCfgServerImpl(ServerManagedObject<? extends AccessLogPublisherCfg> impl) { 386 this.impl = impl; 387 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 388 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 389 this.pSuppressInternalOperations = impl.getPropertyValue(INSTANCE.getSuppressInternalOperationsPropertyDefinition()); 390 this.pSuppressSynchronizationOperations = impl.getPropertyValue(INSTANCE.getSuppressSynchronizationOperationsPropertyDefinition()); 391 } 392 393 394 395 /** 396 * {@inheritDoc} 397 */ 398 public void addAccessChangeListener( 399 ConfigurationChangeListener<AccessLogPublisherCfg> listener) { 400 impl.registerChangeListener(listener); 401 } 402 403 404 405 /** 406 * {@inheritDoc} 407 */ 408 public void removeAccessChangeListener( 409 ConfigurationChangeListener<AccessLogPublisherCfg> listener) { 410 impl.deregisterChangeListener(listener); 411 } 412 /** 413 * {@inheritDoc} 414 */ 415 public void addChangeListener( 416 ConfigurationChangeListener<LogPublisherCfg> listener) { 417 impl.registerChangeListener(listener); 418 } 419 420 421 422 /** 423 * {@inheritDoc} 424 */ 425 public void removeChangeListener( 426 ConfigurationChangeListener<LogPublisherCfg> listener) { 427 impl.deregisterChangeListener(listener); 428 } 429 430 431 432 /** 433 * {@inheritDoc} 434 */ 435 public boolean isEnabled() { 436 return pEnabled; 437 } 438 439 440 441 /** 442 * {@inheritDoc} 443 */ 444 public String getJavaClass() { 445 return pJavaClass; 446 } 447 448 449 450 /** 451 * {@inheritDoc} 452 */ 453 public boolean isSuppressInternalOperations() { 454 return pSuppressInternalOperations; 455 } 456 457 458 459 /** 460 * {@inheritDoc} 461 */ 462 public boolean isSuppressSynchronizationOperations() { 463 return pSuppressSynchronizationOperations; 464 } 465 466 467 468 /** 469 * {@inheritDoc} 470 */ 471 public Class<? extends AccessLogPublisherCfg> configurationClass() { 472 return AccessLogPublisherCfg.class; 473 } 474 475 476 477 /** 478 * {@inheritDoc} 479 */ 480 public DN dn() { 481 return impl.getDN(); 482 } 483 484 } 485 }