(1)MaatConverException调整,将接口返回json异常信息解析。
(2)白名单,IP配置审核异常结果修改
This commit is contained in:
126
src/main/java/com/nis/domain/RestfulResult.java
Normal file
126
src/main/java/com/nis/domain/RestfulResult.java
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
/**
|
||||||
|
*@Title: RestfulResult.java
|
||||||
|
*@Package com.nis.domain
|
||||||
|
*@Description TODO
|
||||||
|
*@author dell
|
||||||
|
*@date 2018年6月8日 下午3:22:26
|
||||||
|
*@version 版本号
|
||||||
|
*/
|
||||||
|
package com.nis.domain;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: RestfulResult.java
|
||||||
|
* @Description: TODO
|
||||||
|
* @author (dell)
|
||||||
|
* @date 2018年6月8日 下午3:22:26
|
||||||
|
* @version V1.0
|
||||||
|
*/
|
||||||
|
public class RestfulResult {
|
||||||
|
private Integer status;
|
||||||
|
private Integer businessCode;
|
||||||
|
private String reason;
|
||||||
|
private String msg;
|
||||||
|
private String traceCode;
|
||||||
|
private String fromuri;
|
||||||
|
public RestfulResult(){
|
||||||
|
|
||||||
|
}
|
||||||
|
public RestfulResult(String content){
|
||||||
|
JSONObject resObject = JSONObject.fromObject(content) ;
|
||||||
|
this.status=resObject.getInt("status");
|
||||||
|
this.businessCode=resObject.getInt("businessCode");
|
||||||
|
this.reason=resObject.getString("reason");
|
||||||
|
this.msg=resObject.getString("msg");
|
||||||
|
this.traceCode=resObject.getString("traceCode");
|
||||||
|
this.fromuri=resObject.getString("fromuri");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* status
|
||||||
|
* @return status
|
||||||
|
*/
|
||||||
|
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param status the status to set
|
||||||
|
*/
|
||||||
|
public void setStatus(Integer status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* businessCode
|
||||||
|
* @return businessCode
|
||||||
|
*/
|
||||||
|
|
||||||
|
public Integer getBusinessCode() {
|
||||||
|
return businessCode;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param businessCode the businessCode to set
|
||||||
|
*/
|
||||||
|
public void setBusinessCode(Integer businessCode) {
|
||||||
|
this.businessCode = businessCode;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* reason
|
||||||
|
* @return reason
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param reason the reason to set
|
||||||
|
*/
|
||||||
|
public void setReason(String reason) {
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* msg
|
||||||
|
* @return msg
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String getMsg() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param msg the msg to set
|
||||||
|
*/
|
||||||
|
public void setMsg(String msg) {
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* traceCode
|
||||||
|
* @return traceCode
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String getTraceCode() {
|
||||||
|
return traceCode;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param traceCode the traceCode to set
|
||||||
|
*/
|
||||||
|
public void setTraceCode(String traceCode) {
|
||||||
|
this.traceCode = traceCode;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* fromuri
|
||||||
|
* @return fromuri
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String getFromuri() {
|
||||||
|
return fromuri;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param fromuri the fromuri to set
|
||||||
|
*/
|
||||||
|
public void setFromuri(String fromuri) {
|
||||||
|
this.fromuri = fromuri;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,15 +1,53 @@
|
|||||||
package com.nis.exceptions;
|
package com.nis.exceptions;
|
||||||
|
|
||||||
|
import com.nis.domain.RestfulResult;
|
||||||
|
|
||||||
public class MaatConvertException extends RuntimeException {
|
public class MaatConvertException extends RuntimeException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
private static final String prefix="<spring:message code=\"request_service_failed\"/>";
|
||||||
|
private RestfulResult result;
|
||||||
public MaatConvertException(String message) {
|
public MaatConvertException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
|
if(message.startsWith(prefix)){
|
||||||
|
result=new RestfulResult(message.replaceFirst(prefix, ""));
|
||||||
|
}else{
|
||||||
|
result=new RestfulResult(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MaatConvertException(String message, Throwable cause) {
|
public MaatConvertException(String message, Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
|
if(message.startsWith(prefix)){
|
||||||
|
result=new RestfulResult(message.replaceFirst(prefix, ""));
|
||||||
|
}else{
|
||||||
|
result=new RestfulResult(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* result
|
||||||
|
* @return result
|
||||||
|
*/
|
||||||
|
|
||||||
|
public RestfulResult getResult() {
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param result the result to set
|
||||||
|
*/
|
||||||
|
public void setResult(RestfulResult result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* prefix
|
||||||
|
* @return prefix
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static String getPrefix() {
|
||||||
|
return prefix;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ public class ConfigServiceUtil {
|
|||||||
JSONObject resObject = JSONObject.fromObject(result,config);
|
JSONObject resObject = JSONObject.fromObject(result,config);
|
||||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||||
}else{
|
}else{
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>"+response.readEntity(String.class));
|
||||||
}
|
}
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.nis.web.controller.configuration.ntc;
|
package com.nis.web.controller.configuration.ntc;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -10,7 +9,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.authz.annotation.Logical;
|
import org.apache.shiro.authz.annotation.Logical;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
@@ -21,6 +19,7 @@ import com.nis.domain.Page;
|
|||||||
import com.nis.domain.configuration.AreaIpCfg;
|
import com.nis.domain.configuration.AreaIpCfg;
|
||||||
import com.nis.domain.configuration.BaseIpCfg;
|
import com.nis.domain.configuration.BaseIpCfg;
|
||||||
import com.nis.domain.configuration.IpPortCfg;
|
import com.nis.domain.configuration.IpPortCfg;
|
||||||
|
import com.nis.exceptions.MaatConvertException;
|
||||||
import com.nis.util.Constants;
|
import com.nis.util.Constants;
|
||||||
import com.nis.web.controller.BaseController;
|
import com.nis.web.controller.BaseController;
|
||||||
|
|
||||||
@@ -118,6 +117,9 @@ public class IpController extends BaseController{
|
|||||||
ipCfgService.audit(bean);
|
ipCfgService.audit(bean);
|
||||||
}
|
}
|
||||||
addMessage(redirectAttributes,"audit_success");
|
addMessage(redirectAttributes,"audit_success");
|
||||||
|
}catch(MaatConvertException e){
|
||||||
|
logger.error("审核失败", e);
|
||||||
|
addMessage(redirectAttributes, e.getPrefix()+e.getResult().getReason());
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("审核失败", e);
|
logger.error("审核失败", e);
|
||||||
addMessage(redirectAttributes, "audit_failed");
|
addMessage(redirectAttributes, "audit_failed");
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.nis.domain.configuration.BaseIpCfg;
|
|||||||
import com.nis.domain.configuration.BaseStringCfg;
|
import com.nis.domain.configuration.BaseStringCfg;
|
||||||
import com.nis.domain.configuration.HttpUrlCfg;
|
import com.nis.domain.configuration.HttpUrlCfg;
|
||||||
import com.nis.domain.configuration.IpPortCfg;
|
import com.nis.domain.configuration.IpPortCfg;
|
||||||
|
import com.nis.exceptions.MaatConvertException;
|
||||||
import com.nis.util.Constants;
|
import com.nis.util.Constants;
|
||||||
import com.nis.web.controller.BaseController;
|
import com.nis.web.controller.BaseController;
|
||||||
|
|
||||||
@@ -180,6 +181,9 @@ public class WhiteListController extends BaseController{
|
|||||||
ipCfgService.auditWhiteIp(bean);
|
ipCfgService.auditWhiteIp(bean);
|
||||||
}
|
}
|
||||||
addMessage(redirectAttributes,"audit_success");
|
addMessage(redirectAttributes,"audit_success");
|
||||||
|
}catch(MaatConvertException e){
|
||||||
|
logger.error("审核失败", e);
|
||||||
|
addMessage(redirectAttributes, e.getPrefix()+e.getResult().getReason());
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("审核失败", e);
|
logger.error("审核失败", e);
|
||||||
addMessage(redirectAttributes, "audit_failed");
|
addMessage(redirectAttributes, "audit_failed");
|
||||||
@@ -201,6 +205,9 @@ public class WhiteListController extends BaseController{
|
|||||||
stringCfgService.auditWhiteDomain(bean);
|
stringCfgService.auditWhiteDomain(bean);
|
||||||
}
|
}
|
||||||
addMessage(redirectAttributes,"audit_success");
|
addMessage(redirectAttributes,"audit_success");
|
||||||
|
}catch(MaatConvertException e){
|
||||||
|
logger.error("审核失败", e);
|
||||||
|
addMessage(redirectAttributes, e.getPrefix()+e.getResult().getReason());
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("审核失败", e);
|
logger.error("审核失败", e);
|
||||||
addMessage(redirectAttributes, "audit_failed");
|
addMessage(redirectAttributes, "audit_failed");
|
||||||
|
|||||||
Reference in New Issue
Block a user