配置下发类漏掉两个方法的response异常判断

拦截强度只有拦截域名监测增加
This commit is contained in:
DuanDongmei
2018-11-22 09:23:38 +08:00
parent 6bbb2b6038
commit 0b849bfaed
3 changed files with 127 additions and 14 deletions

View File

@@ -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,13 +142,25 @@ 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));
@@ -161,8 +181,16 @@ 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){
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();
@@ -170,7 +198,13 @@ 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();
}
return bean;
}
@@ -189,13 +223,27 @@ 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,7 +279,13 @@ 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,7 +324,13 @@ 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,7 +371,13 @@ 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,7 +446,13 @@ 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,7 +489,13 @@ 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));
@@ -449,12 +542,21 @@ 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;
}
@@ -503,12 +605,21 @@ 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;
}

View File

@@ -213,7 +213,7 @@
<shiro:hasPermission name="intercept:${fn:toLowerCase(interceptType)}:config">
<sys:delRow url="${ctx}/proxy/intercept/intercept${interceptType}Form" id="contentTable" label="update"></sys:delRow>
<sys:delRow url="${ctx}/proxy/intercept/updateIntercept${interceptType}Valid?isValid=-1&functionId=${cfg.functionId }" id="contentTable" label="delete"></sys:delRow>
<sys:delRow url="${ctx}/proxy/intercept/exportIpAddr?functionId=${cfg.functionId }&audit=${audit}" searchUrl="${ctx}/proxy/intercept/${fn:toLowerCase(interceptType)}/list?functionId=${cfg.functionId}" id="contentTable" maxRow="10000" label="export"></sys:delRow>
<sys:delRow url="${ctx}/proxy/intercept/exportIpAddr?functionId=${cfg.functionId }" searchUrl="${ctx}/proxy/intercept/${fn:toLowerCase(interceptType)}/list?functionId=${cfg.functionId}" id="contentTable" maxRow="10000" label="export"></sys:delRow>
</shiro:hasPermission>
<shiro:hasPermission name="intercept:${fn:toLowerCase(interceptType)}:confirm">
<div class="btn-group">
@@ -485,11 +485,13 @@
</c:if>
<c:if test="${cfg.functionId eq 201 }">
<td>
<c:if test="${cfg.action eq 1 }">
<c:forEach items="${fns:getDictList('INTERCEPT_DOMAIN_INTENSITY') }" var="intentsityC">
<c:if test="${intentsityC.itemCode eq indexCfg.userRegion5 }">
<spring:message code="${intentsityC.itemValue }"/>
</c:if>
</c:forEach>
</c:if>
</td>
</c:if>
<td>

View File

@@ -197,7 +197,7 @@
<shiro:hasPermission name="iplist:config">
<sys:delRow url="${ctx}/ntc/iplist/form" id="contentTable" label="update"></sys:delRow>
<sys:delRow url="${ctx}/ntc/iplist/updateValid?isValid=-1&functionId=${cfg.functionId }" id="contentTable" label="delete"></sys:delRow>
<sys:delRow url="${ctx}/ntc/iplist/exportIpAddr?functionId=${cfg.functionId }&audit=${audit}" searchUrl="${ctx}/ntc/iplist/list?functionId=${cfg.functionId}" id="contentTable" maxRow="10000" label="export"></sys:delRow>
<sys:delRow url="${ctx}/ntc/iplist/exportIpAddr?functionId=${cfg.functionId }" searchUrl="${ctx}/ntc/iplist/list?functionId=${cfg.functionId}" id="contentTable" maxRow="10000" label="export"></sys:delRow>
</shiro:hasPermission>
<shiro:hasPermission name="iplist:confirm">
<div class="btn-group">