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