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