diff options
author | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2018-03-15 09:38:49 +0530 |
---|---|---|
committer | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2018-03-15 09:38:49 +0530 |
commit | 34c8e8c890a8a53e49aadcbc1bca567a93b11048 (patch) | |
tree | 302740704e0ae01dceb44d269fe44387969ae4df /profiles/http/src/main | |
parent | d1dd5de42c7ac60dfa227c4c3a29b5afe9d68d7e (diff) |
HTTP body validation reports invalid error
Issue-ID: CLI-93
Change-Id: I667604198cc3d0dfcb2c2d5b576aa2efc5bb48dc
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'profiles/http/src/main')
-rw-r--r-- | profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java | 16 |
1 files changed, 9 insertions, 7 deletions
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 43772e56..52b7571d 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 @@ -385,15 +385,17 @@ public class OnapCommandSchemaHttpLoader { } String body = String.valueOf(bodyString); - JSONObject obj = null; - try { - obj = new ObjectMapper().readValue(body, JSONObject.class); - } catch (IOException e1) { // NOSONAR - errorList.add(OnapCommandHttpConstants.HTTP_BODY_FAILED_PARSING); - } - if (obj == null || "".equals(obj.toString())) { + + if (body == null || "".equals(body)) { errorList.add(OnapCommandHttpConstants.HTTP_BODY_JSON_EMPTY); + } else { + try { + new ObjectMapper().readValue(body, JSONObject.class); + } catch (IOException e1) { // NOSONAR + errorList.add(OnapCommandHttpConstants.HTTP_BODY_FAILED_PARSING); + } } + OnapCommandUtils.parseParameters(body, bodyParamNames); return bodyParamNames; |