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.opends.server.admin.std.meta; 027 028 029 030import org.opends.server.admin.AdministratorAction; 031import org.opends.server.admin.BooleanPropertyDefinition; 032import org.opends.server.admin.ClassPropertyDefinition; 033import org.opends.server.admin.client.AuthorizationException; 034import org.opends.server.admin.client.CommunicationException; 035import org.opends.server.admin.client.ConcurrentModificationException; 036import org.opends.server.admin.client.ManagedObject; 037import org.opends.server.admin.client.MissingMandatoryPropertiesException; 038import org.opends.server.admin.client.OperationRejectedException; 039import org.opends.server.admin.ManagedObjectAlreadyExistsException; 040import org.opends.server.admin.ManagedObjectDefinition; 041import org.opends.server.admin.PropertyOption; 042import org.opends.server.admin.PropertyProvider; 043import org.opends.server.admin.server.ConfigurationChangeListener; 044import org.opends.server.admin.server.ServerManagedObject; 045import org.opends.server.admin.std.client.GroupImplementationCfgClient; 046import org.opends.server.admin.std.server.GroupImplementationCfg; 047import org.opends.server.admin.Tag; 048import org.opends.server.admin.TopCfgDefn; 049import org.opends.server.admin.UndefinedDefaultBehaviorProvider; 050import org.opends.server.types.DN; 051 052 053 054/** 055 * An interface for querying the Group Implementation managed object 056 * definition meta information. 057 * <p> 058 * Group Implementations define named collections of users. 059 */ 060public final class GroupImplementationCfgDefn extends ManagedObjectDefinition<GroupImplementationCfgClient, GroupImplementationCfg> { 061 062 // The singleton configuration definition instance. 063 private static final GroupImplementationCfgDefn INSTANCE = new GroupImplementationCfgDefn(); 064 065 066 067 // The "enabled" property definition. 068 private static final BooleanPropertyDefinition PD_ENABLED; 069 070 071 072 // The "java-class" property definition. 073 private static final ClassPropertyDefinition PD_JAVA_CLASS; 074 075 076 077 // Build the "enabled" property definition. 078 static { 079 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "enabled"); 080 builder.setOption(PropertyOption.MANDATORY); 081 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "enabled")); 082 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<Boolean>()); 083 PD_ENABLED = builder.getInstance(); 084 INSTANCE.registerPropertyDefinition(PD_ENABLED); 085 } 086 087 088 089 // Build the "java-class" property definition. 090 static { 091 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 092 builder.setOption(PropertyOption.MANDATORY); 093 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class")); 094 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 095 builder.addInstanceOf("org.opends.server.api.Group"); 096 PD_JAVA_CLASS = builder.getInstance(); 097 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 098 } 099 100 101 102 // Register the tags associated with this managed object definition. 103 static { 104 INSTANCE.registerTag(Tag.valueOf("core-server")); 105 } 106 107 108 109 /** 110 * Get the Group Implementation configuration definition singleton. 111 * 112 * @return Returns the Group Implementation configuration definition 113 * singleton. 114 */ 115 public static GroupImplementationCfgDefn getInstance() { 116 return INSTANCE; 117 } 118 119 120 121 /** 122 * Private constructor. 123 */ 124 private GroupImplementationCfgDefn() { 125 super("group-implementation", TopCfgDefn.getInstance()); 126 } 127 128 129 130 /** 131 * {@inheritDoc} 132 */ 133 public GroupImplementationCfgClient createClientConfiguration( 134 ManagedObject<? extends GroupImplementationCfgClient> impl) { 135 return new GroupImplementationCfgClientImpl(impl); 136 } 137 138 139 140 /** 141 * {@inheritDoc} 142 */ 143 public GroupImplementationCfg createServerConfiguration( 144 ServerManagedObject<? extends GroupImplementationCfg> impl) { 145 return new GroupImplementationCfgServerImpl(impl); 146 } 147 148 149 150 /** 151 * {@inheritDoc} 152 */ 153 public Class<GroupImplementationCfg> getServerConfigurationClass() { 154 return GroupImplementationCfg.class; 155 } 156 157 158 159 /** 160 * Get the "enabled" property definition. 161 * <p> 162 * Indicates whether the Group Implementation is enabled. 163 * 164 * @return Returns the "enabled" property definition. 165 */ 166 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 167 return PD_ENABLED; 168 } 169 170 171 172 /** 173 * Get the "java-class" property definition. 174 * <p> 175 * Specifies the fully-qualified name of the Java class that 176 * provides the Group Implementation implementation. 177 * 178 * @return Returns the "java-class" property definition. 179 */ 180 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 181 return PD_JAVA_CLASS; 182 } 183 184 185 186 /** 187 * Managed object client implementation. 188 */ 189 private static class GroupImplementationCfgClientImpl implements 190 GroupImplementationCfgClient { 191 192 // Private implementation. 193 private ManagedObject<? extends GroupImplementationCfgClient> impl; 194 195 196 197 // Private constructor. 198 private GroupImplementationCfgClientImpl( 199 ManagedObject<? extends GroupImplementationCfgClient> impl) { 200 this.impl = impl; 201 } 202 203 204 205 /** 206 * {@inheritDoc} 207 */ 208 public Boolean isEnabled() { 209 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 210 } 211 212 213 214 /** 215 * {@inheritDoc} 216 */ 217 public void setEnabled(boolean value) { 218 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 219 } 220 221 222 223 /** 224 * {@inheritDoc} 225 */ 226 public String getJavaClass() { 227 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 228 } 229 230 231 232 /** 233 * {@inheritDoc} 234 */ 235 public void setJavaClass(String value) { 236 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 237 } 238 239 240 241 /** 242 * {@inheritDoc} 243 */ 244 public ManagedObjectDefinition<? extends GroupImplementationCfgClient, ? extends GroupImplementationCfg> definition() { 245 return INSTANCE; 246 } 247 248 249 250 /** 251 * {@inheritDoc} 252 */ 253 public PropertyProvider properties() { 254 return impl; 255 } 256 257 258 259 /** 260 * {@inheritDoc} 261 */ 262 public void commit() throws ManagedObjectAlreadyExistsException, 263 MissingMandatoryPropertiesException, ConcurrentModificationException, 264 OperationRejectedException, AuthorizationException, 265 CommunicationException { 266 impl.commit(); 267 } 268 269 270 271 /** {@inheritDoc} */ 272 public String toString() { 273 return impl.toString(); 274 } 275 } 276 277 278 279 /** 280 * Managed object server implementation. 281 */ 282 private static class GroupImplementationCfgServerImpl implements 283 GroupImplementationCfg { 284 285 // Private implementation. 286 private ServerManagedObject<? extends GroupImplementationCfg> impl; 287 288 // The value of the "enabled" property. 289 private final boolean pEnabled; 290 291 // The value of the "java-class" property. 292 private final String pJavaClass; 293 294 295 296 // Private constructor. 297 private GroupImplementationCfgServerImpl(ServerManagedObject<? extends GroupImplementationCfg> impl) { 298 this.impl = impl; 299 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 300 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 301 } 302 303 304 305 /** 306 * {@inheritDoc} 307 */ 308 public void addChangeListener( 309 ConfigurationChangeListener<GroupImplementationCfg> listener) { 310 impl.registerChangeListener(listener); 311 } 312 313 314 315 /** 316 * {@inheritDoc} 317 */ 318 public void removeChangeListener( 319 ConfigurationChangeListener<GroupImplementationCfg> listener) { 320 impl.deregisterChangeListener(listener); 321 } 322 323 324 325 /** 326 * {@inheritDoc} 327 */ 328 public boolean isEnabled() { 329 return pEnabled; 330 } 331 332 333 334 /** 335 * {@inheritDoc} 336 */ 337 public String getJavaClass() { 338 return pJavaClass; 339 } 340 341 342 343 /** 344 * {@inheritDoc} 345 */ 346 public Class<? extends GroupImplementationCfg> configurationClass() { 347 return GroupImplementationCfg.class; 348 } 349 350 351 352 /** 353 * {@inheritDoc} 354 */ 355 public DN dn() { 356 return impl.getDN(); 357 } 358 359 360 361 /** {@inheritDoc} */ 362 public String toString() { 363 return impl.toString(); 364 } 365 } 366}