|
|
@ -62,7 +62,7 @@ public class IvsCommonService { |
|
|
return webClient.method(httpMethod).uri(getAddress().concat(uri)); |
|
|
return webClient.method(httpMethod).uri(getAddress().concat(uri)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public <T> T get(String uri, Class<T> clazz) { |
|
|
|
|
|
|
|
|
public <T> T get(final String label, String uri, Class<T> clazz) { |
|
|
String cookie = this.getCookie(); |
|
|
String cookie = this.getCookie(); |
|
|
String res = HttpUtil.createGet(getAddress().concat(uri)) |
|
|
String res = HttpUtil.createGet(getAddress().concat(uri)) |
|
|
//.cookie(new HttpCookie[]{new HttpCookie(IvsConst.HTTP_JSESSIONID_SESSION_NAME, cookie)}) |
|
|
//.cookie(new HttpCookie[]{new HttpCookie(IvsConst.HTTP_JSESSIONID_SESSION_NAME, cookie)}) |
|
|
@ -70,10 +70,10 @@ public class IvsCommonService { |
|
|
.execute() |
|
|
.execute() |
|
|
.body(); |
|
|
.body(); |
|
|
log.info("[IVS] GET URI: {}, RES: {}", uri, res); |
|
|
log.info("[IVS] GET URI: {}, RES: {}", uri, res); |
|
|
return checkResultCodeAndConvertResult(JSONObject.parseObject(res), clazz); |
|
|
|
|
|
|
|
|
return checkResultCodeAndConvertResult(label, uri, JSONObject.parseObject(res), clazz); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public <T> T getJson(String uri, Class<T> clazz) { |
|
|
|
|
|
|
|
|
public <T> T getJson(String label, String uri, Class<T> clazz) { |
|
|
String cookie = this.getCookie(); |
|
|
String cookie = this.getCookie(); |
|
|
String res = HttpUtil.createGet(getAddress().concat(uri)) |
|
|
String res = HttpUtil.createGet(getAddress().concat(uri)) |
|
|
.cookie(new HttpCookie[]{new HttpCookie(IvsConst.HTTP_JSESSIONID_SESSION_NAME, cookie)}) |
|
|
.cookie(new HttpCookie[]{new HttpCookie(IvsConst.HTTP_JSESSIONID_SESSION_NAME, cookie)}) |
|
|
@ -84,10 +84,10 @@ public class IvsCommonService { |
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
.cookie("JSESSIONID", cookie).retrieve().bodyToMono(JSONObject.class).block(); |
|
|
.cookie("JSESSIONID", cookie).retrieve().bodyToMono(JSONObject.class).block(); |
|
|
log.info("[CALL IVS] getJson POST, Response:{}", t.toJSONString()); |
|
|
log.info("[CALL IVS] getJson POST, Response:{}", t.toJSONString()); |
|
|
return this.checkResultCodeAndConvertResult(t, clazz); |
|
|
|
|
|
|
|
|
return this.checkResultCodeAndConvertResult(label, uri, t, clazz); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public JSONObject getResultJson(String uri) { |
|
|
|
|
|
|
|
|
public JSONObject getResultJson(String label, String uri) { |
|
|
String cookie = this.getCookie(); |
|
|
String cookie = this.getCookie(); |
|
|
JSONObject result = this.http(HttpMethod.GET, uri) |
|
|
JSONObject result = this.http(HttpMethod.GET, uri) |
|
|
.cookie(IvsConst.HTTP_JSESSIONID_SESSION_NAME, cookie) |
|
|
.cookie(IvsConst.HTTP_JSESSIONID_SESSION_NAME, cookie) |
|
|
@ -97,7 +97,7 @@ public class IvsCommonService { |
|
|
String resultCode = result.getString(IvsConst.RESULT_CODE); |
|
|
String resultCode = result.getString(IvsConst.RESULT_CODE); |
|
|
if (IvsConst.HTTP_STATUS_LOGIN_EXPIRE.equals(resultCode)) { |
|
|
if (IvsConst.HTTP_STATUS_LOGIN_EXPIRE.equals(resultCode)) { |
|
|
(new Thread(() -> { |
|
|
(new Thread(() -> { |
|
|
this.get(IvsConst.LOCAL_LOGIN_URL); |
|
|
|
|
|
|
|
|
this.get(label, IvsConst.LOCAL_LOGIN_URL); |
|
|
})).start(); |
|
|
})).start(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -108,7 +108,7 @@ public class IvsCommonService { |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public IvsResult delete(String uri) { |
|
|
|
|
|
|
|
|
public IvsResult delete(String label, String uri) { |
|
|
String cookie = getCookie(); |
|
|
String cookie = getCookie(); |
|
|
JSONObject jsonObject |
|
|
JSONObject jsonObject |
|
|
= http(HttpMethod.DELETE, uri) |
|
|
= http(HttpMethod.DELETE, uri) |
|
|
@ -117,15 +117,15 @@ public class IvsCommonService { |
|
|
.retrieve() |
|
|
.retrieve() |
|
|
.bodyToMono(JSONObject.class) |
|
|
.bodyToMono(JSONObject.class) |
|
|
.block(); |
|
|
.block(); |
|
|
return checkResultCodeAndConvertResult(jsonObject, IvsResult.class); |
|
|
|
|
|
|
|
|
return checkResultCodeAndConvertResult(label, uri, jsonObject, IvsResult.class); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public IvsResult get(String uri) { |
|
|
|
|
|
return this.get(uri, IvsResult.class); |
|
|
|
|
|
|
|
|
public IvsResult get(String label, String uri) { |
|
|
|
|
|
return this.get(label, uri, IvsResult.class); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private <T> T checkResultCodeAndConvertResult(JSONObject result, Class<T> clazz) { |
|
|
|
|
|
log.info("!!!!!!checkResultCodeAndConvertResult: {}", result.toJSONString()); |
|
|
|
|
|
|
|
|
private <T> T checkResultCodeAndConvertResult(final String label, final String uri, JSONObject result, Class<T> clazz) { |
|
|
|
|
|
log.info("CHECK_IVS_RET LABEL: {}, URI: {}, RES: {}", label, uri, result.toJSONString()); |
|
|
String resultCode = result.getString(IvsConst.RESULT_CODE); |
|
|
String resultCode = result.getString(IvsConst.RESULT_CODE); |
|
|
if (IvsConst.HTTP_STATUS_LOGIN_EXPIRE.equals(resultCode)) { |
|
|
if (IvsConst.HTTP_STATUS_LOGIN_EXPIRE.equals(resultCode)) { |
|
|
(new Thread(() -> HttpUtil.get(IvsConst.LOCAL_LOGIN_URL))).start(); |
|
|
(new Thread(() -> HttpUtil.get(IvsConst.LOCAL_LOGIN_URL))).start(); |
|
|
@ -138,7 +138,7 @@ public class IvsCommonService { |
|
|
return result.toJavaObject(clazz); |
|
|
return result.toJavaObject(clazz); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public <T> T putJson(Object requestParam, String uri, Class<T> clazz) { |
|
|
|
|
|
|
|
|
public <T> T putJson(String label, Object requestParam, String uri, Class<T> clazz) { |
|
|
String cookie = this.getCookie(); |
|
|
String cookie = this.getCookie(); |
|
|
JSONObject t = http(HttpMethod.PUT, uri) |
|
|
JSONObject t = http(HttpMethod.PUT, uri) |
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
@ -149,7 +149,7 @@ public class IvsCommonService { |
|
|
.block(); |
|
|
.block(); |
|
|
|
|
|
|
|
|
log.debug("[IVS] PUT PARAM: {}\n, RES: {}", JSONObject.toJSONString(requestParam), t.toJSONString()); |
|
|
log.debug("[IVS] PUT PARAM: {}\n, RES: {}", JSONObject.toJSONString(requestParam), t.toJSONString()); |
|
|
return checkResultCodeAndConvertResult(t, clazz); |
|
|
|
|
|
|
|
|
return checkResultCodeAndConvertResult(label, uri, t, clazz); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// public <T> T postJson(Object requestParam, String uri, Class<T> clazz) { |
|
|
// public <T> T postJson(Object requestParam, String uri, Class<T> clazz) { |
|
|
@ -166,16 +166,16 @@ public class IvsCommonService { |
|
|
// return checkResultCodeAndConvertResult(t, clazz); |
|
|
// return checkResultCodeAndConvertResult(t, clazz); |
|
|
// } |
|
|
// } |
|
|
|
|
|
|
|
|
public <T> T postJson(Object requestParam, String uri, Class<T> clazz) { |
|
|
|
|
|
|
|
|
public <T> T postJson(String label, Object requestParam, String uri, Class<T> clazz) { |
|
|
String cookie = this.getCookie(); |
|
|
String cookie = this.getCookie(); |
|
|
JSONObject t = (JSONObject) ((RequestBodySpec) this.http(HttpMethod.POST, uri).contentType(MediaType.APPLICATION_JSON).cookie("JSESSIONID", cookie)).bodyValue(requestParam).retrieve().bodyToMono(JSONObject.class).block(); |
|
|
JSONObject t = (JSONObject) ((RequestBodySpec) this.http(HttpMethod.POST, uri).contentType(MediaType.APPLICATION_JSON).cookie("JSESSIONID", cookie)).bodyValue(requestParam).retrieve().bodyToMono(JSONObject.class).block(); |
|
|
log.info("[CALL IVS] POST, Parameter:{}", JSONObject.toJSONString(requestParam)); |
|
|
log.info("[CALL IVS] POST, Parameter:{}", JSONObject.toJSONString(requestParam)); |
|
|
log.info("[CALL IVS] POST, Response:{}", t.toJSONString()); |
|
|
log.info("[CALL IVS] POST, Response:{}", t.toJSONString()); |
|
|
return this.checkResultCodeAndConvertResult(t, clazz); |
|
|
|
|
|
|
|
|
return this.checkResultCodeAndConvertResult(label, uri, t, clazz); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public IvsResult postJson(Object requestParam, String uri) { |
|
|
|
|
|
return this.postJson(requestParam, uri, IvsResult.class); |
|
|
|
|
|
|
|
|
public IvsResult postJson(String label, Object requestParam, String uri) { |
|
|
|
|
|
return this.postJson(label, requestParam, uri, IvsResult.class); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public byte[] sendSSLPost(String url, String param) throws Exception { |
|
|
public byte[] sendSSLPost(String url, String param) throws Exception { |
|
|
|