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 /** {@inheritDoc} */ 141 public RootDSEBackendCfgClient createClientConfiguration( 142 ManagedObject<? extends RootDSEBackendCfgClient> impl) { 143 return new RootDSEBackendCfgClientImpl(impl); 144 } 145 146 147 148 /** {@inheritDoc} */ 149 public RootDSEBackendCfg createServerConfiguration( 150 ServerManagedObject<? extends RootDSEBackendCfg> impl) { 151 return new RootDSEBackendCfgServerImpl(impl); 152 } 153 154 155 156 /** {@inheritDoc} */ 157 public Class<RootDSEBackendCfg> getServerConfigurationClass() { 158 return RootDSEBackendCfg.class; 159 } 160 161 162 163 /** 164 * Get the "show-all-attributes" property definition. 165 * <p> 166 * Indicates whether all attributes in the root DSE are to be 167 * treated like user attributes (and therefore returned to clients by 168 * default) regardless of the directory server schema configuration. 169 * 170 * @return Returns the "show-all-attributes" property definition. 171 */ 172 public BooleanPropertyDefinition getShowAllAttributesPropertyDefinition() { 173 return PD_SHOW_ALL_ATTRIBUTES; 174 } 175 176 177 178 /** 179 * Get the "subordinate-base-dn" property definition. 180 * <p> 181 * Specifies the set of base DNs used for singleLevel, wholeSubtree, 182 * and subordinateSubtree searches based at the root DSE. 183 * 184 * @return Returns the "subordinate-base-dn" property definition. 185 */ 186 public DNPropertyDefinition getSubordinateBaseDNPropertyDefinition() { 187 return PD_SUBORDINATE_BASE_DN; 188 } 189 190 191 192 /** 193 * Managed object client implementation. 194 */ 195 private static class RootDSEBackendCfgClientImpl implements 196 RootDSEBackendCfgClient { 197 198 /** Private implementation. */ 199 private ManagedObject<? extends RootDSEBackendCfgClient> impl; 200 201 202 203 /** Private constructor. */ 204 private RootDSEBackendCfgClientImpl( 205 ManagedObject<? extends RootDSEBackendCfgClient> impl) { 206 this.impl = impl; 207 } 208 209 210 211 /** {@inheritDoc} */ 212 public Boolean isShowAllAttributes() { 213 return impl.getPropertyValue(INSTANCE.getShowAllAttributesPropertyDefinition()); 214 } 215 216 217 218 /** {@inheritDoc} */ 219 public void setShowAllAttributes(boolean value) { 220 impl.setPropertyValue(INSTANCE.getShowAllAttributesPropertyDefinition(), value); 221 } 222 223 224 225 /** {@inheritDoc} */ 226 public SortedSet<DN> getSubordinateBaseDN() { 227 return impl.getPropertyValues(INSTANCE.getSubordinateBaseDNPropertyDefinition()); 228 } 229 230 231 232 /** {@inheritDoc} */ 233 public void setSubordinateBaseDN(Collection<DN> values) { 234 impl.setPropertyValues(INSTANCE.getSubordinateBaseDNPropertyDefinition(), values); 235 } 236 237 238 239 /** {@inheritDoc} */ 240 public ManagedObjectDefinition<? extends RootDSEBackendCfgClient, ? extends RootDSEBackendCfg> definition() { 241 return INSTANCE; 242 } 243 244 245 246 /** {@inheritDoc} */ 247 public PropertyProvider properties() { 248 return impl; 249 } 250 251 252 253 /** {@inheritDoc} */ 254 public void commit() throws ManagedObjectAlreadyExistsException, 255 MissingMandatoryPropertiesException, ConcurrentModificationException, 256 OperationRejectedException, LdapException { 257 impl.commit(); 258 } 259 260 261 262 /** {@inheritDoc} */ 263 public String toString() { 264 return impl.toString(); 265 } 266 } 267 268 269 270 /** 271 * Managed object server implementation. 272 */ 273 private static class RootDSEBackendCfgServerImpl implements 274 RootDSEBackendCfg { 275 276 /** Private implementation. */ 277 private ServerManagedObject<? extends RootDSEBackendCfg> impl; 278 279 /** The value of the "show-all-attributes" property. */ 280 private final boolean pShowAllAttributes; 281 282 /** The value of the "subordinate-base-dn" property. */ 283 private final SortedSet<DN> pSubordinateBaseDN; 284 285 286 287 /** Private constructor. */ 288 private RootDSEBackendCfgServerImpl(ServerManagedObject<? extends RootDSEBackendCfg> impl) { 289 this.impl = impl; 290 this.pShowAllAttributes = impl.getPropertyValue(INSTANCE.getShowAllAttributesPropertyDefinition()); 291 this.pSubordinateBaseDN = impl.getPropertyValues(INSTANCE.getSubordinateBaseDNPropertyDefinition()); 292 } 293 294 295 296 /** {@inheritDoc} */ 297 public void addChangeListener( 298 ConfigurationChangeListener<RootDSEBackendCfg> listener) { 299 impl.registerChangeListener(listener); 300 } 301 302 303 304 /** {@inheritDoc} */ 305 public void removeChangeListener( 306 ConfigurationChangeListener<RootDSEBackendCfg> listener) { 307 impl.deregisterChangeListener(listener); 308 } 309 310 311 312 /** {@inheritDoc} */ 313 public boolean isShowAllAttributes() { 314 return pShowAllAttributes; 315 } 316 317 318 319 /** {@inheritDoc} */ 320 public SortedSet<DN> getSubordinateBaseDN() { 321 return pSubordinateBaseDN; 322 } 323 324 325 326 /** {@inheritDoc} */ 327 public Class<? extends RootDSEBackendCfg> configurationClass() { 328 return RootDSEBackendCfg.class; 329 } 330 331 332 333 /** {@inheritDoc} */ 334 public DN dn() { 335 return impl.getDN(); 336 } 337 338 339 340 /** {@inheritDoc} */ 341 public String toString() { 342 return impl.toString(); 343 } 344 } 345}