diff options
Diffstat (limited to 'models')
-rwxr-xr-x | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java index 9f267d32d..a518c4908 100755 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java @@ -66,6 +66,10 @@ public class AcDefinitionProvider { serviceTemplate.getMetadata().put("compositionId", compositionId); acmDefinition.setServiceTemplate(serviceTemplate); var acElements = AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate, toscaElementName); + if (acElements.isEmpty()) { + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, + "NodeTemplate with element type " + toscaElementName + " must exist!"); + } acmDefinition.setElementStateMap(AcmUtils.createElementStateMap(acElements, AcTypeState.COMMISSIONED)); var jpaAcmDefinition = ProviderUtils.getJpaAndValidate(acmDefinition, JpaAutomationCompositionDefinition::new, "AutomationCompositionDefinition"); @@ -94,6 +98,10 @@ public class AcDefinitionProvider { acmDefinition.setServiceTemplate(serviceTemplate); var acElements = AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate, toscaElementName); + if (acElements.isEmpty()) { + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, + "NodeTemplate with element type " + toscaElementName + " must exist!"); + } acmDefinition.setElementStateMap(AcmUtils.createElementStateMap(acElements, AcTypeState.COMMISSIONED)); updateAcDefinition(acmDefinition, toscaCompositionName); } |