aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java b/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java
index 44ee52262..d47bc9644 100644
--- a/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java
+++ b/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java
@@ -35,6 +35,7 @@ import java.util.List;
import javax.persistence.Transient;
import org.apache.camel.Exchange;
+import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.loop.Loop;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
import org.onap.clamp.policy.operational.OperationalPolicy;
@@ -81,18 +82,44 @@ public class PolicyComponent extends ExternalComponent {
public static String createPoliciesPayloadPdpGroup(Loop loop) {
JsonObject jsonObject = new JsonObject();
JsonArray jsonArray = new JsonArray();
- jsonObject.add("policies", jsonArray);
+ jsonObject.add("groups", jsonArray);
- for (String policyName : PolicyComponent.listPolicyNamesPdpGroup(loop)) {
- JsonObject policyNode = new JsonObject();
- jsonArray.add(policyNode);
- policyNode.addProperty("policy-id", policyName);
+ for (OperationalPolicy opPolicy : loop.getOperationalPolicies()) {
+ jsonArray.add(createPdpDeploymentPayload(opPolicy.getPdpGroup(), opPolicy.getPdpSubGroup(),
+ opPolicy.getPolicyModel().getPolicyModelType(), opPolicy.getPolicyModel().getVersion()));
+ }
+
+ for (MicroServicePolicy msPolicy : loop.getMicroServicePolicies()) {
+ jsonArray.add(createPdpDeploymentPayload(msPolicy.getPdpGroup(), msPolicy.getPdpSubGroup(),
+ msPolicy.getPolicyModel().getPolicyModelType(), msPolicy.getPolicyModel().getVersion()));
}
+
String payload = new GsonBuilder().setPrettyPrinting().create().toJson(jsonObject);
logger.info("PdpGroup policy payload: " + payload);
return new GsonBuilder().setPrettyPrinting().create().toJson(jsonObject);
}
+ private static JsonObject createPdpDeploymentPayload(String pdpGroup, String pdpSubGroup,
+ String policyType, String version) {
+ JsonObject pdpGroupNode = new JsonObject();
+ JsonArray subPdpArray = new JsonArray();
+ pdpGroupNode.addProperty("name", pdpGroup);
+ pdpGroupNode.add("deploymentSubgroups", subPdpArray);
+
+ JsonObject pdpSubGroupNode = new JsonObject();
+ subPdpArray.add(pdpSubGroupNode);
+ pdpSubGroupNode.addProperty("pdpType", pdpSubGroup);
+ pdpSubGroupNode.addProperty("action", "POST");
+
+ JsonArray policyArray = new JsonArray();
+ pdpSubGroupNode.add("policies", policyArray);
+ JsonObject policyNode = new JsonObject();
+ policyNode.addProperty("name", policyType);
+ policyNode.addProperty("version", version);
+ policyArray.add(policyNode);
+ return pdpGroupNode;
+ }
+
/**
* Generates the list of policy names that must be send/remove to/from active
* PDP group.