diff options
author | brunomilitzer <bruno.militzer@est.tech> | 2021-09-30 17:36:44 +0100 |
---|---|---|
committer | brunomilitzer <bruno.militzer@est.tech> | 2021-10-06 13:21:36 +0100 |
commit | b4f25510c8e71554cbbecf1cf1d9c21326d2d249 (patch) | |
tree | 0f9be95e4e8d57f28f836e76fab916284c48509b /runtime-controlloop | |
parent | 01da1b3a38467e1b917a15ee00dc786ab2d5c649 (diff) |
Fixed Service Template Parsing
Issue-Id: POLICY-3691
Change-Id: Ie04711cd01e4140b0842e8d0d4ffbbe8e1b83361
Signed-off-by: brunomilitzer <bruno.militzer@est.tech>
Diffstat (limited to 'runtime-controlloop')
-rw-r--r-- | runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java index 72c153b6d..d055ba266 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java @@ -262,11 +262,19 @@ public class CommissioningProvider { * @return the tosca service template * @throws PfModelException on errors getting tosca service template */ - public String getToscaServiceTemplateReduced(String name, String version) throws PfModelException { + public String getToscaServiceTemplateReduced(String name, String version) + throws PfModelException { var serviceTemplateList = serviceTemplateProvider.getServiceTemplateList(name, version); - ToscaServiceTemplate fullTemplate = filterToscaNodeTemplateInstance(serviceTemplateList).get(0); + List<ToscaServiceTemplate> filteredServiceTemplateList = filterToscaNodeTemplateInstance( + serviceTemplateList); + + if (filteredServiceTemplateList.isEmpty()) { + throw new PfModelException(Status.BAD_REQUEST, "Invalid Service Template"); + } + + ToscaServiceTemplate fullTemplate = filteredServiceTemplateList.get(0); var template = new HashMap<String, Object>(); template.put("tosca_definitions_version", fullTemplate.getToscaDefinitionsVersion()); |