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