1、回调类中改为属于策略一部分无action;
2、添加分组复用域配置新增和删除接口;只有属于分组复用的业务类型在新增MAAT规则时才能只不填写域配置;
This commit is contained in:
103
src/main/java/com/nis/domain/restful/GroupReuse.java
Normal file
103
src/main/java/com/nis/domain/restful/GroupReuse.java
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
/**
|
||||||
|
* @Title: DfConfigCompile.java
|
||||||
|
* @Package com.nis.domain.restful
|
||||||
|
* @Description: TODO(用一句话描述该文件做什么)
|
||||||
|
* @author (darnell)
|
||||||
|
* @date 2016年8月29日 下午9:36:28
|
||||||
|
* @version V1.0
|
||||||
|
*/
|
||||||
|
package com.nis.domain.restful;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @ClassName:RegionRepeat
|
||||||
|
* @Description:TODO(这里用一句话描述这个类的作用)
|
||||||
|
* @author (zdx)
|
||||||
|
* @date 2018年8月22日 下午6:57:42
|
||||||
|
* @version V1.0
|
||||||
|
*/
|
||||||
|
public class GroupReuse implements Serializable {
|
||||||
|
private static final long serialVersionUID = 5803814776173252917L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "业务ID", required = true)
|
||||||
|
private Integer service;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "字符串域分组列表", access = "", required = true)
|
||||||
|
private List<StrRegion> strRegionList;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "IP域分组列表", required = true)
|
||||||
|
private List<IpRegion> ipRegionList;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "数值域分组列表", required = true)
|
||||||
|
private List<NumRegion> numRegionList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return service
|
||||||
|
*/
|
||||||
|
public Integer getService() {
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param service
|
||||||
|
* 要设置的 service
|
||||||
|
*/
|
||||||
|
public void setService(Integer service) {
|
||||||
|
this.service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return strRegionList
|
||||||
|
*/
|
||||||
|
public List<StrRegion> getStrRegionList() {
|
||||||
|
return strRegionList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param strRegionList
|
||||||
|
* 要设置的 strRegionList
|
||||||
|
*/
|
||||||
|
public void setStrRegionList(List<StrRegion> strRegionList) {
|
||||||
|
this.strRegionList = strRegionList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ipRegionList
|
||||||
|
*/
|
||||||
|
public List<IpRegion> getIpRegionList() {
|
||||||
|
return ipRegionList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ipRegionList
|
||||||
|
* 要设置的 ipRegionList
|
||||||
|
*/
|
||||||
|
public void setIpRegionList(List<IpRegion> ipRegionList) {
|
||||||
|
this.ipRegionList = ipRegionList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return numRegionList
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "数值域分组列表", required = true)
|
||||||
|
public List<NumRegion> getNumRegionList() {
|
||||||
|
return numRegionList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param numRegionList
|
||||||
|
* 要设置的 numRegionList
|
||||||
|
*/
|
||||||
|
public void setNumRegionList(List<NumRegion> numRegionList) {
|
||||||
|
this.numRegionList = numRegionList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
119
src/main/java/com/nis/domain/restful/GroupReuseSource.java
Normal file
119
src/main/java/com/nis/domain/restful/GroupReuseSource.java
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/**
|
||||||
|
* @Title: ConfigSource.java
|
||||||
|
* @Package com.nis.domain.restful
|
||||||
|
* @Description: TODO(用一句话描述该文件做什么)
|
||||||
|
* @author (darnell)
|
||||||
|
* @date 2016年8月29日 下午9:31:24
|
||||||
|
* @version V1.0
|
||||||
|
*/
|
||||||
|
package com.nis.domain.restful;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.nis.util.JsonDateDeserializer;
|
||||||
|
import com.nis.util.JsonDateSerializer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName:RegionRepeatSource
|
||||||
|
* @Description:TODO(这里用一句话描述这个类的作用)
|
||||||
|
* @author (zdx)
|
||||||
|
* @date 2018年8月22日 下午7:03:36
|
||||||
|
* @version V1.0
|
||||||
|
*/
|
||||||
|
public class GroupReuseSource extends ConfigCommonSource{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -7543263486915343526L;
|
||||||
|
private static final String DEFAULT_VERSION = "1.0";
|
||||||
|
private List<GroupReuse> groupReuseList; //分组复用域配置列表
|
||||||
|
/**
|
||||||
|
* @Title:
|
||||||
|
* @Description: TODO
|
||||||
|
* @param
|
||||||
|
*/
|
||||||
|
public GroupReuseSource() {
|
||||||
|
this.version = DEFAULT_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupReuseSource(String Version) {
|
||||||
|
this.version = Version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return version
|
||||||
|
*/
|
||||||
|
public String getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param version 要设置的 version
|
||||||
|
*/
|
||||||
|
public void setVersion(String version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return operator
|
||||||
|
*/
|
||||||
|
public String getOperator() {
|
||||||
|
return operator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param operator 要设置的 operator
|
||||||
|
*/
|
||||||
|
public void setOperator(String operator) {
|
||||||
|
this.operator = operator;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return opTime
|
||||||
|
*/
|
||||||
|
@JsonSerialize(using=JsonDateSerializer.class)
|
||||||
|
public Date getOpTime() {
|
||||||
|
return opTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param opTime 要设置的 opTime
|
||||||
|
*/
|
||||||
|
@JsonDeserialize(using=JsonDateDeserializer.class)
|
||||||
|
public void setOpTime(Date opTime) {
|
||||||
|
this.opTime = opTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return opAction
|
||||||
|
*/
|
||||||
|
public Integer getOpAction() {
|
||||||
|
return opAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param opAction 要设置的 opAction
|
||||||
|
*/
|
||||||
|
public void setOpAction(Integer opAction) {
|
||||||
|
this.opAction = opAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the groupReuseList
|
||||||
|
*/
|
||||||
|
public List<GroupReuse> getGroupReuseList() {
|
||||||
|
return groupReuseList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param groupReuseList the groupReuseList to set
|
||||||
|
*/
|
||||||
|
public void setGroupReuseList(List<GroupReuse> groupReuseList) {
|
||||||
|
this.groupReuseList = groupReuseList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -113,6 +113,11 @@ public enum RestBusinessCode {
|
|||||||
*/
|
*/
|
||||||
IsValidIsNull(4001013, "配置isValid属性不能为空"),
|
IsValidIsNull(4001013, "配置isValid属性不能为空"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MAAT配置的域配置信息不能全为空
|
||||||
|
*/
|
||||||
|
RegionListIsNull(4001014, "MAAT配置的域配置信息不能全为空"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编译配置的groupNum不能为空
|
* 编译配置的groupNum不能为空
|
||||||
*/
|
*/
|
||||||
@@ -414,7 +419,14 @@ public enum RestBusinessCode {
|
|||||||
*/
|
*/
|
||||||
CfdsLevelIsWrongRange(4002500,"摘要域-cfdsLevel的值只能是1到10"),
|
CfdsLevelIsWrongRange(4002500,"摘要域-cfdsLevel的值只能是1到10"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* service不能为空并且必须是分组复用的业务类型
|
||||||
|
*/
|
||||||
|
ServiceIsNullOrNotReuse(4002501, "service不能为空并且必须是分组复用的业务类型"),
|
||||||
|
/**
|
||||||
|
* 分组复用配置中域不能全为空
|
||||||
|
*/
|
||||||
|
ReuseRegionIsNull(4002501, "分组复用配置中域不能全为空"),
|
||||||
//回调类
|
//回调类
|
||||||
/**
|
/**
|
||||||
* 回调类service配置不正确
|
* 回调类service配置不正确
|
||||||
|
|||||||
@@ -132,7 +132,8 @@ public class CompileVal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//只有分组复用的业务类型,域可以不埴写,其他的maat配置至少填写一个域配置
|
||||||
|
Boolean hasRegionFlag = false;
|
||||||
List<Long> regionGroupIdList = new ArrayList<Long>();// 所有域配置中groupId的集合,不重复
|
List<Long> regionGroupIdList = new ArrayList<Long>();// 所有域配置中groupId的集合,不重复
|
||||||
List<NumRegion> numRegionList = configCompile.getNumRegionList();
|
List<NumRegion> numRegionList = configCompile.getNumRegionList();
|
||||||
if (numRegionList == null) {
|
if (numRegionList == null) {
|
||||||
@@ -142,6 +143,7 @@ public class CompileVal {
|
|||||||
RestBusinessCode.NumRegionIsNull.getValue());
|
RestBusinessCode.NumRegionIsNull.getValue());
|
||||||
}
|
}
|
||||||
if (numRegionList.size() > 0) {
|
if (numRegionList.size() > 0) {
|
||||||
|
hasRegionFlag = true;
|
||||||
for (NumRegion numRegion : numRegionList) {
|
for (NumRegion numRegion : numRegionList) {
|
||||||
// if (configCompile.getIsValid() != 0 &&
|
// if (configCompile.getIsValid() != 0 &&
|
||||||
// !regionGroupIdList.contains(numRegion.getGroupId())) {
|
// !regionGroupIdList.contains(numRegion.getGroupId())) {
|
||||||
@@ -194,6 +196,7 @@ public class CompileVal {
|
|||||||
RestBusinessCode.StrRegionIsNull.getValue());
|
RestBusinessCode.StrRegionIsNull.getValue());
|
||||||
}
|
}
|
||||||
if (strRegionList != null && strRegionList.size() > 0) {
|
if (strRegionList != null && strRegionList.size() > 0) {
|
||||||
|
hasRegionFlag = true;
|
||||||
for (StrRegion strRegion : strRegionList) {
|
for (StrRegion strRegion : strRegionList) {
|
||||||
// if (configCompile.getIsValid() != 0 &&
|
// if (configCompile.getIsValid() != 0 &&
|
||||||
// !regionGroupIdList.contains(strRegion.getGroupId())) {
|
// !regionGroupIdList.contains(strRegion.getGroupId())) {
|
||||||
@@ -248,6 +251,7 @@ public class CompileVal {
|
|||||||
RestBusinessCode.IpRegionIsNull.getValue());
|
RestBusinessCode.IpRegionIsNull.getValue());
|
||||||
}
|
}
|
||||||
if (ipRegionList != null && ipRegionList.size() > 0) {
|
if (ipRegionList != null && ipRegionList.size() > 0) {
|
||||||
|
hasRegionFlag = true;
|
||||||
for (IpRegion ipRegion : ipRegionList) {
|
for (IpRegion ipRegion : ipRegionList) {
|
||||||
// if (configCompile.getIsValid() != 0 &&
|
// if (configCompile.getIsValid() != 0 &&
|
||||||
// !regionGroupIdList.contains(ipRegion.getGroupId())) {
|
// !regionGroupIdList.contains(ipRegion.getGroupId())) {
|
||||||
@@ -295,6 +299,7 @@ public class CompileVal {
|
|||||||
|
|
||||||
// 验证
|
// 验证
|
||||||
if (digestRegionList != null && digestRegionList.size() > 0) {
|
if (digestRegionList != null && digestRegionList.size() > 0) {
|
||||||
|
hasRegionFlag = true;
|
||||||
for (DigestRegion digestRegion : digestRegionList) {
|
for (DigestRegion digestRegion : digestRegionList) {
|
||||||
|
|
||||||
// 不验证表名和业务类型是否对应
|
// 不验证表名和业务类型是否对应
|
||||||
@@ -335,6 +340,7 @@ public class CompileVal {
|
|||||||
List<IpRegion> ipClientRangeList = configCompile.getIpClientRangeList();
|
List<IpRegion> ipClientRangeList = configCompile.getIpClientRangeList();
|
||||||
|
|
||||||
if (ipClientRangeList != null && ipClientRangeList.size() > 0) {
|
if (ipClientRangeList != null && ipClientRangeList.size() > 0) {
|
||||||
|
hasRegionFlag = true;
|
||||||
for (IpRegion ipRegion : ipClientRangeList) {
|
for (IpRegion ipRegion : ipClientRangeList) {
|
||||||
// if (configCompile.getIsValid() != 0 &&
|
// if (configCompile.getIsValid() != 0 &&
|
||||||
// !regionGroupIdList.contains(ipRegion.getGroupId())) {
|
// !regionGroupIdList.contains(ipRegion.getGroupId())) {
|
||||||
@@ -376,6 +382,10 @@ public class CompileVal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!hasRegionFlag&&!ServiceAndRDBIndexReal.serviceIsReuse(configCompile.getService())) {
|
||||||
|
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的业务类型属于分组复用,域配置信息不能全为空",RestBusinessCode.RegionListIsNull.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
551
src/main/java/com/nis/util/GroupReuseVal.java
Normal file
551
src/main/java/com/nis/util/GroupReuseVal.java
Normal file
@@ -0,0 +1,551 @@
|
|||||||
|
package com.nis.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.nis.domain.restful.GroupReuse;
|
||||||
|
import com.nis.domain.restful.IpRegion;
|
||||||
|
import com.nis.domain.restful.NumRegion;
|
||||||
|
import com.nis.domain.restful.StrRegion;
|
||||||
|
import com.nis.restful.RestBusinessCode;
|
||||||
|
import com.nis.restful.RestServiceException;
|
||||||
|
import com.nis.restful.ServiceRuntimeException;
|
||||||
|
import com.nis.web.service.restful.ConfigSourcesService;
|
||||||
|
|
||||||
|
public class GroupReuseVal {
|
||||||
|
|
||||||
|
public static void valGroupReuse(List<GroupReuse> groupReuseList,
|
||||||
|
Boolean isUpdate) throws Exception {
|
||||||
|
for (GroupReuse groupReuse : groupReuseList) {
|
||||||
|
Integer service = groupReuse.getService();
|
||||||
|
if (StringUtil.isEmpty(service)
|
||||||
|
|| !ServiceAndRDBIndexReal.serviceIsReuse(service)) {
|
||||||
|
throw new RestServiceException("server为空或" + service
|
||||||
|
+ "或不属于分组复用的业务类型",
|
||||||
|
RestBusinessCode.ServiceIsNullOrNotReuse.getValue());
|
||||||
|
}
|
||||||
|
Map<String, List<String>> regTabNameMap = ServiceAndRDBIndexReal
|
||||||
|
.getServiceGroupReuseMap(service);
|
||||||
|
// 验证各类型域配置
|
||||||
|
Boolean hasRegionFlag = false;
|
||||||
|
if (regTabNameMap.containsKey("numRegion")
|
||||||
|
&& !StringUtil.isEmpty(groupReuse.getNumRegionList())
|
||||||
|
&& groupReuse.getNumRegionList().size() > 0) {
|
||||||
|
hasRegionFlag = true;
|
||||||
|
List<NumRegion> numRegionList = groupReuse.getNumRegionList();
|
||||||
|
for (NumRegion numRegion : numRegionList) {
|
||||||
|
if (!StringUtil.isEmpty(numRegion.getTableName())
|
||||||
|
&& !CompileVal.type2TableNameIsOk(service,
|
||||||
|
numRegion.getTableName())) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的配置中numRegionList中的regionId为"
|
||||||
|
+ numRegion.getRegionId()
|
||||||
|
+ "的域配置tableName与业务类型不一致",
|
||||||
|
RestBusinessCode.TableNameUnmatchService
|
||||||
|
.getValue());
|
||||||
|
}
|
||||||
|
if (!isUpdate && numRegion.getIsValid() != 1) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的配置中numRegionList中的regionId为"
|
||||||
|
+ numRegion.getRegionId() + "的域配置在添加时不能为无效",
|
||||||
|
RestBusinessCode.IsValidIsT.getValue());
|
||||||
|
}
|
||||||
|
if (isUpdate && numRegion.getIsValid() != 0) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的配置中numRegionList中的regionId为"
|
||||||
|
+ numRegion.getRegionId() + "的域配置在修改时不能为有效",
|
||||||
|
RestBusinessCode.IsValidIsF.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isUpdate && Constants.BASE_VALIDATE) {
|
||||||
|
valNumRegion(numRegion, service);
|
||||||
|
}
|
||||||
|
if (!isUpdate && Constants.SERVICE_VALIDATE) {
|
||||||
|
serviceNumRegionVal(numRegion, service);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (regTabNameMap.containsKey("strRegion")
|
||||||
|
&& !StringUtil.isEmpty(groupReuse.getStrRegionList())
|
||||||
|
&& groupReuse.getStrRegionList().size() > 0) {
|
||||||
|
hasRegionFlag = true;
|
||||||
|
List<StrRegion> strRegionList = groupReuse.getStrRegionList();
|
||||||
|
for (StrRegion strRegion : strRegionList) {
|
||||||
|
// if (groupReuse.getIsValid() != 0 &&
|
||||||
|
// !regionGroupIdList.contains(strRegion.getGroupId()))
|
||||||
|
// {
|
||||||
|
if (!StringUtil.isEmpty(strRegion.getTableName())
|
||||||
|
&& !CompileVal.type2TableNameIsOk(service,
|
||||||
|
strRegion.getTableName())) {
|
||||||
|
throw new RestServiceException("配置id为" + service
|
||||||
|
+ "的配置中strRegionList中的regionId为"
|
||||||
|
+ strRegion.getRegionId()
|
||||||
|
+ "的域配置tableName与业务类型不一致",
|
||||||
|
RestBusinessCode.TableNameUnmatchService
|
||||||
|
.getValue());
|
||||||
|
}
|
||||||
|
if (!isUpdate && strRegion.getIsValid() != 1) {
|
||||||
|
throw new RestServiceException("配置id为" + service
|
||||||
|
+ "的配置中strRegionList中的regionId为"
|
||||||
|
+ strRegion.getRegionId() + "的域配置在添加时不能为无效",
|
||||||
|
RestBusinessCode.IsValidIsT.getValue());
|
||||||
|
}
|
||||||
|
if (isUpdate && strRegion.getIsValid() != 0) {
|
||||||
|
throw new RestServiceException("配置id为" + service
|
||||||
|
+ "的配置中strRegionList中的regionId为"
|
||||||
|
+ strRegion.getRegionId() + "的域配置在修改时不能为有效",
|
||||||
|
RestBusinessCode.IsValidIsF.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isUpdate && Constants.BASE_VALIDATE) {
|
||||||
|
valStrRegion(strRegion, service,
|
||||||
|
ConfigSourcesService.isStrStrongRegion(
|
||||||
|
strRegion.getTableName(), service));
|
||||||
|
}
|
||||||
|
if (!isUpdate && Constants.SERVICE_VALIDATE) {
|
||||||
|
serviceStrRegionVal(strRegion, service,
|
||||||
|
ConfigSourcesService.isStrStrongRegion(
|
||||||
|
strRegion.getTableName(), service));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (regTabNameMap.containsKey("ipRegion")
|
||||||
|
&& !StringUtil.isEmpty(groupReuse.getIpRegionList())
|
||||||
|
&& groupReuse.getIpRegionList().size() > 0) {
|
||||||
|
hasRegionFlag = true;
|
||||||
|
List<IpRegion> ipRegionList = groupReuse.getIpRegionList();
|
||||||
|
for (IpRegion ipRegion : ipRegionList) {
|
||||||
|
// if (groupReuse.getIsValid() != 0 &&
|
||||||
|
// !regionGroupIdList.contains(ipRegion.getGroupId())) {
|
||||||
|
if (!StringUtil.isEmpty(ipRegion.getTableName())
|
||||||
|
&& !CompileVal.type2TableNameIsOk(service,
|
||||||
|
ipRegion.getTableName())) {
|
||||||
|
throw new RestServiceException("配置id为" + service
|
||||||
|
+ "的配置中ipRegionList中的regionId为"
|
||||||
|
+ ipRegion.getRegionId()
|
||||||
|
+ "的域配置tableName与业务类型不一致",
|
||||||
|
RestBusinessCode.TableNameUnmatchService
|
||||||
|
.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isUpdate
|
||||||
|
&& (null == ipRegion.getIsValid() || ipRegion
|
||||||
|
.getIsValid() != 1)) {
|
||||||
|
throw new RestServiceException("配置id为" + service
|
||||||
|
+ "的配置中ipRegionList中的regionId为"
|
||||||
|
+ ipRegion.getRegionId() + "的域配置在添加时不能为无效",
|
||||||
|
RestBusinessCode.IsValidIsT.getValue());
|
||||||
|
}
|
||||||
|
if (isUpdate
|
||||||
|
&& (null == ipRegion.getIsValid() || ipRegion
|
||||||
|
.getIsValid() != 0)) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的配置中ipRegionList中的regionId为"
|
||||||
|
+ ipRegion.getRegionId() + "的域配置在修改时不能为有效",
|
||||||
|
RestBusinessCode.IsValidIsF.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isUpdate && Constants.BASE_VALIDATE) {
|
||||||
|
valIpRegion(ipRegion, service);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isUpdate && Constants.SERVICE_VALIDATE) {
|
||||||
|
serviceIpRegionVal(ipRegion, service, "ipRegionList");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasRegionFlag) {
|
||||||
|
// 所有的域类型都不包括,可能是配置文件配错了
|
||||||
|
throw new ServiceRuntimeException("service为" + service + "的"
|
||||||
|
+ RestBusinessCode.ReuseRegionIsNull.getErrorReason(),
|
||||||
|
RestBusinessCode.ReuseRegionIsNull.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void valIpRegion(IpRegion ipRegion, Integer service) {
|
||||||
|
Long regionId = ipRegion.getRegionId();
|
||||||
|
if (null == regionId) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的ip类域配置的regionId不能为空",
|
||||||
|
RestBusinessCode.RegionIdIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (null == ipRegion.getGroupId()) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的ip类域配置id为" + regionId + "的配置groupId不能为空",
|
||||||
|
RestBusinessCode.RegionsGroupIdIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (null == ipRegion.getAddrType()) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的ip类域配置id为" + regionId + "的配置addrType不能为空",
|
||||||
|
RestBusinessCode.AddrTypeIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (null == ipRegion.getSrcIp() || ipRegion.getSrcIp().equals("")) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的ip类域配置id为" + regionId + "的配置srcIp不能为空",
|
||||||
|
RestBusinessCode.SrcIpIsNull.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null == ipRegion.getMaskSrcIp()
|
||||||
|
|| ipRegion.getMaskSrcIp().equals("")) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的ip类域配置id为" + regionId + "的配置maskSrcIp不能为空",
|
||||||
|
RestBusinessCode.MaskSrcIpIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (null == ipRegion.getSrcPort() || ipRegion.getSrcPort().equals("")) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的ip类域配置id为" + regionId + "的配置srcPort不能为空",
|
||||||
|
RestBusinessCode.SrcPortIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (null == ipRegion.getMaskSrcPort()
|
||||||
|
|| ipRegion.getMaskSrcPort().equals("")) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的ip类域配置id为" + regionId + "的配置maskSrcPort不能为空",
|
||||||
|
RestBusinessCode.MaskSrcPortIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (null == ipRegion.getDstIp() || ipRegion.getDstIp().equals("")) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的ip类域配置id为" + regionId + "的配置dstIp不能为空",
|
||||||
|
RestBusinessCode.DstIpIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (null == ipRegion.getMaskDstIp()
|
||||||
|
|| ipRegion.getMaskDstIp().equals("")) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的ip类域配置id为" + regionId + "的配置maskDstIp不能为空",
|
||||||
|
RestBusinessCode.MaskDstIpIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (null == ipRegion.getDstPort() || ipRegion.getDstPort().equals("")) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的ip类域配置id为" + regionId + "的配置dstPort不能为空",
|
||||||
|
RestBusinessCode.DstPortIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (null == ipRegion.getMaskDstPort()
|
||||||
|
|| ipRegion.getMaskDstPort().equals("")) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的ip类域配置id为" + regionId + "的配置maskDstPort不能为空",
|
||||||
|
RestBusinessCode.MaskDstPortIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (null == ipRegion.getProtocol()) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的ip类域配置id为" + regionId + "的配置protocol不能为空",
|
||||||
|
RestBusinessCode.ProtocolIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (null == ipRegion.getDirection()) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的ip类域配置id为" + regionId + "的配置direction不能为空",
|
||||||
|
RestBusinessCode.DirectionIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (null == ipRegion.getIsValid()) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的ip类域配置id为" + regionId + "的配置isValid不能为空",
|
||||||
|
RestBusinessCode.IsValidIsNull.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void valNumRegion(NumRegion numRegion, Integer service)
|
||||||
|
throws Exception {
|
||||||
|
Long regionId = numRegion.getRegionId();
|
||||||
|
if (null == regionId) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的数值类域配置的regionId不能为空",
|
||||||
|
RestBusinessCode.RegionIdIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (null == numRegion.getGroupId()) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的数值类域配置id为" + regionId + "的配置groupId不能为空",
|
||||||
|
RestBusinessCode.RegionsGroupIdIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (null == numRegion.getLowBoundary()) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的数值类域配置id为" + regionId + "的配置lowBoundary不能为空",
|
||||||
|
RestBusinessCode.LowBoundaryIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (null == numRegion.getUpBoundary()) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的数值类域配置id为" + regionId + "的配置upBoundary不能为空",
|
||||||
|
RestBusinessCode.UpBoundaryIsNull.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void valStrRegion(StrRegion strRegion, Integer service,
|
||||||
|
boolean isDirtrict) throws Exception {
|
||||||
|
Long regionId = strRegion.getRegionId();
|
||||||
|
if (null == regionId) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的字符串类域配置的regionId不能为空",
|
||||||
|
RestBusinessCode.RegionIdIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (null == strRegion.getGroupId()) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的字符串类域配置id为" + regionId + "的配置groupId不能为空",
|
||||||
|
RestBusinessCode.RegionsGroupIdIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (isDirtrict
|
||||||
|
&& (null == strRegion.getDistrict() || strRegion.getDistrict()
|
||||||
|
.equals(""))) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的字符串类域配置id为" + regionId + "的配置district不能为空",
|
||||||
|
RestBusinessCode.DistrictIsNull.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null == strRegion.getKeywords()
|
||||||
|
|| strRegion.getKeywords().equals("")) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的字符串类域配置id为" + regionId + "的配置keywords不能为空",
|
||||||
|
RestBusinessCode.KeywordsIsNull.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null == strRegion.getExprType()) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的字符串类域配置id为" + regionId + "的配置exprType不能为空",
|
||||||
|
RestBusinessCode.ExprTypeIsNull.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null == strRegion.getMatchMethod()) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的字符串类域配置id为" + regionId + "的配置matchMethod不能为空",
|
||||||
|
RestBusinessCode.MatchMethodIsNull.getValue());
|
||||||
|
}
|
||||||
|
if (null == strRegion.getIsHexbin()) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的中的字符串类域配置id为" + regionId + "的配置isHexbin不能为空",
|
||||||
|
RestBusinessCode.MatchMethodIsNull.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void validateIpAndMask(IpRegion ipRegion, Integer service,
|
||||||
|
String listName) throws Exception {
|
||||||
|
// 源IP信息和目的IP信息格式s为IPV4或IPV6
|
||||||
|
if (ipRegion.getAddrType().intValue() == 4
|
||||||
|
|| ipRegion.getAddrType().intValue() == 6) {
|
||||||
|
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getSrcIp(),
|
||||||
|
ipRegion.getAddrType())) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置srcIp的格式不正确或与addrType不一致",
|
||||||
|
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||||
|
}
|
||||||
|
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskSrcIp(),
|
||||||
|
ipRegion.getAddrType())) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置maskSrcIp的格式不正确或与addrType不一致",
|
||||||
|
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||||
|
}
|
||||||
|
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getDstIp(),
|
||||||
|
ipRegion.getAddrType())) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置dstIp的格式不正确或与addrType不一致",
|
||||||
|
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||||
|
}
|
||||||
|
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskDstIp(),
|
||||||
|
ipRegion.getAddrType())) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置maskDstIp的格式不正确或与addrType不一致",
|
||||||
|
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||||
|
}
|
||||||
|
} else if (ipRegion.getAddrType().intValue() == 46) {// 4OVER6:源IP信息格式为IPV4、目的IP信息格式IPV6
|
||||||
|
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getSrcIp(), 4)) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置srcIp的格式不正确或与addrType不一致",
|
||||||
|
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||||
|
}
|
||||||
|
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskSrcIp(), 4)) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置maskSrcIp的格式不正确或与addrType不一致",
|
||||||
|
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||||
|
}
|
||||||
|
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getDstIp(), 6)) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置dstIp的格式不正确或与addrType不一致",
|
||||||
|
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||||
|
}
|
||||||
|
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskDstIp(), 6)) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置maskDstIp的格式不正确或与addrType不一致",
|
||||||
|
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||||
|
}
|
||||||
|
} else if (ipRegion.getAddrType().intValue() == 64) {// 6OVER4:源IP信息格式为IPV6、目的IP信息格式IPV4
|
||||||
|
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getSrcIp(), 6)) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置srcIp的格式不正确或与addrType不一致",
|
||||||
|
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||||
|
}
|
||||||
|
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskSrcIp(), 6)) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置maskSrcIp的格式不正确或与addrType不一致",
|
||||||
|
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||||
|
}
|
||||||
|
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getDstIp(), 4)) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置dstIp的格式不正确或与addrType不一致",
|
||||||
|
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||||
|
}
|
||||||
|
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskDstIp(), 4)) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置maskDstIp的格式不正确或与addrType不一致",
|
||||||
|
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||||
|
}
|
||||||
|
} else if (ipRegion.getAddrType().intValue() == 10) {// all:符合IP格式即可
|
||||||
|
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getSrcIp(), null)) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置srcIp的格式不正确或与addrType不一致",
|
||||||
|
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||||
|
}
|
||||||
|
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskSrcIp(), null)) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置maskSrcIp的格式不正确或与addrType不一致",
|
||||||
|
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||||
|
}
|
||||||
|
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getDstIp(), null)) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置dstIp的格式不正确或与addrType不一致",
|
||||||
|
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||||
|
}
|
||||||
|
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskDstIp(), null)) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置maskDstIp的格式不正确或与addrType不一致",
|
||||||
|
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void serviceIpRegionVal(IpRegion ipRegion, Integer service,
|
||||||
|
String listName) throws Exception {
|
||||||
|
|
||||||
|
validateIpAndMask(ipRegion, service, listName);
|
||||||
|
|
||||||
|
if (!BasicProvingUtil.isPortOrPortMask(ipRegion.getSrcPort())) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置srcPort的格式不正确",
|
||||||
|
RestBusinessCode.PortIsNotVal.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!BasicProvingUtil.isPortOrPortMask(ipRegion.getMaskSrcPort())) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置maskSrcPort的格式不正确",
|
||||||
|
RestBusinessCode.PortIsNotVal.getValue());
|
||||||
|
}
|
||||||
|
if (!BasicProvingUtil.isPortOrPortMask(ipRegion.getDstPort())) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置dstPort的格式不正确",
|
||||||
|
RestBusinessCode.PortIsNotVal.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!BasicProvingUtil.isPortOrPortMask(ipRegion.getMaskDstPort())) {
|
||||||
|
// if (!BasicProvingUtil.isIntType(ipRegion.getMaskDstPort())) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置maskDstPort的格式不正确",
|
||||||
|
RestBusinessCode.PortIsNotVal.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ipRegion.getSrcIp().equals(ipRegion.getDstIp())) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置srcIp和dstIp不能相同",
|
||||||
|
RestBusinessCode.SrcIpEQDstIp.getValue());
|
||||||
|
}
|
||||||
|
if (ipRegion.getDirection() != 1 && ipRegion.getDirection() != 0) {
|
||||||
|
throw new RestServiceException("service为" + service + "的配置中"
|
||||||
|
+ listName + "中regionId为" + ipRegion.getRegionId()
|
||||||
|
+ "的域配置direction的值不正确,只能是0或1",
|
||||||
|
RestBusinessCode.DirectionIsWrongRange.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
// zdx protocol验证?
|
||||||
|
// if (ipRegion.getTableName().toLowerCase().equals("dj_ip_port")) {
|
||||||
|
// if (ipRegion.getProtocol() < 0 || ipRegion.getProtocol() > 255) {
|
||||||
|
// return "service为" + service + "的配置中"+listName+"中regionId为" +
|
||||||
|
// ipRegion.getRegionId()
|
||||||
|
// + "的域配置tableName为dj_ip_port时,protocol的取值范围只能是0-255";
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// if (ipRegion.getProtocol() != 0) {
|
||||||
|
// return "service为" + service + "的配置中"+listName+"中regionId为" +
|
||||||
|
// ipRegion.getRegionId() + "的域配置tableName为"
|
||||||
|
// + ipRegion.getTableName() + "时,protocol的值只能是0";
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void serviceNumRegionVal(NumRegion numRegion, Integer service)
|
||||||
|
throws Exception {
|
||||||
|
Long lowBoundary = numRegion.getLowBoundary();
|
||||||
|
Long upBoundary = numRegion.getUpBoundary();
|
||||||
|
if (lowBoundary <= upBoundary) {
|
||||||
|
if (lowBoundary > 4294967295l || lowBoundary < 0l) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的配置中numRegionList中regionId为"
|
||||||
|
+ numRegion.getRegionId()
|
||||||
|
+ "的域配置lowBoundary的值不能大于2的32次方减一(4294967295)或者小于0",
|
||||||
|
RestBusinessCode.LowBoundaryIsWrongRange.getValue());
|
||||||
|
}
|
||||||
|
if (upBoundary > 4294967295l || upBoundary < 0l) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的配置中numRegionList中regionId为"
|
||||||
|
+ numRegion.getRegionId()
|
||||||
|
+ "的域配置upBoundary的值不能大于2的32次方减一(4294967295)或者小于0",
|
||||||
|
RestBusinessCode.UpBoundaryIsWrongRange.getValue());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的配置中numRegionList中regionId为" + numRegion.getRegionId()
|
||||||
|
+ "的域配置lowBoundary的值大于upBoundary,应该是小于或等于",
|
||||||
|
RestBusinessCode.LowBoundaryGTUpBoundary.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void serviceStrRegionVal(StrRegion strRegion,
|
||||||
|
Integer service, boolean isDirtrict) throws Exception {
|
||||||
|
|
||||||
|
Integer exprType = strRegion.getExprType();
|
||||||
|
Integer matchMethod = strRegion.getMatchMethod();
|
||||||
|
Integer isHexbin = strRegion.getIsHexbin();
|
||||||
|
if (exprType != 0 && exprType != 1) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的配置中strRegionList中regionId为" + strRegion.getRegionId()
|
||||||
|
+ "的域配置exprType的值只能是0(无表达式)或者1(与表达式)",
|
||||||
|
RestBusinessCode.ExprTypeIsWrongRange.getValue());
|
||||||
|
}
|
||||||
|
if (matchMethod != 0 && matchMethod != 1 && matchMethod != 2
|
||||||
|
&& matchMethod != 3) {
|
||||||
|
throw new RestServiceException("service为" + service
|
||||||
|
+ "的配置中strRegionList中regionId为" + strRegion.getRegionId()
|
||||||
|
+ "的域配置matchMethod的值只能是0(子串匹配),1(右匹配),2(左匹配),3(完全匹配)",
|
||||||
|
RestBusinessCode.MatchMethodIsWrongRange.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHexbin != 0 && isHexbin != 1 && isHexbin != 2) {
|
||||||
|
throw new RestServiceException(
|
||||||
|
"service为"
|
||||||
|
+ service
|
||||||
|
+ "的配置中strRegionList中regionId为"
|
||||||
|
+ strRegion.getRegionId()
|
||||||
|
+ "的域配置isHexbin的值只能是0(大小写不敏感,且非HEX)或者1(HEX)或者2(大小写敏感,且非HEX)",
|
||||||
|
RestBusinessCode.IsHexbinIsWrongRange.getValue());
|
||||||
|
}
|
||||||
|
// strRegProhibitConfigWord(strRegion,service);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -26,8 +26,9 @@ public class ServiceAndRDBIndexReal {
|
|||||||
private static Logger logger = LoggerFactory.getLogger(ServiceAndRDBIndexReal.class);
|
private static Logger logger = LoggerFactory.getLogger(ServiceAndRDBIndexReal.class);
|
||||||
/**
|
/**
|
||||||
* 记录哪些service可以被分组复用(只有maat类配置可以被分组复用)
|
* 记录哪些service可以被分组复用(只有maat类配置可以被分组复用)
|
||||||
|
* Map<Service,Map<regionName,List<tableName>>
|
||||||
*/
|
*/
|
||||||
private static Set<Integer> serviceRepeatedRealSet = new HashSet<Integer>();
|
private static Map<Integer,Map<String, List<String>>> serviceGroupReuseMap = new HashMap<Integer, Map<String,List<String>>>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 第一个key是业务类型,第二个key是type(编译配置,分组配置,域配置)value是表名
|
* 第一个key是业务类型,第二个key是type(编译配置,分组配置,域配置)value是表名
|
||||||
@@ -64,35 +65,26 @@ public class ServiceAndRDBIndexReal {
|
|||||||
if (unMaatService != null && !unMaatService.trim().equals("")) {
|
if (unMaatService != null && !unMaatService.trim().equals("")) {
|
||||||
String[] split = unMaatService.split(";");
|
String[] split = unMaatService.split(";");
|
||||||
for (String str : split) {
|
for (String str : split) {
|
||||||
// 回调类删除action zdx20180821
|
String[] serviceAction = str.split(":");
|
||||||
// String[] serviceAction = str.split(":");
|
if (serviceAction.length==2) {
|
||||||
// serviceActionMap.put(Integer.valueOf(serviceAction[0]),
|
serviceActionMap.put(Integer.valueOf(serviceAction[0]),
|
||||||
// Integer.valueOf(serviceAction[1]));
|
Integer.valueOf(serviceAction[1]));
|
||||||
//
|
}else{
|
||||||
// String serviceType = Configurations.getStringProperty(serviceAction[0], "");
|
serviceActionMap.put(Integer.valueOf(serviceAction[0]),
|
||||||
// if (serviceType != null && !serviceType.trim().equals("")) {
|
null);
|
||||||
// String[] typeArrs = serviceType.split(";");
|
}
|
||||||
// for (String typeStr : typeArrs) {
|
String serviceType = Configurations.getStringProperty(serviceAction[0], "");
|
||||||
// String[] typeArr = typeStr.split(":");
|
if (serviceType != null && !serviceType.trim().equals("")) {
|
||||||
// String tableNameArr[] = typeArr[1].split(",");
|
String[] typeArrs = serviceType.split(";");
|
||||||
// for (String tableName : tableNameArr) {
|
for (String typeStr : typeArrs) {
|
||||||
// unMaatSercieNameMap.put(Integer.parseInt(serviceAction[0]),
|
String[] typeArr = typeStr.split(":");
|
||||||
// tableName.toUpperCase());
|
String tableNameArr[] = typeArr[1].split(",");
|
||||||
// }
|
for (String tableName : tableNameArr) {
|
||||||
// }
|
unMaatSercieNameMap.put(Integer.parseInt(serviceAction[0]),
|
||||||
// }
|
tableName.toUpperCase());
|
||||||
|
}
|
||||||
String serviceType = Configurations.getStringProperty(str, "");
|
}
|
||||||
if (serviceType != null && !serviceType.trim().equals("")) {
|
}
|
||||||
String[] typeArrs = serviceType.split(";");
|
|
||||||
for (String typeStr : typeArrs) {
|
|
||||||
String[] typeArr = typeStr.split(":");
|
|
||||||
String tableNameArr[] = typeArr[1].split(",");
|
|
||||||
for (String tableName : tableNameArr) {
|
|
||||||
unMaatSercieNameMap.put(Integer.parseInt(str), tableName.toUpperCase());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,13 +157,25 @@ public class ServiceAndRDBIndexReal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String serviceRepeatedReal = Configurations.getStringProperty("serviceRepeatedReal", "");
|
String serviceRepeatedReal = Configurations.getStringProperty("serviceRepeatedReal", "");
|
||||||
if (serviceRepeatedReal != null && !serviceRepeatedReal.trim().equals("")) {
|
if (!StringUtil.isEmpty(serviceRepeatedReal)) {
|
||||||
String[] serviceRepeatedRealArr = serviceRepeatedReal.split(",");
|
String[] serviceRepeatedRealArr = serviceRepeatedReal.split(";");
|
||||||
for (String ser : serviceRepeatedRealArr) {
|
for (String serviceRepeated : serviceRepeatedRealArr) {
|
||||||
if (ser != null && !ser.trim().equals("")) {
|
String [] serInfos = serviceRepeated.split(":");
|
||||||
serviceRepeatedRealSet.add(Integer.parseInt(ser));
|
String [] regionInfos = serInfos[1].split("[|]");
|
||||||
|
for (String regionInfo : regionInfos) {
|
||||||
|
String [] regionTabName = regionInfo.split("@");
|
||||||
|
String [] tableNames = regionTabName[1].split(",");
|
||||||
|
for (String tableName : tableNames) {
|
||||||
|
if(serviceGroupReuseMap.containsKey(Integer.valueOf(serInfos[0]))){
|
||||||
|
serviceGroupReuseMap.get(Integer.valueOf(serInfos[0])).get(regionTabName[0]).add(tableName);
|
||||||
|
}else{
|
||||||
|
Map<String,List<String>> regTabMap = new HashMap<String, List<String>>();
|
||||||
|
List<String> tabList = new ArrayList<String>();
|
||||||
|
tabList.add(tableName);
|
||||||
|
regTabMap.put(regionTabName[0], tabList);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -325,12 +329,12 @@ public class ServiceAndRDBIndexReal {
|
|||||||
* @param service
|
* @param service
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Boolean serviceIsRepeated(Integer service) {
|
public static Boolean serviceIsReuse(Integer service) {
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
return serviceRepeatedRealSet.contains(service);
|
return serviceGroupReuseMap.containsKey(service);
|
||||||
} else {
|
} else {
|
||||||
} throw new ServiceRuntimeException("判断service是否是分组复用时发生了异常,异常原因:service=null", RestBusinessCode.ServiceIsNull.getValue());
|
throw new ServiceRuntimeException("判断service是否是分组复用时发生了异常,异常原因:service=null", RestBusinessCode.ServiceIsNull.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -394,5 +398,12 @@ public class ServiceAndRDBIndexReal {
|
|||||||
public static void setUnMaatSercieNameMap(Map<Integer, String> unMaatSercieNameMap) {
|
public static void setUnMaatSercieNameMap(Map<Integer, String> unMaatSercieNameMap) {
|
||||||
ServiceAndRDBIndexReal.unMaatSercieNameMap = unMaatSercieNameMap;
|
ServiceAndRDBIndexReal.unMaatSercieNameMap = unMaatSercieNameMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the serviceGroupReuseMap
|
||||||
|
*/
|
||||||
|
public static Map<String, List<String>> getServiceGroupReuseMap(Integer service) {
|
||||||
|
return serviceGroupReuseMap.get(service);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.nis.web.controller.restful;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -10,7 +9,8 @@ import java.util.Map;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import com.nis.web.service.AuditLogThread;
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@@ -22,16 +22,17 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import com.nis.domain.restful.ConfigCompile;
|
import com.nis.domain.restful.ConfigCompile;
|
||||||
import com.nis.domain.restful.ConfigSource;
|
import com.nis.domain.restful.ConfigSource;
|
||||||
import com.nis.domain.restful.FileDesc;
|
import com.nis.domain.restful.FileDesc;
|
||||||
|
import com.nis.domain.restful.GroupReuse;
|
||||||
|
import com.nis.domain.restful.GroupReuseSource;
|
||||||
import com.nis.restful.RestBusinessCode;
|
import com.nis.restful.RestBusinessCode;
|
||||||
import com.nis.restful.RestServiceException;
|
import com.nis.restful.RestServiceException;
|
||||||
import com.nis.restful.ServiceRuntimeException;
|
import com.nis.restful.ServiceRuntimeException;
|
||||||
import com.nis.util.CompileVal;
|
|
||||||
import com.nis.util.Constants;
|
import com.nis.util.Constants;
|
||||||
import com.nis.util.FileUtils;
|
import com.nis.util.FileUtils;
|
||||||
import com.nis.util.OracleErrorCodeUtil;
|
|
||||||
import com.nis.util.StringUtil;
|
import com.nis.util.StringUtil;
|
||||||
import com.nis.util.StringUtils;
|
import com.nis.util.StringUtils;
|
||||||
import com.nis.web.controller.BaseRestController;
|
import com.nis.web.controller.BaseRestController;
|
||||||
|
import com.nis.web.service.AuditLogThread;
|
||||||
import com.nis.web.service.ServicesRequestLogService;
|
import com.nis.web.service.ServicesRequestLogService;
|
||||||
import com.nis.web.service.fdfs.FastDFSFile;
|
import com.nis.web.service.fdfs.FastDFSFile;
|
||||||
import com.nis.web.service.fdfs.FileManager;
|
import com.nis.web.service.fdfs.FileManager;
|
||||||
@@ -41,8 +42,6 @@ import com.wordnik.swagger.annotations.Api;
|
|||||||
import com.wordnik.swagger.annotations.ApiOperation;
|
import com.wordnik.swagger.annotations.ApiOperation;
|
||||||
import com.wordnik.swagger.annotations.ApiParam;
|
import com.wordnik.swagger.annotations.ApiParam;
|
||||||
|
|
||||||
import net.sf.json.JSONObject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName: ConfigSourcesController
|
* @ClassName: ConfigSourcesController
|
||||||
* @Description: 配置存储服务
|
* @Description: 配置存储服务
|
||||||
@@ -177,7 +176,7 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/cfg/v1/commonSources", method = RequestMethod.POST, produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/cfg/v1/commonSources", method = RequestMethod.POST, produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ApiOperation(value = "回调(通用)规则存储接口", httpMethod = "POST", response = Map.class, notes = "接收回调规则数据,格式为结构化行列式JSON,存储到流量处理平台配置线中")
|
@ApiOperation(value = "回调(通用)规则存储接口", httpMethod = "POST", response = Map.class, notes = "接收回调规则数据,格式为结构化行列式JSON,存储到流量处理平台配置线中")
|
||||||
public Map createCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
|
public Map createCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
|
||||||
@@ -208,7 +207,6 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
Constants.IS_DEBUG ? jsonString : null);
|
Constants.IS_DEBUG ? jsonString : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "/cfg/v1/commonSources", method = RequestMethod.PUT)
|
@RequestMapping(value = "/cfg/v1/commonSources", method = RequestMethod.PUT)
|
||||||
@ApiOperation(value = "回调(通用)规则状态更新接口", httpMethod = "PUT", response = Map.class, notes = "接收回调规则,对其状态置为失效")
|
@ApiOperation(value = "回调(通用)规则状态更新接口", httpMethod = "PUT", response = Map.class, notes = "接收回调规则,对其状态置为失效")
|
||||||
public Map updateCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
|
public Map updateCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
|
||||||
@@ -376,6 +374,119 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "摘要获取成功", resultObject);
|
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "摘要获取成功", resultObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/cfg/v1/groupReuseSources", method = RequestMethod.POST)
|
||||||
|
@ApiOperation(value = "分组复用域配置新增接口", httpMethod = "POST", response = Map.class, notes = "接收分组复用域配置,增加到对应的分组中")
|
||||||
|
@ApiParam(value = "分组复用域配置对象", name = "configSource", required = true)
|
||||||
|
public Map addGroupReuseSources(@RequestBody GroupReuseSource groupReuseSource, HttpServletRequest request,
|
||||||
|
HttpServletResponse response) {
|
||||||
|
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
||||||
|
groupReuseSource);
|
||||||
|
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
try {
|
||||||
|
if (null != groupReuseSource && null != groupReuseSource.getGroupReuseList()
|
||||||
|
&& groupReuseSource.getGroupReuseList().size() > 0) {
|
||||||
|
checkOpAction(thread, System.currentTimeMillis() - start, groupReuseSource.getOpAction(), Constants.OPACTION_POST);
|
||||||
|
// 验证配置编译数据
|
||||||
|
validateGroupReuseSource(thread, start, groupReuseSource);
|
||||||
|
configSourcesService.addGroupReuseSources(thread, start, groupReuseSource.getGroupReuseList(), sb);
|
||||||
|
} else {
|
||||||
|
throw new RestServiceException("Maat规则不能为空",
|
||||||
|
RestBusinessCode.ConfigSourceIsNull.getValue());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO: handle exception
|
||||||
|
thread.setExceptionInfo("Maat 分组复用规则存储异常:" + e.getMessage());
|
||||||
|
logger.error("Maat 分组复用规则存储异常:" + e.getMessage());
|
||||||
|
if (e instanceof RestServiceException) {
|
||||||
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
||||||
|
"Maat 分组复用规则存储异常:" + e.getMessage(), ((RestServiceException) e).getErrorCode());
|
||||||
|
}else if(e instanceof ServiceRuntimeException) {
|
||||||
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
||||||
|
"Maat 分组复用规则存储异常:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode());
|
||||||
|
}else{
|
||||||
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
||||||
|
"Maat 分组复用规则存储异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
||||||
|
"Maat分组复用规则添加成功" + sb.toString(), Constants.IS_DEBUG ? groupReuseSource : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/cfg/v1/groupReuseSources", method = RequestMethod.PUT)
|
||||||
|
@ApiOperation(value = "分组复用域配置删除接口", httpMethod = "PUT", response = Map.class, notes = "接收分组复用域配置,并从对应分组中删除")
|
||||||
|
@ApiParam(value = "分组复用域配置对象", name = "configSource", required = true)
|
||||||
|
public Map delGroupReuseSources(@RequestBody GroupReuseSource groupReuseSource, HttpServletRequest request,
|
||||||
|
HttpServletResponse response) {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
|
||||||
|
groupReuseSource);
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
try {
|
||||||
|
if (null == groupReuseSource.getOpTime()) {
|
||||||
|
groupReuseSource.setOpTime(new Date());
|
||||||
|
}
|
||||||
|
if (null != groupReuseSource && null != groupReuseSource.getGroupReuseList()
|
||||||
|
&& groupReuseSource.getGroupReuseList().size() > 0) {
|
||||||
|
int opAction = groupReuseSource.getOpAction();
|
||||||
|
checkOpAction(thread, System.currentTimeMillis() - start, opAction, 2);
|
||||||
|
configSourcesService.deleteGroupReuseSources(thread, start,groupReuseSource.getGroupReuseList(),
|
||||||
|
groupReuseSource.getOpTime(), sb);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
throw new RestServiceException("分组复用信息不能为空" + sb.toString(),
|
||||||
|
RestBusinessCode.ConfigSourceIsNull.getValue());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO: handle exception
|
||||||
|
thread.setExceptionInfo("MAAT规则状态更新时出现异常:" + e.getMessage());
|
||||||
|
logger.error("删除MAAT规则分组复用域配置时出现异常:" + e.getMessage());
|
||||||
|
if (e instanceof RestServiceException) {
|
||||||
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
||||||
|
"删除MAAT规则分组复用域配置时出现异常:" + e.getMessage(), ((RestServiceException) e).getErrorCode());
|
||||||
|
}else if(e instanceof ServiceRuntimeException) {
|
||||||
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
||||||
|
"删除MAAT规则分组复用域配置时出现异常:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode());
|
||||||
|
}else{
|
||||||
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
||||||
|
"删除MAAT规则分组复用域配置时出现异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
||||||
|
"MAAT规则分组复用域配置删除成功" + sb.toString(), Constants.IS_DEBUG ?groupReuseSource : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateGroupReuseSource(AuditLogThread thread, long start, GroupReuseSource groupReuseSource) {
|
||||||
|
String errorInfo = "";
|
||||||
|
|
||||||
|
List<GroupReuse> groupReuseSourceList = groupReuseSource.getGroupReuseList();
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(groupReuseSource.getOperator())) {
|
||||||
|
errorInfo = "get operator is Empty";
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(groupReuseSource.getVersion())) {
|
||||||
|
errorInfo = "get version is Empty";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isBlank(groupReuseSource.getOpTime())) {
|
||||||
|
errorInfo = "get OpTime is Empty";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (groupReuseSourceList.size() <= 0) {
|
||||||
|
errorInfo = "分组复用的域配置列表不能为空";
|
||||||
|
}
|
||||||
|
if (!errorInfo.equals("")) {
|
||||||
|
thread.setExceptionInfo(errorInfo);
|
||||||
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorInfo,
|
||||||
|
RestBusinessCode.missing_args.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
private boolean isBlank(Date datetime) {
|
private boolean isBlank(Date datetime) {
|
||||||
if (null != datetime) {
|
if (null != datetime) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -179,15 +179,9 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
transaction.discard();
|
transaction.discard();
|
||||||
|
String error = "保存非maat类配置发生了异常," + e.getMessage();
|
||||||
if (e instanceof ServiceRuntimeException) {
|
// logger.error(error);
|
||||||
throw e;
|
throw new ServiceRuntimeException(error, RestBusinessCode.SaveDataInError.getValue());
|
||||||
}else {
|
|
||||||
String error = "保存非maat类配置发生了异常," + e.getMessage();
|
|
||||||
// logger.error(error);
|
|
||||||
throw new ServiceRuntimeException(error, RestBusinessCode.SaveDataInError.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
// 释放连接到连接池
|
// 释放连接到连接池
|
||||||
JedisUtils.returnResource(resource);
|
JedisUtils.returnResource(resource);
|
||||||
@@ -531,13 +525,9 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
|||||||
throw new ServiceRuntimeException(error, RestBusinessCode.CannotConnectionRedis.getValue());
|
throw new ServiceRuntimeException(error, RestBusinessCode.CannotConnectionRedis.getValue());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
transaction.discard();
|
transaction.discard();
|
||||||
if (e instanceof ServiceRuntimeException) {
|
String error = "保存maat类配置发生了异常" + e.getMessage();
|
||||||
throw e;
|
logger.error(error);
|
||||||
}else {
|
throw new ServiceRuntimeException(error, RestBusinessCode.SaveDataInError.getValue());
|
||||||
String error = "保存maat类配置发生了异常" + e.getMessage();
|
|
||||||
logger.error(error);
|
|
||||||
throw new ServiceRuntimeException(error, RestBusinessCode.SaveDataInError.getValue());
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
// 释放连接到连接池
|
// 释放连接到连接池
|
||||||
JedisUtils.returnResource(resource);
|
JedisUtils.returnResource(resource);
|
||||||
@@ -952,13 +942,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
|||||||
transaction.discard();
|
transaction.discard();
|
||||||
String error = "删除非maat类配置发生了异常," + e.getMessage();
|
String error = "删除非maat类配置发生了异常," + e.getMessage();
|
||||||
// logger.error(error);
|
// logger.error(error);
|
||||||
if (e instanceof ServiceRuntimeException) {
|
throw new ServiceRuntimeException(error, RestBusinessCode.DeleteDataInError.getValue());
|
||||||
throw e;
|
|
||||||
}else {
|
|
||||||
throw new ServiceRuntimeException(error, RestBusinessCode.DeleteDataInError.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
// 释放连接到连接池
|
// 释放连接到连接池
|
||||||
JedisUtils.returnResource(resource);
|
JedisUtils.returnResource(resource);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.nis.domain.restful.CommonSourceFieldCfg;
|
|||||||
import com.nis.domain.restful.ConfigCompile;
|
import com.nis.domain.restful.ConfigCompile;
|
||||||
import com.nis.domain.restful.ConfigGroupRelation;
|
import com.nis.domain.restful.ConfigGroupRelation;
|
||||||
import com.nis.domain.restful.DigestRegion;
|
import com.nis.domain.restful.DigestRegion;
|
||||||
|
import com.nis.domain.restful.GroupReuse;
|
||||||
import com.nis.domain.restful.IpRegion;
|
import com.nis.domain.restful.IpRegion;
|
||||||
import com.nis.domain.restful.MaatConfig;
|
import com.nis.domain.restful.MaatConfig;
|
||||||
import com.nis.domain.restful.NumRegion;
|
import com.nis.domain.restful.NumRegion;
|
||||||
@@ -37,6 +38,7 @@ import com.nis.util.BasicProvingUtil;
|
|||||||
import com.nis.util.CamelUnderlineUtil;
|
import com.nis.util.CamelUnderlineUtil;
|
||||||
import com.nis.util.CompileVal;
|
import com.nis.util.CompileVal;
|
||||||
import com.nis.util.Constants;
|
import com.nis.util.Constants;
|
||||||
|
import com.nis.util.GroupReuseVal;
|
||||||
import com.nis.util.JsonMapper;
|
import com.nis.util.JsonMapper;
|
||||||
import com.nis.util.ReadCommSourceXmlUtil;
|
import com.nis.util.ReadCommSourceXmlUtil;
|
||||||
import com.nis.util.ServiceAndRDBIndexReal;
|
import com.nis.util.ServiceAndRDBIndexReal;
|
||||||
@@ -55,7 +57,7 @@ import com.nis.web.service.BaseService;
|
|||||||
public class ConfigSourcesService extends BaseService {
|
public class ConfigSourcesService extends BaseService {
|
||||||
|
|
||||||
private Map<Integer, Map<String, String>> map;
|
private Map<Integer, Map<String, String>> map;
|
||||||
|
|
||||||
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -70,13 +72,15 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static boolean isStrStrongRegion(String tableName,Integer service) throws Exception{
|
public static boolean isStrStrongRegion(String tableName, Integer service)
|
||||||
|
throws Exception {
|
||||||
if (null != tableName && !tableName.equals("")) {
|
if (null != tableName && !tableName.equals("")) {
|
||||||
List<String> tableList = new ArrayList<String>();
|
List<String> tableList = new ArrayList<String>();
|
||||||
Map<Integer, List<String>> sercieNameMap = ServiceAndRDBIndexReal.getSercieNameMap().get(service);
|
Map<Integer, List<String>> sercieNameMap = ServiceAndRDBIndexReal
|
||||||
|
.getSercieNameMap().get(service);
|
||||||
if (sercieNameMap != null && sercieNameMap.size() > 0) {
|
if (sercieNameMap != null && sercieNameMap.size() > 0) {
|
||||||
for (Integer type : sercieNameMap.keySet()) {
|
for (Integer type : sercieNameMap.keySet()) {
|
||||||
// 12代表是ip类域配置,13代表是数值类配置,14代表是字符串类域配置,15代表是增强字符串类域配置,
|
// 12代表是ip类域配置,13代表是数值类配置,14代表是字符串类域配置,15代表是增强字符串类域配置,
|
||||||
if ("15".equals(type.toString())) {
|
if ("15".equals(type.toString())) {
|
||||||
List<String> tableNameList = sercieNameMap.get(type);
|
List<String> tableNameList = sercieNameMap.get(type);
|
||||||
if (tableNameList != null && tableNameList.size() > 0) {
|
if (tableNameList != null && tableNameList.size() > 0) {
|
||||||
@@ -118,8 +122,9 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public void saveMaatConfig(AuditLogThread thread, long start,
|
public void saveMaatConfig(AuditLogThread thread, long start,
|
||||||
List<ConfigCompile> configCompileList, StringBuffer sb) throws Exception {
|
List<ConfigCompile> configCompileList, StringBuffer sb)
|
||||||
Map<Integer, List<MaatConfig>> maatMap = new HashMap<Integer, List<MaatConfig>>();
|
throws Exception {
|
||||||
|
Map<Integer, List<MaatConfig>> maatMap = new HashMap<Integer, List<MaatConfig>>();
|
||||||
Map<Integer, List<MaatConfig>> configMap = new HashMap<Integer, List<MaatConfig>>();
|
Map<Integer, List<MaatConfig>> configMap = new HashMap<Integer, List<MaatConfig>>();
|
||||||
|
|
||||||
for (ConfigCompile configCompile : configCompileList) {
|
for (ConfigCompile configCompile : configCompileList) {
|
||||||
@@ -163,8 +168,7 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
}
|
}
|
||||||
maatConfig.setStrRegionMapList(dstMaplList);
|
maatConfig.setStrRegionMapList(dstMaplList);
|
||||||
// 增强字符串域
|
// 增强字符串域
|
||||||
if (!StringUtil.isEmpty(strongMapList)
|
if (!StringUtil.isEmpty(strongMapList) && strongMapList.size() > 0) {
|
||||||
&& strongMapList.size() > 0) {
|
|
||||||
maatConfig.setStrStrRegionMapList((strongMapList));
|
maatConfig.setStrStrRegionMapList((strongMapList));
|
||||||
}
|
}
|
||||||
// 数值域
|
// 数值域
|
||||||
@@ -172,8 +176,8 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
if (!StringUtil.isEmpty(configCompile.getNumRegionList())) {
|
if (!StringUtil.isEmpty(configCompile.getNumRegionList())) {
|
||||||
dstMaplList = new ArrayList<Map<String, String>>();
|
dstMaplList = new ArrayList<Map<String, String>>();
|
||||||
for (NumRegion region : configCompile.getNumRegionList()) {
|
for (NumRegion region : configCompile.getNumRegionList()) {
|
||||||
dstMaplList.add(convertObjectToMap(region,
|
dstMaplList
|
||||||
NumRegion.class));
|
.add(convertObjectToMap(region, NumRegion.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
maatConfig.setNumRegionMapList(dstMaplList);
|
maatConfig.setNumRegionMapList(dstMaplList);
|
||||||
@@ -183,8 +187,7 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
if (!StringUtil.isEmpty(configCompile.getIpRegionList())) {
|
if (!StringUtil.isEmpty(configCompile.getIpRegionList())) {
|
||||||
dstMaplList = new ArrayList<Map<String, String>>();
|
dstMaplList = new ArrayList<Map<String, String>>();
|
||||||
for (IpRegion region : configCompile.getIpRegionList()) {
|
for (IpRegion region : configCompile.getIpRegionList()) {
|
||||||
dstMaplList.add(convertObjectToMap(region,
|
dstMaplList.add(convertObjectToMap(region, IpRegion.class));
|
||||||
IpRegion.class));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
maatConfig.setIpRegionMapList(dstMaplList);
|
maatConfig.setIpRegionMapList(dstMaplList);
|
||||||
@@ -193,8 +196,7 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
dstMaplList = null;
|
dstMaplList = null;
|
||||||
if (!StringUtil.isEmpty(configCompile.getDigestRegionList())) {
|
if (!StringUtil.isEmpty(configCompile.getDigestRegionList())) {
|
||||||
dstMaplList = new ArrayList<Map<String, String>>();
|
dstMaplList = new ArrayList<Map<String, String>>();
|
||||||
for (DigestRegion region : configCompile
|
for (DigestRegion region : configCompile.getDigestRegionList()) {
|
||||||
.getDigestRegionList()) {
|
|
||||||
dstMaplList.add(convertObjectToMap(region,
|
dstMaplList.add(convertObjectToMap(region,
|
||||||
DigestRegion.class));
|
DigestRegion.class));
|
||||||
}
|
}
|
||||||
@@ -211,8 +213,7 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
if (!StringUtil.isEmpty(configCompile.getIpClientRangeList())) {
|
if (!StringUtil.isEmpty(configCompile.getIpClientRangeList())) {
|
||||||
dstMaplList = new ArrayList<Map<String, String>>();
|
dstMaplList = new ArrayList<Map<String, String>>();
|
||||||
for (IpRegion region : configCompile.getIpClientRangeList()) {
|
for (IpRegion region : configCompile.getIpClientRangeList()) {
|
||||||
dstMaplList.add(convertObjectToMap(region,
|
dstMaplList.add(convertObjectToMap(region, IpRegion.class));
|
||||||
IpRegion.class));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
maatConfig.setIpClientRangeMapList(dstMaplList);
|
maatConfig.setIpClientRangeMapList(dstMaplList);
|
||||||
@@ -231,8 +232,8 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
|
|
||||||
Iterator serviceIterator = maatMap.keySet().iterator();
|
Iterator serviceIterator = maatMap.keySet().iterator();
|
||||||
while (serviceIterator.hasNext()) {
|
while (serviceIterator.hasNext()) {
|
||||||
Integer service = Integer.valueOf(serviceIterator.next()
|
Integer service = Integer
|
||||||
.toString());
|
.valueOf(serviceIterator.next().toString());
|
||||||
List<Integer> dbIndexList = ServiceAndRDBIndexReal
|
List<Integer> dbIndexList = ServiceAndRDBIndexReal
|
||||||
.getRedisDBByService(service);
|
.getRedisDBByService(service);
|
||||||
if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) {
|
if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) {
|
||||||
@@ -255,16 +256,15 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
.fromJsonString(JsonMapper
|
.fromJsonString(JsonMapper
|
||||||
.toJsonString(maatConfig),
|
.toJsonString(maatConfig),
|
||||||
MaatConfig.class);
|
MaatConfig.class);
|
||||||
Iterator iterator = regionAndFiledMap
|
Iterator iterator = regionAndFiledMap.keySet()
|
||||||
.keySet().iterator();
|
.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
String regionName = iterator.next()
|
String regionName = iterator.next()
|
||||||
.toString();
|
.toString();
|
||||||
PropertyDescriptor pd;
|
PropertyDescriptor pd;
|
||||||
try {
|
try {
|
||||||
pd = new PropertyDescriptor(
|
pd = new PropertyDescriptor(regionName
|
||||||
regionName + "MapList",
|
+ "MapList", MaatConfig.class);
|
||||||
MaatConfig.class);
|
|
||||||
Method method = pd.getReadMethod();
|
Method method = pd.getReadMethod();
|
||||||
Object object = method
|
Object object = method
|
||||||
.invoke(newMaatConfig);
|
.invoke(newMaatConfig);
|
||||||
@@ -280,8 +280,7 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
.getCompileMap()
|
.getCompileMap()
|
||||||
.get(fieldName
|
.get(fieldName
|
||||||
.toLowerCase());
|
.toLowerCase());
|
||||||
if (!StringUtil
|
if (!StringUtil.isEmpty(value)) {
|
||||||
.isEmpty(value)) {
|
|
||||||
for (Map<String, String> map : listMaps) {
|
for (Map<String, String> map : listMaps) {
|
||||||
map.put(fieldName
|
map.put(fieldName
|
||||||
.toLowerCase(),
|
.toLowerCase(),
|
||||||
@@ -293,11 +292,14 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
method.invoke(newMaatConfig,
|
method.invoke(newMaatConfig,
|
||||||
listMaps);
|
listMaps);
|
||||||
}
|
}
|
||||||
newMaatConfigList.set(i,
|
newMaatConfigList.set(i, newMaatConfig);
|
||||||
newMaatConfig);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
throw new RestServiceException("未找到域列表,请检查配置文件中域类型是否正确!:"+e.getMessage(),RestBusinessCode.service_runtime_error.getValue());
|
throw new RestServiceException(
|
||||||
|
"未找到域列表,请检查配置文件中域类型是否正确!:"
|
||||||
|
+ e.getMessage(),
|
||||||
|
RestBusinessCode.service_runtime_error
|
||||||
|
.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -315,14 +317,17 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ServiceRuntimeException(RestBusinessCode.ServiceNoFoundDBIndex.getErrorReason(),RestBusinessCode.ServiceNoFoundDBIndex.getValue());
|
throw new ServiceRuntimeException(
|
||||||
|
RestBusinessCode.ServiceNoFoundDBIndex.getErrorReason(),
|
||||||
|
RestBusinessCode.ServiceNoFoundDBIndex.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.info("---------------调用Redis maat配置新增接口---------------------");
|
logger.info("---------------调用Redis maat配置新增接口---------------------");
|
||||||
configRedisService.saveMaatConfig(configMap);
|
configRedisService.saveMaatConfig(configMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> convertObjectToMap(Object obj, Class clazz) throws Exception {
|
private Map<String, String> convertObjectToMap(Object obj, Class clazz)
|
||||||
|
throws Exception {
|
||||||
Map<String, String> dstMap = new HashMap<String, String>();
|
Map<String, String> dstMap = new HashMap<String, String>();
|
||||||
Field[] fields = obj.getClass().getDeclaredFields();
|
Field[] fields = obj.getClass().getDeclaredFields();
|
||||||
for (Field field : fields) {
|
for (Field field : fields) {
|
||||||
@@ -347,7 +352,8 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateConfigSources(AuditLogThread thread, long start,
|
public void updateConfigSources(AuditLogThread thread, long start,
|
||||||
List<ConfigCompile> compileList, Date opTime, StringBuffer sb) throws Exception {
|
List<ConfigCompile> compileList, Date opTime, StringBuffer sb)
|
||||||
|
throws Exception {
|
||||||
Map<Integer, List<Long>> compileMap = new HashMap<Integer, List<Long>>();
|
Map<Integer, List<Long>> compileMap = new HashMap<Integer, List<Long>>();
|
||||||
if (null != compileList && compileList.size() > 0) {
|
if (null != compileList && compileList.size() > 0) {
|
||||||
for (ConfigCompile config : compileList) {
|
for (ConfigCompile config : compileList) {
|
||||||
@@ -371,7 +377,7 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
throw new RestServiceException("编译配置不能为空" + sb.toString(),
|
throw new RestServiceException("编译配置不能为空" + sb.toString(),
|
||||||
RestBusinessCode.CompileIsNull.getValue());
|
RestBusinessCode.CompileIsNull.getValue());
|
||||||
}
|
}
|
||||||
//Map<DBIndex,Map<Service,List<CompileId>>
|
// Map<DBIndex,Map<Service,List<CompileId>>
|
||||||
Map<Integer, Map<Integer, List<Long>>> restMap = new HashMap<Integer, Map<Integer, List<Long>>>();
|
Map<Integer, Map<Integer, List<Long>>> restMap = new HashMap<Integer, Map<Integer, List<Long>>>();
|
||||||
Iterator serviceIterator = compileMap.keySet().iterator();
|
Iterator serviceIterator = compileMap.keySet().iterator();
|
||||||
while (serviceIterator.hasNext()) {
|
while (serviceIterator.hasNext()) {
|
||||||
@@ -391,13 +397,15 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ServiceRuntimeException e = new ServiceRuntimeException("service值为" + service
|
ServiceRuntimeException e = new ServiceRuntimeException(
|
||||||
+ ",与写入数据库序号映射关系不存在",RestBusinessCode.ServiceNoFoundDBIndex.getValue());
|
"service值为" + service + ",与写入数据库序号映射关系不存在",
|
||||||
|
RestBusinessCode.ServiceNoFoundDBIndex.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//所有的都删除成功返回true
|
// 所有的都删除成功返回true
|
||||||
if (!configRedisService.delMaatConfig(restMap)) {
|
if (!configRedisService.delMaatConfig(restMap)) {
|
||||||
throw new ServiceRuntimeException("取消MAAT配置时出现异常,具体原因不详,请联系管理员",RestBusinessCode.service_runtime_error.getValue());
|
throw new ServiceRuntimeException("取消MAAT配置时出现异常,具体原因不详,请联系管理员",
|
||||||
|
RestBusinessCode.service_runtime_error.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,33 +422,44 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
* @param config
|
* @param config
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private void checkCompileOptForUpdate(ConfigCompile config) throws Exception{
|
private void checkCompileOptForUpdate(ConfigCompile config)
|
||||||
|
throws Exception {
|
||||||
|
|
||||||
if (StringUtil.isEmpty(config.getCompileId())) {
|
if (StringUtil.isEmpty(config.getCompileId())) {
|
||||||
throw new RestServiceException(RestBusinessCode.CompileIdIsNull.getErrorReason(),RestBusinessCode.CompileIdIsNull.getValue());
|
throw new RestServiceException(
|
||||||
|
RestBusinessCode.CompileIdIsNull.getErrorReason(),
|
||||||
|
RestBusinessCode.CompileIdIsNull.getValue());
|
||||||
}
|
}
|
||||||
if (StringUtil.isEmpty(config.getService())) {
|
if (StringUtil.isEmpty(config.getService())) {
|
||||||
throw new RestServiceException(RestBusinessCode.ServiceIsNull.getErrorReason(),RestBusinessCode.ServiceIsNull.getValue());
|
throw new RestServiceException(
|
||||||
|
RestBusinessCode.ServiceIsNull.getErrorReason(),
|
||||||
|
RestBusinessCode.ServiceIsNull.getValue());
|
||||||
}
|
}
|
||||||
if (StringUtil.isEmpty(config.getIsValid())) {
|
if (StringUtil.isEmpty(config.getIsValid())) {
|
||||||
throw new RestServiceException("编译配置id为" + config.getCompileId() + "的IsValid字段不能为空",RestBusinessCode.IsValidIsNull.getValue());
|
throw new RestServiceException("编译配置id为" + config.getCompileId()
|
||||||
|
+ "的IsValid字段不能为空",
|
||||||
|
RestBusinessCode.IsValidIsNull.getValue());
|
||||||
}
|
}
|
||||||
if (config.getIsValid() != 0) {
|
if (config.getIsValid() != 0) {
|
||||||
throw new RestServiceException("编译配置id为" + config.getCompileId() + "的配置在修改时不能为有效",RestBusinessCode.IsValidIsF.getValue());
|
throw new RestServiceException("编译配置id为" + config.getCompileId()
|
||||||
|
+ "的配置在修改时不能为有效", RestBusinessCode.IsValidIsF.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveCommonSources(AuditLogThread thread, long start,
|
public void saveCommonSources(AuditLogThread thread, long start,
|
||||||
String jsonString) throws Exception{
|
String jsonString) throws Exception {
|
||||||
JsonArray jsonObjectList = null;
|
JsonArray jsonObjectList = null;
|
||||||
try {
|
try {
|
||||||
jsonObjectList = new JsonParser().parse(jsonString)
|
jsonObjectList = new JsonParser().parse(jsonString)
|
||||||
.getAsJsonArray();
|
.getAsJsonArray();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
throw new RestServiceException(RestBusinessCode.CBParamFormateError.getErrorReason()+","+e.getMessage(),RestBusinessCode.CBParamFormateError.getValue());
|
throw new RestServiceException(
|
||||||
|
RestBusinessCode.CBParamFormateError.getErrorReason() + ","
|
||||||
|
+ e.getMessage(),
|
||||||
|
RestBusinessCode.CBParamFormateError.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Integer, List<Map<String, String>>> dstMaps = new HashMap<Integer, List<Map<String, String>>>();
|
Map<Integer, List<Map<String, String>>> dstMaps = new HashMap<Integer, List<Map<String, String>>>();
|
||||||
for (int i = 0; i < jsonObjectList.size(); i++) {
|
for (int i = 0; i < jsonObjectList.size(); i++) {
|
||||||
JsonObject jsonObj = (JsonObject) jsonObjectList.get(i);
|
JsonObject jsonObj = (JsonObject) jsonObjectList.get(i);
|
||||||
@@ -452,12 +471,15 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
.getCommonSourceCfgByService(srcMap.get("service")
|
.getCommonSourceCfgByService(srcMap.get("service")
|
||||||
.toString().trim());
|
.toString().trim());
|
||||||
if (StringUtil.isEmpty(commonSourceFieldCfgList)) {
|
if (StringUtil.isEmpty(commonSourceFieldCfgList)) {
|
||||||
throw new RestServiceException(RestBusinessCode.ServiceIsWrong.getErrorReason()+",请检查service配置是否正确",RestBusinessCode.ServiceIsWrong.getValue());
|
throw new RestServiceException(
|
||||||
|
RestBusinessCode.ServiceIsWrong.getErrorReason()
|
||||||
|
+ ",请检查service配置是否正确",
|
||||||
|
RestBusinessCode.ServiceIsWrong.getValue());
|
||||||
}
|
}
|
||||||
// 获取IP类型
|
// 获取IP类型
|
||||||
Integer ipType = null;
|
Integer ipType = null;
|
||||||
String ipTypeName = "";
|
String ipTypeName = "";
|
||||||
|
|
||||||
for (CommonSourceFieldCfg commonSourceFieldCfg : commonSourceFieldCfgList) {
|
for (CommonSourceFieldCfg commonSourceFieldCfg : commonSourceFieldCfgList) {
|
||||||
if (commonSourceFieldCfg.getDstName().equals("addr_type")) {
|
if (commonSourceFieldCfg.getDstName().equals("addr_type")) {
|
||||||
String dstVal = srcMap.get(
|
String dstVal = srcMap.get(
|
||||||
@@ -473,25 +495,32 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
valFlag = valFlag & matcher.matches();
|
valFlag = valFlag & matcher.matches();
|
||||||
}
|
}
|
||||||
if (!valFlag) {
|
if (!valFlag) {
|
||||||
throw new RestServiceException(RestBusinessCode.IpTypeIsWrong
|
throw new RestServiceException(
|
||||||
.getErrorReason(),RestBusinessCode.IpTypeIsWrong.getValue());
|
RestBusinessCode.IpTypeIsWrong
|
||||||
|
.getErrorReason(),
|
||||||
|
RestBusinessCode.IpTypeIsWrong.getValue());
|
||||||
}
|
}
|
||||||
ipType = Integer.parseInt(dstVal);
|
ipType = Integer.parseInt(dstVal);
|
||||||
}
|
}
|
||||||
//验证service与action是否匹配
|
// 验证service与action是否匹配
|
||||||
if (commonSourceFieldCfg.getDstName().equals("action")) {
|
if (commonSourceFieldCfg.getDstName().equals("action")) {
|
||||||
String dstVal = srcMap.get(
|
String dstVal = srcMap
|
||||||
commonSourceFieldCfg.getSrcName()).toString().trim();
|
.get(commonSourceFieldCfg.getSrcName())
|
||||||
if (Integer.valueOf(dstVal).compareTo(ServiceAndRDBIndexReal.getActionByService(Integer.valueOf(srcMap.get("service")
|
.toString().trim();
|
||||||
.toString().trim())))!=0) {
|
if (Integer.valueOf(dstVal).compareTo(
|
||||||
throw new RestServiceException(RestBusinessCode.ServiceUnmatchAction
|
ServiceAndRDBIndexReal
|
||||||
|
.getActionByService(Integer
|
||||||
|
.valueOf(srcMap.get("service")
|
||||||
|
.toString().trim()))) != 0) {
|
||||||
|
throw new RestServiceException(
|
||||||
|
RestBusinessCode.ServiceUnmatchAction
|
||||||
.getErrorReason(),
|
.getErrorReason(),
|
||||||
RestBusinessCode.ServiceUnmatchAction
|
RestBusinessCode.ServiceUnmatchAction
|
||||||
.getValue());
|
.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ipType==null) {
|
if (ipType == null) {
|
||||||
ipType = 4;
|
ipType = 4;
|
||||||
}
|
}
|
||||||
for (CommonSourceFieldCfg commonSourceFieldCfg : commonSourceFieldCfgList) {
|
for (CommonSourceFieldCfg commonSourceFieldCfg : commonSourceFieldCfgList) {
|
||||||
@@ -499,7 +528,8 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
if (commonSourceFieldCfg.getIsRequired()
|
if (commonSourceFieldCfg.getIsRequired()
|
||||||
&& !srcMap.containsKey(commonSourceFieldCfg
|
&& !srcMap.containsKey(commonSourceFieldCfg
|
||||||
.getSrcName())) {
|
.getSrcName())) {
|
||||||
throw new RestServiceException(commonSourceFieldCfg.getSrcName() + "参数不能为空",
|
throw new RestServiceException(
|
||||||
|
commonSourceFieldCfg.getSrcName() + "参数不能为空",
|
||||||
RestBusinessCode.FieldIsNull.getValue());
|
RestBusinessCode.FieldIsNull.getValue());
|
||||||
}
|
}
|
||||||
// 字段类型 String Number Date Ip Port
|
// 字段类型 String Number Date Ip Port
|
||||||
@@ -513,25 +543,29 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
dstStr.substring(1, dstStr.length() - 1))
|
dstStr.substring(1, dstStr.length() - 1))
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if("dstFile".equals(commonSourceFieldCfg
|
if ("dstFile".equals(commonSourceFieldCfg.getSrcName())) {
|
||||||
.getSrcName())){
|
if ("dst_file"
|
||||||
if ("dst_file".equals(commonSourceFieldCfg
|
.equals(commonSourceFieldCfg.getDstName())) {
|
||||||
.getDstName())) {
|
|
||||||
String maatTableName = ServiceAndRDBIndexReal
|
String maatTableName = ServiceAndRDBIndexReal
|
||||||
.getUnMaatTableName(Integer.valueOf(srcMap.get("service")
|
.getUnMaatTableName(Integer.valueOf(srcMap
|
||||||
.toString().trim()));
|
.get("service").toString().trim()));
|
||||||
String dstPath = Constants.MM_SAMPLE_DST_PATH.replace("{tableType}", maatTableName.substring(maatTableName.lastIndexOf("_")+1));
|
String dstPath = Constants.MM_SAMPLE_DST_PATH
|
||||||
dstStr=dstPath.replace("{fileName}", dstStr.substring(dstStr.lastIndexOf("/")+1));
|
.replace("{tableType}", maatTableName
|
||||||
}else if ("file_id".equals(commonSourceFieldCfg
|
.substring(maatTableName
|
||||||
.getDstName())) {
|
.lastIndexOf("_") + 1));
|
||||||
dstStr= dstStr.substring(dstStr.indexOf("group"));
|
dstStr = dstPath.replace("{fileName}", dstStr
|
||||||
|
.substring(dstStr.lastIndexOf("/") + 1));
|
||||||
|
} else if ("file_id".equals(commonSourceFieldCfg
|
||||||
|
.getDstName())) {
|
||||||
|
dstStr = dstStr.substring(dstStr.indexOf("group"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (commonSourceFieldCfg.getFieldType()) {
|
switch (commonSourceFieldCfg.getFieldType()) {
|
||||||
case "Number":
|
case "Number":
|
||||||
if (!StringUtil.isNumeric(dstStr)) {
|
if (!StringUtil.isNumeric(dstStr)) {
|
||||||
throw new RestServiceException(commonSourceFieldCfg.getSrcName()
|
throw new RestServiceException(
|
||||||
|
commonSourceFieldCfg.getSrcName()
|
||||||
+ "参数不能格式不正确,必需是数值型",
|
+ "参数不能格式不正确,必需是数值型",
|
||||||
RestBusinessCode.MastNumberic.getValue());
|
RestBusinessCode.MastNumberic.getValue());
|
||||||
}
|
}
|
||||||
@@ -539,37 +573,42 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
case "Date":
|
case "Date":
|
||||||
try {
|
try {
|
||||||
// sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
// sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
// System.out.println("--------------------TimeZone:"
|
// System.out.println("--------------------TimeZone:"
|
||||||
// + sdf.getTimeZone());
|
// + sdf.getTimeZone());
|
||||||
sdf.setLenient(false);
|
sdf.setLenient(false);
|
||||||
Date date = sdf.parse(dstStr);
|
Date date = sdf.parse(dstStr);
|
||||||
dstStr = date.getTime() + "000";
|
dstStr = date.getTime() + "000";
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
throw new RestServiceException(commonSourceFieldCfg.getSrcName()
|
throw new RestServiceException(
|
||||||
|
commonSourceFieldCfg.getSrcName()
|
||||||
+ "参数格式不正确或不是规范的日期串",
|
+ "参数格式不正确或不是规范的日期串",
|
||||||
RestBusinessCode.MastDate.getValue());
|
RestBusinessCode.MastDate.getValue());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "IP":
|
case "IP":
|
||||||
Boolean isSrcInfo = commonSourceFieldCfg.getIsSrcInfo();
|
Boolean isSrcInfo = commonSourceFieldCfg.getIsSrcInfo();
|
||||||
Integer valAddrType = ipType;
|
Integer valAddrType = ipType;
|
||||||
if (ipType.intValue()==46) {
|
if (ipType.intValue() == 46) {
|
||||||
valAddrType=isSrcInfo?4:6;
|
valAddrType = isSrcInfo ? 4 : 6;
|
||||||
}else if (ipType.intValue()==64) {
|
} else if (ipType.intValue() == 64) {
|
||||||
valAddrType=isSrcInfo?6:4;
|
valAddrType = isSrcInfo ? 6 : 4;
|
||||||
}else if (ipType.intValue()==10) {
|
} else if (ipType.intValue() == 10) {
|
||||||
valAddrType=null;
|
valAddrType = null;
|
||||||
}
|
}
|
||||||
if (!BasicProvingUtil.isIpOrIpMask(dstStr, valAddrType)) {
|
if (!BasicProvingUtil.isIpOrIpMask(dstStr, valAddrType)) {
|
||||||
throw new RestServiceException(commonSourceFieldCfg.getSrcName()
|
throw new RestServiceException(
|
||||||
+ "参数格式不正确或与" + ipTypeName + "不一致",RestBusinessCode.IpIsUnMatchType.getValue());
|
commonSourceFieldCfg.getSrcName()
|
||||||
|
+ "参数格式不正确或与" + ipTypeName + "不一致",
|
||||||
|
RestBusinessCode.IpIsUnMatchType.getValue());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "Port":
|
case "Port":
|
||||||
if (!BasicProvingUtil.isPortOrPortMask(dstStr)) {
|
if (!BasicProvingUtil.isPortOrPortMask(dstStr)) {
|
||||||
throw new RestServiceException(commonSourceFieldCfg.getSrcName()
|
throw new RestServiceException(
|
||||||
+ "参数不能格式不正确,不是合法的Port", RestBusinessCode.PortIsNotVal.getValue());
|
commonSourceFieldCfg.getSrcName()
|
||||||
|
+ "参数不能格式不正确,不是合法的Port",
|
||||||
|
RestBusinessCode.PortIsNotVal.getValue());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -600,9 +639,13 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flag) {
|
if (flag) {
|
||||||
throw new RestServiceException( commonSourceFieldCfg.getSrcName()
|
throw new RestServiceException(
|
||||||
+ "参数不在有效范围("+ commonSourceFieldCfg.getRange()
|
commonSourceFieldCfg.getSrcName()
|
||||||
+ ")",RestBusinessCode.ValueInWrongRange.getValue());
|
+ "参数不在有效范围("
|
||||||
|
+ commonSourceFieldCfg.getRange()
|
||||||
|
+ ")",
|
||||||
|
RestBusinessCode.ValueInWrongRange
|
||||||
|
.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// regexp 特殊格式正则验证
|
// regexp 特殊格式正则验证
|
||||||
@@ -616,8 +659,11 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
if (valFlag) {
|
if (valFlag) {
|
||||||
dstMap.put(commonSourceFieldCfg.getDstName(), dstStr);
|
dstMap.put(commonSourceFieldCfg.getDstName(), dstStr);
|
||||||
} else {
|
} else {
|
||||||
throw new RestServiceException(commonSourceFieldCfg.getSrcName() + "参数格式与正则("
|
throw new RestServiceException(
|
||||||
+ commonSourceFieldCfg.getRegexp()+ ")不匹配",RestBusinessCode.ValueInWrongRegexp.getValue());
|
commonSourceFieldCfg.getSrcName() + "参数格式与正则("
|
||||||
|
+ commonSourceFieldCfg.getRegexp()
|
||||||
|
+ ")不匹配",
|
||||||
|
RestBusinessCode.ValueInWrongRegexp.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StringUtil.isEmpty(dstMaps.get(Integer.valueOf(srcMap.get(
|
if (StringUtil.isEmpty(dstMaps.get(Integer.valueOf(srcMap.get(
|
||||||
@@ -634,7 +680,8 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new RestServiceException("service参数不能为空",RestBusinessCode.ServiceIsNull.getValue());
|
throw new RestServiceException("service参数不能为空",
|
||||||
|
RestBusinessCode.ServiceIsNull.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.info("------------------调用非maat配置新增接口-------------------");
|
logger.info("------------------调用非maat配置新增接口-------------------");
|
||||||
@@ -657,7 +704,8 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ServiceRuntimeException("service与写入数据库序号映射关系不存在",RestBusinessCode.ServiceNoFoundDBIndex.getValue());
|
throw new ServiceRuntimeException("service与写入数据库序号映射关系不存在",
|
||||||
|
RestBusinessCode.ServiceNoFoundDBIndex.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -677,29 +725,34 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void updateCommonSources(AuditLogThread thread, long start,
|
public void updateCommonSources(AuditLogThread thread, long start,
|
||||||
String jsonString, Date opTime, StringBuffer sb) throws Exception{
|
String jsonString, Date opTime, StringBuffer sb) throws Exception {
|
||||||
JsonArray jsonObjectList = null;
|
JsonArray jsonObjectList = null;
|
||||||
try {
|
try {
|
||||||
jsonObjectList = new JsonParser().parse(jsonString)
|
jsonObjectList = new JsonParser().parse(jsonString)
|
||||||
.getAsJsonArray();
|
.getAsJsonArray();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
throw new RestServiceException (RestBusinessCode.CBParamFormateError.getErrorReason()+","+e.getMessage(),RestBusinessCode.CBParamFormateError.getValue());
|
throw new RestServiceException(
|
||||||
|
RestBusinessCode.CBParamFormateError.getErrorReason() + ","
|
||||||
|
+ e.getMessage(),
|
||||||
|
RestBusinessCode.CBParamFormateError.getValue());
|
||||||
}
|
}
|
||||||
// <service,cfgIdList>
|
// <service,cfgIdList>
|
||||||
Map<Integer, List<Long>> cfgMap = new HashMap<Integer, List<Long>>();
|
Map<Integer, List<Long>> cfgMap = new HashMap<Integer, List<Long>>();
|
||||||
//所有状态更新的配置isValid的值必须相同
|
// 所有状态更新的配置isValid的值必须相同
|
||||||
Map<String, String> validIdMap = new HashMap<String, String>();
|
Map<String, String> validIdMap = new HashMap<String, String>();
|
||||||
for (int i = 0; i < jsonObjectList.size(); i++) {
|
for (int i = 0; i < jsonObjectList.size(); i++) {
|
||||||
JsonObject jsonObj = (JsonObject) jsonObjectList.get(i);
|
JsonObject jsonObj = (JsonObject) jsonObjectList.get(i);
|
||||||
Map<String, Object> srcMap = JSONObject.fromObject(JSONObject
|
Map<String, Object> srcMap = JSONObject.fromObject(JSONObject
|
||||||
.fromObject((jsonObj.toString())));
|
.fromObject((jsonObj.toString())));
|
||||||
checkOptForUpdate(srcMap);
|
checkOptForUpdate(srcMap);
|
||||||
validIdMap.put(srcMap.get("isValid").toString(), srcMap.get("isValid").toString());
|
validIdMap.put(srcMap.get("isValid").toString(),
|
||||||
|
srcMap.get("isValid").toString());
|
||||||
Integer service = Integer.valueOf(srcMap.get("service").toString());
|
Integer service = Integer.valueOf(srcMap.get("service").toString());
|
||||||
|
|
||||||
List<CommonSourceFieldCfg> list = ReadCommSourceXmlUtil.getCommonSourceCfgByService(service+"");
|
List<CommonSourceFieldCfg> list = ReadCommSourceXmlUtil
|
||||||
String srcName="cfgId";
|
.getCommonSourceCfgByService(service + "");
|
||||||
|
String srcName = "cfgId";
|
||||||
for (CommonSourceFieldCfg commonSourceFieldCfg : list) {
|
for (CommonSourceFieldCfg commonSourceFieldCfg : list) {
|
||||||
if (commonSourceFieldCfg.getIsCfgId()) {
|
if (commonSourceFieldCfg.getIsCfgId()) {
|
||||||
srcName = commonSourceFieldCfg.getSrcName();
|
srcName = commonSourceFieldCfg.getSrcName();
|
||||||
@@ -715,8 +768,10 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validIdMap.size()>1) {
|
if (validIdMap.size() > 1) {
|
||||||
throw new RestServiceException(RestBusinessCode.IsValidNonUniq.getErrorReason(), RestBusinessCode.IsValidNonUniq.getValue());
|
throw new RestServiceException(
|
||||||
|
RestBusinessCode.IsValidNonUniq.getErrorReason(),
|
||||||
|
RestBusinessCode.IsValidNonUniq.getValue());
|
||||||
}
|
}
|
||||||
Map<Integer, Map<Integer, List<Long>>> restMap = new HashMap<Integer, Map<Integer, List<Long>>>();
|
Map<Integer, Map<Integer, List<Long>>> restMap = new HashMap<Integer, Map<Integer, List<Long>>>();
|
||||||
Iterator serviceIterator = cfgMap.keySet().iterator();
|
Iterator serviceIterator = cfgMap.keySet().iterator();
|
||||||
@@ -736,16 +791,19 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ServiceRuntimeException("service与写入数据库序号映射关系不存在",RestBusinessCode.ServiceNoFoundDBIndex.getValue());
|
throw new ServiceRuntimeException("service与写入数据库序号映射关系不存在",
|
||||||
|
RestBusinessCode.ServiceNoFoundDBIndex.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
//停用时isInvalid=true,启用时isInvalid = false
|
// 停用时isInvalid=true,启用时isInvalid = false
|
||||||
configRedisService.delUnMaatConfig(restMap,validIdMap.containsKey("0")?true:false);
|
configRedisService.delUnMaatConfig(restMap,
|
||||||
|
validIdMap.containsKey("0") ? true : false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
throw e;
|
throw e;
|
||||||
//throw new ServiceRuntimeException(RestBusinessCode.service_runtime_error.getErrorReason(),RestBusinessCode.service_runtime_error.getValue());
|
// throw new
|
||||||
|
// ServiceRuntimeException(RestBusinessCode.service_runtime_error.getErrorReason(),RestBusinessCode.service_runtime_error.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,17 +815,22 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
* @param srcMap
|
* @param srcMap
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private void checkOptForUpdate(Map<String, Object> srcMap) throws Exception{
|
private void checkOptForUpdate(Map<String, Object> srcMap) throws Exception {
|
||||||
Object service = srcMap.get("service");
|
Object service = srcMap.get("service");
|
||||||
Object isValid = srcMap.get("isValid");
|
Object isValid = srcMap.get("isValid");
|
||||||
|
|
||||||
if (StringUtil.isEmpty(service)) {
|
if (StringUtil.isEmpty(service)) {
|
||||||
throw new RestServiceException(RestBusinessCode.ServiceIsNull.getErrorReason(),RestBusinessCode.ServiceIsNull.getValue());
|
throw new RestServiceException(
|
||||||
|
RestBusinessCode.ServiceIsNull.getErrorReason(),
|
||||||
|
RestBusinessCode.ServiceIsNull.getValue());
|
||||||
} else if (!StringUtil.isNumeric(service.toString())) {
|
} else if (!StringUtil.isNumeric(service.toString())) {
|
||||||
throw new RestServiceException("service字段格式不正确,"+RestBusinessCode.MastNumberic.getErrorReason(),RestBusinessCode.MastNumberic.getValue());
|
throw new RestServiceException("service字段格式不正确,"
|
||||||
|
+ RestBusinessCode.MastNumberic.getErrorReason(),
|
||||||
|
RestBusinessCode.MastNumberic.getValue());
|
||||||
}
|
}
|
||||||
List<CommonSourceFieldCfg> list = ReadCommSourceXmlUtil.getCommonSourceCfgByService(service+"");
|
List<CommonSourceFieldCfg> list = ReadCommSourceXmlUtil
|
||||||
String srcName="cfgId";
|
.getCommonSourceCfgByService(service + "");
|
||||||
|
String srcName = "cfgId";
|
||||||
for (CommonSourceFieldCfg commonSourceFieldCfg : list) {
|
for (CommonSourceFieldCfg commonSourceFieldCfg : list) {
|
||||||
if (commonSourceFieldCfg.getIsCfgId()) {
|
if (commonSourceFieldCfg.getIsCfgId()) {
|
||||||
srcName = commonSourceFieldCfg.getSrcName();
|
srcName = commonSourceFieldCfg.getSrcName();
|
||||||
@@ -775,21 +838,29 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
}
|
}
|
||||||
Object cfgId = srcMap.get(srcName);
|
Object cfgId = srcMap.get(srcName);
|
||||||
if (StringUtil.isEmpty(cfgId)) {
|
if (StringUtil.isEmpty(cfgId)) {
|
||||||
throw new RestServiceException(RestBusinessCode.CfgIdIsNull.getErrorReason(),RestBusinessCode.CfgIdIsNull.getValue());
|
throw new RestServiceException(
|
||||||
|
RestBusinessCode.CfgIdIsNull.getErrorReason(),
|
||||||
|
RestBusinessCode.CfgIdIsNull.getValue());
|
||||||
} else if (!StringUtil.isNumeric(cfgId.toString())) {
|
} else if (!StringUtil.isNumeric(cfgId.toString())) {
|
||||||
throw new RestServiceException("cfgId字段格式不正确,"+RestBusinessCode.MastNumberic.getErrorReason(),RestBusinessCode.MastNumberic.getValue());
|
throw new RestServiceException("cfgId字段格式不正确,"
|
||||||
|
+ RestBusinessCode.MastNumberic.getErrorReason(),
|
||||||
|
RestBusinessCode.MastNumberic.getValue());
|
||||||
}
|
}
|
||||||
if (StringUtil.isEmpty(isValid)) {
|
if (StringUtil.isEmpty(isValid)) {
|
||||||
throw new RestServiceException("配置id为" + srcMap.get("cfgId") + "的isValid字段不能为空",RestBusinessCode.IsValidIsNull.getValue());
|
throw new RestServiceException("配置id为" + srcMap.get("cfgId")
|
||||||
|
+ "的isValid字段不能为空",
|
||||||
|
RestBusinessCode.IsValidIsNull.getValue());
|
||||||
} else {
|
} else {
|
||||||
if (!StringUtil.isNumeric(service.toString())) {
|
if (!StringUtil.isNumeric(service.toString())) {
|
||||||
throw new RestServiceException(RestBusinessCode.IsValidInWrongRange.getErrorReason(),RestBusinessCode.IsValidInWrongRange.getValue());
|
throw new RestServiceException(
|
||||||
|
RestBusinessCode.IsValidInWrongRange.getErrorReason(),
|
||||||
|
RestBusinessCode.IsValidInWrongRange.getValue());
|
||||||
}
|
}
|
||||||
//配置取消改为状态更新(停/启用)
|
// 配置取消改为状态更新(停/启用)
|
||||||
// else if (!isValid.equals("0")) {
|
// else if (!isValid.equals("0")) {
|
||||||
// CompileVal.setBusinessCode(RestBusinessCode.IsValidIsF.getValue());
|
// CompileVal.setBusinessCode(RestBusinessCode.IsValidIsF.getValue());
|
||||||
// return RestBusinessCode.IsValidIsF.getErrorReason();
|
// return RestBusinessCode.IsValidIsF.getErrorReason();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -833,4 +904,307 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @Description:增加分组复用域配置
|
||||||
|
* @author (zdx)
|
||||||
|
* @date 2018年5月25日 下午3:49:46
|
||||||
|
* @param thread
|
||||||
|
* @param start
|
||||||
|
* @param configCompileList
|
||||||
|
* @param sb
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public void addGroupReuseSources(AuditLogThread thread, long start,
|
||||||
|
List<GroupReuse> groupReuseList, StringBuffer sb) throws Exception {
|
||||||
|
// Map<service,List<maat配置>> 存放解析后输入数据
|
||||||
|
Map<Integer, List<MaatConfig>> maatMap = new HashMap<Integer, List<MaatConfig>>();
|
||||||
|
// Map<service,List<maat配置>> 存放多分发的数据
|
||||||
|
Map<Integer, List<MaatConfig>> configMap = new HashMap<Integer, List<MaatConfig>>();
|
||||||
|
//验证
|
||||||
|
GroupReuseVal.valGroupReuse(groupReuseList, false);
|
||||||
|
|
||||||
|
for (GroupReuse groupReuse : groupReuseList) {
|
||||||
|
Integer service = groupReuse.getService();
|
||||||
|
MaatConfig maatConfig = new MaatConfig();
|
||||||
|
maatConfig.setService(service);
|
||||||
|
List<Map<String, String>> dstMaplList = null;
|
||||||
|
// 字符串域
|
||||||
|
List<Map<String, String>> strongMapList = null;
|
||||||
|
if (!StringUtil.isEmpty(groupReuse.getStrRegionList())) {
|
||||||
|
dstMaplList = new ArrayList<Map<String, String>>();
|
||||||
|
for (StrRegion region : groupReuse.getStrRegionList()) {
|
||||||
|
if (StringUtil.isEmpty(region.getDistrict())) {
|
||||||
|
dstMaplList.add(convertObjectToMap(region,
|
||||||
|
StrRegion.class));
|
||||||
|
} else {
|
||||||
|
if (StringUtil.isEmpty(strongMapList)) {
|
||||||
|
strongMapList = new ArrayList<Map<String, String>>();
|
||||||
|
}
|
||||||
|
strongMapList.add(convertObjectToMap(region,
|
||||||
|
StrRegion.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maatConfig.setStrRegionMapList(dstMaplList);
|
||||||
|
// 增强字符串域
|
||||||
|
if (!StringUtil.isEmpty(strongMapList) && strongMapList.size() > 0) {
|
||||||
|
maatConfig.setStrStrRegionMapList((strongMapList));
|
||||||
|
}
|
||||||
|
// 数值域
|
||||||
|
dstMaplList = null;
|
||||||
|
if (!StringUtil.isEmpty(groupReuse.getNumRegionList())) {
|
||||||
|
dstMaplList = new ArrayList<Map<String, String>>();
|
||||||
|
for (NumRegion region : groupReuse.getNumRegionList()) {
|
||||||
|
dstMaplList
|
||||||
|
.add(convertObjectToMap(region, NumRegion.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maatConfig.setNumRegionMapList(dstMaplList);
|
||||||
|
|
||||||
|
// Ip域
|
||||||
|
dstMaplList = null;
|
||||||
|
if (!StringUtil.isEmpty(groupReuse.getIpRegionList())) {
|
||||||
|
dstMaplList = new ArrayList<Map<String, String>>();
|
||||||
|
for (IpRegion region : groupReuse.getIpRegionList()) {
|
||||||
|
dstMaplList.add(convertObjectToMap(region, IpRegion.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maatConfig.setIpRegionMapList(dstMaplList);
|
||||||
|
|
||||||
|
if (maatMap.containsKey(service)) {
|
||||||
|
maatMap.get(service).add(maatConfig);
|
||||||
|
} else {
|
||||||
|
List<MaatConfig> maatCfgList = new ArrayList<MaatConfig>();
|
||||||
|
maatCfgList.add(maatConfig);
|
||||||
|
maatMap.put(service, maatCfgList);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 调用接口入redis
|
||||||
|
// 根据service分发到各系统
|
||||||
|
Iterator serviceIterator = maatMap.keySet().iterator();
|
||||||
|
while (serviceIterator.hasNext()) {
|
||||||
|
Integer service = Integer
|
||||||
|
.valueOf(serviceIterator.next().toString());
|
||||||
|
List<Integer> dbIndexList = ServiceAndRDBIndexReal
|
||||||
|
.getRedisDBByService(service);
|
||||||
|
if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) {
|
||||||
|
for (Integer dbIndex : dbIndexList) {
|
||||||
|
List<MaatConfig> newMaatConfigList = new ArrayList<MaatConfig>();
|
||||||
|
newMaatConfigList.addAll(maatMap.get(service));
|
||||||
|
if (configMap.containsKey(dbIndex)) {
|
||||||
|
configMap.get(dbIndex).addAll(newMaatConfigList);
|
||||||
|
} else {
|
||||||
|
List<MaatConfig> list = new ArrayList<MaatConfig>();
|
||||||
|
list.addAll(newMaatConfigList);
|
||||||
|
configMap.put(dbIndex, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new ServiceRuntimeException(
|
||||||
|
RestBusinessCode.ServiceNoFoundDBIndex.getErrorReason(),
|
||||||
|
RestBusinessCode.ServiceNoFoundDBIndex.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.info("---------------调用Redis 分组复用配置新增接口---------------------");
|
||||||
|
// configRedisService.addGroupReuseConfig(configMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @Description:删除分组复用域配置
|
||||||
|
* @author (zdx)
|
||||||
|
* @date 2018年8月23日 下午7:37:14
|
||||||
|
* @param thread
|
||||||
|
* @param start
|
||||||
|
* @param groupReuseList
|
||||||
|
* @param opTime
|
||||||
|
* @param sb
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void deleteGroupReuseSources(AuditLogThread thread, long start,
|
||||||
|
List<GroupReuse> groupReuseList, Date opTime, StringBuffer sb)
|
||||||
|
throws Exception {
|
||||||
|
//按service分类
|
||||||
|
Map<Integer, List<MaatConfig>> maatMap = new HashMap<Integer, List<MaatConfig>>();
|
||||||
|
|
||||||
|
GroupReuseVal.valGroupReuse(groupReuseList, false);
|
||||||
|
for (GroupReuse groupReuse : groupReuseList) {
|
||||||
|
//验证格式
|
||||||
|
checkGroupReuseForUpdate(groupReuse);
|
||||||
|
|
||||||
|
Integer service = groupReuse.getService();
|
||||||
|
MaatConfig maatConfig = new MaatConfig();
|
||||||
|
maatConfig.setService(service);
|
||||||
|
List<Map<String, String>> dstMaplList = null;
|
||||||
|
// 字符串域
|
||||||
|
List<Map<String, String>> strongMapList = null;
|
||||||
|
if (!StringUtil.isEmpty(groupReuse.getStrRegionList())) {
|
||||||
|
dstMaplList = new ArrayList<Map<String, String>>();
|
||||||
|
for (StrRegion region : groupReuse.getStrRegionList()) {
|
||||||
|
if (StringUtil.isEmpty(region.getDistrict())) {
|
||||||
|
dstMaplList.add(convertObjectToMap(region,
|
||||||
|
StrRegion.class));
|
||||||
|
} else {
|
||||||
|
if (StringUtil.isEmpty(strongMapList)) {
|
||||||
|
strongMapList = new ArrayList<Map<String, String>>();
|
||||||
|
}
|
||||||
|
strongMapList.add(convertObjectToMap(region,
|
||||||
|
StrRegion.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maatConfig.setStrRegionMapList(dstMaplList);
|
||||||
|
// 增强字符串域
|
||||||
|
if (!StringUtil.isEmpty(strongMapList) && strongMapList.size() > 0) {
|
||||||
|
maatConfig.setStrStrRegionMapList((strongMapList));
|
||||||
|
}
|
||||||
|
// 数值域
|
||||||
|
dstMaplList = null;
|
||||||
|
if (!StringUtil.isEmpty(groupReuse.getNumRegionList())) {
|
||||||
|
dstMaplList = new ArrayList<Map<String, String>>();
|
||||||
|
for (NumRegion region : groupReuse.getNumRegionList()) {
|
||||||
|
dstMaplList
|
||||||
|
.add(convertObjectToMap(region, NumRegion.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maatConfig.setNumRegionMapList(dstMaplList);
|
||||||
|
|
||||||
|
// Ip域
|
||||||
|
dstMaplList = null;
|
||||||
|
if (!StringUtil.isEmpty(groupReuse.getIpRegionList())) {
|
||||||
|
dstMaplList = new ArrayList<Map<String, String>>();
|
||||||
|
for (IpRegion region : groupReuse.getIpRegionList()) {
|
||||||
|
dstMaplList.add(convertObjectToMap(region, IpRegion.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maatConfig.setIpRegionMapList(dstMaplList);
|
||||||
|
|
||||||
|
if (maatMap.containsKey(service)) {
|
||||||
|
maatMap.get(service).add(maatConfig);
|
||||||
|
} else {
|
||||||
|
List<MaatConfig> maatCfgList = new ArrayList<MaatConfig>();
|
||||||
|
maatCfgList.add(maatConfig);
|
||||||
|
maatMap.put(service, maatCfgList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.info("调用接口删除Redis中分组复用的域配置接口");
|
||||||
|
// 所有的都删除成功返回true
|
||||||
|
// if (!configRedisService.delMaatConfig(maatMap)) {
|
||||||
|
// throw new ServiceRuntimeException("删除分组利用域配置时出现异常,具体原因不详,请联系管理员",
|
||||||
|
// RestBusinessCode.service_runtime_error.getValue());
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @Description:验证service+regionId+isValid+tableName
|
||||||
|
* @author (zdx)
|
||||||
|
* @date 2017年8月16日 上午11:48:46
|
||||||
|
* @param config
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private void checkGroupReuseForUpdate(GroupReuse config)
|
||||||
|
throws Exception {
|
||||||
|
|
||||||
|
if (StringUtil.isEmpty(config.getService())) {
|
||||||
|
throw new RestServiceException(
|
||||||
|
RestBusinessCode.ServiceIsNull.getErrorReason(),
|
||||||
|
RestBusinessCode.ServiceIsNull.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ServiceAndRDBIndexReal.serviceIsReuse(config.getService())) {
|
||||||
|
throw new RestServiceException("server为空或" + config.getService()
|
||||||
|
+ "或不属于分组复用的业务类型",
|
||||||
|
RestBusinessCode.ServiceIsNullOrNotReuse.getValue());
|
||||||
|
}
|
||||||
|
Boolean hasRegionFlag = false;
|
||||||
|
Map<String, List<String>> regTabNameMap = ServiceAndRDBIndexReal
|
||||||
|
.getServiceGroupReuseMap(config.getService());
|
||||||
|
if (regTabNameMap.containsKey("numRegion")
|
||||||
|
&& !StringUtil.isEmpty(config.getNumRegionList())
|
||||||
|
&& config.getNumRegionList().size() > 0) {
|
||||||
|
hasRegionFlag = true;
|
||||||
|
List<NumRegion> numRegionList = config.getNumRegionList();
|
||||||
|
for (NumRegion numRegion : numRegionList) {
|
||||||
|
if (!StringUtil.isEmpty(numRegion.getTableName())
|
||||||
|
&& !CompileVal.type2TableNameIsOk(config.getService(),
|
||||||
|
numRegion.getTableName())) {
|
||||||
|
throw new RestServiceException("service为" + config.getService()
|
||||||
|
+ "的配置中numRegionList中的regionId为"
|
||||||
|
+ numRegion.getRegionId()
|
||||||
|
+ "的域配置tableName与业务类型不一致",
|
||||||
|
RestBusinessCode.TableNameUnmatchService
|
||||||
|
.getValue());
|
||||||
|
}
|
||||||
|
if (numRegion.getIsValid() != 0) {
|
||||||
|
throw new RestServiceException("service为" + config.getService()
|
||||||
|
+ "的配置中numRegionList中的regionId为"
|
||||||
|
+ numRegion.getRegionId() + "的域配置在修改时不能为有效",
|
||||||
|
RestBusinessCode.IsValidIsF.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (regTabNameMap.containsKey("strRegion")
|
||||||
|
&& !StringUtil.isEmpty(config.getStrRegionList())
|
||||||
|
&& config.getStrRegionList().size() > 0) {
|
||||||
|
hasRegionFlag = true;
|
||||||
|
List<StrRegion> strRegionList = config.getStrRegionList();
|
||||||
|
for (StrRegion strRegion : strRegionList) {
|
||||||
|
// if (groupReuse.getIsValid() != 0 &&
|
||||||
|
// !regionGroupIdList.contains(strRegion.getGroupId()))
|
||||||
|
// {
|
||||||
|
if (!StringUtil.isEmpty(strRegion.getTableName())
|
||||||
|
&& !CompileVal.type2TableNameIsOk(config.getService(),
|
||||||
|
strRegion.getTableName())) {
|
||||||
|
throw new RestServiceException("配置id为" + config.getService()
|
||||||
|
+ "的配置中strRegionList中的regionId为"
|
||||||
|
+ strRegion.getRegionId()
|
||||||
|
+ "的域配置tableName与业务类型不一致",
|
||||||
|
RestBusinessCode.TableNameUnmatchService
|
||||||
|
.getValue());
|
||||||
|
}
|
||||||
|
if (strRegion.getIsValid() != 0) {
|
||||||
|
throw new RestServiceException("配置id为" + config.getService()
|
||||||
|
+ "的配置中strRegionList中的regionId为"
|
||||||
|
+ strRegion.getRegionId() + "的域配置在修改时不能为有效",
|
||||||
|
RestBusinessCode.IsValidIsF.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else if (regTabNameMap.containsKey("ipRegion")
|
||||||
|
&& !StringUtil.isEmpty(config.getIpRegionList())
|
||||||
|
&& config.getIpRegionList().size() > 0) {
|
||||||
|
hasRegionFlag = true;
|
||||||
|
List<IpRegion> ipRegionList = config.getIpRegionList();
|
||||||
|
for (IpRegion ipRegion : ipRegionList) {
|
||||||
|
if (!StringUtil.isEmpty(ipRegion.getTableName())
|
||||||
|
&& !CompileVal.type2TableNameIsOk(config.getService(),
|
||||||
|
ipRegion.getTableName())) {
|
||||||
|
throw new RestServiceException("配置id为" + config.getService()
|
||||||
|
+ "的配置中ipRegionList中的regionId为"
|
||||||
|
+ ipRegion.getRegionId()
|
||||||
|
+ "的域配置tableName与业务类型不一致",
|
||||||
|
RestBusinessCode.TableNameUnmatchService
|
||||||
|
.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null == ipRegion.getIsValid() || ipRegion
|
||||||
|
.getIsValid() != 0) {
|
||||||
|
throw new RestServiceException("service为" + config.getService()
|
||||||
|
+ "的配置中ipRegionList中的regionId为"
|
||||||
|
+ ipRegion.getRegionId() + "的域配置在修改时不能为有效",
|
||||||
|
RestBusinessCode.IsValidIsF.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasRegionFlag) {
|
||||||
|
// 所有的域类型都不包括,可能是配置文件配错了
|
||||||
|
throw new ServiceRuntimeException("service为" + config.getService() + "的"
|
||||||
|
+ RestBusinessCode.ReuseRegionIsNull.getErrorReason(),
|
||||||
|
RestBusinessCode.ReuseRegionIsNull.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
##回流 0x60 96 loop
|
##回流 0x60 96 loop
|
||||||
##白名单 0x80 128 whitelist
|
##白名单 0x80 128 whitelist
|
||||||
|
|
||||||
service=1:128;2:128;16:16;17:16;18:16;19:16;20:16;21:16;22:16;23:16;24:16;26:16;27:16;30:16;31:16;32:16;33:16;34:16;35:16;36:16;128:1;129:1;130:1;131:1;132:1;133:1;134:1;135:1;136:1;137:1;138:1;139:1;140:1;141:1;142:1;143:1;144:1;145:1;147:1;148:1;256:16;257:16;258:16;259:16;260:16;267:16;384:1;385:1;386:1;387:1;388:1;395:1;512:1;513:1;514:64;515:64;517:80;521:128;528:48;544:2;560:80;576:16;592:1;750:128;768:96;1024:1;1026:1;1027:1;1028:1;1029:1;1030:1;1031:1;1040:32;1041:32;1042:32;1056:64;1057:64;1058:64;1059:64;1060:64;1152:1
|
service=1:128;2:128;16:16;17:16;18:16;19:16;20:16;21:16;22:16;23:16;24:16;26:16;27:16;30:16;31:16;32:16;33:16;34:16;35:16;36:16;37:16;128:1;129:1;130:1;131:1;132:1;133:1;134:1;135:1;136:1;137:1;138:1;139:1;140:1;141:1;142:1;143:1;144:1;145:1;147:1;148:1;149:1;256:16;257:16;258:16;259:16;260:16;267:16;384:1;385:1;386:1;387:1;388:1;395:1;512:1;513:1;514:64;515:64;517:80;521:128;528:48;544:2;560:80;576:16;592:1;750:128;768:96;1024:1;1026:1;1027:1;1028:1;1029:1;1030:1;1031:1;1040:32;1041:32;1042:32;1056:64;1057:64;1058:64;1059:64;1060:64;1152:1
|
||||||
|
|
||||||
#0x1E 0x8E 有问题:14:NTC_XMPP_REGION,NTC_XMPP_CONT 无表结构 不确定表是不是字符串类
|
#0x1E 0x8E 有问题:14:NTC_XMPP_REGION,NTC_XMPP_CONT 无表结构 不确定表是不是字符串类
|
||||||
|
|
||||||
@@ -65,6 +65,8 @@ service=1:128;2:128;16:16;17:16;18:16;19:16;20:16;21:16;22:16;23:16;24:16;26:16;
|
|||||||
35=10:APP_COMPILE;11:APP_GROUP;14:APP_POLICY,APP_SUBSCRIBE_ID;18:NTC_IP_RANGE
|
35=10:APP_COMPILE;11:APP_GROUP;14:APP_POLICY,APP_SUBSCRIBE_ID;18:NTC_IP_RANGE
|
||||||
#0x24 隧道行为阻断
|
#0x24 隧道行为阻断
|
||||||
36=10:APP_COMPILE;11:APP_GROUP;14:APP_POLICY,APP_SUBSCRIBE_ID;18:NTC_IP_RANGE
|
36=10:APP_COMPILE;11:APP_GROUP;14:APP_POLICY,APP_SUBSCRIBE_ID;18:NTC_IP_RANGE
|
||||||
|
#0x25 ASN IP阻断
|
||||||
|
37=10:NTC_COMPILE;11:NTC_GROUP;12:NTC_ASN_IP;14:APP_SUBSCRIBE_ID;18:NTC_IP_RANGE
|
||||||
|
|
||||||
#0x80 IP地址监测
|
#0x80 IP地址监测
|
||||||
128=10:NTC_COMPILE;11:NTC_GROUP;12:NTC_IP;14:NTC_SUBSCRIBE_ID;18:NTC_IP_RANGE
|
128=10:NTC_COMPILE;11:NTC_GROUP;12:NTC_IP;14:NTC_SUBSCRIBE_ID;18:NTC_IP_RANGE
|
||||||
@@ -104,6 +106,8 @@ service=1:128;2:128;16:16;17:16;18:16;19:16;20:16;21:16;22:16;23:16;24:16;26:16;
|
|||||||
147=10:APP_COMPILE;11:APP_GROUP;14:APP_POLICY,APP_SUBSCRIBE_ID;18:NTC_IP_RANGE
|
147=10:APP_COMPILE;11:APP_GROUP;14:APP_POLICY,APP_SUBSCRIBE_ID;18:NTC_IP_RANGE
|
||||||
#0x94 隧道行为监测
|
#0x94 隧道行为监测
|
||||||
148=10:APP_COMPILE;11:APP_GROUP;14:APP_POLICY,APP_SUBSCRIBE_ID;18:NTC_IP_RANGE
|
148=10:APP_COMPILE;11:APP_GROUP;14:APP_POLICY,APP_SUBSCRIBE_ID;18:NTC_IP_RANGE
|
||||||
|
#0x95 ASN IP监测
|
||||||
|
149=10:NTC_COMPILE;11:NTC_GROUP;12:NTC_ASN_IP;14:APP_SUBSCRIBE_ID;18:NTC_IP_RANGE
|
||||||
|
|
||||||
#0xA0 通联关系监测 monit 无配置
|
#0xA0 通联关系监测 monit 无配置
|
||||||
#0xA1 邮件泛收 monit 无配置
|
#0xA1 邮件泛收 monit 无配置
|
||||||
@@ -201,9 +205,8 @@ service=1:128;2:128;16:16;17:16;18:16;19:16;20:16;21:16;22:16;23:16;24:16;26:16;
|
|||||||
#0x480 APP 主题网站配置
|
#0x480 APP 主题网站配置
|
||||||
1152=10:APP_COMPILE;11:APP_GROUP;14:APP_TOPIC_DOMAIN,APP_SUBSCRIBE_ID;18:NTC_IP_RANGE
|
1152=10:APP_COMPILE;11:APP_GROUP;14:APP_TOPIC_DOMAIN,APP_SUBSCRIBE_ID;18:NTC_IP_RANGE
|
||||||
|
|
||||||
#格式:业务类型1:动作;业务类型2:动作 ( 用于验证回调类service与action对应关系) 删除所有回调类的action属性 zdx20180821
|
#格式:业务类型1:动作;业务类型2:动作 ( 用于验证回调类service与action对应关系
|
||||||
#unMaatService=3:32;4:96;5:32;25:32;28:32;64:16;65:16;261:16;262:16;263:16;264:16;265:16;266:16;389:1;390:1;391:1;392:1;393:1;394:1;832:96;1025:1
|
unMaatService=3:32;4:96;5:32;25:32;28:32;64;65;261:16;262:16;263:16;264:16;265:16;266:16;389:1;390:1;391:1;392:1;393:1;394:1;520;608;832;1025:1
|
||||||
unMaatService=3;4;5;25;28;64;65;261;262;263;264;265;266;389;390;391;392;393;394;520;608;832;1025
|
|
||||||
#0x03 IP地址丢弃
|
#0x03 IP地址丢弃
|
||||||
3=0:INLINE_IP_CB
|
3=0:INLINE_IP_CB
|
||||||
#0x04 IP地址回流
|
#0x04 IP地址回流
|
||||||
@@ -297,7 +300,7 @@ unMaatService=3;4;5;25;28;64;65;261;262;263;264;265;266;389;390;391;392;393;394;
|
|||||||
#0x19 IPSec丢弃 25:7;
|
#0x19 IPSec丢弃 25:7;
|
||||||
#0x340 IP复用地址池配置(回调)832:2,4,5,7
|
#0x340 IP复用地址池配置(回调)832:2,4,5,7
|
||||||
##########
|
##########
|
||||||
serviceDBIndex=1:2,3,4,6,7;2:2,3,4,6,7;16:2;17:2;18:2;19:2;20:2;21:2;22:2;23:2;24:2;26:2;27:2;30:2;31:2;32:2;33:2,6,7;34:2;35:2,6,7;36:2,6,7;128:2;129:2;130:2;131:2;132:2;133:2;134:2;135:2;136:2;137:2;138:2;139:2;140:2;141:2;142:2;143:2;144:2;145:2,6,7;147:2,6,7;148:2,6,7;256:3;257:3;258:3;259:3;260:3;267:3;384:3;385:3;386:3;387:3;388:3;395:3;512:4,7;513:4,2,7;514:4;515:4;517:4;520:4;521:4;528:4;544:4;560:4;576:4;592:4;608:4;750:4;768:5;1024:2,6,7;1024:2;1025:2;1026:2,6,7;1027:2,6,7;1028:2,6,7;1029:2,6,7;1030:2,6,7;1031:2,6,7;1040:2,6,7;1041:2,6,7;1042:2,6,7;1056:2,6,7;1057:6,7;1058:6,2,7;1059:2,6,7;1060:2,6,7;1152:2,6;3:7;4:7;5:2;25:7;28:7;64:2;65:2;261:8;262:9;263:10;264:11;265:3;266:3;389:8;390:9;391:10;392:11;393:3;394:3;832:2,4,5,7
|
serviceDBIndex=1:2,3,4,6,7;2:2,3,4,6,7;16:2;17:2;18:2;19:2;20:2;21:2;22:2;23:2;24:2;26:2;27:2;30:2;31:2;32:2;33:2,6,7;34:2;35:2,6,7;36:2,6,7;37:2;128:2;129:2;130:2;131:2;132:2;133:2;134:2;135:2;136:2;137:2;138:2;139:2;140:2;141:2;142:2;143:2;144:2;145:2,6,7;147:2,6,7;148:2,6,7;149:2;256:3;257:3;258:3;259:3;260:3;267:3;384:3;385:3;386:3;387:3;388:3;395:3;512:4,7;513:4,2,7;514:4;515:4;517:4;520:4;521:4;528:4;544:4;560:4;576:4;592:4;608:4;750:4;768:5;1024:2,6,7;1024:2;1025:2;1026:2,6,7;1027:2,6,7;1028:2,6,7;1029:2,6,7;1030:2,6,7;1031:2,6,7;1040:2,6,7;1041:2,6,7;1042:2,6,7;1056:2,6,7;1057:6,7;1058:6,2,7;1059:2,6,7;1060:2,6,7;1152:2,6;3:7;4:7;5:2;25:7;28:7;64:2;65:2;261:8;262:9;263:10;264:11;265:3;266:3;389:8;390:9;391:10;392:11;393:3;394:3;832:2,4,5,7
|
||||||
|
|
||||||
|
|
||||||
##maat配置入阀门需要将编译中的部分参数写到域配置中,目前最多包含ACTION,SERVICE,USER_REGION三个属性
|
##maat配置入阀门需要将编译中的部分参数写到域配置中,目前最多包含ACTION,SERVICE,USER_REGION三个属性
|
||||||
@@ -322,5 +325,6 @@ maat2Valve=33:strRegion@ACTION&SERVICE&USER_REGION;35:strRegion@ACTION&SERVICE&U
|
|||||||
|
|
||||||
|
|
||||||
##记录哪些service可以被分组复用(只有maat类配置可以被分组复用)
|
##记录哪些service可以被分组复用(只有maat类配置可以被分组复用)
|
||||||
serviceRepeatedReal=256,257,258,259,260,267,384,385,386,387,388,395,512,513,521,528,544,560,576,592,750,768
|
#业务ID:域类型1@表名,表名|域类型2@表名;业务ID:域类型1@表名,表名|域类型2@表名
|
||||||
|
##域类型:IP域 =ipRegion 字符串域=strRegion 数值域=numRegion
|
||||||
|
serviceRepeatedReal=37:ipRegion@NTC_ASN_IP;149:ipRegion@NTC_ASN_IP;1028:ipRegion@APP_STATIC_SER_IP
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
-->
|
-->
|
||||||
<t:commonSource serviceIds="3,4,25,28,5">
|
<t:commonSource serviceIds="3,4,25,28,5">
|
||||||
<t:field fieldType="String" srcName="service" dstName="service" isRequired="true"/>
|
<t:field fieldType="String" srcName="service" dstName="service" isRequired="true"/>
|
||||||
<!-- <t:field fieldType="Number" srcName="action" dstName="action" isRequired="true"/> -->
|
<t:field fieldType="Number" srcName="action" dstName="action" isRequired="true"/>
|
||||||
<t:field fieldType="Number" srcName="cfgId" dstName="cfg_id" isRequired="true" isCfgId="true"/>
|
<t:field fieldType="Number" srcName="cfgId" dstName="cfg_id" isRequired="true" isCfgId="true"/>
|
||||||
<t:field fieldType="Number" srcName="addrType" dstName="addr_type" isRequired="true" regexp="^([4|6]{1})|46|64|10$"/>
|
<t:field fieldType="Number" srcName="addrType" dstName="addr_type" isRequired="true" regexp="^([4|6]{1})|46|64|10$"/>
|
||||||
<t:field fieldType="IP" srcName="srcIp" dstName="src_ip" isRequired="true" isSrcInfo="true"/>
|
<t:field fieldType="IP" srcName="srcIp" dstName="src_ip" isRequired="true" isSrcInfo="true"/>
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
-->
|
-->
|
||||||
<t:commonSource serviceIds="261,262,263,264,389,390,391,392,1025">
|
<t:commonSource serviceIds="261,262,263,264,389,390,391,392,1025">
|
||||||
<t:field fieldType="String" srcName="service" dstName="service" isRequired="true"/>
|
<t:field fieldType="String" srcName="service" dstName="service" isRequired="true"/>
|
||||||
<!-- <t:field fieldType="Number" srcName="action" dstName="action" isRequired="true"/> -->
|
<t:field fieldType="Number" srcName="action" dstName="action" isRequired="true"/>
|
||||||
<t:field fieldType="Number" srcName="cfgId" dstName="cfg_id" isRequired="true" isCfgId="true"/>
|
<t:field fieldType="Number" srcName="cfgId" dstName="cfg_id" isRequired="true" isCfgId="true"/>
|
||||||
<t:field fieldType="String" srcName="dstFile" dstName="dst_file" isRequired="true"/>
|
<t:field fieldType="String" srcName="dstFile" dstName="dst_file" isRequired="true"/>
|
||||||
<t:field fieldType="String" srcName="dstFileMd5" dstName="dst_file_md5" isRequired="true"/>
|
<t:field fieldType="String" srcName="dstFileMd5" dstName="dst_file_md5" isRequired="true"/>
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
-->
|
-->
|
||||||
<t:commonSource serviceIds="265,266,393,394">
|
<t:commonSource serviceIds="265,266,393,394">
|
||||||
<t:field fieldType="String" srcName="service" dstName="service" isRequired="true"/>
|
<t:field fieldType="String" srcName="service" dstName="service" isRequired="true"/>
|
||||||
<!-- <t:field fieldType="Number" srcName="action" dstName="action" isRequired="true"/> -->
|
<t:field fieldType="Number" srcName="action" dstName="action" isRequired="true"/>
|
||||||
<t:field fieldType="Number" srcName="cfgId" dstName="cfg_id" isRequired="true" isCfgId="true"/>
|
<t:field fieldType="Number" srcName="cfgId" dstName="cfg_id" isRequired="true" isCfgId="true"/>
|
||||||
<t:field fieldType="String" srcName="description" dstName="description" isRequired="true"/>
|
<t:field fieldType="String" srcName="description" dstName="description" isRequired="true"/>
|
||||||
<t:field fieldType="Number" srcName="level" dstName="level" range="0-100" defaultVal="0"/>
|
<t:field fieldType="Number" srcName="level" dstName="level" range="0-100" defaultVal="0"/>
|
||||||
@@ -141,7 +141,7 @@
|
|||||||
<t:field fieldType="String" srcName="publicKeyAlgo" dstName="public_key_algo" isRequired="true"/>
|
<t:field fieldType="String" srcName="publicKeyAlgo" dstName="public_key_algo" isRequired="true"/>
|
||||||
<t:field fieldType="Number" srcName="crl" dstName="crl" defaultVal=""/>
|
<t:field fieldType="Number" srcName="crl" dstName="crl" defaultVal=""/>
|
||||||
<t:field fieldType="Number" srcName="isValid" dstName="is_valid" isRequired="true" regexp="[1]"/>
|
<t:field fieldType="Number" srcName="isValid" dstName="is_valid" isRequired="true" regexp="[1]"/>
|
||||||
<t:field fieldType="Date" srcName="opTime" dstName="op_time" isRequired="true"/>
|
<!-- <t:field fieldType="Date" srcName="opTime" dstName="op_time" isRequired="true"/> -->
|
||||||
</t:commonSource>
|
</t:commonSource>
|
||||||
|
|
||||||
<!-- # 0x260 PXY 管控文件策略 608=0:PXY_OBJ_FILE -->
|
<!-- # 0x260 PXY 管控文件策略 608=0:PXY_OBJ_FILE -->
|
||||||
@@ -153,7 +153,7 @@
|
|||||||
<t:field fieldType="Number" srcName="contentLength" dstName="content_length" isRequired="true"/>
|
<t:field fieldType="Number" srcName="contentLength" dstName="content_length" isRequired="true"/>
|
||||||
<t:field fieldType="String" srcName="filePath" dstName="file_path" isRequired="true"/>
|
<t:field fieldType="String" srcName="filePath" dstName="file_path" isRequired="true"/>
|
||||||
<t:field fieldType="Number" srcName="isValid" dstName="is_valid" isRequired="true" regexp="[1]"/>
|
<t:field fieldType="Number" srcName="isValid" dstName="is_valid" isRequired="true" regexp="[1]"/>
|
||||||
<t:field fieldType="Date" srcName="opTime" dstName="op_time" isRequired="true"/>
|
<!-- <t:field fieldType="Date" srcName="opTime" dstName="op_time" isRequired="true"/> -->
|
||||||
</t:commonSource>
|
</t:commonSource>
|
||||||
</t:commonSources>
|
</t:commonSources>
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<p:expressions>
|
<p:expressions>
|
||||||
<p:keyExpression>EFFECTIVE_RULE;:;{un_maat_table_name};,;[cfg_id]</p:keyExpression>
|
<p:keyExpression>EFFECTIVE_RULE;:;{un_maat_table_name};,;[cfg_id]</p:keyExpression>
|
||||||
<!-- 最开始调整的这个,格式不是\t;[op_time];&nbsp;0;\n,后面的要求都改成这个格式,前端不好该代码,所以这个与其他的有区别 -->
|
<!-- 最开始调整的这个,格式不是\t;[op_time];&nbsp;0;\n,后面的要求都改成这个格式,前端不好该代码,所以这个与其他的有区别 -->
|
||||||
<p:valueExpression>[cfg_id];\t;[is_valid];\t;[dst_file];\t;[dst_file_md5];\t;[op_time];&nbsp;[service];\t;0;\t;[file_id];\n</p:valueExpression>
|
<p:valueExpression>[cfg_id];\t;[is_valid];\t;[dst_file];\t;[dst_file_md5];\t;[op_time];&nbsp;[service];\t;[action];\t;0;\t;[file_id];\n</p:valueExpression>
|
||||||
<!-- <p:valueExpression>[cfg_id];\t;[is_valid];\t;[dst_file];\t;[dst_file_md5];\t;[time_stamp];&nbsp;[level];\t;[file_id];\n</p:valueExpression> -->
|
<!-- <p:valueExpression>[cfg_id];\t;[is_valid];\t;[dst_file];\t;[dst_file_md5];\t;[time_stamp];&nbsp;[level];\t;[file_id];\n</p:valueExpression> -->
|
||||||
</p:expressions>
|
</p:expressions>
|
||||||
<p:sequences>
|
<p:sequences>
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
<p:maatType service="265;266;393;394">
|
<p:maatType service="265;266;393;394">
|
||||||
<p:expressions>
|
<p:expressions>
|
||||||
<p:keyExpression>EFFECTIVE_RULE;:;{un_maat_table_name};,;[cfg_id]</p:keyExpression>
|
<p:keyExpression>EFFECTIVE_RULE;:;{un_maat_table_name};,;[cfg_id]</p:keyExpression>
|
||||||
<p:valueExpression>[cfg_id];\t;[service];\t;[level];\t;[description];\t;[is_valid];\t;[op_time];&nbsp;0;\n</p:valueExpression>
|
<p:valueExpression>[cfg_id];\t;[service];\t;[action];\t; [level];\t;[description];\t;[is_valid];\t;[op_time];&nbsp;0;\n</p:valueExpression>
|
||||||
</p:expressions>
|
</p:expressions>
|
||||||
<p:sequences>
|
<p:sequences>
|
||||||
<p:operation>1</p:operation>
|
<p:operation>1</p:operation>
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
<p:maatType service="3;4;25;28;5">
|
<p:maatType service="3;4;25;28;5">
|
||||||
<p:expressions>
|
<p:expressions>
|
||||||
<p:keyExpression>EFFECTIVE_RULE;:;{un_maat_table_name};,;[cfg_id]</p:keyExpression>
|
<p:keyExpression>EFFECTIVE_RULE;:;{un_maat_table_name};,;[cfg_id]</p:keyExpression>
|
||||||
<p:valueExpression>[cfg_id];\t;0;\t;[addr_type];\t;[src_ip];\t;[mask_src_ip];\t;[src_port];\t;[mask_src_port];\t;[dst_ip];\t;[mask_dst_ip];\t;[dst_port];\t;[mask_dst_port];\t;[protocol];\t;[direction];\t;[is_valid];\t;[service];\t;[op_time];&nbsp;0;\n</p:valueExpression>
|
<p:valueExpression>[cfg_id];\t;0;\t;[addr_type];\t;[src_ip];\t;[mask_src_ip];\t;[src_port];\t;[mask_src_port];\t;[dst_ip];\t;[mask_dst_ip];\t;[dst_port];\t;[mask_dst_port];\t;[protocol];\t;[direction];\t;[is_valid];\t;[action];\t;[service];\t;[op_time];&nbsp;0;\n</p:valueExpression>
|
||||||
</p:expressions>
|
</p:expressions>
|
||||||
<p:sequences>
|
<p:sequences>
|
||||||
<p:operation>1</p:operation>
|
<p:operation>1</p:operation>
|
||||||
@@ -177,7 +177,7 @@
|
|||||||
</p:expressions>
|
</p:expressions>
|
||||||
</p:maatType>
|
</p:maatType>
|
||||||
<p:maatType
|
<p:maatType
|
||||||
service="1;2;16;17;18;19;20;21;22;23;24;26;27;30;31;32;33;34;35;36;128;129;130;131;132;133;134;135;136;137;138;139;140;141;142;143;144;145;147;148;256;257;258;259;260;267;384;385;386;387;388;395;512;513;514;515;517;521;528;544;560;576;592;750;768;848;1024;1026;1027;1028;1029;1030;1031;1040;1041;1042;1056;1057;1058;1059;1060;1152">
|
service="1;2;16;17;18;19;20;21;22;23;24;26;27;30;31;32;33;34;35;36;37;128;129;130;131;132;133;134;135;136;137;138;139;140;141;142;143;144;145;147;148;149;256;257;258;259;260;267;384;385;386;387;388;395;512;513;514;515;517;521;528;544;560;576;592;750;768;848;1024;1026;1027;1028;1029;1030;1031;1040;1041;1042;1056;1057;1058;1059;1060;1152">
|
||||||
<p:expressions>
|
<p:expressions>
|
||||||
<p:keyExpression>EFFECTIVE_RULE;:;{compile_table_name};,;[compile_id]</p:keyExpression>
|
<p:keyExpression>EFFECTIVE_RULE;:;{compile_table_name};,;[compile_id]</p:keyExpression>
|
||||||
<p:valueExpression>[compile_id];\t;[service];\t;[action];\t;[do_blacklist];\t;[do_log];\t;[effective_range];\t;[user_region];\t;[is_valid];\t;[group_num];\t;[father_cfg_id];\t;[op_time];&nbsp;0;\n</p:valueExpression>
|
<p:valueExpression>[compile_id];\t;[service];\t;[action];\t;[do_blacklist];\t;[do_log];\t;[effective_range];\t;[user_region];\t;[is_valid];\t;[group_num];\t;[father_cfg_id];\t;[op_time];&nbsp;0;\n</p:valueExpression>
|
||||||
|
|||||||
Reference in New Issue
Block a user