Code Review
/
holmes
/
common.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fixed the CLM Issues
[holmes/common.git]
/
holmes-actions
/
src
/
main
/
java
/
org
/
onap
/
holmes
/
common
/
config
/
MicroServiceConfig.java
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
3d94325
..
33bd1d2
100644
(file)
--- 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
@@
-1,5
+1,5
@@
/**
\r
/**
\r
- * Copyright 2017 ZTE Corporation.
\r
+ * Copyright 2017
-2020
ZTE Corporation.
\r
* <p>
\r
* Licensed under the Apache License, Version 2.0 (the "License");
\r
* you may not use this file except in compliance with the License.
\r
* <p>
\r
* Licensed under the Apache License, Version 2.0 (the "License");
\r
* you may not use this file except in compliance with the License.
\r
@@
-15,19
+15,17
@@
*/
\r
package org.onap.holmes.common.config;
\r
\r
*/
\r
package org.onap.holmes.common.config;
\r
\r
-import com.alibaba.fastjson.JSON;
\r
-import com.alibaba.fastjson.JSONObject;
\r
+import com.google.gson.JsonObject;
\r
+import com.google.gson.JsonParser;
\r
+import org.onap.holmes.common.constant.AlarmConst;
\r
+import org.slf4j.Logger;
\r
+import org.slf4j.LoggerFactory;
\r
\r
import javax.ws.rs.client.Client;
\r
import javax.ws.rs.client.ClientBuilder;
\r
import javax.ws.rs.core.Response;
\r
\r
import javax.ws.rs.client.Client;
\r
import javax.ws.rs.client.ClientBuilder;
\r
import javax.ws.rs.core.Response;
\r
-
\r
-import lombok.extern.slf4j.Slf4j;
\r
-import org.onap.holmes.common.constant.AlarmConst;
\r
-
\r
import java.util.regex.Pattern;
\r
\r
import java.util.regex.Pattern;
\r
\r
-@Slf4j
\r
public class MicroServiceConfig {
\r
\r
final static public String CONSUL_ADDR_SUF = ":8500/v1/catalog/service/";
\r
public class MicroServiceConfig {
\r
\r
final static public String CONSUL_ADDR_SUF = ":8500/v1/catalog/service/";
\r
@@
-40,6
+38,8
@@
public class MicroServiceConfig {
final static public Pattern IP_REG = Pattern.compile("(http(s)?://)?(\\d+\\.\\d+\\.\\d+\\.\\d+)(:(\\d+))?");
\r
final static public String AAI_HOSTNAME = "aai.onap";
\r
\r
final static public Pattern IP_REG = Pattern.compile("(http(s)?://)?(\\d+\\.\\d+\\.\\d+\\.\\d+)(:(\\d+))?");
\r
final static public String AAI_HOSTNAME = "aai.onap";
\r
\r
+ final static public Logger log = LoggerFactory.getLogger(MicroServiceConfig.class);
\r
+
\r
public static String getEnv(String name) {
\r
String value = System.getenv(name);
\r
if (value == null) {
\r
public static String getEnv(String name) {
\r
String value = System.getenv(name);
\r
if (value == null) {
\r
@@
-57,11
+57,14
@@
public class MicroServiceConfig {
String queryString = getConsulAddrInfo() + hostname;
\r
log.info("Query the " + hostname + " address using the URL: " + queryString);
\r
try {
\r
String queryString = getConsulAddrInfo() + hostname;
\r
log.info("Query the " + hostname + " address using the URL: " + queryString);
\r
try {
\r
- JSONObject addrJson = (JSONObject) JSON.parseArray(execQuery(queryString)).get(0);
\r
+ JsonObject addrJson = JsonParser.parseString(execQuery(queryString))
\r
+ .getAsJsonArray()
\r
+ .get(0)
\r
+ .getAsJsonObject();
\r
if (addrJson != null && addrJson.get("ServiceAddress") != null
\r
&& addrJson.get("ServicePort") != null) {
\r
if (addrJson != null && addrJson.get("ServiceAddress") != null
\r
&& addrJson.get("ServicePort") != null) {
\r
- ret = "http://" + addrJson.get
String("ServiceAddress"
) + ":" + addrJson
\r
- .get
String("ServicePort"
);
\r
+ ret = "http://" + addrJson.get
("ServiceAddress").getAsString(
) + ":" + addrJson
\r
+ .get
("ServicePort").getAsString(
);
\r
}
\r
} catch (Exception e) {
\r
log.warn(e.getMessage(), e);
\r
}
\r
} catch (Exception e) {
\r
log.warn(e.getMessage(), e);
\r