aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Venkatesh Kumar <vv770d@att.com>2017-04-17 17:10:56 +0000
committerGerrit Code Review <gerrit@onap.org>2017-04-17 17:10:56 +0000
commite0f595119ca537a91bbb0db668e9306ce544a535 (patch)
tree2fc905975c243512bacb52bafb7855e05bc16703
parentf6352b96eafaf691324c1870bfeee95e0e75affd (diff)
parent03177c7c79176ab93d1be89762fc5841b33e4691 (diff)
Merge "[DCAE-15] Changes related to version 1.1"
-rw-r--r--ncomp-utils-java/.classpath10
-rw-r--r--ncomp-utils-java/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--ncomp-utils-java/pom.xml5
-rw-r--r--ncomp-utils-java/src/main/java/org/openecomp/ncomp/webservice/utils/FileUtils.java2
-rw-r--r--ncomp-utils-java/src/main/java/org/openecomp/ncomp/webservice/utils/JsonUtils.java20
5 files changed, 26 insertions, 14 deletions
diff --git a/ncomp-utils-java/.classpath b/ncomp-utils-java/.classpath
index e0e6b3f..79ccca7 100644
--- a/ncomp-utils-java/.classpath
+++ b/ncomp-utils-java/.classpath
@@ -23,15 +23,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
- <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
diff --git a/ncomp-utils-java/.settings/org.eclipse.core.resources.prefs b/ncomp-utils-java/.settings/org.eclipse.core.resources.prefs
index 29abf99..e9441bb 100644
--- a/ncomp-utils-java/.settings/org.eclipse.core.resources.prefs
+++ b/ncomp-utils-java/.settings/org.eclipse.core.resources.prefs
@@ -1,6 +1,3 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
-encoding//src/main/resources=UTF-8
-encoding//src/test/java=UTF-8
-encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
diff --git a/ncomp-utils-java/pom.xml b/ncomp-utils-java/pom.xml
index d3efa75..efc183e 100644
--- a/ncomp-utils-java/pom.xml
+++ b/ncomp-utils-java/pom.xml
@@ -95,6 +95,11 @@
<artifactId>org.eclipse.emf.ecore.xmi</artifactId>
<version>2.11.0-v20150123-0347</version>
</dependency>
+ <dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ <version>1.15</version>
+ </dependency>
</dependencies>
diff --git a/ncomp-utils-java/src/main/java/org/openecomp/ncomp/webservice/utils/FileUtils.java b/ncomp-utils-java/src/main/java/org/openecomp/ncomp/webservice/utils/FileUtils.java
index 423a1be..7c2e16d 100644
--- a/ncomp-utils-java/src/main/java/org/openecomp/ncomp/webservice/utils/FileUtils.java
+++ b/ncomp-utils-java/src/main/java/org/openecomp/ncomp/webservice/utils/FileUtils.java
@@ -635,7 +635,7 @@ public class FileUtils {
public static String safeFileName(String file) {
// creating file with safer creation.
- if (file.contains(".."))
+ if (file.contains("../"))
throw new RuntimeException("File name contain ..: " + file);
if (file.contains("\n"))
throw new RuntimeException("File name contain newline: " + file);
diff --git a/ncomp-utils-java/src/main/java/org/openecomp/ncomp/webservice/utils/JsonUtils.java b/ncomp-utils-java/src/main/java/org/openecomp/ncomp/webservice/utils/JsonUtils.java
index ee899ed..0fbb1d9 100644
--- a/ncomp-utils-java/src/main/java/org/openecomp/ncomp/webservice/utils/JsonUtils.java
+++ b/ncomp-utils-java/src/main/java/org/openecomp/ncomp/webservice/utils/JsonUtils.java
@@ -22,6 +22,7 @@
package org.openecomp.ncomp.webservice.utils;
import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -29,6 +30,7 @@ import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.Vector;
@@ -43,6 +45,7 @@ import org.json.JSONObject;
import org.openecomp.ncomp.utils.PropertyUtil;
import org.openecomp.ncomp.utils.StringUtil;
+import org.yaml.snakeyaml.Yaml;
public class JsonUtils {
public static final Logger logger = Logger.getLogger(JsonUtils.class);
@@ -464,4 +467,21 @@ public class JsonUtils {
}
return res;
}
+
+ public static JSONObject yaml2json(File file) throws IOException {
+ InputStream in = FileUtils.filename2stream(file.getAbsolutePath(), null);
+ if (in == null)
+ throw new RuntimeException("Unable to open: " + file);
+ ByteArrayOutputStream buf = new ByteArrayOutputStream();
+ try {
+ FileUtils.copyStream(in, buf);
+ } finally {
+ in.close();
+ buf.close();
+ }
+ Yaml yaml= new Yaml();
+ @SuppressWarnings("unchecked")
+ Map<String,Object> map= (Map<String, Object>) yaml.load(buf.toString());
+ return new JSONObject(map);
+ }
}