summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl
diff options
context:
space:
mode:
authorAvi Ziv <avi.ziv@amdocs.com>2017-07-18 19:45:38 +0300
committerAvi Ziv <avi.ziv@amdocs.com>2017-07-18 19:45:38 +0300
commitb8e2faf476202b6ffe61bc3a9a37df1304881d40 (patch)
treef78b8c0517d8e16c5ae610bf8b49f68ea8a312a1 /openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl
parent75aacbbe1acf78fa53378f07f0a8c7769449a17e (diff)
[SDC] Onboarding 1710 rebase.
Change-Id: If3b6b81d221fde13908f1e8160db6f7d9433c535 Signed-off-by: Avi Ziv <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl')
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml10
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml.versionsBackup49
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java23
3 files changed, 76 insertions, 6 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml
index a3b1e0db9f..30c4bde443 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml
@@ -16,6 +16,11 @@
<dependencies>
<dependency>
+ <groupId>org.openecomp.sdc.common</groupId>
+ <artifactId>openecomp-tosca-datatype</artifactId>
+ <version>${openecomp.sdc.common.version}</version>
+ </dependency>
+ <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
@@ -46,5 +51,10 @@
<scope>test</scope>
<version>${mockito.all.version}</version>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.5</version>
+ </dependency>
</dependencies>
</project>
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml.versionsBackup
new file mode 100644
index 0000000000..b8db689bd5
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml.versionsBackup
@@ -0,0 +1,49 @@
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>openecomp-sdc-model-impl</name>
+ <artifactId>openecomp-sdc-model-impl</artifactId>
+
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>${logback.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-utilities-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-model-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-datatypes-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ <version>1.10.19</version>
+ </dependency>
+
+
+ </dependencies>
+</project> \ No newline at end of file
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,