diff options
author | YiLi <li.yi101@zte.com.cn> | 2018-02-14 10:30:21 +0800 |
---|---|---|
committer | YiLi <li.yi101@zte.com.cn> | 2018-02-22 17:02:39 +0800 |
commit | bbf13d0f5335ec70948baf84d2289dc431b12734 (patch) | |
tree | d09dd3bdfb7e11c5810767df72be3b6268bde417 /holmes-actions/src/main | |
parent | 65bc277abe20baebfdc45310b34d4ba7aab9f15b (diff) |
Test Replace Jackson with GSON
Change-Id: I359884ca228d6191b95770952d5684cef101cdee
Issue-ID: HOLMES-115
Signed-off-by: YiLi <li.yi101@zte.com.cn>
Diffstat (limited to 'holmes-actions/src/main')
3 files changed, 12 insertions, 9 deletions
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);
}
|