From 4a41c53f70eaf12d28215a8aee4fef4d02bc5a57 Mon Sep 17 00:00:00 2001
From: jdemendi <jdemendi@localhost>
Date: Wed, 05 Nov 2008 18:08:58 +0000
Subject: [PATCH] additional fix for issue 3560, when network groups are deleted the workflow reference counters are not updated

---
 opends/src/server/org/opends/server/core/networkgroups/NetworkGroup.java |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/networkgroups/NetworkGroup.java b/opends/src/server/org/opends/server/core/networkgroups/NetworkGroup.java
index 59b119f..30ad1c6 100644
--- a/opends/src/server/org/opends/server/core/networkgroups/NetworkGroup.java
+++ b/opends/src/server/org/opends/server/core/networkgroups/NetworkGroup.java
@@ -94,6 +94,7 @@
   private static NetworkGroup adminNetworkGroup =
       new NetworkGroup (ADMIN_NETWORK_GROUP_NAME);
 
+
   // The internal network group (singleton).
   // The internal network group has no criterion, no policy, and gives
   // access to all the workflows. The purpose of the internal network
@@ -214,6 +215,8 @@
 
   /**
    * Deregisters the current network group (this) with the server.
+   * The method also decrements the reference counter of the workflows
+   * so that workflows can be disabled or deleted if needed.
    */
   public void deregister()
   {
@@ -224,6 +227,27 @@
       networkGroups.remove(networkGroupID);
       registeredNetworkGroups = networkGroups;
       orderedNetworkGroups.remove(this);
+
+      // decrement the reference counter of the workflows registered with
+      // this network group
+      updateWorkflowReferenceCounters();
+    }
+  }
+
+
+  /**
+   * Decrements the workflow reference counters of all the workflows
+   * registered with this network group.
+   */
+  private void updateWorkflowReferenceCounters()
+  {
+    synchronized (registeredWorkflowNodesLock)
+    {
+      for (WorkflowTopologyNode workflowNode: registeredWorkflowNodes.values())
+      {
+        WorkflowImpl workflowImpl = workflowNode.getWorkflowImpl();
+        workflowImpl.decrementReferenceCounter();
+      }
     }
   }
 

--
Gitblit v1.10.0