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