diff options
Diffstat (limited to 'ncomp-utils-java')
5 files changed, 37 insertions, 25 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 390c135..efc183e 100644 --- a/ncomp-utils-java/pom.xml +++ b/ncomp-utils-java/pom.xml @@ -1,20 +1,20 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<?xml version="1.0"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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> <groupId>org.openecomp.ncomp.utils</groupId> <artifactId>ncomp-utils-java</artifactId> - <version>1.0.0-SNAPSHOT</version> + <version>1.1.0-SNAPSHOT</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.target>1.7</maven.compiler.target> <maven.compiler.source>1.7</maven.compiler.source> - <openecomp.nexus.releases>https://nexus.openecomp.org/content/repositories/releases/</openecomp.nexus.releases> - <openecomp.nexus.snapshots>https://nexus.openecomp.org/content/repositories/snapshots/</openecomp.nexus.snapshots> - <openecomp.nexus.proxy>https://nexus.openecomp.org</openecomp.nexus.proxy> + <openecomp.nexus.releases>https://nexus.onap.org/content/repositories/releases/</openecomp.nexus.releases> + <openecomp.nexus.snapshots>https://nexus.onap.org/content/repositories/snapshots/</openecomp.nexus.snapshots> + <openecomp.nexus.proxy>https://nexus.onap.org</openecomp.nexus.proxy> <openecomp.nexus.staging.serverId>ecomp-staging</openecomp.nexus.staging.serverId> <openecomp.nexus.staging.profileId>176c31dfe190a</openecomp.nexus.staging.profileId> - </properties> + <nexusproxy>https://nexus.onap.org</nexusproxy></properties> <build> @@ -48,8 +48,8 @@ <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> - <source /> - <target /> + <source/> + <target/> </configuration> </plugin> </plugins> @@ -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> @@ -110,8 +115,8 @@ <url>${openecomp.nexus.snapshots}</url> </snapshotRepository> <site> - <id>dcae-javadoc</id> - <url>${site.urlroot}/${project.artifactId}/${project.version}/</url> + <id>ecomp-site</id> + <url>dav:${nexusproxy}/content/sites/site/org/openecomp/ncomp/utils/${project.artifactId}/${project.version}/</url> </site> </distributionManagement> 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); + } } |