diff options
author | 2018-02-13 17:34:17 +0800 | |
---|---|---|
committer | 2018-02-14 09:08:56 +0800 | |
commit | 65bc277abe20baebfdc45310b34d4ba7aab9f15b (patch) | |
tree | 7bf167fda818a9e43ab796a0d8814cfa0c28d7af | |
parent | ceda3116851e86b5ab25d6e6674be6b6397d763f (diff) |
Test Replace Jackson with GSON
Change-Id: I684770d078e92c07d082889dcc9cb73ee590fb77
Issue-ID: HOLMES-115
Signed-off-by: YiLi <li.yi101@zte.com.cn>
3 files changed, 17 insertions, 3 deletions
diff --git a/holmes-actions/pom.xml b/holmes-actions/pom.xml index b13870a..7551cda 100644 --- a/holmes-actions/pom.xml +++ b/holmes-actions/pom.xml @@ -104,6 +104,12 @@ <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
@@ -172,7 +178,7 @@ <dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
- <version>1.8.3</version>
+ <version>1.9.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery.java b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery.java index 48e6ec0..b3005d5 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery.java @@ -14,6 +14,7 @@ package org.onap.holmes.common.aai; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.inject.Inject; import lombok.extern.slf4j.Slf4j; @@ -65,7 +66,11 @@ public class AaiQuery { private String getVmResourceLinks(String vserverId, String vserverName) throws CorrelationException { String response = getResourceLinksResponse(vserverId, vserverName); - return aaiResponseUtil.convertJsonToVmResourceLink(response).get(0).getResourceLink(); + List linkList = aaiResponseUtil.convertJsonToVmResourceLink(response); + if (linkList.size() != 0) { + return aaiResponseUtil.convertJsonToVmResourceLink(response).get(0).getResourceLink(); + } + return ""; } private String getResourceLinksResponse(String vserverId, String vserverName) throws CorrelationException { @@ -108,6 +113,9 @@ public class AaiQuery { } private String getMsbSuffixAddr(String suffixUrl) { + if (suffixUrl.length() <= 0) { + return ""; + } String[] addrSplits = suffixUrl.substring(1).split("/"); String[] conv = addrSplits[2].split("-"); addrSplits[2] = conv[0]; diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiResponseUtil.java b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiResponseUtil.java index a8d3c0d..748dde0 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiResponseUtil.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiResponseUtil.java @@ -41,7 +41,7 @@ public class AaiResponseUtil { List<VmResourceLink> vmResourceLinkList = new ArrayList<>(); String resultDataKey = "result-data"; JSONObject jsonNode = JSON.parseObject(responseJson); - if (jsonNode.get(resultDataKey) != null) { + if (jsonNode != null && jsonNode.get(resultDataKey) != null) { JSONArray resultData = jsonNode.getJSONArray(resultDataKey); vmResourceLinkList = convertResultDataList(resultData); } |