X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=POLICY-SDK-APP%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fcontroller%2FCreateClosedLoopPMController.java;h=8d47be76c00248d4b99fcff030e283d98953f4b4;hp=1ca027b9c3db7cc1c1b7292431ab2fc202789377;hb=0950d79047d3404c15b4dd30cffeb81346565f64;hpb=f36e53a3637e1204a42491ec0eeed7b3c763f681 diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java index 1ca027b9c..8d47be76c 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java @@ -53,32 +53,28 @@ public class CreateClosedLoopPMController { protected PolicyRestAdapter policyAdapter = null; public void prePopulateClosedLoopPMPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) { - if (policyAdapter.getPolicyData() instanceof PolicyType) { - Object policyData = policyAdapter.getPolicyData(); - PolicyType policy = (PolicyType) policyData; + if (! (policyAdapter.getPolicyData() instanceof PolicyType)) { + return; + } + Object policyData = policyAdapter.getPolicyData(); + PolicyType policy = (PolicyType) policyData; - // Set oldPolicyFileName to PolicyAdapter - policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName()); + // Set oldPolicyFileName to PolicyAdapter + policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName()); - // Set policyNameValue and description to PolicyAdapter - setPolicyAdapterNameValueAndDescription(policyAdapter, policy); + // Set policyNameValue and description to PolicyAdapter + setPolicyAdapterNameValueAndDescription(policyAdapter, policy); - // Set PolicyAdapter JsonBodyData - setClosedLoopJsonFile(policyAdapter, entity); + // Set PolicyAdapter JsonBodyData + setClosedLoopJsonFile(policyAdapter, entity); - // Get the target data under policy. - TargetType target = policy.getTarget(); - if (target == null) { - return; - } - // Under target we have AnyOFType - List anyOfList = target.getAnyOf(); - if (anyOfList == null) { - return; - } - // Set PolicyAdapter OnapNameField, riskType, riskLevel, guard, ttlDate, ServiceType from match attributes - setPolicyAdapterMatchAttributes(policyAdapter, anyOfList); + // Get the target data under policy. + TargetType target = policy.getTarget(); + if (target == null) { + return; } + // Set PolicyAdapter OnapNameField, riskType, riskLevel, guard, ttlDate, ServiceType from match attributes + setPolicyAdapterMatchAttributes(policyAdapter, target.getAnyOf()); } private void setPolicyAdapterNameValueAndDescription(PolicyRestAdapter policyAdapter, PolicyType policy) {