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 /** {@inheritDoc} */ 142 public ExternalChangelogDomainCfgClient createClientConfiguration( 143 ManagedObject<? extends ExternalChangelogDomainCfgClient> impl) { 144 return new ExternalChangelogDomainCfgClientImpl(impl); 145 } 146 147 148 149 /** {@inheritDoc} */ 150 public ExternalChangelogDomainCfg createServerConfiguration( 151 ServerManagedObject<? extends ExternalChangelogDomainCfg> impl) { 152 return new ExternalChangelogDomainCfgServerImpl(impl); 153 } 154 155 156 157 /** {@inheritDoc} */ 158 public Class<ExternalChangelogDomainCfg> getServerConfigurationClass() { 159 return ExternalChangelogDomainCfg.class; 160 } 161 162 163 164 /** 165 * Get the "ecl-include" property definition. 166 * <p> 167 * Specifies a list of attributes which should be published with 168 * every change log entry, regardless of whether or not the attribute 169 * itself has changed. 170 * <p> 171 * The list of attributes may include wild cards such as "*" and "+" 172 * as well as object class references prefixed with an ampersand, for 173 * example "@person". The included attributes will be published using 174 * the "includedAttributes" operational attribute as a single LDIF 175 * value rather like the "changes" attribute. For modify and modifyDN 176 * operations the included attributes will be taken from the entry 177 * before any changes were applied. 178 * 179 * @return Returns the "ecl-include" property definition. 180 */ 181 public StringPropertyDefinition getECLIncludePropertyDefinition() { 182 return PD_ECL_INCLUDE; 183 } 184 185 186 187 /** 188 * Get the "ecl-include-for-deletes" property definition. 189 * <p> 190 * Specifies a list of attributes which should be published with 191 * every delete operation change log entry, in addition to those 192 * specified by the "ecl-include" property. 193 * <p> 194 * This property provides a means for applications to archive 195 * entries after they have been deleted. See the description of the 196 * "ecl-include" property for further information about how the 197 * included attributes are published. 198 * 199 * @return Returns the "ecl-include-for-deletes" property definition. 200 */ 201 public StringPropertyDefinition getECLIncludeForDeletesPropertyDefinition() { 202 return PD_ECL_INCLUDE_FOR_DELETES; 203 } 204 205 206 207 /** 208 * Get the "enabled" property definition. 209 * <p> 210 * Indicates whether the External Changelog Domain is enabled. To 211 * enable computing the change numbers, set the Replication Server's 212 * "ds-cfg-compute-change-number" property to true. 213 * 214 * @return Returns the "enabled" property definition. 215 */ 216 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 217 return PD_ENABLED; 218 } 219 220 221 222 /** 223 * Managed object client implementation. 224 */ 225 private static class ExternalChangelogDomainCfgClientImpl implements 226 ExternalChangelogDomainCfgClient { 227 228 /** Private implementation. */ 229 private ManagedObject<? extends ExternalChangelogDomainCfgClient> impl; 230 231 232 233 /** Private constructor. */ 234 private ExternalChangelogDomainCfgClientImpl( 235 ManagedObject<? extends ExternalChangelogDomainCfgClient> impl) { 236 this.impl = impl; 237 } 238 239 240 241 /** {@inheritDoc} */ 242 public SortedSet<String> getECLInclude() { 243 return impl.getPropertyValues(INSTANCE.getECLIncludePropertyDefinition()); 244 } 245 246 247 248 /** {@inheritDoc} */ 249 public void setECLInclude(Collection<String> values) { 250 impl.setPropertyValues(INSTANCE.getECLIncludePropertyDefinition(), values); 251 } 252 253 254 255 /** {@inheritDoc} */ 256 public SortedSet<String> getECLIncludeForDeletes() { 257 return impl.getPropertyValues(INSTANCE.getECLIncludeForDeletesPropertyDefinition()); 258 } 259 260 261 262 /** {@inheritDoc} */ 263 public void setECLIncludeForDeletes(Collection<String> values) { 264 impl.setPropertyValues(INSTANCE.getECLIncludeForDeletesPropertyDefinition(), values); 265 } 266 267 268 269 /** {@inheritDoc} */ 270 public Boolean isEnabled() { 271 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 272 } 273 274 275 276 /** {@inheritDoc} */ 277 public void setEnabled(boolean value) { 278 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 279 } 280 281 282 283 /** {@inheritDoc} */ 284 public ManagedObjectDefinition<? extends ExternalChangelogDomainCfgClient, ? extends ExternalChangelogDomainCfg> definition() { 285 return INSTANCE; 286 } 287 288 289 290 /** {@inheritDoc} */ 291 public PropertyProvider properties() { 292 return impl; 293 } 294 295 296 297 /** {@inheritDoc} */ 298 public void commit() throws ManagedObjectAlreadyExistsException, 299 MissingMandatoryPropertiesException, ConcurrentModificationException, 300 OperationRejectedException, LdapException { 301 impl.commit(); 302 } 303 304 305 306 /** {@inheritDoc} */ 307 public String toString() { 308 return impl.toString(); 309 } 310 } 311 312 313 314 /** 315 * Managed object server implementation. 316 */ 317 private static class ExternalChangelogDomainCfgServerImpl implements 318 ExternalChangelogDomainCfg { 319 320 /** Private implementation. */ 321 private ServerManagedObject<? extends ExternalChangelogDomainCfg> impl; 322 323 /** The value of the "ecl-include" property. */ 324 private final SortedSet<String> pECLInclude; 325 326 /** The value of the "ecl-include-for-deletes" property. */ 327 private final SortedSet<String> pECLIncludeForDeletes; 328 329 /** The value of the "enabled" property. */ 330 private final boolean pEnabled; 331 332 333 334 /** Private constructor. */ 335 private ExternalChangelogDomainCfgServerImpl(ServerManagedObject<? extends ExternalChangelogDomainCfg> impl) { 336 this.impl = impl; 337 this.pECLInclude = impl.getPropertyValues(INSTANCE.getECLIncludePropertyDefinition()); 338 this.pECLIncludeForDeletes = impl.getPropertyValues(INSTANCE.getECLIncludeForDeletesPropertyDefinition()); 339 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 340 } 341 342 343 344 /** {@inheritDoc} */ 345 public void addChangeListener( 346 ConfigurationChangeListener<ExternalChangelogDomainCfg> listener) { 347 impl.registerChangeListener(listener); 348 } 349 350 351 352 /** {@inheritDoc} */ 353 public void removeChangeListener( 354 ConfigurationChangeListener<ExternalChangelogDomainCfg> listener) { 355 impl.deregisterChangeListener(listener); 356 } 357 358 359 360 /** {@inheritDoc} */ 361 public SortedSet<String> getECLInclude() { 362 return pECLInclude; 363 } 364 365 366 367 /** {@inheritDoc} */ 368 public SortedSet<String> getECLIncludeForDeletes() { 369 return pECLIncludeForDeletes; 370 } 371 372 373 374 /** {@inheritDoc} */ 375 public boolean isEnabled() { 376 return pEnabled; 377 } 378 379 380 381 /** {@inheritDoc} */ 382 public Class<? extends ExternalChangelogDomainCfg> configurationClass() { 383 return ExternalChangelogDomainCfg.class; 384 } 385 386 387 388 /** {@inheritDoc} */ 389 public DN dn() { 390 return impl.getDN(); 391 } 392 393 394 395 /** {@inheritDoc} */ 396 public String toString() { 397 return impl.toString(); 398 } 399 } 400}