From b8e2faf476202b6ffe61bc3a9a37df1304881d40 Mon Sep 17 00:00:00 2001 From: Avi Ziv Date: Tue, 18 Jul 2017 19:45:38 +0300 Subject: [SDC] Onboarding 1710 rebase. Change-Id: If3b6b81d221fde13908f1e8160db6f7d9433c535 Signed-off-by: Avi Ziv --- .../impl/zusammen/ServiceModelDaoZusammenImpl.java | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java') diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java index 530ad44574..575ba856a7 100644 --- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java @@ -9,6 +9,7 @@ import com.amdocs.zusammen.datatypes.item.Action; import com.amdocs.zusammen.datatypes.item.ElementContext; import com.amdocs.zusammen.datatypes.item.Info; import com.amdocs.zusammen.datatypes.item.ItemVersion; +import org.apache.commons.io.IOUtils; import org.openecomp.core.model.dao.ServiceModelDao; import org.openecomp.core.model.types.ServiceElement; import org.openecomp.core.utilities.file.FileContentHandler; @@ -18,13 +19,15 @@ import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; -import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil; +import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.dao.types.VersionStatus; import java.io.ByteArrayInputStream; +import java.io.IOException; import java.util.Collection; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; @@ -89,7 +92,6 @@ public class ServiceModelDaoZusammenImpl return elements.stream().collect(Collectors.toMap( element -> element.getInfo().getName(), this::elementToServiceTemplate)); - /*elements.stream().forEach(element ->serviceTemplateMap.put(element.getInfo().getName(), elementToServiceTemplate(element))); return serviceTemplateMap;*/ @@ -127,8 +129,10 @@ public class ServiceModelDaoZusammenImpl ZusammenElement artifactsElement = buildStructuralElement(StructureElement.Artifacts.name(), Action.UPDATE); - serviceModel.getArtifactFiles().getFiles().entrySet().forEach(entry -> artifactsElement - .addSubElement(buildArtifactElement(entry.getKey(), entry.getValue(), Action.CREATE))); + if (Objects.nonNull(serviceModel.getArtifactFiles())) { + serviceModel.getArtifactFiles().getFiles().entrySet().forEach(entry -> artifactsElement + .addSubElement(buildArtifactElement(entry.getKey(), entry.getValue(), Action.CREATE))); + } ZusammenElement serviceModelElement = buildStructuralElement(name, Action.UPDATE); serviceModelElement.getInfo() @@ -175,8 +179,15 @@ public class ServiceModelDaoZusammenImpl return artifactElement; } - private ServiceTemplate elementToServiceTemplate(Element element) { - return new ToscaExtensionYamlUtil().yamlToObject(element.getData(), ServiceTemplate.class); + private ServiceTemplate elementToServiceTemplate(Element element){ + + try { + String yamlContent = IOUtils.toString(element.getData()); + return new ToscaExtensionYamlUtil(). + yamlToObject(yamlContent, ServiceTemplate.class); + }catch (Exception e){ + return null; + } } private Element buildServiceTemplateElement(String name, ServiceTemplate serviceTemplate, -- cgit 1.2.3-korg