From 7d9f9ebbdd79002266e85efa0f7f19aeb7339e9b Mon Sep 17 00:00:00 2001
From: jdemendi <jdemendi@localhost>
Date: Fri, 31 Oct 2008 11:12:52 +0000
Subject: [PATCH] fix 35353, Workflows are not notified when their root workflow elements are disabled
---
opendj-sdk/opends/src/server/org/opends/server/workflowelement/WorkflowElementConfigManager.java | 52 +++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 39 insertions(+), 13 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/workflowelement/WorkflowElementConfigManager.java b/opendj-sdk/opends/src/server/org/opends/server/workflowelement/WorkflowElementConfigManager.java
index 2d43211..95e62bd 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/workflowelement/WorkflowElementConfigManager.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/workflowelement/WorkflowElementConfigManager.java
@@ -121,7 +121,7 @@
* @throws org.opends.server.types.InitializationException Exception while
* initializing the workflow element
*/
- public WorkflowElement loadAndRegisterWorkflowElement(String workflowName)
+ public WorkflowElement<?> loadAndRegisterWorkflowElement(String workflowName)
throws ConfigException, InitializationException {
ServerManagementContext managementContext =
ServerManagementContext.getInstance();
@@ -188,7 +188,11 @@
{
try
{
- loadAndRegisterWorkflowElement(configuration);
+ WorkflowElement<?> we = loadAndRegisterWorkflowElement(configuration);
+
+ // Notify observers who want to be notify when new workflow elements
+ // are created.
+ WorkflowElement.notifyStateUpdate(we);
}
catch (InitializationException de)
{
@@ -214,7 +218,7 @@
List<Message> unacceptableReasons)
{
// FIXME -- We should try to perform some check to determine whether the
- // worklfow element is in use.
+ // workflow element is in use.
return true;
}
@@ -232,11 +236,18 @@
);
- WorkflowElement workflowElement =
+ WorkflowElement<?> workflowElement =
DirectoryServer.getWorkflowElement(
configuration.getWorkflowElementId());
if (workflowElement != null)
{
+ // Notify to observers that the workflow element is now disabled
+ ObservableWorkflowElementState observableState =
+ workflowElement.getObservableState();
+ observableState.setWorkflowElementEnabled(false);
+ observableState.notifyObservers();
+
+ // Remove the workflow element
DirectoryServer.deregisterWorkflowElement(workflowElement);
workflowElement.finalizeWorkflowElement();
}
@@ -291,9 +302,8 @@
// Get the existing workflow element if it's already enabled.
- WorkflowElement existingWorkflowElement =
- DirectoryServer.getWorkflowElement(
- configuration.getWorkflowElementId());
+ WorkflowElement<?> existingWorkflowElement =
+ DirectoryServer.getWorkflowElement(configuration.getWorkflowElementId());
// If the new configuration has the workflow element disabled,
// then disable it if it is enabled, or do nothing if it's already disabled.
@@ -301,6 +311,13 @@
{
if (existingWorkflowElement != null)
{
+ // Notify to observers that the workflow element is now disabled
+ ObservableWorkflowElementState observableState =
+ existingWorkflowElement.getObservableState();
+ observableState.setWorkflowElementEnabled(false);
+ observableState.notifyObservers();
+
+ // Remove the workflow element
DirectoryServer.deregisterWorkflowElement(existingWorkflowElement);
existingWorkflowElement.finalizeWorkflowElement();
}
@@ -313,7 +330,11 @@
{
try
{
- loadAndRegisterWorkflowElement(configuration);
+ WorkflowElement<?> we = loadAndRegisterWorkflowElement(configuration);
+
+ // Notify observers who want to be notify when new workflow elements
+ // are created.
+ WorkflowElement.notifyStateUpdate(we);
}
catch (InitializationException de)
{
@@ -343,13 +364,13 @@
* ID of an existing workflow during workflow
* registration.
*/
- WorkflowElement loadAndRegisterWorkflowElement(
+ WorkflowElement<?> loadAndRegisterWorkflowElement(
WorkflowElementCfg workflowElementCfg
) throws InitializationException
{
// Load the workflow element class
String className = workflowElementCfg.getJavaClass();
- WorkflowElement workflowElement =
+ WorkflowElement<?> workflowElement =
loadWorkflowElement(className, workflowElementCfg, true);
try
@@ -381,7 +402,7 @@
* @throws InitializationException If a problem occurred while attempting
* to initialize the workflow element.
*/
- private WorkflowElement loadWorkflowElement(
+ private WorkflowElement<?> loadWorkflowElement(
String className,
WorkflowElementCfg configuration,
boolean initialize
@@ -391,15 +412,20 @@
{
WorkflowElementCfgDefn definition;
ClassPropertyDefinition propertyDefinition;
+ // I cannot use the parameterized type WorflowElement<?>
+ // because it would break the line WorkflowElement.class below.
+ // Use SuppressWarning because we know the cast is safe.
+ @SuppressWarnings("unchecked")
Class<? extends WorkflowElement> workflowElementClass;
- WorkflowElement<? extends WorkflowElementCfg> workflowElement;
definition = WorkflowElementCfgDefn.getInstance();
propertyDefinition =
definition.getJavaClassPropertyDefinition();
workflowElementClass =
propertyDefinition.loadClass(className, WorkflowElement.class);
- workflowElement =
+ // Again, use SuppressWarning because we know the cast is safe
+ @SuppressWarnings("unchecked")
+ WorkflowElement<? extends WorkflowElementCfg> workflowElement =
(WorkflowElement<? extends WorkflowElementCfg>)
workflowElementClass.newInstance();
--
Gitblit v1.10.0