From 4428fc40a81ff3234b918af87da74a27ccbfe650 Mon Sep 17 00:00:00 2001 From: shiria Date: Tue, 26 Mar 2019 10:08:43 +0200 Subject: Load tosca with no imports section Change-Id: I50df2a149bd8d27973bb66e41f80a3260b8a9b8b Issue-ID: SDC-2192 Signed-off-by: shiria --- .../openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp') diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java index bb557f6076..053253a993 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java @@ -182,7 +182,6 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { } String convertServiceTemplateImport(ToscaExtensionYamlUtil toscaExtensionYamlUtil, byte[] fileContent) { - Map serviceTemplateMap = toscaExtensionYamlUtil.yamlToObject(new String(fileContent), Map.class); convertToscaImports(serviceTemplateMap, toscaExtensionYamlUtil); return toscaExtensionYamlUtil.objectToYaml(serviceTemplateMap); @@ -191,8 +190,8 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { private void convertToscaImports(Map serviceTemplateMap, ToscaExtensionYamlUtil toscaExtensionYamlUtil) { List> convertedImport = new ArrayList<>(); Object importObj = serviceTemplateMap.get(IMPORTS); - if (!(importObj instanceof List)) { - throw new SdcRuntimeException("Illegal Statement"); + if (Objects.nonNull(importObj) && !(importObj instanceof List)) { + throw new SdcRuntimeException(new IllegalStateException("Invalid TOSCA import section")); } List imports = (List) importObj; if (CollectionUtils.isEmpty(imports)) { -- cgit 1.2.3-korg