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 org.opends.server.admin.AdministratorAction; 032 import org.opends.server.admin.BooleanPropertyDefinition; 033 import org.opends.server.admin.ClassPropertyDefinition; 034 import org.opends.server.admin.client.AuthorizationException; 035 import org.opends.server.admin.client.CommunicationException; 036 import org.opends.server.admin.client.ConcurrentModificationException; 037 import org.opends.server.admin.client.ManagedObject; 038 import org.opends.server.admin.client.MissingMandatoryPropertiesException; 039 import org.opends.server.admin.client.OperationRejectedException; 040 import org.opends.server.admin.ManagedObjectAlreadyExistsException; 041 import org.opends.server.admin.ManagedObjectDefinition; 042 import org.opends.server.admin.PropertyIsReadOnlyException; 043 import org.opends.server.admin.PropertyOption; 044 import org.opends.server.admin.PropertyProvider; 045 import org.opends.server.admin.server.ConfigurationChangeListener; 046 import org.opends.server.admin.server.ServerManagedObject; 047 import org.opends.server.admin.std.client.WorkflowElementCfgClient; 048 import org.opends.server.admin.std.server.WorkflowElementCfg; 049 import org.opends.server.admin.StringPropertyDefinition; 050 import org.opends.server.admin.Tag; 051 import org.opends.server.admin.TopCfgDefn; 052 import org.opends.server.admin.UndefinedDefaultBehaviorProvider; 053 import org.opends.server.types.DN; 054 055 056 057 /** 058 * An interface for querying the Workflow Element managed object 059 * definition meta information. 060 * <p> 061 * Workflow Elements implement a single processing step in a Work 062 * Flow. 063 */ 064 public final class WorkflowElementCfgDefn extends ManagedObjectDefinition<WorkflowElementCfgClient, WorkflowElementCfg> { 065 066 // The singleton configuration definition instance. 067 private static final WorkflowElementCfgDefn INSTANCE = new WorkflowElementCfgDefn(); 068 069 070 071 // The "enabled" property definition. 072 private static final BooleanPropertyDefinition PD_ENABLED; 073 074 075 076 // The "java-class" property definition. 077 private static final ClassPropertyDefinition PD_JAVA_CLASS; 078 079 080 081 // The "workflow-element-id" property definition. 082 private static final StringPropertyDefinition PD_WORKFLOW_ELEMENT_ID; 083 084 085 086 // Build the "enabled" property definition. 087 static { 088 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "enabled"); 089 builder.setOption(PropertyOption.MANDATORY); 090 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "enabled")); 091 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<Boolean>()); 092 PD_ENABLED = builder.getInstance(); 093 INSTANCE.registerPropertyDefinition(PD_ENABLED); 094 } 095 096 097 098 // Build the "java-class" property definition. 099 static { 100 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 101 builder.setOption(PropertyOption.MANDATORY); 102 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class")); 103 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 104 builder.addInstanceOf("org.opends.server.workflowelement.WorkflowElement"); 105 PD_JAVA_CLASS = builder.getInstance(); 106 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 107 } 108 109 110 111 // Build the "workflow-element-id" property definition. 112 static { 113 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "workflow-element-id"); 114 builder.setOption(PropertyOption.READ_ONLY); 115 builder.setOption(PropertyOption.MANDATORY); 116 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "workflow-element-id")); 117 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 118 PD_WORKFLOW_ELEMENT_ID = builder.getInstance(); 119 INSTANCE.registerPropertyDefinition(PD_WORKFLOW_ELEMENT_ID); 120 } 121 122 123 124 // Register the tags associated with this managed object definition. 125 static { 126 INSTANCE.registerTag(Tag.valueOf("core-server")); 127 } 128 129 130 131 /** 132 * Get the Workflow Element configuration definition singleton. 133 * 134 * @return Returns the Workflow Element configuration definition 135 * singleton. 136 */ 137 public static WorkflowElementCfgDefn getInstance() { 138 return INSTANCE; 139 } 140 141 142 143 /** 144 * Private constructor. 145 */ 146 private WorkflowElementCfgDefn() { 147 super("workflow-element", TopCfgDefn.getInstance()); 148 } 149 150 151 152 /** 153 * {@inheritDoc} 154 */ 155 public WorkflowElementCfgClient createClientConfiguration( 156 ManagedObject<? extends WorkflowElementCfgClient> impl) { 157 return new WorkflowElementCfgClientImpl(impl); 158 } 159 160 161 162 /** 163 * {@inheritDoc} 164 */ 165 public WorkflowElementCfg createServerConfiguration( 166 ServerManagedObject<? extends WorkflowElementCfg> impl) { 167 return new WorkflowElementCfgServerImpl(impl); 168 } 169 170 171 172 /** 173 * {@inheritDoc} 174 */ 175 public Class<WorkflowElementCfg> getServerConfigurationClass() { 176 return WorkflowElementCfg.class; 177 } 178 179 180 181 /** 182 * Get the "enabled" property definition. 183 * <p> 184 * Indicates whether the Workflow Element is enabled for use in the 185 * server. 186 * <p> 187 * If a Workflow Element is not enabled, then its contents are not 188 * accessible when processing operations. 189 * 190 * @return Returns the "enabled" property definition. 191 */ 192 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 193 return PD_ENABLED; 194 } 195 196 197 198 /** 199 * Get the "java-class" property definition. 200 * <p> 201 * Specifies the fully-qualified name of the Java class that 202 * provides the Workflow Element implementation. 203 * 204 * @return Returns the "java-class" property definition. 205 */ 206 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 207 return PD_JAVA_CLASS; 208 } 209 210 211 212 /** 213 * Get the "workflow-element-id" property definition. 214 * <p> 215 * Provides a name that identifies the associated Workflow Element . 216 * <p> 217 * The name must be unique among all Workflow Elements in the 218 * server. 219 * 220 * @return Returns the "workflow-element-id" property definition. 221 */ 222 public StringPropertyDefinition getWorkflowElementIdPropertyDefinition() { 223 return PD_WORKFLOW_ELEMENT_ID; 224 } 225 226 227 228 /** 229 * Managed object client implementation. 230 */ 231 private static class WorkflowElementCfgClientImpl implements 232 WorkflowElementCfgClient { 233 234 // Private implementation. 235 private ManagedObject<? extends WorkflowElementCfgClient> impl; 236 237 238 239 // Private constructor. 240 private WorkflowElementCfgClientImpl( 241 ManagedObject<? extends WorkflowElementCfgClient> impl) { 242 this.impl = impl; 243 } 244 245 246 247 /** 248 * {@inheritDoc} 249 */ 250 public Boolean isEnabled() { 251 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 252 } 253 254 255 256 /** 257 * {@inheritDoc} 258 */ 259 public void setEnabled(boolean value) { 260 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 261 } 262 263 264 265 /** 266 * {@inheritDoc} 267 */ 268 public String getJavaClass() { 269 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 270 } 271 272 273 274 /** 275 * {@inheritDoc} 276 */ 277 public void setJavaClass(String value) { 278 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 279 } 280 281 282 283 /** 284 * {@inheritDoc} 285 */ 286 public String getWorkflowElementId() { 287 return impl.getPropertyValue(INSTANCE.getWorkflowElementIdPropertyDefinition()); 288 } 289 290 291 292 /** 293 * {@inheritDoc} 294 */ 295 public void setWorkflowElementId(String value) throws PropertyIsReadOnlyException { 296 impl.setPropertyValue(INSTANCE.getWorkflowElementIdPropertyDefinition(), value); 297 } 298 299 300 301 /** 302 * {@inheritDoc} 303 */ 304 public ManagedObjectDefinition<? extends WorkflowElementCfgClient, ? extends WorkflowElementCfg> definition() { 305 return INSTANCE; 306 } 307 308 309 310 /** 311 * {@inheritDoc} 312 */ 313 public PropertyProvider properties() { 314 return impl; 315 } 316 317 318 319 /** 320 * {@inheritDoc} 321 */ 322 public void commit() throws ManagedObjectAlreadyExistsException, 323 MissingMandatoryPropertiesException, ConcurrentModificationException, 324 OperationRejectedException, AuthorizationException, 325 CommunicationException { 326 impl.commit(); 327 } 328 329 } 330 331 332 333 /** 334 * Managed object server implementation. 335 */ 336 private static class WorkflowElementCfgServerImpl implements 337 WorkflowElementCfg { 338 339 // Private implementation. 340 private ServerManagedObject<? extends WorkflowElementCfg> impl; 341 342 // The value of the "enabled" property. 343 private final boolean pEnabled; 344 345 // The value of the "java-class" property. 346 private final String pJavaClass; 347 348 // The value of the "workflow-element-id" property. 349 private final String pWorkflowElementId; 350 351 352 353 // Private constructor. 354 private WorkflowElementCfgServerImpl(ServerManagedObject<? extends WorkflowElementCfg> impl) { 355 this.impl = impl; 356 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 357 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 358 this.pWorkflowElementId = impl.getPropertyValue(INSTANCE.getWorkflowElementIdPropertyDefinition()); 359 } 360 361 362 363 /** 364 * {@inheritDoc} 365 */ 366 public void addChangeListener( 367 ConfigurationChangeListener<WorkflowElementCfg> listener) { 368 impl.registerChangeListener(listener); 369 } 370 371 372 373 /** 374 * {@inheritDoc} 375 */ 376 public void removeChangeListener( 377 ConfigurationChangeListener<WorkflowElementCfg> listener) { 378 impl.deregisterChangeListener(listener); 379 } 380 381 382 383 /** 384 * {@inheritDoc} 385 */ 386 public boolean isEnabled() { 387 return pEnabled; 388 } 389 390 391 392 /** 393 * {@inheritDoc} 394 */ 395 public String getJavaClass() { 396 return pJavaClass; 397 } 398 399 400 401 /** 402 * {@inheritDoc} 403 */ 404 public String getWorkflowElementId() { 405 return pWorkflowElementId; 406 } 407 408 409 410 /** 411 * {@inheritDoc} 412 */ 413 public Class<? extends WorkflowElementCfg> configurationClass() { 414 return WorkflowElementCfg.class; 415 } 416 417 418 419 /** 420 * {@inheritDoc} 421 */ 422 public DN dn() { 423 return impl.getDN(); 424 } 425 426 } 427 }