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