summaryrefslogtreecommitdiffstats
path: root/holmes-actions/src/main/java/org
diff options
context:
space:
mode:
authorYiLi <li.yi101@zte.com.cn>2018-02-13 17:34:17 +0800
committerYiLi <li.yi101@zte.com.cn>2018-02-14 09:08:56 +0800
commit65bc277abe20baebfdc45310b34d4ba7aab9f15b (patch)
tree7bf167fda818a9e43ab796a0d8814cfa0c28d7af /holmes-actions/src/main/java/org
parentceda3116851e86b5ab25d6e6674be6b6397d763f (diff)
Test Replace Jackson with GSON
Change-Id: I684770d078e92c07d082889dcc9cb73ee590fb77 Issue-ID: HOLMES-115 Signed-off-by: YiLi <li.yi101@zte.com.cn>
Diffstat (limited to 'holmes-actions/src/main/java/org')
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery.java10
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiResponseUtil.java2
2 files changed, 10 insertions, 2 deletions
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);
}