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.AliasDefaultBehaviorProvider; 034import org.forgerock.opendj.config.BooleanPropertyDefinition; 035import org.forgerock.opendj.config.client.ConcurrentModificationException; 036import org.forgerock.opendj.config.client.ManagedObject; 037import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException; 038import org.forgerock.opendj.config.client.OperationRejectedException; 039import org.forgerock.opendj.config.DNPropertyDefinition; 040import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException; 041import org.forgerock.opendj.config.ManagedObjectDefinition; 042import org.forgerock.opendj.config.ManagedObjectOption; 043import org.forgerock.opendj.config.PropertyOption; 044import org.forgerock.opendj.config.PropertyProvider; 045import org.forgerock.opendj.config.server.ConfigurationChangeListener; 046import org.forgerock.opendj.config.server.ServerManagedObject; 047import org.forgerock.opendj.config.Tag; 048import org.forgerock.opendj.config.TopCfgDefn; 049import org.forgerock.opendj.config.UndefinedDefaultBehaviorProvider; 050import org.forgerock.opendj.ldap.DN; 051import org.forgerock.opendj.ldap.LdapException; 052import org.forgerock.opendj.server.config.client.RootDSEBackendCfgClient; 053import org.forgerock.opendj.server.config.server.RootDSEBackendCfg; 054 055 056 057/** 058 * An interface for querying the Root DSE Backend managed object 059 * definition meta information. 060 * <p> 061 * The Root DSE Backend contains the directory server root DSE. 062 */ 063public final class RootDSEBackendCfgDefn extends ManagedObjectDefinition<RootDSEBackendCfgClient, RootDSEBackendCfg> { 064 065 // The singleton configuration definition instance. 066 private static final RootDSEBackendCfgDefn INSTANCE = new RootDSEBackendCfgDefn(); 067 068 069 070 // The "show-all-attributes" property definition. 071 private static final BooleanPropertyDefinition PD_SHOW_ALL_ATTRIBUTES; 072 073 074 075 // The "subordinate-base-dn" property definition. 076 private static final DNPropertyDefinition PD_SUBORDINATE_BASE_DN; 077 078 079 080 // Build the "show-all-attributes" property definition. 081 static { 082 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "show-all-attributes"); 083 builder.setOption(PropertyOption.MANDATORY); 084 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "show-all-attributes")); 085 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<Boolean>()); 086 PD_SHOW_ALL_ATTRIBUTES = builder.getInstance(); 087 INSTANCE.registerPropertyDefinition(PD_SHOW_ALL_ATTRIBUTES); 088 } 089 090 091 092 // Build the "subordinate-base-dn" property definition. 093 static { 094 DNPropertyDefinition.Builder builder = DNPropertyDefinition.createBuilder(INSTANCE, "subordinate-base-dn"); 095 builder.setOption(PropertyOption.MULTI_VALUED); 096 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "subordinate-base-dn")); 097 builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<DN>(INSTANCE, "subordinate-base-dn")); 098 PD_SUBORDINATE_BASE_DN = builder.getInstance(); 099 INSTANCE.registerPropertyDefinition(PD_SUBORDINATE_BASE_DN); 100 } 101 102 103 104 // Register the options associated with this managed object definition. 105 static { 106 INSTANCE.registerOption(ManagedObjectOption.ADVANCED); 107 } 108 109 110 111 // Register the tags associated with this managed object definition. 112 static { 113 INSTANCE.registerTag(Tag.valueOf("core-server")); 114 INSTANCE.registerTag(Tag.valueOf("database")); 115 } 116 117 118 119 /** 120 * Get the Root DSE Backend configuration definition singleton. 121 * 122 * @return Returns the Root DSE Backend configuration definition 123 * singleton. 124 */ 125 public static RootDSEBackendCfgDefn getInstance() { 126 return INSTANCE; 127 } 128 129 130 131 /** 132 * Private constructor. 133 */ 134 private RootDSEBackendCfgDefn() { 135 super("root-dse-backend", TopCfgDefn.getInstance()); 136 } 137 138 139 140 /** 141 * {@inheritDoc} 142 */ 143 public RootDSEBackendCfgClient createClientConfiguration( 144 ManagedObject<? extends RootDSEBackendCfgClient> impl) { 145 return new RootDSEBackendCfgClientImpl(impl); 146 } 147 148 149 150 /** 151 * {@inheritDoc} 152 */ 153 public RootDSEBackendCfg createServerConfiguration( 154 ServerManagedObject<? extends RootDSEBackendCfg> impl) { 155 return new RootDSEBackendCfgServerImpl(impl); 156 } 157 158 159 160 /** 161 * {@inheritDoc} 162 */ 163 public Class<RootDSEBackendCfg> getServerConfigurationClass() { 164 return RootDSEBackendCfg.class; 165 } 166 167 168 169 /** 170 * Get the "show-all-attributes" property definition. 171 * <p> 172 * Indicates whether all attributes in the root DSE are to be 173 * treated like user attributes (and therefore returned to clients by 174 * default) regardless of the directory server schema configuration. 175 * 176 * @return Returns the "show-all-attributes" property definition. 177 */ 178 public BooleanPropertyDefinition getShowAllAttributesPropertyDefinition() { 179 return PD_SHOW_ALL_ATTRIBUTES; 180 } 181 182 183 184 /** 185 * Get the "subordinate-base-dn" property definition. 186 * <p> 187 * Specifies the set of base DNs used for singleLevel, wholeSubtree, 188 * and subordinateSubtree searches based at the root DSE. 189 * 190 * @return Returns the "subordinate-base-dn" property definition. 191 */ 192 public DNPropertyDefinition getSubordinateBaseDNPropertyDefinition() { 193 return PD_SUBORDINATE_BASE_DN; 194 } 195 196 197 198 /** 199 * Managed object client implementation. 200 */ 201 private static class RootDSEBackendCfgClientImpl implements 202 RootDSEBackendCfgClient { 203 204 // Private implementation. 205 private ManagedObject<? extends RootDSEBackendCfgClient> impl; 206 207 208 209 // Private constructor. 210 private RootDSEBackendCfgClientImpl( 211 ManagedObject<? extends RootDSEBackendCfgClient> impl) { 212 this.impl = impl; 213 } 214 215 216 217 /** 218 * {@inheritDoc} 219 */ 220 public Boolean isShowAllAttributes() { 221 return impl.getPropertyValue(INSTANCE.getShowAllAttributesPropertyDefinition()); 222 } 223 224 225 226 /** 227 * {@inheritDoc} 228 */ 229 public void setShowAllAttributes(boolean value) { 230 impl.setPropertyValue(INSTANCE.getShowAllAttributesPropertyDefinition(), value); 231 } 232 233 234 235 /** 236 * {@inheritDoc} 237 */ 238 public SortedSet<DN> getSubordinateBaseDN() { 239 return impl.getPropertyValues(INSTANCE.getSubordinateBaseDNPropertyDefinition()); 240 } 241 242 243 244 /** 245 * {@inheritDoc} 246 */ 247 public void setSubordinateBaseDN(Collection<DN> values) { 248 impl.setPropertyValues(INSTANCE.getSubordinateBaseDNPropertyDefinition(), values); 249 } 250 251 252 253 /** 254 * {@inheritDoc} 255 */ 256 public ManagedObjectDefinition<? extends RootDSEBackendCfgClient, ? extends RootDSEBackendCfg> definition() { 257 return INSTANCE; 258 } 259 260 261 262 /** 263 * {@inheritDoc} 264 */ 265 public PropertyProvider properties() { 266 return impl; 267 } 268 269 270 271 /** 272 * {@inheritDoc} 273 */ 274 public void commit() throws ManagedObjectAlreadyExistsException, 275 MissingMandatoryPropertiesException, ConcurrentModificationException, 276 OperationRejectedException, LdapException { 277 impl.commit(); 278 } 279 280 } 281 282 283 284 /** 285 * Managed object server implementation. 286 */ 287 private static class RootDSEBackendCfgServerImpl implements 288 RootDSEBackendCfg { 289 290 // Private implementation. 291 private ServerManagedObject<? extends RootDSEBackendCfg> impl; 292 293 // The value of the "show-all-attributes" property. 294 private final boolean pShowAllAttributes; 295 296 // The value of the "subordinate-base-dn" property. 297 private final SortedSet<DN> pSubordinateBaseDN; 298 299 300 301 // Private constructor. 302 private RootDSEBackendCfgServerImpl(ServerManagedObject<? extends RootDSEBackendCfg> impl) { 303 this.impl = impl; 304 this.pShowAllAttributes = impl.getPropertyValue(INSTANCE.getShowAllAttributesPropertyDefinition()); 305 this.pSubordinateBaseDN = impl.getPropertyValues(INSTANCE.getSubordinateBaseDNPropertyDefinition()); 306 } 307 308 309 310 /** 311 * {@inheritDoc} 312 */ 313 public void addChangeListener( 314 ConfigurationChangeListener<RootDSEBackendCfg> listener) { 315 impl.registerChangeListener(listener); 316 } 317 318 319 320 /** 321 * {@inheritDoc} 322 */ 323 public void removeChangeListener( 324 ConfigurationChangeListener<RootDSEBackendCfg> listener) { 325 impl.deregisterChangeListener(listener); 326 } 327 328 329 330 /** 331 * {@inheritDoc} 332 */ 333 public boolean isShowAllAttributes() { 334 return pShowAllAttributes; 335 } 336 337 338 339 /** 340 * {@inheritDoc} 341 */ 342 public SortedSet<DN> getSubordinateBaseDN() { 343 return pSubordinateBaseDN; 344 } 345 346 347 348 /** 349 * {@inheritDoc} 350 */ 351 public Class<? extends RootDSEBackendCfg> configurationClass() { 352 return RootDSEBackendCfg.class; 353 } 354 355 356 357 /** 358 * {@inheritDoc} 359 */ 360 public DN dn() { 361 return impl.getDN(); 362 } 363 364 } 365}