summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java12
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());