From ab3eab60a0883ffa22eb12e2b8680088c9ad25a1 Mon Sep 17 00:00:00 2001 From: sebdet Date: Thu, 16 Apr 2020 12:09:24 +0200 Subject: Remove policy from PEF when removing op policy The operational policy must be removed from the PEF when the user remove an operational policy (at least attempt to purge the PEF) Issue-ID: CLAMP-824 Signed-off-by: sebdet Change-Id: I442c0890c391d43e8fcbdb89189d6ad2581db3af --- src/main/java/org/onap/clamp/loop/Loop.java | 30 + .../java/org/onap/clamp/loop/LoopController.java | 4 +- src/main/java/org/onap/clamp/loop/LoopService.java | 2 +- .../resources/clds/camel/rest/clamp-api-v2.xml | 18 +- .../resources/clds/camel/routes/policy-flows.xml | 1076 +++++++++++--------- 5 files changed, 616 insertions(+), 514 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/onap/clamp/loop/Loop.java b/src/main/java/org/onap/clamp/loop/Loop.java index 19a17dbb..08133133 100644 --- a/src/main/java/org/onap/clamp/loop/Loop.java +++ b/src/main/java/org/onap/clamp/loop/Loop.java @@ -330,6 +330,36 @@ public class Loop extends AuditEntity implements Serializable { } } + /** + * Return the operationalPolicy object with the opPolicyName. + * + * @param opPolicyName The operationalPolicy name + * @return The OperationalPolicy object found in loop object + */ + public OperationalPolicy getOperationalPolicy(String opPolicyName) { + for (OperationalPolicy operationalPolicy : this.getOperationalPolicies()) { + if (operationalPolicy.getName().equals(opPolicyName)) { + return operationalPolicy; + } + } + return null; + } + + /** + * Return the microServicePolicy object with the msPolicyName. + * + * @param msPolicyName The microServicePolicy name + * @return The MicroServicePolicy object found in loop object + */ + public MicroServicePolicy getMicroServicePolicy(String msPolicyName) { + for (MicroServicePolicy microServicePolicy : this.getMicroServicePolicies()) { + if (microServicePolicy.getName().equals(msPolicyName)) { + return microServicePolicy; + } + } + return null; + } + /** * Generate the loop name. * diff --git a/src/main/java/org/onap/clamp/loop/LoopController.java b/src/main/java/org/onap/clamp/loop/LoopController.java index a2a44631..fad93bc7 100644 --- a/src/main/java/org/onap/clamp/loop/LoopController.java +++ b/src/main/java/org/onap/clamp/loop/LoopController.java @@ -137,11 +137,11 @@ public class LoopController { } /** - * This method remove an operational policy to a loop instance. + * This method removes an operational policy from a loop instance. * * @param loopName The loop name * @param policyType The policy model type - * @param policyVersion The policy model version + * @param policyVersion The policy model version * @return The loop modified */ public Loop removeOperationalPolicy(String loopName, String policyType, String policyVersion) { diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java index 6658c5a3..ca3681b6 100644 --- a/src/main/java/org/onap/clamp/loop/LoopService.java +++ b/src/main/java/org/onap/clamp/loop/LoopService.java @@ -131,7 +131,7 @@ public class LoopService { * * @param loopName The loop name * @param policyType The policy model type - * @param policyVersion The policy model version + * @param policyVersion The policy model version * @return The loop modified */ Loop removeOperationalPolicy(String loopName, String policyType, String policyVersion) { diff --git a/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/src/main/resources/clds/camel/rest/clamp-api-v2.xml index 77062675..fc7dbd49 100644 --- a/src/main/resources/clds/camel/rest/clamp-api-v2.xml +++ b/src/main/resources/clds/camel/rest/clamp-api-v2.xml @@ -770,15 +770,29 @@ - + - + + + ${header.policyName} + + + ${exchangeProperty[loopObject].getOperationalPolicy(header.policyName)} + + + false + + + + false + + - - - - false - - - - ${header.CamelHttpResponseCode} != 200 - - false - - - - - false - - - - ${header.CamelHttpResponseCode} != 200 - - false - - - - - ${exchangeProperty[policyComponent].computeState(*)} - - + + + + false + + + + ${header.CamelHttpResponseCode} != 200 + + false + + + + + false + + + + ${header.CamelHttpResponseCode} != 200 + + false + + + + + ${exchangeProperty[policyComponent].computeState(*)} + + - - - - - - - GET - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[policyName]} GET - Policy status - - - - POLICY - - - - - + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[policyName]} GET + Policy status + + + + POLICY + + + + + - - - - - - - GET - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[policyName]} GET Policy deployment - status - - - - POLICY - - - - - - - - - - - - GET - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - - - - - - - - - - GET - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - - - - - - - - - - ${exchangeProperty[policy].createPolicyPayload()} - - - - POST - - - application/json - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[policy].getName()} creation - status - - - - POLICY - - - - - + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[policyName]} GET Policy deployment + status + + + + POLICY + + + + + + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + + + + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + + + + + + + + + + ${exchangeProperty[policy].createPolicyPayload()} + + + + POST + + + application/json + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[policy].getName()} creation + status + + + + POLICY + + + + + - - - - - - - null - - - DELETE - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - ${exchangeProperty[policy].isLegacy()} == true - - 1 - - - - - 1.0.0 - - - - - + + + + + + + null + + + DELETE + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + ${exchangeProperty[policy].isLegacy()} == true + + 1 + + + + + 1.0.0 + + + + + - - - - - ${exchangeProperty[policy].getName()} removal - status - - - - POLICY - - - - - - - - - - - - ${exchangeProperty[guardPolicy].getValue()} - - - - POST - - - application/json - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[guardPolicy].getKey()} creation status - - - - POLICY - - - - - + + + + + ${exchangeProperty[policy].getName()} removal + status + + + + POLICY + + + + + + + + + + + + ${exchangeProperty[guardPolicy].getValue()} + + + + POST + + + application/json + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[guardPolicy].getKey()} creation status + + + + POLICY + + + + + - - - - - - - null - - - DELETE - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - + + + + + + + null + + + DELETE + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + - - - - - ${exchangeProperty[guardPolicy].getKey()} removal status - - - - POLICY - - - - - + + + + + ${exchangeProperty[guardPolicy].getKey()} removal status + + + + POLICY + + + + + - - - - - - - ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject],"POST")} - - - - POST - - - application/json - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - + + + + + + + + ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject],"POST")} + + + + POST + + + application/json + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + - - - - - PDP Group push ALL status - - - POLICY - - - - - + + + + + PDP Group push ALL status + + + POLICY + + + + + - - - - - - - ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject],"DELETE")} - - - - POST - - - application/json - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - + + + + + + + + ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject],"DELETE")} + + + + POST + + + application/json + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + - - - - - PDP Group remove ALL status - - - POLICY - - - - - - - - - - - - GET - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - - - + + + + + PDP Group remove ALL status + + + POLICY + + + + + + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + + + + + + + + + + null + + + DELETE + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + ${exchangeProperty[policyName]} PDP Group removal status + + + + POLICY + + + + java.lang.Exception + + false + + + PDP Group removal, Error reported: ${exception} + + + POLICY + + + + + + + + + \ No newline at end of file -- cgit 1.2.3-korg