Fix a potential NPE
The code must verify if the policy has been found or not
Change-Id: I41343aec40643c29180c892996e4a65d0805193e
Issue-Id: CLAMP-43
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java
index e7b0be5..2c60941 100644
--- a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java
+++ b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java
@@ -56,13 +56,15 @@
prop.setCurrentModelElementId(policy.getId());
String responseMessage = "";
- for (PolicyChain policyChain : policy.getPolicyChains()) {
- prop.setPolicyUniqueId(policyChain.getPolicyId());
- responseMessage = policyClient.deleteBrms(prop);
- }
- if (responseMessage != null) {
- execution.setVariable("operationalPolicyDeleteResponseMessage", responseMessage.getBytes());
- }
+ if(policy.isFound()){
+ for (PolicyChain policyChain : policy.getPolicyChains()) {
+ prop.setPolicyUniqueId(policyChain.getPolicyId());
+ responseMessage = policyClient.deleteBrms(prop);
+ }
+ if (responseMessage != null) {
+ execution.setVariable("operationalPolicyDeleteResponseMessage", responseMessage.getBytes());
+ }
+ }
}
}