Set "source" name in PAP PdpMessages
[policy/pap.git] / main / src / main / java / org / onap / policy / pap / main / rest / ProviderBase.java
index 7f013ac..4cc5a44 100644 (file)
@@ -23,7 +23,6 @@
 package org.onap.policy.pap.main.rest;
 
 import java.util.Collection;
-import java.util.stream.Collectors;
 import javax.ws.rs.core.Response.Status;
 import org.onap.policy.common.utils.services.Registry;
 import org.onap.policy.models.base.PfModelException;
@@ -74,7 +73,6 @@ public abstract class ProviderBase {
      */
     private final PolicyModelsProviderFactoryWrapper daoFactory;
 
-
     /**
      * Constructs the object.
      */
@@ -96,7 +94,7 @@ public abstract class ProviderBase {
 
         synchronized (updateLock) {
             SessionData data;
-            PolicyNotification notif = new PolicyNotification();
+            var notif = new PolicyNotification();
 
             try (PolicyModelsProvider dao = daoFactory.create()) {
 
@@ -139,7 +137,7 @@ public abstract class ProviderBase {
                             + desiredPolicy.getName() + " " + desiredPolicy.getVersion());
         }
 
-        Updater updater = makeUpdater(data, policy, desiredPolicy);
+        var updater = makeUpdater(data, policy, desiredPolicy);
 
         for (PdpGroup group : groups) {
             upgradeGroup(data, group, updater);
@@ -182,9 +180,10 @@ public abstract class ProviderBase {
      * @param updater function to update a group
      * @throws PfModelException if an error occurred
      */
-    private void upgradeGroup(SessionData data, PdpGroup group, Updater updater) throws PfModelException {
+    private void upgradeGroup(SessionData data, PdpGroup group, Updater updater)
+                    throws PfModelException {
 
-        boolean updated = false;
+        var updated = false;
 
         for (PdpSubGroup subgroup : group.getPdpSubgroups()) {
 
@@ -197,7 +196,6 @@ public abstract class ProviderBase {
             makeUpdates(data, group, subgroup);
         }
 
-
         if (updated) {
             // something changed
             data.update(group);
@@ -228,14 +226,15 @@ public abstract class ProviderBase {
      */
     private PdpUpdate makeUpdate(SessionData data, PdpGroup group, PdpSubGroup subgroup, Pdp pdp) {
 
-        PdpUpdate update = new PdpUpdate();
+        var update = new PdpUpdate();
 
+        update.setSource(PapConstants.PAP_NAME);
         update.setName(pdp.getInstanceId());
         update.setDescription(group.getDescription());
         update.setPdpGroup(group.getName());
         update.setPdpSubgroup(subgroup.getPdpType());
-        update.setPolicies(subgroup.getPolicies().stream().map(ToscaConceptIdentifierOptVersion::new)
-                        .map(ident -> getPolicy(data, ident)).collect(Collectors.toList()));
+        update.setPoliciesToBeDeployed(data.getPoliciesToBeDeployed());
+        update.setPoliciesToBeUndeployed(data.getPoliciesToBeUndeployed());
 
         return update;
     }