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