From bbf13d0f5335ec70948baf84d2289dc431b12734 Mon Sep 17 00:00:00 2001 From: YiLi Date: Wed, 14 Feb 2018 10:30:21 +0800 Subject: Test Replace Jackson with GSON Change-Id: I359884ca228d6191b95770952d5684cef101cdee Issue-ID: HOLMES-115 Signed-off-by: YiLi --- holmes-actions/pom.xml | 5 ----- .../src/main/java/org/onap/holmes/common/api/stat/Alarm.java | 4 ++-- .../org/onap/holmes/common/config/MicroServiceConfig.java | 12 +++++++----- .../holmes/common/dcae/utils/DcaeConfigurationParser.java | 5 +++-- 4 files changed, 12 insertions(+), 14 deletions(-) (limited to 'holmes-actions') diff --git a/holmes-actions/pom.xml b/holmes-actions/pom.xml index 7551cda..3e35e33 100644 --- a/holmes-actions/pom.xml +++ b/holmes-actions/pom.xml @@ -175,11 +175,6 @@ commons-collections 3.2.2 - - commons-beanutils - commons-beanutils - 1.9.2 - com.google.code.gson gson diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/api/stat/Alarm.java b/holmes-actions/src/main/java/org/onap/holmes/common/api/stat/Alarm.java index 9822076..4046307 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/api/stat/Alarm.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/api/stat/Alarm.java @@ -16,9 +16,9 @@ package org.onap.holmes.common.api.stat; +import com.alibaba.fastjson.JSONObject; import lombok.Getter; import lombok.Setter; -import net.sf.json.JSONObject; import java.io.Serializable; import java.util.*; @@ -112,7 +112,7 @@ public class Alarm implements AplusData, Cloneable, Serializable { @Override public String toString() { - return JSONObject.fromObject(this).toString(); + return JSONObject.toJSONString(this); } @Override diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/config/MicroServiceConfig.java b/holmes-actions/src/main/java/org/onap/holmes/common/config/MicroServiceConfig.java index 9a1b0ea..f74d1b2 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/config/MicroServiceConfig.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/config/MicroServiceConfig.java @@ -15,12 +15,12 @@ */ package org.onap.holmes.common.config; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.Response; import lombok.extern.slf4j.Slf4j; -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; import org.onap.holmes.common.constant.AlarmConst; @Slf4j @@ -50,9 +50,11 @@ public class MicroServiceConfig { String queryString = getConsulAddrInfo() + hostname; log.info("Query the " + hostname + " address using the URL: " + queryString); try { - JSONObject addrJson = (JSONObject) JSONArray.fromObject(execQuery(queryString)).get(0); - if (addrJson.has("ServiceAddress") && addrJson.has("ServicePort")) { - ret = "http://" + addrJson.getString("ServiceAddress") + ":" + addrJson.getString("ServicePort"); + JSONObject addrJson = (JSONObject) JSON.parseArray(execQuery(queryString)).get(0); + if (addrJson != null && addrJson.get("ServiceAddress") != null + && addrJson.get("ServicePort") != null) { + ret = "http://" + addrJson.getString("ServiceAddress") + ":" + addrJson + .getString("ServicePort"); } } catch (Exception e) { log.warn(e.getMessage(), e); diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dcae/utils/DcaeConfigurationParser.java b/holmes-actions/src/main/java/org/onap/holmes/common/dcae/utils/DcaeConfigurationParser.java index 1143263..092e478 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/dcae/utils/DcaeConfigurationParser.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/dcae/utils/DcaeConfigurationParser.java @@ -15,12 +15,13 @@ */ package org.onap.holmes.common.dcae.utils; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import java.util.Arrays; import java.util.List; import java.util.Map.Entry; import java.util.Set; import java.util.stream.Stream; -import net.sf.json.JSONObject; import org.apache.commons.lang3.StringUtils; import org.onap.holmes.common.dcae.entity.DcaeConfigurations; import org.onap.holmes.common.dcae.entity.Rule; @@ -44,7 +45,7 @@ public class DcaeConfigurationParser { JSONObject jsonObject = null; try { - jsonObject = JSONObject.fromObject(jsonStr); + jsonObject = JSON.parseObject(jsonStr); } catch (Exception e) { throw new CorrelationException(e.getMessage(), e); } -- cgit 1.2.3-korg