Generate notifications when policies change
[policy/pap.git] / main / src / main / java / org / onap / policy / pap / main / comm / PdpModifyRequestMap.java
index 3f0b5c1..f058da3 100644 (file)
@@ -41,6 +41,7 @@ import org.onap.policy.pap.main.comm.msgdata.Request;
 import org.onap.policy.pap.main.comm.msgdata.RequestListener;
 import org.onap.policy.pap.main.comm.msgdata.StateChangeReq;
 import org.onap.policy.pap.main.comm.msgdata.UpdateReq;
+import org.onap.policy.pap.main.notification.PolicyNotifier;
 import org.onap.policy.pap.main.parameters.PdpModifyRequestMapParams;
 import org.onap.policy.pap.main.parameters.RequestParams;
 import org.slf4j.Logger;
@@ -74,6 +75,11 @@ public class PdpModifyRequestMap {
      */
     private final PolicyModelsProviderFactoryWrapper daoFactory;
 
+    /**
+     * Used to notify when policy updates completes.
+     */
+    private final PolicyNotifier policyNotifier;
+
 
     /**
      * Constructs the object.
@@ -88,6 +94,7 @@ public class PdpModifyRequestMap {
         this.params = params;
         this.modifyLock = params.getModifyLock();
         this.daoFactory = params.getDaoFactory();
+        this.policyNotifier = params.getPolicyNotifier();
     }
 
     /**
@@ -150,7 +157,7 @@ public class PdpModifyRequestMap {
             .setMaxRetryCount(params.getParams().getUpdateParameters().getMaxRetryCount())
             .setTimers(params.getUpdateTimers())
             .setModifyLock(params.getModifyLock())
-            .setPublisher(params.getPublisher())
+            .setPdpPublisher(params.getPdpPublisher())
             .setResponseDispatcher(params.getResponseDispatcher());
         // @formatter:on
 
@@ -179,7 +186,7 @@ public class PdpModifyRequestMap {
             .setMaxRetryCount(params.getParams().getStateChangeParameters().getMaxRetryCount())
             .setTimers(params.getStateChangeTimers())
             .setModifyLock(params.getModifyLock())
-            .setPublisher(params.getPublisher())
+            .setPdpPublisher(params.getPdpPublisher())
             .setResponseDispatcher(params.getResponseDispatcher());
         // @formatter:on
 
@@ -299,7 +306,7 @@ public class PdpModifyRequestMap {
      * @return a new set of requests
      */
     protected PdpRequests makePdpRequests(String pdpName) {
-        return new PdpRequests(pdpName);
+        return new PdpRequests(pdpName, policyNotifier);
     }
 
     /**
@@ -359,6 +366,8 @@ public class PdpModifyRequestMap {
          */
         private void disablePdp(PdpRequests requests) {
 
+            policyNotifier.removePdp(requests.getPdpName());
+
             // remove the requests from the map
             if (!pdp2requests.remove(requests.getPdpName(), requests)) {
                 // don't have the info we need to disable it