配置下发类漏掉两个方法的response异常判断
拦截强度只有拦截域名监测增加
This commit is contained in:
@@ -121,8 +121,16 @@ public class ConfigServiceUtil {
|
||||
logger.info("getId url:"+url);
|
||||
//获取响应结果
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
||||
Response response= header.get();
|
||||
if( response.getStatus() == 200){
|
||||
Response response=null;
|
||||
try {
|
||||
response= header.get();
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response != null && response.getStatus() == 200){
|
||||
logger.info("get result success");
|
||||
result= response.readEntity(String.class);
|
||||
// result = "{\"status\":200,\"businessCode\":2000,\"reason\":\"数据获取操作成功\","
|
||||
@@ -134,14 +142,26 @@ public class ConfigServiceUtil {
|
||||
if(!StringUtil.isEmpty(bean.getData())){
|
||||
list = bean.getData().getPzIdList();
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("get ids finish,cost:"+(end-start));
|
||||
return list;
|
||||
@@ -161,17 +181,31 @@ public class ConfigServiceUtil {
|
||||
logger.info("postMaatCfg url:"+url);
|
||||
//获取响应结果
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
||||
Response response= header.post(Entity.entity(params, MediaType.APPLICATION_JSON));
|
||||
if( response.getStatus() == 200){
|
||||
logger.info("get result success");
|
||||
Response response=null;
|
||||
try {
|
||||
response= header.post(Entity.entity(params, MediaType.APPLICATION_JSON));
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response != null && response.getStatus() == 200){
|
||||
logger.info("get result success");
|
||||
result= response.readEntity(String.class);
|
||||
JsonConfig config=new JsonConfig();
|
||||
config.setExcludes(new String[]{"configCompileList"});
|
||||
JSONObject resObject = JSONObject.fromObject(result,config);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
/**
|
||||
@@ -189,14 +223,28 @@ public class ConfigServiceUtil {
|
||||
logger.info("postCallbackCfg url:"+url);
|
||||
//获取响应结果
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
||||
Response response= header.post(Entity.entity(params, MediaType.APPLICATION_JSON));
|
||||
if( response.getStatus() == 200){
|
||||
Response response=null;
|
||||
try {
|
||||
response= header.post(Entity.entity(params, MediaType.APPLICATION_JSON));
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response != null && response.getStatus() == 200){
|
||||
result= response.readEntity(String.class);
|
||||
JSONObject resObject = JSONObject.fromObject(result);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
return bean;
|
||||
|
||||
}
|
||||
@@ -221,6 +269,9 @@ public class ConfigServiceUtil {
|
||||
try {
|
||||
response= header.post(Entity.entity(formDataMultiPart, formDataMultiPart.getMediaType()));
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response != null && response.getStatus() == 200){
|
||||
@@ -228,8 +279,14 @@ public class ConfigServiceUtil {
|
||||
JSONObject resObject = JSONObject.fromObject(result);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
return bean;
|
||||
|
||||
}
|
||||
@@ -257,6 +314,9 @@ public class ConfigServiceUtil {
|
||||
try {
|
||||
response= header.delete();
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response != null && response.getStatus() == 200){
|
||||
@@ -264,8 +324,14 @@ public class ConfigServiceUtil {
|
||||
JSONObject resObject = JSONObject.fromObject(result);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
return bean;
|
||||
|
||||
}
|
||||
@@ -295,6 +361,9 @@ public class ConfigServiceUtil {
|
||||
try {
|
||||
response= header.put(Entity.entity(params, MediaType.APPLICATION_JSON));
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response !=null && response.getStatus() == 200){
|
||||
@@ -302,8 +371,14 @@ public class ConfigServiceUtil {
|
||||
JSONObject resObject = JSONObject.fromObject(result);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
/**
|
||||
@@ -360,6 +435,9 @@ public class ConfigServiceUtil {
|
||||
try {
|
||||
response= header.post(Entity.entity(formDataMultiPart, formDataMultiPart.getMediaType()));
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response !=null && response.getStatus() == 200){
|
||||
@@ -368,8 +446,14 @@ public class ConfigServiceUtil {
|
||||
JSONObject resObject = JSONObject.fromObject(result);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
/**
|
||||
@@ -393,6 +477,9 @@ public class ConfigServiceUtil {
|
||||
try {
|
||||
response= header.post(Entity.entity(params, MediaType.APPLICATION_JSON));
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response !=null && response.getStatus() == 200){
|
||||
@@ -402,8 +489,14 @@ public class ConfigServiceUtil {
|
||||
JSONObject resObject = JSONObject.fromObject(result,config);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("postGroupReuseSources end,cost:"+(end-start));
|
||||
return bean;
|
||||
@@ -449,13 +542,22 @@ public class ConfigServiceUtil {
|
||||
try {
|
||||
response= header.get();
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response !=null && response.getStatus() == 200){
|
||||
result= response.readEntity(String.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static String getReport(String reportUrl, SearchReport searchCondition) throws MaatConvertException, UnsupportedEncodingException{
|
||||
@@ -503,13 +605,22 @@ public class ConfigServiceUtil {
|
||||
try {
|
||||
response= header.get();
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response !=null && response.getStatus() == 200){
|
||||
result= response.readEntity(String.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
|
||||
Reference in New Issue
Block a user