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 java.util.SortedSet; 032import org.forgerock.opendj.config.AdministratorAction; 033import org.forgerock.opendj.config.BooleanPropertyDefinition; 034import org.forgerock.opendj.config.client.ConcurrentModificationException; 035import org.forgerock.opendj.config.client.ManagedObject; 036import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException; 037import org.forgerock.opendj.config.client.OperationRejectedException; 038import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException; 039import org.forgerock.opendj.config.ManagedObjectDefinition; 040import org.forgerock.opendj.config.PropertyOption; 041import org.forgerock.opendj.config.PropertyProvider; 042import org.forgerock.opendj.config.server.ConfigurationChangeListener; 043import org.forgerock.opendj.config.server.ServerManagedObject; 044import org.forgerock.opendj.config.StringPropertyDefinition; 045import org.forgerock.opendj.config.TopCfgDefn; 046import org.forgerock.opendj.config.UndefinedDefaultBehaviorProvider; 047import org.forgerock.opendj.ldap.DN; 048import org.forgerock.opendj.ldap.LdapException; 049import org.forgerock.opendj.server.config.client.ExternalChangelogDomainCfgClient; 050import org.forgerock.opendj.server.config.server.ExternalChangelogDomainCfg; 051 052 053 054/** 055 * An interface for querying the External Changelog Domain managed 056 * object definition meta information. 057 * <p> 058 * The External Changelog Domain provides configuration of the 059 * external changelog for the replication domain. 060 */ 061public final class ExternalChangelogDomainCfgDefn extends ManagedObjectDefinition<ExternalChangelogDomainCfgClient, ExternalChangelogDomainCfg> { 062 063 // The singleton configuration definition instance. 064 private static final ExternalChangelogDomainCfgDefn INSTANCE = new ExternalChangelogDomainCfgDefn(); 065 066 067 068 // The "ecl-include" property definition. 069 private static final StringPropertyDefinition PD_ECL_INCLUDE; 070 071 072 073 // The "ecl-include-for-deletes" property definition. 074 private static final StringPropertyDefinition PD_ECL_INCLUDE_FOR_DELETES; 075 076 077 078 // The "enabled" property definition. 079 private static final BooleanPropertyDefinition PD_ENABLED; 080 081 082 083 // Build the "ecl-include" property definition. 084 static { 085 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "ecl-include"); 086 builder.setOption(PropertyOption.MULTI_VALUED); 087 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "ecl-include")); 088 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 089 PD_ECL_INCLUDE = builder.getInstance(); 090 INSTANCE.registerPropertyDefinition(PD_ECL_INCLUDE); 091 } 092 093 094 095 // Build the "ecl-include-for-deletes" property definition. 096 static { 097 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "ecl-include-for-deletes"); 098 builder.setOption(PropertyOption.MULTI_VALUED); 099 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "ecl-include-for-deletes")); 100 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 101 PD_ECL_INCLUDE_FOR_DELETES = builder.getInstance(); 102 INSTANCE.registerPropertyDefinition(PD_ECL_INCLUDE_FOR_DELETES); 103 } 104 105 106 107 // Build the "enabled" property definition. 108 static { 109 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "enabled"); 110 builder.setOption(PropertyOption.MANDATORY); 111 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "enabled")); 112 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<Boolean>()); 113 PD_ENABLED = builder.getInstance(); 114 INSTANCE.registerPropertyDefinition(PD_ENABLED); 115 } 116 117 118 119 /** 120 * Get the External Changelog Domain configuration definition 121 * singleton. 122 * 123 * @return Returns the External Changelog Domain configuration 124 * definition singleton. 125 */ 126 public static ExternalChangelogDomainCfgDefn getInstance() { 127 return INSTANCE; 128 } 129 130 131 132 /** 133 * Private constructor. 134 */ 135 private ExternalChangelogDomainCfgDefn() { 136 super("external-changelog-domain", TopCfgDefn.getInstance()); 137 } 138 139 140 141 /** 142 * {@inheritDoc} 143 */ 144 public ExternalChangelogDomainCfgClient createClientConfiguration( 145 ManagedObject<? extends ExternalChangelogDomainCfgClient> impl) { 146 return new ExternalChangelogDomainCfgClientImpl(impl); 147 } 148 149 150 151 /** 152 * {@inheritDoc} 153 */ 154 public ExternalChangelogDomainCfg createServerConfiguration( 155 ServerManagedObject<? extends ExternalChangelogDomainCfg> impl) { 156 return new ExternalChangelogDomainCfgServerImpl(impl); 157 } 158 159 160 161 /** 162 * {@inheritDoc} 163 */ 164 public Class<ExternalChangelogDomainCfg> getServerConfigurationClass() { 165 return ExternalChangelogDomainCfg.class; 166 } 167 168 169 170 /** 171 * Get the "ecl-include" property definition. 172 * <p> 173 * Specifies a list of attributes which should be published with 174 * every change log entry, regardless of whether or not the attribute 175 * itself has changed. 176 * <p> 177 * The list of attributes may include wild cards such as "*" and "+" 178 * as well as object class references prefixed with an ampersand, for 179 * example "@person". The included attributes will be published using 180 * the "includedAttributes" operational attribute as a single LDIF 181 * value rather like the "changes" attribute. For modify and modifyDN 182 * operations the included attributes will be taken from the entry 183 * before any changes were applied. 184 * 185 * @return Returns the "ecl-include" property definition. 186 */ 187 public StringPropertyDefinition getECLIncludePropertyDefinition() { 188 return PD_ECL_INCLUDE; 189 } 190 191 192 193 /** 194 * Get the "ecl-include-for-deletes" property definition. 195 * <p> 196 * Specifies a list of attributes which should be published with 197 * every delete operation change log entry, in addition to those 198 * specified by the "ecl-include" property. 199 * <p> 200 * This property provides a means for applications to archive 201 * entries after they have been deleted. See the description of the 202 * "ecl-include" property for further information about how the 203 * included attributes are published. 204 * 205 * @return Returns the "ecl-include-for-deletes" property definition. 206 */ 207 public StringPropertyDefinition getECLIncludeForDeletesPropertyDefinition() { 208 return PD_ECL_INCLUDE_FOR_DELETES; 209 } 210 211 212 213 /** 214 * Get the "enabled" property definition. 215 * <p> 216 * Indicates whether the External Changelog Domain is enabled. To 217 * enable computing the change numbers, set the Replication Server's 218 * "ds-cfg-compute-change-number" property to true. 219 * 220 * @return Returns the "enabled" property definition. 221 */ 222 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 223 return PD_ENABLED; 224 } 225 226 227 228 /** 229 * Managed object client implementation. 230 */ 231 private static class ExternalChangelogDomainCfgClientImpl implements 232 ExternalChangelogDomainCfgClient { 233 234 // Private implementation. 235 private ManagedObject<? extends ExternalChangelogDomainCfgClient> impl; 236 237 238 239 // Private constructor. 240 private ExternalChangelogDomainCfgClientImpl( 241 ManagedObject<? extends ExternalChangelogDomainCfgClient> impl) { 242 this.impl = impl; 243 } 244 245 246 247 /** 248 * {@inheritDoc} 249 */ 250 public SortedSet<String> getECLInclude() { 251 return impl.getPropertyValues(INSTANCE.getECLIncludePropertyDefinition()); 252 } 253 254 255 256 /** 257 * {@inheritDoc} 258 */ 259 public void setECLInclude(Collection<String> values) { 260 impl.setPropertyValues(INSTANCE.getECLIncludePropertyDefinition(), values); 261 } 262 263 264 265 /** 266 * {@inheritDoc} 267 */ 268 public SortedSet<String> getECLIncludeForDeletes() { 269 return impl.getPropertyValues(INSTANCE.getECLIncludeForDeletesPropertyDefinition()); 270 } 271 272 273 274 /** 275 * {@inheritDoc} 276 */ 277 public void setECLIncludeForDeletes(Collection<String> values) { 278 impl.setPropertyValues(INSTANCE.getECLIncludeForDeletesPropertyDefinition(), values); 279 } 280 281 282 283 /** 284 * {@inheritDoc} 285 */ 286 public Boolean isEnabled() { 287 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 288 } 289 290 291 292 /** 293 * {@inheritDoc} 294 */ 295 public void setEnabled(boolean value) { 296 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 297 } 298 299 300 301 /** 302 * {@inheritDoc} 303 */ 304 public ManagedObjectDefinition<? extends ExternalChangelogDomainCfgClient, ? extends ExternalChangelogDomainCfg> definition() { 305 return INSTANCE; 306 } 307 308 309 310 /** 311 * {@inheritDoc} 312 */ 313 public PropertyProvider properties() { 314 return impl; 315 } 316 317 318 319 /** 320 * {@inheritDoc} 321 */ 322 public void commit() throws ManagedObjectAlreadyExistsException, 323 MissingMandatoryPropertiesException, ConcurrentModificationException, 324 OperationRejectedException, LdapException { 325 impl.commit(); 326 } 327 328 } 329 330 331 332 /** 333 * Managed object server implementation. 334 */ 335 private static class ExternalChangelogDomainCfgServerImpl implements 336 ExternalChangelogDomainCfg { 337 338 // Private implementation. 339 private ServerManagedObject<? extends ExternalChangelogDomainCfg> impl; 340 341 // The value of the "ecl-include" property. 342 private final SortedSet<String> pECLInclude; 343 344 // The value of the "ecl-include-for-deletes" property. 345 private final SortedSet<String> pECLIncludeForDeletes; 346 347 // The value of the "enabled" property. 348 private final boolean pEnabled; 349 350 351 352 // Private constructor. 353 private ExternalChangelogDomainCfgServerImpl(ServerManagedObject<? extends ExternalChangelogDomainCfg> impl) { 354 this.impl = impl; 355 this.pECLInclude = impl.getPropertyValues(INSTANCE.getECLIncludePropertyDefinition()); 356 this.pECLIncludeForDeletes = impl.getPropertyValues(INSTANCE.getECLIncludeForDeletesPropertyDefinition()); 357 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 358 } 359 360 361 362 /** 363 * {@inheritDoc} 364 */ 365 public void addChangeListener( 366 ConfigurationChangeListener<ExternalChangelogDomainCfg> listener) { 367 impl.registerChangeListener(listener); 368 } 369 370 371 372 /** 373 * {@inheritDoc} 374 */ 375 public void removeChangeListener( 376 ConfigurationChangeListener<ExternalChangelogDomainCfg> listener) { 377 impl.deregisterChangeListener(listener); 378 } 379 380 381 382 /** 383 * {@inheritDoc} 384 */ 385 public SortedSet<String> getECLInclude() { 386 return pECLInclude; 387 } 388 389 390 391 /** 392 * {@inheritDoc} 393 */ 394 public SortedSet<String> getECLIncludeForDeletes() { 395 return pECLIncludeForDeletes; 396 } 397 398 399 400 /** 401 * {@inheritDoc} 402 */ 403 public boolean isEnabled() { 404 return pEnabled; 405 } 406 407 408 409 /** 410 * {@inheritDoc} 411 */ 412 public Class<? extends ExternalChangelogDomainCfg> configurationClass() { 413 return ExternalChangelogDomainCfg.class; 414 } 415 416 417 418 /** 419 * {@inheritDoc} 420 */ 421 public DN dn() { 422 return impl.getDN(); 423 } 424 425 } 426}