aboutsummaryrefslogtreecommitdiffstats
path: root/profiles
diff options
context:
space:
mode:
Diffstat (limited to 'profiles')
-rw-r--r--profiles/http/pom.xml11
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java9
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java17
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java32
-rw-r--r--profiles/snmp/pom.xml2
-rw-r--r--profiles/snmp/src/test/resources/log4j.properties23
6 files changed, 42 insertions, 52 deletions
diff --git a/profiles/http/pom.xml b/profiles/http/pom.xml
index fe2cee86..058749d7 100644
--- a/profiles/http/pom.xml
+++ b/profiles/http/pom.xml
@@ -77,9 +77,9 @@ Excluded commons-codec vulnerable version and added invulnerable version
<version>2.2.0</version>
</dependency>
<dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>2.9.4</version>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.onap.cli</groupId>
@@ -110,6 +110,11 @@ Excluded commons-codec vulnerable version and added invulnerable version
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
</exclusion>
+ <!--JIRA: CLI-253-->
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java b/profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java
index f0fe43cd..25cf14a3 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java
@@ -32,8 +32,8 @@ import org.onap.cli.fw.utils.OnapCommandDiscoveryUtils;
import org.springframework.core.io.Resource;
import org.yaml.snakeyaml.Yaml;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
import com.github.dreamhead.moco.HttpServer;
import com.github.dreamhead.moco.Moco;
import com.github.dreamhead.moco.ResponseHandler;
@@ -43,6 +43,7 @@ public class MocoServer {
private Runner runner;
private Map<String, Object> mocoServerConfigs = new HashMap();
+ private static Gson gson = new GsonBuilder().serializeNulls().create();
public MocoServer(String mockFile) throws OnapCommandException {
Resource resource = null;
@@ -71,8 +72,8 @@ public class MocoServer {
if(response.get(OnapCommandHttpConstants.VERIFY_RESPONSE_JSON) != null) {
try {
mocoServerConfigs.put(OnapCommandHttpConstants.VERIFY_RESPONSE_JSON,
- new ObjectMapper().writeValueAsString(response.get(OnapCommandHttpConstants.VERIFY_RESPONSE_JSON)));
- } catch (JsonProcessingException e) {
+ gson.toJson(response.get(OnapCommandHttpConstants.VERIFY_RESPONSE_JSON)));
+ } catch (Exception e) { // NOSONAR
throw new OnapCommandException("Invalid mocking file" + mockFile, e);
}
}
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java b/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
index aaca5c87..c07a6f7f 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
@@ -16,7 +16,6 @@
package org.onap.cli.fw.http.schema;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -42,20 +41,20 @@ import org.onap.cli.fw.registrar.OnapCommandRegistrar;
import org.onap.cli.fw.schema.OnapCommandSchemaLoader;
import org.onap.cli.fw.utils.OnapCommandUtils;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import net.minidev.json.JSONObject;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonElement;
public class OnapCommandSchemaHttpLoader {
private static final String ATTRIBUTE = "Attribute '";
+ private static Gson gson = new GsonBuilder().serializeNulls().create();
private OnapCommandSchemaHttpLoader() {
// to follow standards !
}
- public static List<String> loadHttpSchema(OnapHttpCommand cmd, String schemaName, boolean includeDefault,
- boolean validateSchema) throws OnapCommandException {
+ public static List<String> loadHttpSchema(OnapHttpCommand cmd, String schemaName, boolean includeDefault, boolean validateSchema) throws OnapCommandException {
try {
List<String> errors = new ArrayList<>();
if (includeDefault) {
@@ -70,7 +69,7 @@ public class OnapCommandSchemaHttpLoader {
}
Map<String, List<Map<String, String>>> commandYamlMap =
- (Map<String, List<Map<String, String>>>)OnapCommandSchemaLoader.validateSchemaVersion(schemaName, cmd.getSchemaVersion());
+ (Map<String, List<Map<String, String>>>) OnapCommandSchemaLoader.validateSchemaVersion(schemaName, cmd.getSchemaVersion());
errors.addAll(parseHttpSchema(cmd, commandYamlMap, validateSchema));
@@ -417,8 +416,8 @@ public class OnapCommandSchemaHttpLoader {
errorList.add(OnapCommandHttpConstants.HTTP_BODY_JSON_EMPTY);
} else {
try {
- new ObjectMapper().readValue(body, JSONObject.class);
- } catch (IOException e1) { // NOSONAR
+ gson.fromJson(body, JsonElement.class);
+ } catch (Exception e1) { // NOSONAR
errorList.add(OnapCommandHttpConstants.HTTP_BODY_FAILED_PARSING);
}
}
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java b/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java
index d1f88df4..0eb06c96 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java
@@ -40,8 +40,9 @@ import org.onap.cli.fw.utils.OnapCommandUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonElement;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.PathNotFoundException;
@@ -50,6 +51,7 @@ import net.minidev.json.JSONArray;
public class OnapCommandHttpUtils {
static Logger LOG = LoggerFactory.getLogger(OnapCommandHttpUtils.class);
+ private static Gson gson = new GsonBuilder().serializeNulls().create();
/**
* Set argument to param value.
@@ -277,26 +279,32 @@ public class OnapCommandHttpUtils {
}
}
- public static void normalizeJson(JsonNode node) {
- Iterator<JsonNode> it = node.iterator();
+ public static void normalizeJson(JsonElement node) {
+ Iterator<Entry<String, JsonElement>> it = node.getAsJsonObject().entrySet().iterator();
+
while (it.hasNext()) {
- JsonNode child = it.next();
- if (child.isTextual() && child.asText().equals(""))
+ JsonElement child = it.next().getValue();
+ if (child.isJsonPrimitive() && child.getAsJsonPrimitive().isString() && child.getAsJsonPrimitive().getAsString().equals(""))
it.remove();
- else if (child.isNull())
+ else if (child.isJsonNull())
it.remove();
- else
+ else if (child.isJsonObject())
normalizeJson(child);
+ else if (child.isJsonArray()) {
+ for (JsonElement ele:child.getAsJsonArray()) {
+ if (ele.isJsonObject())
+ normalizeJson(ele);
+ }
+ }
}
}
public static String normalizeJson(String json) throws OnapCommandHttpInvalidRequestBody {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode node;
+ JsonElement node;
try {
- node = mapper.readTree(json);
+ node = gson.fromJson(json,JsonElement.class);
normalizeJson(node);
- return mapper.writeValueAsString(node);
+ return gson.toJson(node);
} catch (Exception e) { //NOSONAR
throw new OnapCommandHttpInvalidRequestBody(e);
}
diff --git a/profiles/snmp/pom.xml b/profiles/snmp/pom.xml
index ba59cf8d..293230ff 100644
--- a/profiles/snmp/pom.xml
+++ b/profiles/snmp/pom.xml
@@ -43,7 +43,7 @@
<groupId>org.snmp4j</groupId>
<artifactId>snmp4j</artifactId>
<version>2.5.6</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
diff --git a/profiles/snmp/src/test/resources/log4j.properties b/profiles/snmp/src/test/resources/log4j.properties
deleted file mode 100644
index 78f32285..00000000
--- a/profiles/snmp/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright 2018 Huawei Technologies Co., Ltd.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-log4j.rootLogger=ERROR, stdout
-
-log4j.logger.org.onap.cli=DEBUG, stdout
-
-# Direct log messages to stdout
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n