diff options
author | liamfallon <liam.fallon@est.tech> | 2019-05-14 13:20:01 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2019-05-14 13:20:01 +0000 |
commit | cee63084a9ebe9f91dc7afa490d18572448e6668 (patch) | |
tree | 0c8667418a6795f2f4de03ab59d6ef2adc4496d8 /models-tosca/src/main | |
parent | 338933f534afef90fdd16bc12a389e2099c94ef5 (diff) |
Remove sonar issue in simple provider
Issue-ID: POLICY-1738
Change-Id: Id85d710154727c7c535db7cc50af88f52114a358
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-tosca/src/main')
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java index 761a47c9a..47e0b67a3 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java @@ -288,7 +288,10 @@ public class SimpleToscaProvider { if (PfKey.NULL_KEY_VERSION.equals(policyTypeKey.getVersion())) { policyType = getLatestPolicyTypeVersion(dao, policyTypeKey.getName()); - policy.getType().setVersion(policyType.getKey().getVersion()); + + if (policyType != null) { + policy.getType().setVersion(policyType.getKey().getVersion()); + } } else { policyType = dao.get(JpaToscaPolicyType.class, policyTypeKey); } @@ -310,8 +313,7 @@ public class SimpleToscaProvider { */ private JpaToscaPolicyType getLatestPolicyTypeVersion(final PfDao dao, final String policyTypeName) { // Policy type version is not specified, get the latest version from the database - List<JpaToscaPolicyType> jpaPolicyTypeList = - dao.getFiltered(JpaToscaPolicyType.class, policyTypeName, null); + List<JpaToscaPolicyType> jpaPolicyTypeList = dao.getFiltered(JpaToscaPolicyType.class, policyTypeName, null); if (jpaPolicyTypeList.isEmpty()) { return null; @@ -325,9 +327,8 @@ public class SimpleToscaProvider { List<PfConcept> filterdPolicyTypeList = pfConceptFilter.filter(policyTypeKeyList); // We should have one and only one returned entry - if (filterdPolicyTypeList.size() != 1 ) { - String errorMessage = - "search for lates policy type " + policyTypeName + " returned more than one entry"; + if (filterdPolicyTypeList.size() != 1) { + String errorMessage = "search for lates policy type " + policyTypeName + " returned more than one entry"; LOGGER.warn(errorMessage); throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage); } |