1:完善maat类配置下发程序

2:删除对ip域配置对象集合的大小判断
This commit is contained in:
RenKaiGe-Office
2018-08-14 14:25:09 +08:00
parent 8e132327aa
commit d3704bcb22
4 changed files with 543 additions and 342 deletions

View File

@@ -30,40 +30,51 @@ public class CompileVal {
*
*/
@SuppressWarnings("null")
public static void groupNumAndListIsOk(ConfigCompile configCompile, boolean isUpdate) throws Exception{
public static void groupNumAndListIsOk(ConfigCompile configCompile, boolean isUpdate) throws Exception {
if (null != configCompile) {
if (!isUpdate && Constants.BASE_VALIDATE) {
valCompile(configCompile);
}
if (null != configCompile.getGroupNum() && configCompile.getGroupNum() <= 0) {
throw new RestServiceException("编译配置id为" + configCompile.getCompileId() + "的配置中"
+ RestBusinessCode.GroupNumIsZero.getErrorReason(),RestBusinessCode.GroupNumIsZero.getValue());
throw new RestServiceException(
"编译配置id为" + configCompile.getCompileId() + "的配置中"
+ RestBusinessCode.GroupNumIsZero.getErrorReason(),
RestBusinessCode.GroupNumIsZero.getValue());
}
if (null != configCompile.getGroupNum() && configCompile.getGroupNum() > 8) {
throw new RestServiceException("编译配置id为" + configCompile.getCompileId() + "的配置中"
+ RestBusinessCode.GroupNumGtEight.getErrorReason(),RestBusinessCode.GroupNumGtEight.getValue());
throw new RestServiceException(
"编译配置id为" + configCompile.getCompileId() + "的配置中"
+ RestBusinessCode.GroupNumGtEight.getErrorReason(),
RestBusinessCode.GroupNumGtEight.getValue());
}
if (null == configCompile.getGroupRelationList()||configCompile.getGroupRelationList().size()==0) {
throw new RestServiceException("编译配置id为" + configCompile.getCompileId() + "的配置中"
+ RestBusinessCode.CompileGroupIsNull.getErrorReason(),RestBusinessCode.CompileGroupIsNull.getValue());
if (null == configCompile.getGroupRelationList() || configCompile.getGroupRelationList().size() == 0) {
throw new RestServiceException(
"编译配置id为" + configCompile.getCompileId() + "的配置中"
+ RestBusinessCode.CompileGroupIsNull.getErrorReason(),
RestBusinessCode.CompileGroupIsNull.getValue());
}
if (configCompile.getGroupRelationList().size() != configCompile.getGroupNum()) {
throw new RestServiceException("编译配置id为" + configCompile.getCompileId() + "的配置中"
+ RestBusinessCode.GroupNumNEQGroupList.getErrorReason(),RestBusinessCode.GroupNumNEQGroupList.getValue());
throw new RestServiceException(
"编译配置id为" + configCompile.getCompileId() + "的配置中"
+ RestBusinessCode.GroupNumNEQGroupList.getErrorReason(),
RestBusinessCode.GroupNumNEQGroupList.getValue());
}
if (!isUpdate) {
if (configCompile.getIsValid() != 1)
throw new RestServiceException("编译配置id为" + configCompile.getCompileId() + "的配置在添加时不能为无效",RestBusinessCode.IsValidIsT.getValue());{
throw new RestServiceException("编译配置id为" + configCompile.getCompileId() + "的配置在添加时不能为无效",
RestBusinessCode.IsValidIsT.getValue());
{
}
} else {
throw new RestServiceException("编译配置id为" + configCompile.getCompileId() + "的配置在修改时不能为有效",RestBusinessCode.IsValidIsF.getValue());
throw new RestServiceException("编译配置id为" + configCompile.getCompileId() + "的配置在修改时不能为有效",
RestBusinessCode.IsValidIsF.getValue());
}
} else {
throw new RestServiceException(RestBusinessCode.CompileIsNull.getErrorReason(),RestBusinessCode.CompileIsNull.getValue());
throw new RestServiceException(RestBusinessCode.CompileIsNull.getErrorReason(),
RestBusinessCode.CompileIsNull.getValue());
}
}
@@ -76,7 +87,8 @@ public class CompileVal {
* @return CompileGroupSizeGtZero CompileGroupSizeEqZero
* CompileGroupIdNotExist CompileGroupIdIsRepeat GroupListEQZero
*/
public static void compileGroupSizeIsGtZero(ConfigCompile configCompile, boolean isUpdate, StringBuffer sb) throws Exception {
public static void compileGroupSizeIsGtZero(ConfigCompile configCompile, boolean isUpdate, StringBuffer sb)
throws Exception {
Long compileId = configCompile.getCompileId();
if (!isUpdate && Constants.SERVICE_VALIDATE) {
@@ -88,12 +100,16 @@ public class CompileVal {
if (groupRelationList.size() > 0) {
for (ConfigGroupRelation configGroupRelation : groupRelationList) {
if (!isUpdate && (null == configGroupRelation.getIsValid() || configGroupRelation.getIsValid() != 1)) {
throw new RestServiceException("编译配置id为" + configCompile.getCompileId() + "的配置groupRelationList字段中的groupId为"
+ configGroupRelation.getGroupId() + "的配置在添加时不能为无效",RestBusinessCode.IsValidIsT.getValue());
throw new RestServiceException(
"编译配置id为" + configCompile.getCompileId() + "的配置groupRelationList字段中的groupId为"
+ configGroupRelation.getGroupId() + "的配置在添加时不能为无效",
RestBusinessCode.IsValidIsT.getValue());
}
if (isUpdate && (null == configGroupRelation.getIsValid() || configGroupRelation.getIsValid() != 0)) {
throw new RestServiceException("编译配置id为" + configCompile.getCompileId() + "的配置groupRelationList字段中的groupId为"
+ configGroupRelation.getGroupId() + "的配置在修改时不能为有效",RestBusinessCode.IsValidIsF.getValue());
throw new RestServiceException(
"编译配置id为" + configCompile.getCompileId() + "的配置groupRelationList字段中的groupId为"
+ configGroupRelation.getGroupId() + "的配置在修改时不能为有效",
RestBusinessCode.IsValidIsF.getValue());
}
if (!isUpdate && Constants.BASE_VALIDATE) {
@@ -101,14 +117,18 @@ public class CompileVal {
}
if (!configGroupRelation.getCompileId().equals(compileId)) {
throw new RestServiceException("编译配置id为" + configCompile.getCompileId() + "的配置中groupRelationList字段中的groupId为"
+ configGroupRelation.getGroupId() + "的配置分组与编译配置id不一致", RestBusinessCode.CompileIdIsNeq.getValue());
throw new RestServiceException(
"编译配置id为" + configCompile.getCompileId() + "的配置中groupRelationList字段中的groupId为"
+ configGroupRelation.getGroupId() + "的配置分组与编译配置id不一致",
RestBusinessCode.CompileIdIsNeq.getValue());
}
if (!groupList.contains(configGroupRelation.getGroupId())) {
groupList.add(configGroupRelation.getGroupId());
} else {
throw new RestServiceException("编译配置id为" + configCompile.getCompileId() + "的配置中groupRelationList存在多个groupId为"
+ configGroupRelation.getGroupId() + "的配置分组",RestBusinessCode.GroupIdIsRepeat.getValue());
throw new RestServiceException(
"编译配置id为" + configCompile.getCompileId() + "的配置中groupRelationList存在多个groupId为"
+ configGroupRelation.getGroupId() + "的配置分组",
RestBusinessCode.GroupIdIsRepeat.getValue());
}
}
}
@@ -116,8 +136,10 @@ public class CompileVal {
List<Long> regionGroupIdList = new ArrayList<Long>();// 所有域配置中groupId的集合,不重复
List<NumRegion> numRegionList = configCompile.getNumRegionList();
if (numRegionList == null) {
throw new RestServiceException("编译配置id为" + configCompile.getCompileId() + "的配置中"
+ RestBusinessCode.NumRegionIsNull.getErrorReason(),RestBusinessCode.NumRegionIsNull.getValue());
throw new RestServiceException(
"编译配置id为" + configCompile.getCompileId() + "的配置中"
+ RestBusinessCode.NumRegionIsNull.getErrorReason(),
RestBusinessCode.NumRegionIsNull.getValue());
}
if (numRegionList.size() > 0) {
for (NumRegion numRegion : numRegionList) {
@@ -126,21 +148,29 @@ public class CompileVal {
if (!StringUtil.isEmpty(numRegion.getTableName())
&& !type2TableNameIsOk(configCompile.getService(), numRegion.getTableName())) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中numRegionList中的regionId为"
+ numRegion.getRegionId() + "配置tableName与编译配置业务类型不一致",RestBusinessCode.TableNameUnmatchService.getValue());
throw new RestServiceException(
"配置id为" + configCompile.getCompileId() + "的配置中numRegionList中的regionId为"
+ numRegion.getRegionId() + "的域配置tableName与编译配置业务类型不一致",
RestBusinessCode.TableNameUnmatchService.getValue());
}
if (!isUpdate && numRegion.getIsValid() != 1) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中numRegionList中的regionId为"
+ numRegion.getRegionId() + "配置在添加时不能为无效",RestBusinessCode.IsValidIsT.getValue());
throw new RestServiceException(
"配置id为" + configCompile.getCompileId() + "的配置中numRegionList中的regionId为"
+ numRegion.getRegionId() + "的域配置在添加时不能为无效",
RestBusinessCode.IsValidIsT.getValue());
}
if (isUpdate && numRegion.getIsValid() != 0) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中numRegionList中的regionId为"
+ numRegion.getRegionId() + "配置在修改时不能为有效",RestBusinessCode.IsValidIsF.getValue());
throw new RestServiceException(
"配置id为" + configCompile.getCompileId() + "的配置中numRegionList中的regionId为"
+ numRegion.getRegionId() + "的域配置在修改时不能为有效",
RestBusinessCode.IsValidIsF.getValue());
}
if (groupList.size() > 0 && !groupList.contains(numRegion.getGroupId())) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中numRegionList中的regionId为"
+ numRegion.getRegionId() + "的配置的groupId在配置分组关系中不存在",RestBusinessCode.RegionsGroupIdIsNotFound.getValue());
throw new RestServiceException(
"配置id为" + configCompile.getCompileId() + "的配置中numRegionList中的regionId为"
+ numRegion.getRegionId() + "的配置的groupId在配置分组关系中不存在",
RestBusinessCode.RegionsGroupIdIsNotFound.getValue());
}
if (!regionGroupIdList.contains(numRegion.getGroupId())) {
@@ -158,8 +188,10 @@ public class CompileVal {
List<StrRegion> strRegionList = configCompile.getStrRegionList();
if (strRegionList == null) {
throw new RestServiceException("编译配置id为" + configCompile.getCompileId() + "的配置中"
+ RestBusinessCode.StrRegionIsNull.getErrorReason(),RestBusinessCode.StrRegionIsNull.getValue());
throw new RestServiceException(
"编译配置id为" + configCompile.getCompileId() + "的配置中"
+ RestBusinessCode.StrRegionIsNull.getErrorReason(),
RestBusinessCode.StrRegionIsNull.getValue());
}
if (strRegionList != null && strRegionList.size() > 0) {
for (StrRegion strRegion : strRegionList) {
@@ -167,21 +199,29 @@ public class CompileVal {
// !regionGroupIdList.contains(strRegion.getGroupId())) {
if (!StringUtil.isEmpty(strRegion.getTableName())
&& !type2TableNameIsOk(configCompile.getService(), strRegion.getTableName())) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中strRegionList中的regionId为"
+ strRegion.getRegionId() + "配置tableName与编译配置业务类型不一致",RestBusinessCode.TableNameUnmatchService.getValue());
throw new RestServiceException(
"配置id为" + configCompile.getCompileId() + "的配置中strRegionList中的regionId为"
+ strRegion.getRegionId() + "的域配置tableName与编译配置业务类型不一致",
RestBusinessCode.TableNameUnmatchService.getValue());
}
if (!isUpdate && strRegion.getIsValid() != 1) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中strRegionList中的regionId为"
+ strRegion.getRegionId() + "配置在添加时不能为无效",RestBusinessCode.IsValidIsT.getValue());
throw new RestServiceException(
"配置id为" + configCompile.getCompileId() + "的配置中strRegionList中的regionId为"
+ strRegion.getRegionId() + "的域配置在添加时不能为无效",
RestBusinessCode.IsValidIsT.getValue());
}
if (isUpdate && strRegion.getIsValid() != 0) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中strRegionList中的regionId为"
+ strRegion.getRegionId() + "配置在修改时不能为有效",RestBusinessCode.IsValidIsF.getValue());
throw new RestServiceException(
"配置id为" + configCompile.getCompileId() + "的配置中strRegionList中的regionId为"
+ strRegion.getRegionId() + "的域配置在修改时不能为有效",
RestBusinessCode.IsValidIsF.getValue());
}
if (groupList.size() > 0 && !groupList.contains(strRegion.getGroupId())) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中strRegionList中的regionId为"
+ strRegion.getRegionId() + "的配置的groupId在配置分组关系中不存在",RestBusinessCode.RegionsGroupIdIsNotFound.getValue());
throw new RestServiceException(
"配置id为" + configCompile.getCompileId() + "的配置中strRegionList中的regionId为"
+ strRegion.getRegionId() + "的配置的groupId在配置分组关系中不存在",
RestBusinessCode.RegionsGroupIdIsNotFound.getValue());
}
if (!regionGroupIdList.contains(strRegion.getGroupId())) {
@@ -189,43 +229,52 @@ public class CompileVal {
}
if (!isUpdate && Constants.BASE_VALIDATE) {
valStrRegion(strRegion, compileId,
ConfigSourcesService.isStrStrongRegion(strRegion.getTableName(),configCompile.getService()));
valStrRegion(strRegion, compileId, ConfigSourcesService.isStrStrongRegion(strRegion.getTableName(),
configCompile.getService()));
}
if (!isUpdate && Constants.SERVICE_VALIDATE) {
serviceStrRegionVal(strRegion, compileId,
ConfigSourcesService.isStrStrongRegion(strRegion.getTableName(),configCompile.getService()));
serviceStrRegionVal(strRegion, compileId, ConfigSourcesService
.isStrStrongRegion(strRegion.getTableName(), configCompile.getService()));
}
}
}
List<IpRegion> ipRegionList = configCompile.getIpRegionList();
if (ipRegionList == null || ipRegionList.size() == 0) {
throw new RestServiceException("编译配置id为" + configCompile.getCompileId() + "的配置中"
+ RestBusinessCode.IpRegionIsNull.getErrorReason(),RestBusinessCode.IpRegionIsNull.getValue());
} else {
if (ipRegionList == null) {
throw new RestServiceException(
"编译配置id为" + configCompile.getCompileId() + "的配置中"
+ RestBusinessCode.IpRegionIsNull.getErrorReason(),
RestBusinessCode.IpRegionIsNull.getValue());
}
if (ipRegionList != null && ipRegionList.size() > 0) {
for (IpRegion ipRegion : ipRegionList) {
// if (configCompile.getIsValid() != 0 &&
// !regionGroupIdList.contains(ipRegion.getGroupId())) {
if (!StringUtil.isEmpty(ipRegion.getTableName())
&& !type2TableNameIsOk(configCompile.getService(), ipRegion.getTableName())) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中ipRegionList中的regionId为"
+ ipRegion.getRegionId() + "配置tableName与编译配置业务类型不一致",RestBusinessCode.TableNameUnmatchService.getValue());
throw new RestServiceException(
"配置id为" + configCompile.getCompileId() + "的配置中ipRegionList中的regionId为"
+ ipRegion.getRegionId() + "的域配置tableName与编译配置业务类型不一致",
RestBusinessCode.TableNameUnmatchService.getValue());
}
if (!isUpdate && (null == ipRegion.getIsValid() || ipRegion.getIsValid() != 1)) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中ipRegionList中的regionId为"
+ ipRegion.getRegionId() + "的域配置在添加时不能为无效",RestBusinessCode.IsValidIsT.getValue());
throw new RestServiceException("配置id为" + configCompile.getCompileId()
+ "的配置中ipRegionList中的regionId为" + ipRegion.getRegionId() + "的域配置在添加时不能为无效",
RestBusinessCode.IsValidIsT.getValue());
}
if (isUpdate && (null == ipRegion.getIsValid() || ipRegion.getIsValid() != 0)) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中ipRegionList中的regionId为"
+ ipRegion.getRegionId() + "的域配置在修改时不能为有效",RestBusinessCode.IsValidIsF.getValue());
throw new RestServiceException("配置id为" + configCompile.getCompileId()
+ "的配置中ipRegionList中的regionId为" + ipRegion.getRegionId() + "的域配置在修改时不能为有效",
RestBusinessCode.IsValidIsF.getValue());
}
if (groupList.size() > 0 && !groupList.contains(ipRegion.getGroupId())) {
throw new RestServiceException( "配置id为" + configCompile.getCompileId() + "的配置中ipRegionList中的regionId为"
+ ipRegion.getRegionId() + "的配置的groupId在配置分组关系中不存在",RestBusinessCode.RegionsGroupIdIsNotFound.getValue());
throw new RestServiceException(
"配置id为" + configCompile.getCompileId() + "的配置中ipRegionList中的regionId为"
+ ipRegion.getRegionId() + "的配置的groupId在配置分组关系中不存在",
RestBusinessCode.RegionsGroupIdIsNotFound.getValue());
}
if (!regionGroupIdList.contains(ipRegion.getGroupId())) {
regionGroupIdList.add(ipRegion.getGroupId());
@@ -236,7 +285,7 @@ public class CompileVal {
}
if (!isUpdate && Constants.SERVICE_VALIDATE) {
serviceIpRegionVal(ipRegion, compileId,"ipRegionList");
serviceIpRegionVal(ipRegion, compileId, "ipRegionList");
}
}
}
@@ -251,17 +300,23 @@ public class CompileVal {
// 不验证表名和业务类型是否对应
if (!isUpdate && digestRegion.getIsValid() != 1) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中digestRegionList中的regionId为"
+ digestRegion.getRegionId() + "配置在添加时不能为无效",RestBusinessCode.IsValidIsT.getValue());
throw new RestServiceException(
"配置id为" + configCompile.getCompileId() + "的配置中digestRegionList中的regionId为"
+ digestRegion.getRegionId() + "的域配置在添加时不能为无效",
RestBusinessCode.IsValidIsT.getValue());
}
if (isUpdate && digestRegion.getIsValid() != 0) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中digestRegionList中的regionId为"
+ digestRegion.getRegionId() + "配置在修改时不能为有效",RestBusinessCode.IsValidIsF.getValue());
throw new RestServiceException(
"配置id为" + configCompile.getCompileId() + "的配置中digestRegionList中的regionId为"
+ digestRegion.getRegionId() + "的域配置在修改时不能为有效",
RestBusinessCode.IsValidIsF.getValue());
}
if (groupList.size() > 0 && !groupList.contains(digestRegion.getGroupId())) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中digestRegion中的regionId为"
+ digestRegion.getRegionId() + "的配置的groupId在配置分组关系中不存在",RestBusinessCode.RegionsGroupIdIsNotFound.getValue());
throw new RestServiceException(
"配置id为" + configCompile.getCompileId() + "的配置中digestRegion中的regionId为"
+ digestRegion.getRegionId() + "的配置的groupId在配置分组关系中不存在",
RestBusinessCode.RegionsGroupIdIsNotFound.getValue());
}
if (!regionGroupIdList.contains(digestRegion.getGroupId())) {
regionGroupIdList.add(digestRegion.getGroupId());
@@ -285,22 +340,28 @@ public class CompileVal {
// !regionGroupIdList.contains(ipRegion.getGroupId())) {
if (!StringUtil.isEmpty(ipRegion.getTableName())
&& !type2TableNameIsOk(configCompile.getService(), ipRegion.getTableName())) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中ipClientRangeList中的regionId为"
+ ipRegion.getRegionId() + "配置tableName与编译配置业务类型不一致",RestBusinessCode.TableNameUnmatchService.getValue());
throw new RestServiceException(
"配置id为" + configCompile.getCompileId() + "的配置中ipClientRangeList中的regionId为"
+ ipRegion.getRegionId() + "的域配置tableName与编译配置业务类型不一致",
RestBusinessCode.TableNameUnmatchService.getValue());
}
if (!isUpdate && (null == ipRegion.getIsValid() || ipRegion.getIsValid() != 1)) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中ipClientRangeList中的regionId为"
+ ipRegion.getRegionId() + "的域配置在添加时不能为无效",RestBusinessCode.IsValidIsT.getValue());
throw new RestServiceException("配置id为" + configCompile.getCompileId()
+ "的配置中ipClientRangeList中的regionId为" + ipRegion.getRegionId() + "的域配置在添加时不能为无效",
RestBusinessCode.IsValidIsT.getValue());
}
if (isUpdate && (null == ipRegion.getIsValid() || ipRegion.getIsValid() != 0)) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中ipClientRangeList中的regionId为"
+ ipRegion.getRegionId() + "的域配置在修改时不能为有效",RestBusinessCode.IsValidIsF.getValue());
throw new RestServiceException("配置id为" + configCompile.getCompileId()
+ "的配置中ipClientRangeList中的regionId为" + ipRegion.getRegionId() + "的域配置在修改时不能为有效",
RestBusinessCode.IsValidIsF.getValue());
}
if (groupList.size() > 0 && !groupList.contains(ipRegion.getGroupId())) {
throw new RestServiceException("配置id为" + configCompile.getCompileId() + "的配置中ipClientRangeList中的regionId为"
+ ipRegion.getRegionId() + "的配置的groupId在配置分组关系中不存在",RestBusinessCode.RegionsGroupIdIsNotFound.getValue());
throw new RestServiceException(
"配置id为" + configCompile.getCompileId() + "的配置中ipClientRangeList中的regionId为"
+ ipRegion.getRegionId() + "的配置的groupId在配置分组关系中不存在",
RestBusinessCode.RegionsGroupIdIsNotFound.getValue());
}
if (!regionGroupIdList.contains(ipRegion.getGroupId())) {
regionGroupIdList.add(ipRegion.getGroupId());
@@ -311,7 +372,7 @@ public class CompileVal {
}
if (!isUpdate && Constants.SERVICE_VALIDATE) {
serviceIpRegionVal(ipRegion, compileId,"ipClientRangeList");
serviceIpRegionVal(ipRegion, compileId, "ipClientRangeList");
}
}
}
@@ -386,281 +447,345 @@ public class CompileVal {
public static void valCompile(ConfigCompile configCompile) throws Exception {
Long compileId = configCompile.getCompileId();
if (null == compileId) {
throw new RestServiceException(RestBusinessCode.CompileIdIsNull.getErrorReason(),RestBusinessCode.CompileIdIsNull.getValue());
throw new RestServiceException(RestBusinessCode.CompileIdIsNull.getErrorReason(),
RestBusinessCode.CompileIdIsNull.getValue());
}
if (null == configCompile.getService()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中service不能为空",RestBusinessCode.ServiceIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中service不能为空",
RestBusinessCode.ServiceIsNull.getValue());
}
if (null == configCompile.getAction()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中action不能为空",RestBusinessCode.ActionIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中action不能为空",
RestBusinessCode.ActionIsNull.getValue());
}
if (null == configCompile.getDoBlacklist()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中doBlacklist不能为空",RestBusinessCode.DoBlacklistIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中doBlacklist不能为空",
RestBusinessCode.DoBlacklistIsNull.getValue());
}
if (null == configCompile.getDoLog()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中doLog不能为空",RestBusinessCode.DoLogIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中doLog不能为空",
RestBusinessCode.DoLogIsNull.getValue());
}
if (null == configCompile.getEffectiveRange() || configCompile.getEffectiveRange().equals("")) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中effectiveRange不能为空",RestBusinessCode.EffectiveRangeIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中effectiveRange不能为空",
RestBusinessCode.EffectiveRangeIsNull.getValue());
}
if (null == configCompile.getStartTime()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中startTime不能为空",RestBusinessCode.StartTimeIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中startTime不能为空",
RestBusinessCode.StartTimeIsNull.getValue());
}
if (null == configCompile.getEndTime()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中endTime不能为空",RestBusinessCode.EndTimeIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中endTime不能为空",
RestBusinessCode.EndTimeIsNull.getValue());
}
// if (null == configCompile.getUserRegion() || configCompile.getUserRegion().equals("")) {
// return "编译配置id为" + compileId + "的编译配置中userRegion不能为空";
// }
// if (null == configCompile.getUserRegion() ||
// configCompile.getUserRegion().equals("")) {
// return "编译配置id为" + compileId + "的编译配置中userRegion不能为空";
// }
if (null == configCompile.getIsValid()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中isValid不能为空", RestBusinessCode.IsValidIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中isValid不能为空",
RestBusinessCode.IsValidIsNull.getValue());
}
if (null == configCompile.getGroupNum()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中groupNum不能为空",RestBusinessCode.GroupNumIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中groupNum不能为空",
RestBusinessCode.GroupNumIsNull.getValue());
}
if (null == configCompile.getFatherCfgId()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中fatherCfgId不能为空",RestBusinessCode.FatherCfgIdIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中fatherCfgId不能为空",
RestBusinessCode.FatherCfgIdIsNull.getValue());
}
if (null == configCompile.getOpTime()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中opTime不能为空",RestBusinessCode.OpTimeIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中opTime不能为空",
RestBusinessCode.OpTimeIsNull.getValue());
}
}
public static void valCompileGroup(ConfigGroupRelation configGroupRelation, Long compileId) throws Exception{
public static void valCompileGroup(ConfigGroupRelation configGroupRelation, Long compileId) throws Exception {
Long groupId = configGroupRelation.getGroupId();
if (null == groupId) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的配置分组的groupId不能为空",RestBusinessCode.GroupIdIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的配置分组的groupId不能为空",
RestBusinessCode.GroupIdIsNull.getValue());
}
if (null == configGroupRelation.getCompileId()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的配置分组id为" + groupId + "的配置compileId不能为空",RestBusinessCode.GroupsCompileIdIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的配置分组id为" + groupId + "的配置compileId不能为空",
RestBusinessCode.GroupsCompileIdIsNull.getValue());
}
if (null == configGroupRelation.getIsValid()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的配置分组id为" + groupId + "的配置isValid不能为空",RestBusinessCode.GroupsIsValidIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的配置分组id为" + groupId + "的配置isValid不能为空",
RestBusinessCode.GroupsIsValidIsNull.getValue());
}
if (null == configGroupRelation.getOpTime()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的配置分组id为" + groupId + "的配置opTime不能为空",RestBusinessCode.OpTimeIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的配置分组id为" + groupId + "的配置opTime不能为空",
RestBusinessCode.OpTimeIsNull.getValue());
}
}
public static void valIpRegion(IpRegion ipRegion, Long compileId) {
Long regionId = ipRegion.getRegionId();
if (null == regionId) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置的regionId不能为空",RestBusinessCode.RegionIdIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置的regionId不能为空",
RestBusinessCode.RegionIdIsNull.getValue());
}
if (null == ipRegion.getGroupId()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置groupId不能为空",RestBusinessCode.RegionsGroupIdIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置groupId不能为空",
RestBusinessCode.RegionsGroupIdIsNull.getValue());
}
if (null == ipRegion.getAddrType()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置addrType不能为空",RestBusinessCode.AddrTypeIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置addrType不能为空",
RestBusinessCode.AddrTypeIsNull.getValue());
}
if (null == ipRegion.getSrcIp() || ipRegion.getSrcIp().equals("")) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置srcIp不能为空",RestBusinessCode.SrcIpIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置srcIp不能为空",
RestBusinessCode.SrcIpIsNull.getValue());
}
if (null == ipRegion.getMaskSrcIp() || ipRegion.getMaskSrcIp().equals("")) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置maskSrcIp不能为空",RestBusinessCode.MaskSrcIpIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置maskSrcIp不能为空",
RestBusinessCode.MaskSrcIpIsNull.getValue());
}
if (null == ipRegion.getSrcPort() || ipRegion.getSrcPort().equals("")) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置srcPort不能为空",RestBusinessCode.SrcPortIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置srcPort不能为空",
RestBusinessCode.SrcPortIsNull.getValue());
}
if (null == ipRegion.getMaskSrcPort() || ipRegion.getMaskSrcPort().equals("")) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置maskSrcPort不能为空",RestBusinessCode.MaskSrcPortIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置maskSrcPort不能为空",
RestBusinessCode.MaskSrcPortIsNull.getValue());
}
if (null == ipRegion.getDstIp() || ipRegion.getDstIp().equals("")) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置dstIp不能为空",RestBusinessCode.DstIpIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置dstIp不能为空",
RestBusinessCode.DstIpIsNull.getValue());
}
if (null == ipRegion.getMaskDstIp() || ipRegion.getMaskDstIp().equals("")) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置maskDstIp不能为空",RestBusinessCode.MaskDstIpIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置maskDstIp不能为空",
RestBusinessCode.MaskDstIpIsNull.getValue());
}
if (null == ipRegion.getDstPort() || ipRegion.getDstPort().equals("")) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置dstPort不能为空",RestBusinessCode.DstPortIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置dstPort不能为空",
RestBusinessCode.DstPortIsNull.getValue());
}
if (null == ipRegion.getMaskDstPort() || ipRegion.getMaskDstPort().equals("")) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置maskDstPort不能为空",RestBusinessCode.MaskDstPortIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置maskDstPort不能为空",
RestBusinessCode.MaskDstPortIsNull.getValue());
}
if (null == ipRegion.getProtocol()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置protocol不能为空",RestBusinessCode.ProtocolIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置protocol不能为空",
RestBusinessCode.ProtocolIsNull.getValue());
}
if (null == ipRegion.getDirection()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置direction不能为空",RestBusinessCode.DirectionIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置direction不能为空",
RestBusinessCode.DirectionIsNull.getValue());
}
if (null == ipRegion.getIsValid()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置isValid不能为空",RestBusinessCode.IsValidIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的ip类域配置id为" + regionId + "的配置isValid不能为空",
RestBusinessCode.IsValidIsNull.getValue());
}
}
public static void valNumRegion(NumRegion numRegion, Long compileId) throws Exception{
public static void valNumRegion(NumRegion numRegion, Long compileId) throws Exception {
Long regionId = numRegion.getRegionId();
if (null == regionId) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的数值类域配置的regionId不能为空",RestBusinessCode.RegionIdIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的数值类域配置的regionId不能为空",
RestBusinessCode.RegionIdIsNull.getValue());
}
if (null == numRegion.getGroupId()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的数值类域配置id为" + regionId + "的配置groupId不能为空",RestBusinessCode.RegionsGroupIdIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的数值类域配置id为" + regionId + "的配置groupId不能为空",
RestBusinessCode.RegionsGroupIdIsNull.getValue());
}
if (null == numRegion.getLowBoundary()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的数值类域配置id为" + regionId + "的配置lowBoundary不能为空",RestBusinessCode.LowBoundaryIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的数值类域配置id为" + regionId + "的配置lowBoundary不能为空",
RestBusinessCode.LowBoundaryIsNull.getValue());
}
if (null == numRegion.getUpBoundary()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的数值类域配置id为" + regionId + "的配置upBoundary不能为空",RestBusinessCode.UpBoundaryIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的数值类域配置id为" + regionId + "的配置upBoundary不能为空",
RestBusinessCode.UpBoundaryIsNull.getValue());
}
}
public static void valStrRegion(StrRegion strRegion, Long compileId, boolean isDirtrict) throws Exception{
public static void valStrRegion(StrRegion strRegion, Long compileId, boolean isDirtrict) throws Exception {
Long regionId = strRegion.getRegionId();
if (null == regionId) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的字符串类域配置的regionId不能为空",RestBusinessCode.RegionIdIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的字符串类域配置的regionId不能为空",
RestBusinessCode.RegionIdIsNull.getValue());
}
if (null == strRegion.getGroupId()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的字符串类域配置id为" + regionId + "的配置groupId不能为空",RestBusinessCode.RegionsGroupIdIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的字符串类域配置id为" + regionId + "的配置groupId不能为空",
RestBusinessCode.RegionsGroupIdIsNull.getValue());
}
if (isDirtrict && (null == strRegion.getDistrict() || strRegion.getDistrict().equals(""))) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的字符串类域配置id为" + regionId + "的配置district不能为空",RestBusinessCode.DistrictIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的字符串类域配置id为" + regionId + "的配置district不能为空",
RestBusinessCode.DistrictIsNull.getValue());
}
if (null == strRegion.getKeywords() || strRegion.getKeywords().equals("")) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的字符串类域配置id为" + regionId + "的配置keywords不能为空",RestBusinessCode.KeywordsIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的字符串类域配置id为" + regionId + "的配置keywords不能为空",
RestBusinessCode.KeywordsIsNull.getValue());
}
if (null == strRegion.getExprType()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的字符串类域配置id为" + regionId + "的配置exprType不能为空", RestBusinessCode.ExprTypeIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的字符串类域配置id为" + regionId + "的配置exprType不能为空",
RestBusinessCode.ExprTypeIsNull.getValue());
}
if (null == strRegion.getMatchMethod()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的字符串类域配置id为" + regionId + "的配置matchMethod不能为空",RestBusinessCode.MatchMethodIsNull.getValue());
throw new RestServiceException(
"编译配置id为" + compileId + "的编译配置中的字符串类域配置id为" + regionId + "的配置matchMethod不能为空",
RestBusinessCode.MatchMethodIsNull.getValue());
}
if (null == strRegion.getIsHexbin()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的字符串类域配置id为" + regionId + "的配置isHexbin不能为空",RestBusinessCode.MatchMethodIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的字符串类域配置id为" + regionId + "的配置isHexbin不能为空",
RestBusinessCode.MatchMethodIsNull.getValue());
}
}
public static void valDigestRegion(DigestRegion digestRegion, Long compileId) throws Exception {
Long regionId = digestRegion.getRegionId();
if (null == regionId) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的摘要类域配置的regionId不能为空",RestBusinessCode.RegionIdIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的摘要类域配置的regionId不能为空",
RestBusinessCode.RegionIdIsNull.getValue());
}
if (null == digestRegion.getGroupId()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的摘要类域配置id为" + regionId + "的配置groupId不能为空",RestBusinessCode.RegionsGroupIdIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的摘要类域配置id为" + regionId + "的配置groupId不能为空",
RestBusinessCode.RegionsGroupIdIsNull.getValue());
}
if (null == digestRegion.getRawLen()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的摘要类域配置id为" + regionId + "的配置rawLen不能为空",RestBusinessCode.RawLenIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的摘要类域配置id为" + regionId + "的配置rawLen不能为空",
RestBusinessCode.RawLenIsNull.getValue());
}
if (null == digestRegion.getDigest() || digestRegion.getDigest().equals("")) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的摘要类域配置id为" + regionId + "的配置digest不能为空",RestBusinessCode.DigestIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的摘要类域配置id为" + regionId + "的配置digest不能为空",
RestBusinessCode.DigestIsNull.getValue());
}
if (null == digestRegion.getCfdsLevel()) {
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的字符串类域配置id为" + regionId + "的配置cfdsLevel不能为空",RestBusinessCode.CfdsLevelIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的编译配置中的字符串类域配置id为" + regionId + "的配置cfdsLevel不能为空",
RestBusinessCode.CfdsLevelIsNull.getValue());
}
}
private static void validateIpAndMask(IpRegion ipRegion, Long compileId,String listName) throws Exception{
//源IP信息和目的IP信息格式为IPV4或IPV6
if (ipRegion.getAddrType().intValue()==4||ipRegion.getAddrType().intValue()==6) {
private static void validateIpAndMask(IpRegion ipRegion, Long compileId, String listName) throws Exception {
// 源IP信息和目的IP信息格式为IPV4或IPV6
if (ipRegion.getAddrType().intValue() == 4 || ipRegion.getAddrType().intValue() == 6) {
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getSrcIp(), ipRegion.getAddrType())) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置srcIp的格式不正确或与addrType不一致",RestBusinessCode.IPUnMatchAddrType.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置srcIp的格式不正确或与addrType不一致",
RestBusinessCode.IPUnMatchAddrType.getValue());
}
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskSrcIp(), ipRegion.getAddrType())) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置maskSrcIp的格式不正确或与addrType不一致",RestBusinessCode.IPUnMatchAddrType.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置maskSrcIp的格式不正确或与addrType不一致",
RestBusinessCode.IPUnMatchAddrType.getValue());
}
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getDstIp(), ipRegion.getAddrType())) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置dstIp的格式不正确或与addrType不一致",RestBusinessCode.IPUnMatchAddrType.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置dstIp的格式不正确或与addrType不一致",
RestBusinessCode.IPUnMatchAddrType.getValue());
}
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskDstIp(), ipRegion.getAddrType())) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置maskDstIp的格式不正确或与addrType不一致",RestBusinessCode.IPUnMatchAddrType.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置maskDstIp的格式不正确或与addrType不一致",
RestBusinessCode.IPUnMatchAddrType.getValue());
}
}else if (ipRegion.getAddrType().intValue()==46) {//4OVER6:源IP信息格式为IPV4、目的IP信息格式IPV6
} else if (ipRegion.getAddrType().intValue() == 46) {// 4OVER6:源IP信息格式为IPV4、目的IP信息格式IPV6
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getSrcIp(), 4)) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置srcIp的格式不正确或与addrType不一致",RestBusinessCode.IPUnMatchAddrType.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置srcIp的格式不正确或与addrType不一致",
RestBusinessCode.IPUnMatchAddrType.getValue());
}
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskSrcIp(), 4)) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置maskSrcIp的格式不正确或与addrType不一致",RestBusinessCode.IPUnMatchAddrType.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置maskSrcIp的格式不正确或与addrType不一致",
RestBusinessCode.IPUnMatchAddrType.getValue());
}
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getDstIp(), 6)) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置dstIp的格式不正确或与addrType不一致",RestBusinessCode.IPUnMatchAddrType.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置dstIp的格式不正确或与addrType不一致",
RestBusinessCode.IPUnMatchAddrType.getValue());
}
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskDstIp(), 6)) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置maskDstIp的格式不正确或与addrType不一致",RestBusinessCode.IPUnMatchAddrType.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置maskDstIp的格式不正确或与addrType不一致",
RestBusinessCode.IPUnMatchAddrType.getValue());
}
}else if (ipRegion.getAddrType().intValue()==64) {//6OVER4:源IP信息格式为IPV6、目的IP信息格式IPV4
} else if (ipRegion.getAddrType().intValue() == 64) {// 6OVER4:源IP信息格式为IPV6、目的IP信息格式IPV4
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getSrcIp(), 6)) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置srcIp的格式不正确或与addrType不一致",RestBusinessCode.IPUnMatchAddrType.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置srcIp的格式不正确或与addrType不一致",
RestBusinessCode.IPUnMatchAddrType.getValue());
}
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskSrcIp(), 6)) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置maskSrcIp的格式不正确或与addrType不一致",RestBusinessCode.IPUnMatchAddrType.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置maskSrcIp的格式不正确或与addrType不一致",
RestBusinessCode.IPUnMatchAddrType.getValue());
}
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getDstIp(), 4)) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置dstIp的格式不正确或与addrType不一致",RestBusinessCode.IPUnMatchAddrType.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置dstIp的格式不正确或与addrType不一致",
RestBusinessCode.IPUnMatchAddrType.getValue());
}
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskDstIp(), 4)) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置maskDstIp的格式不正确或与addrType不一致",RestBusinessCode.IPUnMatchAddrType.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置maskDstIp的格式不正确或与addrType不一致",
RestBusinessCode.IPUnMatchAddrType.getValue());
}
}else if (ipRegion.getAddrType().intValue()==10) {//all:符合IP格式即可
} else if (ipRegion.getAddrType().intValue() == 10) {// all:符合IP格式即可
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getSrcIp(), null)) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置srcIp的格式不正确或与addrType不一致",RestBusinessCode.IPUnMatchAddrType.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置srcIp的格式不正确或与addrType不一致",
RestBusinessCode.IPUnMatchAddrType.getValue());
}
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskSrcIp(), null)) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置maskSrcIp的格式不正确或与addrType不一致",RestBusinessCode.IPUnMatchAddrType.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置maskSrcIp的格式不正确或与addrType不一致",
RestBusinessCode.IPUnMatchAddrType.getValue());
}
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getDstIp(), null)) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置dstIp的格式不正确或与addrType不一致",RestBusinessCode.IPUnMatchAddrType.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置dstIp的格式不正确或与addrType不一致",
RestBusinessCode.IPUnMatchAddrType.getValue());
}
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskDstIp(), null)) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置maskDstIp的格式不正确或与addrType不一致",RestBusinessCode.IPUnMatchAddrType.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置maskDstIp的格式不正确或与addrType不一致",
RestBusinessCode.IPUnMatchAddrType.getValue());
}
}
}
public static void serviceIpRegionVal(IpRegion ipRegion, Long compileId,String listName) throws Exception {
validateIpAndMask(ipRegion, compileId,listName);
public static void serviceIpRegionVal(IpRegion ipRegion, Long compileId, String listName) throws Exception {
validateIpAndMask(ipRegion, compileId, listName);
if (!BasicProvingUtil.isPortOrPortMask(ipRegion.getSrcPort())) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId() + "的域配置srcPort的格式不正确",RestBusinessCode.PortIsNotVal.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置srcPort的格式不正确", RestBusinessCode.PortIsNotVal.getValue());
}
if (!BasicProvingUtil.isPortOrPortMask(ipRegion.getMaskSrcPort())) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置maskSrcPort的格式不正确",RestBusinessCode.PortIsNotVal.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置maskSrcPort的格式不正确", RestBusinessCode.PortIsNotVal.getValue());
}
if (!BasicProvingUtil.isPortOrPortMask(ipRegion.getDstPort())) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId() + "的域配置dstPort的格式不正确",RestBusinessCode.PortIsNotVal.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置dstPort的格式不正确", RestBusinessCode.PortIsNotVal.getValue());
}
if (!BasicProvingUtil.isPortOrPortMask(ipRegion.getMaskDstPort())) {
// if (!BasicProvingUtil.isIntType(ipRegion.getMaskDstPort())) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置maskDstPort的格式不正确",RestBusinessCode.PortIsNotVal.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置maskDstPort的格式不正确", RestBusinessCode.PortIsNotVal.getValue());
}
if (ipRegion.getSrcIp().equals(ipRegion.getDstIp())) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置srcIp和dstIp不能相同",RestBusinessCode.SrcIpEQDstIp.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置srcIp和dstIp不能相同", RestBusinessCode.SrcIpEQDstIp.getValue());
}
if (ipRegion.getDirection() != 1 && ipRegion.getDirection() != 0) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中"+listName+"中regionId为" + ipRegion.getRegionId()
+ "的域配置direction的值不正确,只能是0或1",RestBusinessCode.DirectionIsWrongRange.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中" + listName + "中regionId为"
+ ipRegion.getRegionId() + "的域配置direction的值不正确,只能是0或1",
RestBusinessCode.DirectionIsWrongRange.getValue());
}
// zdx protocol验证
@@ -685,16 +810,22 @@ public class CompileVal {
Long upBoundary = numRegion.getUpBoundary();
if (lowBoundary <= upBoundary) {
if (lowBoundary > 4294967295l || lowBoundary < 0l) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中numRegionList中regionId为" + numRegion.getRegionId()
+ "配置lowBoundary的值不能大于2的32次方减一(4294967295)或者小于0", RestBusinessCode.LowBoundaryIsWrongRange.getValue());
throw new RestServiceException(
"编译配置id为" + compileId + "的配置中numRegionList中regionId为" + numRegion.getRegionId()
+ "的域配置lowBoundary的值不能大于2的32次方减一(4294967295)或者小于0",
RestBusinessCode.LowBoundaryIsWrongRange.getValue());
}
if (upBoundary > 4294967295l || upBoundary < 0l) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中numRegionList中regionId为" + numRegion.getRegionId()
+ "配置upBoundary的值不能大于2的32次方减一(4294967295)或者小于0",RestBusinessCode.UpBoundaryIsWrongRange.getValue());
throw new RestServiceException(
"编译配置id为" + compileId + "的配置中numRegionList中regionId为" + numRegion.getRegionId()
+ "的域配置upBoundary的值不能大于2的32次方减一(4294967295)或者小于0",
RestBusinessCode.UpBoundaryIsWrongRange.getValue());
}
} else {
throw new RestServiceException("编译配置id为" + compileId + "的配置中numRegionList中regionId为" + numRegion.getRegionId()
+ "配置lowBoundary的值大于upBoundary,应该是小于或等于",RestBusinessCode.LowBoundaryGTUpBoundary.getValue());
throw new RestServiceException(
"编译配置id为" + compileId + "的配置中numRegionList中regionId为" + numRegion.getRegionId()
+ "的域配置lowBoundary的值大于upBoundary,应该是小于或等于",
RestBusinessCode.LowBoundaryGTUpBoundary.getValue());
}
}
@@ -702,25 +833,32 @@ public class CompileVal {
Long compileId = configCompile.getCompileId();
Integer action = ServiceAndRDBIndexReal.getActionByService(configCompile.getService());
if (StringUtil.isEmpty(action)) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中service与action的关系不存在",RestBusinessCode.Service2ActionIsNull.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中service与action的关系不存在",
RestBusinessCode.Service2ActionIsNull.getValue());
}
if (action.compareTo(configCompile.getAction()) != 0) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中service的值为" + configCompile.getService() + "时action只能为" + action,RestBusinessCode.ServiceUnmatchAction.getValue());
throw new RestServiceException(
"编译配置id为" + compileId + "的配置中service的值为" + configCompile.getService() + "时action只能为" + action,
RestBusinessCode.ServiceUnmatchAction.getValue());
}
if (configCompile.getDoBlacklist() != 1) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中doBlacklist的值只能是1",RestBusinessCode.DoBlacklistIsWrongRange.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中doBlacklist的值只能是1",
RestBusinessCode.DoBlacklistIsWrongRange.getValue());
}
if (configCompile.getDoLog() != 0 && configCompile.getDoLog() != 1 && configCompile.getDoLog() != 2) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中doLog的值只能是0(不需要),1(需要),2(只记录结构化日志,不记录非结构化日志)",RestBusinessCode.DoLogIsWrongRange.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中doLog的值只能是0(不需要),1(需要),2(只记录结构化日志,不记录非结构化日志)",
RestBusinessCode.DoLogIsWrongRange.getValue());
}
if (configCompile.getFatherCfgId() != 0) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中fatherCfgId的值只能是0",RestBusinessCode.FatherCfgIdIsWrongRange.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中fatherCfgId的值只能是0",
RestBusinessCode.FatherCfgIdIsWrongRange.getValue());
}
if (configCompile.getStartTime().getTime() > configCompile.getEndTime().getTime()) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中startTime不能比endTime晚",RestBusinessCode.EndTimeGTStartTime.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中startTime不能比endTime晚",
RestBusinessCode.EndTimeGTStartTime.getValue());
}
}
@@ -730,17 +868,22 @@ public class CompileVal {
Integer matchMethod = strRegion.getMatchMethod();
Integer isHexbin = strRegion.getIsHexbin();
if (exprType != 0 && exprType != 1) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中strRegionList中regionId为" + strRegion.getRegionId()
+ "的域配置exprType的值只能是0(无表达式)或者1(与表达式)",RestBusinessCode.ExprTypeIsWrongRange.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中strRegionList中regionId为"
+ strRegion.getRegionId() + "的域配置exprType的值只能是0(无表达式)或者1(与表达式)",
RestBusinessCode.ExprTypeIsWrongRange.getValue());
}
if (matchMethod != 0 && matchMethod != 1 && matchMethod != 2 && matchMethod != 3) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中strRegionList中regionId为" + strRegion.getRegionId()
+ "配置matchMethod的值只能是0(子串匹配),1(右匹配),2(左匹配),3(完全匹配)",RestBusinessCode.MatchMethodIsWrongRange.getValue());
throw new RestServiceException(
"编译配置id为" + compileId + "的配置中strRegionList中regionId为" + strRegion.getRegionId()
+ "的域配置matchMethod的值只能是0(子串匹配),1(右匹配),2(左匹配),3(完全匹配)",
RestBusinessCode.MatchMethodIsWrongRange.getValue());
}
if (isHexbin != 0 && isHexbin != 1 && isHexbin != 2) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中strRegionList中regionId为" + strRegion.getRegionId()
+ "配置isHexbin的值只能是0(大小写不敏感且非HEX)或者1(HEX)或者2(大小写敏感且非HEX)",RestBusinessCode.IsHexbinIsWrongRange.getValue());
throw new RestServiceException(
"编译配置id为" + compileId + "的配置中strRegionList中regionId为" + strRegion.getRegionId()
+ "的域配置isHexbin的值只能是0(大小写不敏感且非HEX)或者1(HEX)或者2(大小写敏感且非HEX)",
RestBusinessCode.IsHexbinIsWrongRange.getValue());
}
// strRegProhibitConfigWord(strRegion,compileId);
@@ -750,8 +893,9 @@ public class CompileVal {
Integer cfdsLevel = digestRegion.getCfdsLevel();
if (!(cfdsLevel >= 1 && cfdsLevel <= 10)) {
throw new RestServiceException("编译配置id为" + compileId + "的配置中digestRegionList中regionId为" + digestRegion.getRegionId()
+ "的域配置cfdsLevel的值只能是1到10",RestBusinessCode.CfdsLevelIsWrongRange.getValue());
throw new RestServiceException("编译配置id为" + compileId + "的配置中digestRegionList中regionId为"
+ digestRegion.getRegionId() + "的域配置cfdsLevel的值只能是1到10",
RestBusinessCode.CfdsLevelIsWrongRange.getValue());
}
}

View File

@@ -182,11 +182,11 @@ public class ServiceAndRDBIndexReal {
for (MaatXmlExpr maatXmlExpr : expressionList) {
if (maatXmlExpr.getValueExpression() != null) {
String[] valSplit = maatXmlExpr.getValueExpression().split(";");
int a=1;
int a = 1;
for (int i = 0; i < valSplit.length; i++) {
if (valSplit[i].toLowerCase().contains("is_valid")) {// xml中是字符串的\t这里判断的时候需要转义为\\t,但是添加的时候需要添加\t不是\\t
System.out.println(service+"--"+typeTable.get(service) + "---" + a);
}else if (valSplit[i].toLowerCase().contains("[")){
System.out.println(service + "--" + typeTable.get(service) + "---" + a);
} else if (valSplit[i].toLowerCase().contains("[")) {
a++;
}
}
@@ -255,10 +255,12 @@ public class ServiceAndRDBIndexReal {
Map<Integer, List<String>> typeMap = sercieNameMap.get(service);
if (typeMap != null && typeMap.size() > 0) {
List<String> tableList = typeMap.get(type);
if (tableList != null && tableList.size() > 0) {
if (tableName == null || tableName.trim().equals("")) {
if (tableList.size() > 1) {
logger.error("未从业务类型和表对应关系中,找到业务类型:{},配置类型:{}表名:{}对应的真实表名", service, type, tableName);
throw new ServiceRuntimeException("在applicationConfig-rule.properties配置文件中业务类型:" + service + ",配置类型:" + type + "对应多个表,请输入具体的表名",RestBusinessCode.NotFoundTableName.getValue());
throw new ServiceRuntimeException("在applicationConfig-rule.properties配置文件中业务类型:" + service
+ ",配置类型:" + type + "对应多个表,请输入具体的表名", RestBusinessCode.NotFoundTableName.getValue());
} else {
return tableList.get(0);
}
@@ -275,13 +277,12 @@ public class ServiceAndRDBIndexReal {
return tableList.get(index);
} else {
logger.error("未从业务类型和表对应关系中,找到业务类型:{},配置类型:{}表名:{}对应的真实表名", service, type, tableName);
throw new ServiceRuntimeException(
"无法从applicationConfig-rule.properties配置文件中,找到回调类配置service为" + service+ ",配置类型:" + type
+ "对应的真实表名",RestBusinessCode.NotFoundTableName.getValue());
throw new ServiceRuntimeException("无法从applicationConfig-rule.properties配置文件中,找到回调类配置service为"
+ service + ",配置类型:" + type + "对应的真实表名", RestBusinessCode.NotFoundTableName.getValue());
}
}
}
}
return null;

View File

@@ -7,6 +7,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import com.nis.domain.restful.*;
@@ -95,8 +96,6 @@ public class MaatTestController {
return "false";
}
@RequestMapping(value = "/cfg/v1/delUnMaat", method = RequestMethod.GET)
@ApiOperation(value = "test redis", httpMethod = "GET", response = Map.class, notes = "测试redis事务的crontroller")
@ApiParam(value = "test redis", name = "测试redis事务的crontroller", required = true)
@@ -108,7 +107,7 @@ public class MaatTestController {
map.put(service, arrayList);
Map<Integer, Map<Integer, List<Long>>> idMap = new HashMap<Integer, Map<Integer, List<Long>>>();
idMap.put(redisDB, map);
configRedisService.delUnMaatConfig(idMap,true);
configRedisService.delUnMaatConfig(idMap, true);
// configRedisService.saveMaatConfig(listMap, service);
// new ConfigRedisServiceimpl().GETMaatConfig(listMap);
return "ok";
@@ -148,8 +147,8 @@ public class MaatTestController {
long seq_groupid = configRedisService.getIncrId("SEQ_GROUPID");
List<MaatConfig> listMap = new ArrayList<MaatConfig>();
long seq_regionid2 = configRedisService.getIncrId("SEQ_REGIONID");
listMap.add(getMaatConfig1(service, seq_groupid,seq_regionid2));
//listMap.add(getMaatConfig2(service, seq_groupid,seq_regionid2));
listMap.add(getMaatConfig1(service, seq_groupid, seq_regionid2));
// listMap.add(getMaatConfig2(service, seq_groupid,seq_regionid2));
for (Integer db : redisDBByService) {
configMap.put(db, listMap);
@@ -164,7 +163,7 @@ public class MaatTestController {
return "false";
}
public MaatConfig getMaatConfig1(Integer service, long seq_groupid,long seq_regionid2) {
public MaatConfig getMaatConfig1(Integer service, long seq_groupid, long seq_regionid2) {
String time = new Date().getTime() + "";
Map<String, String> configMap1 = new HashMap<String, String>();
long seq_compileid = configRedisService.getIncrId("SEQ_COMPILEID");
@@ -246,7 +245,7 @@ public class MaatTestController {
return maatConfig;
}
public MaatConfig getMaatConfig2(Integer service, long seq_groupid,long seq_regionid2) {
public MaatConfig getMaatConfig2(Integer service, long seq_groupid, long seq_regionid2) {
String time = new Date().getTime() + "";
Map<String, String> configMap = new HashMap<String, String>();
long seq_compileid = configRedisService.getIncrId("SEQ_COMPILEID");
@@ -302,8 +301,6 @@ public class MaatTestController {
return maatConfig;
}
@RequestMapping(value = "/cfg/v1/testDelMaat", method = RequestMethod.GET)
@ApiOperation(value = "测试批量删除maat配置", httpMethod = "GET", response = String.class, notes = "测试批量删除maat配置,configId为配置id,多个配置id用逗号分隔")
@ApiParam(value = "测试批量删除maat配置", name = "testDelMaat", required = true)
@@ -345,7 +342,7 @@ public class MaatTestController {
}
}
} else {
FileUtils.addStrToFile(sdf.format(new Date()) + "\t" + "获取业务类型" + service + "对应的redisDb失败\n",
FileUtils.addStrToFile(sdf.format(new Date()) + "\t" + "error:获取业务类型" + service + "对应的redisDb失败\n",
Configurations.getStringProperty("maatTestLogPath", ""), true);
return "error";
}
@@ -353,7 +350,7 @@ public class MaatTestController {
try {
if (!configRedisService.delMaatConfig(restMap)) {
FileUtils.addStrToFile(
sdf.format(new Date()) + "\t" + "删除业务类型" + serviceType + "下的配置" + configId + "失败\n",
sdf.format(new Date()) + "\t" + "error:删除业务类型" + serviceType + "下的配置" + configId + "失败\n",
Configurations.getStringProperty("maatTestLogPath", ""), true);
return "error";
} else {
@@ -365,7 +362,7 @@ public class MaatTestController {
} catch (Exception e) {
e.printStackTrace();
FileUtils.addStrToFile(
sdf.format(new Date()) + "\t" + "删除业务类型" + serviceType + "下的配置" + configId + "失败,失败原因:"
sdf.format(new Date()) + "\t" + "error:删除业务类型" + serviceType + "下的配置" + configId + "失败,失败原因:"
+ ExceptionUtil.getExceptionMsg(e) + "\n",
Configurations.getStringProperty("maatTestLogPath", ""), true);
@@ -397,8 +394,8 @@ public class MaatTestController {
compileIdList.add(configCompile.getCompileId());
}
FileUtils.addStrToFile(
sdf.format(new Date()) + "\t" + "业务类型" + service + "添加" + saveCount + "条数据成功,配置id是" + compileIdList
+ "\n" + sdf.format(new Date()) + "\t开始验证添加的数据各字段是否正确\n",
sdf.format(new Date()) + "\t" + "业务类型" + service + "添加" + saveCount + "条数据成功,配置id是"
+ compileIdList + "\n" + sdf.format(new Date()) + "\t开始验证添加的数据各字段是否正确\n",
Configurations.getStringProperty("maatTestLogPath", ""), true);
// 验证数据是否在正确
maatTestServiceimpl.getKeys(configCompileList);
@@ -418,37 +415,90 @@ public class MaatTestController {
@RequestMapping(value = "/cfg/v1/testSaveMaat", method = RequestMethod.GET)
@ApiOperation(value = "测试批量保存maat配置", httpMethod = "GET", response = String.class, notes = "测试批量保存maat配置,service:需要保存的业务类型,saveCount:保存几条配置")
@ApiParam(value = "测试批量保存maat配置", name = "testSaveMaat", required = true)
public String testSaveMaat(@RequestParam(required = true) Integer service,
public Map testSaveMaat(@RequestParam(required = true) Integer service,
@RequestParam(required = true) Integer saveCount) {
long start = System.currentTimeMillis();
AuditLogThread thread = new AuditLogThread();
StringBuffer sb = new StringBuffer();
List<Long> compileIdList = new ArrayList<Long>();
List<Long> compileIdList = null;
Map<Integer, String> map = new HashMap<Integer, String>();
try {
// 获取所有maat类的业务类型
Map<Integer, Map<Integer, List<String>>> sercieNameMap = ServiceAndRDBIndexReal.getSercieNameMap();
if (sercieNameMap != null) {
if (service == -1) {
Set<Integer> keySet = sercieNameMap.keySet();
for (Integer ser : keySet) {
compileIdList = new ArrayList<Long>();
List<ConfigCompile> configCompileList = new ArrayList<ConfigCompile>();
for (int i = 0; i < saveCount; i++) {
configCompileList.add(getConfigCompile(ser));
}
// 保存测试配置
configSourcesService.saveMaatConfig(thread, start, configCompileList, sb);
for (ConfigCompile configCompile : configCompileList) {
compileIdList.add(configCompile.getCompileId());
}
FileUtils.addStrToFile(
sdf.format(new Date()) + "\t" + "业务类型" + ser + "添加" + saveCount + "条数据成功,配置id是"
+ compileIdList + "\n" + sdf.format(new Date()) + "\t开始验证添加的数据各字段是否正确\n",
Configurations.getStringProperty("maatTestLogPath", ""), true);
// 验证数据是否在正确
maatTestServiceimpl.getKeys(configCompileList);
map.put(ser, "http://127.0.0.1:8080/galaxy/service/cfg/v1/testDelMaat?serviceType=" + ser
+ "&configId=" + compileIdList.toString().replace("[", "").replace("]", ""));
testDelMaat(compileIdList.toString().replace("[", "").replace("]", ""), ser);
}
} else {
if (sercieNameMap.containsKey(service)) {
compileIdList = new ArrayList<Long>();
List<ConfigCompile> configCompileList = new ArrayList<ConfigCompile>();
for (int i = 0; i < saveCount; i++) {
configCompileList.add(getConfigCompile(service));
}
// 保存测试配置
configSourcesService.saveMaatConfig(thread, start, configCompileList, sb);
for (ConfigCompile configCompile : configCompileList) {
compileIdList.add(configCompile.getCompileId());
}
FileUtils.addStrToFile(
sdf.format(new Date()) + "\t" + "业务类型" + service + "添加" + saveCount + "条数据成功,配置id是" + compileIdList
+ "\n" + sdf.format(new Date()) + "\t开始验证添加的数据各字段是否正确\n",
sdf.format(new Date()) + "\t" + "业务类型" + service + "添加" + saveCount + "条数据成功,配置id是"
+ compileIdList + "\n" + sdf.format(new Date()) + "\t开始验证添加的数据各字段是否正确\n",
Configurations.getStringProperty("maatTestLogPath", ""), true);
// 验证数据是否在正确
maatTestServiceimpl.getKeys(configCompileList);
map.put(service, "http://127.0.0.1:8080/galaxy/service/cfg/v1/testDelMaat?serviceType="
+ service + "&configId=" + compileIdList.toString().replace("[", "").replace("]", ""));
testDelMaat(compileIdList.toString().replace("[", "").replace("]", ""), service);
} else {
map.put(-2, "is not maat service");
}
}
} else {
map.put(-3, "service map is null");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
map.put(-4, "error");
}
return "http://127.0.0.1:8080/galaxy/service/cfg/v1/testDelMaat?serviceType=" + service + "&configId="
+ compileIdList.toString().replace("[", "").replace("]", "");
return map;
}
private ConfigCompile getConfigCompile(Integer service) {
@@ -487,72 +537,62 @@ public class MaatTestController {
String[] typeArr = typeStr.split(":");
int tableType = Integer.parseInt(typeArr[0]);
String tableNameArr[] = typeArr[1].split(",");
List<IpRegion> ipList = new ArrayList<IpRegion>();
List<NumRegion> numList = new ArrayList<NumRegion>();
List<StrRegion> strList = new ArrayList<StrRegion>();
List<DigestRegion> digestList = new ArrayList<DigestRegion>();
configCompile.setIpRegionList(ipList);
configCompile.setNumRegionList(numList);
configCompile.setStrRegionList(strList);
configCompile.setDigestRegionList(digestList);
configCompile.setIpClientRangeList(ipList);
if (tableType == 12 || tableType == 18) {
ipList = new ArrayList<IpRegion>();
if (tableNameArr.length == 1) {
ipList.add(getIpRegion(service, tableType, groupId, null));
} else {
for (String tableName : tableNameArr) {
ipList.add(getIpRegion(service, tableType, groupId, tableName));
}
}
if (tableType == 12) {
List<IpRegion> list = new ArrayList<IpRegion>();
if (tableNameArr.length == 1) {
list.add(getIpRegion(service, tableType, groupId, null));
} else {
for (String tableName : tableNameArr) {
list.add(getIpRegion(service, tableType, groupId, tableName));
}
}
configCompile.setIpRegionList(list);
} else if (tableType == 13) {
List<NumRegion> list = new ArrayList<NumRegion>();
if (tableNameArr.length == 1) {
list.add(getNumRegion(service, tableType, groupId, null));
} else {
for (String tableName : tableNameArr) {
list.add(getNumRegion(service, tableType, groupId, tableName));
}
}
configCompile.setNumRegionList(list);
} else if (tableType == 14) {
List<StrRegion> list = new ArrayList<StrRegion>();
if (tableNameArr.length == 1) {
list.add(getStrRegion(service, tableType, groupId, null));
} else {
for (String tableName : tableNameArr) {
list.add(getStrRegion(service, tableType, groupId, tableName));
}
}
configCompile.setStrRegionList(list);
} else if (tableType == 15) {
List<StrRegion> list = new ArrayList<StrRegion>();
if (tableNameArr.length == 1) {
list.add(getStrRegion(service, tableType, groupId, null));
} else {
for (String tableName : tableNameArr) {
list.add(getStrRegion(service, tableType, groupId, tableName));
}
}
configCompile.setStrRegionList(list);
} else if (tableType == 16) {
List<DigestRegion> list = new ArrayList<DigestRegion>();
if (tableNameArr.length == 1) {
list.add(getDigestRegion(service, tableType, groupId, null));
} else {
for (String tableName : tableNameArr) {
list.add(getDigestRegion(service, tableType, groupId, tableName));
}
}
configCompile.setDigestRegionList(list);
configCompile.setIpRegionList(ipList);
} else if (tableType == 18) {
List<IpRegion> list = new ArrayList<IpRegion>();
configCompile.setIpClientRangeList(ipList);
}
} else if (tableType == 13) {
numList = new ArrayList<NumRegion>();
if (tableNameArr.length == 1) {
list.add(getIpRegion(service, tableType, groupId, null));
numList.add(getNumRegion(service, tableType, groupId, null));
} else {
for (String tableName : tableNameArr) {
list.add(getIpRegion(service, tableType, groupId, tableName));
numList.add(getNumRegion(service, tableType, groupId, tableName));
}
}
configCompile.setIpClientRangeList(list);
configCompile.setNumRegionList(numList);
} else if (tableType == 14 || tableType == 15) {
strList = new ArrayList<StrRegion>();
if (tableNameArr.length == 1) {
strList.add(getStrRegion(service, tableType, groupId, null));
} else {
for (String tableName : tableNameArr) {
strList.add(getStrRegion(service, tableType, groupId, tableName));
}
}
configCompile.setStrRegionList(strList);
} else if (tableType == 16) {
digestList = new ArrayList<DigestRegion>();
if (tableNameArr.length == 1) {
digestList.add(getDigestRegion(service, tableType, groupId, null));
} else {
for (String tableName : tableNameArr) {
digestList.add(getDigestRegion(service, tableType, groupId, tableName));
}
}
configCompile.setDigestRegionList(digestList);
}
}
}

View File

@@ -6,7 +6,6 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@@ -21,9 +20,9 @@ import com.nis.domain.restful.StrRegion;
import com.nis.util.CamelUnderlineUtil;
import com.nis.util.Configurations;
import com.nis.util.FileUtils;
import com.nis.util.JedisUtils;
import com.nis.util.ReadMaatXmlUtil;
import com.nis.util.ServiceAndRDBIndexReal;
import com.nis.web.service.SpringContextHolder;
@Service()
public class MaatTestServiceimpl {
@@ -47,58 +46,56 @@ public class MaatTestServiceimpl {
public void getConfigByKey(Integer redisDB, Integer service, ConfigCompile configCompile,
MaatXmlConfig maatXmlConfig) {
RedisTemplate<String, String> redisTemplate = SpringContextHolder.getBean("redisTemplate" + redisDB);
if (maatXmlConfig != null && configCompile != null) {
Long compileId = configCompile.getCompileId();
validData(service, 10, compileId, configCompile.getCompileId(), redisDB, null, maatXmlConfig, redisTemplate,
configCompile,configCompile);
validData(service, 10, compileId, configCompile.getCompileId(), redisDB, null, maatXmlConfig, configCompile,
configCompile);
List<ConfigGroupRelation> groupRelationList = configCompile.getGroupRelationList();
for (ConfigGroupRelation configGroupRelation : groupRelationList) {
validData(service, 11, compileId, configGroupRelation.getGroupId(), redisDB, null, maatXmlConfig,
redisTemplate, configGroupRelation,configCompile);
configGroupRelation, configCompile);
}
List<IpRegion> ipRegionList = configCompile.getIpRegionList();
for (IpRegion ipRegion : ipRegionList) {
validData(service, 12, compileId, ipRegion.getRegionId(), redisDB, null, maatXmlConfig, redisTemplate,
ipRegion,configCompile);
validData(service, 12, compileId, ipRegion.getRegionId(), redisDB, ipRegion.getTableName(),
maatXmlConfig, ipRegion, configCompile);
}
List<NumRegion> numRegionList = configCompile.getNumRegionList();
for (NumRegion numRegion : numRegionList) {
validData(service, 13, compileId, numRegion.getRegionId(), redisDB, null, maatXmlConfig, redisTemplate,
numRegion,configCompile);
validData(service, 13, compileId, numRegion.getRegionId(), redisDB, numRegion.getTableName(),
maatXmlConfig, numRegion, configCompile);
}
List<StrRegion> strRegionList = configCompile.getStrRegionList();
for (StrRegion strRegion : strRegionList) {
if (strRegion.getDistrict() == null || strRegion.getDistrict().trim().equals("")) {
validData(service, 14, compileId, strRegion.getRegionId(), redisDB, null, maatXmlConfig,
redisTemplate, strRegion,configCompile);
validData(service, 14, compileId, strRegion.getRegionId(), redisDB, strRegion.getTableName(),
maatXmlConfig, strRegion, configCompile);
} else {
validData(service, 15, compileId, strRegion.getRegionId(), redisDB, null, maatXmlConfig,
redisTemplate, strRegion,configCompile);
validData(service, 15, compileId, strRegion.getRegionId(), redisDB, strRegion.getTableName(),
maatXmlConfig, strRegion, configCompile);
}
}
List<DigestRegion> digestRegionList = configCompile.getDigestRegionList();
for (DigestRegion digestRegion : digestRegionList) {
validData(service, 16, compileId, digestRegion.getRegionId(), redisDB, null, maatXmlConfig,
redisTemplate, digestRegion,configCompile);
validData(service, 16, compileId, digestRegion.getRegionId(), redisDB, digestRegion.getTableName(),
maatXmlConfig, digestRegion, configCompile);
}
List<IpRegion> ipClientRangeList = configCompile.getIpClientRangeList();
for (IpRegion ipRegion : ipClientRangeList) {
validData(service, 18, compileId, ipRegion.getRegionId(), redisDB, null, maatXmlConfig, redisTemplate,
ipRegion,configCompile);
validData(service, 18, compileId, ipRegion.getRegionId(), redisDB, ipRegion.getTableName(),
maatXmlConfig, ipRegion, configCompile);
}
}
}
public void validData(Integer service, Integer type, Long compileId, Long id, Integer redisDb, String tableName,
MaatXmlConfig maatXmlConfig, RedisTemplate<String, String> redisTemplate, Object obj,
ConfigCompile configCompile) {
MaatXmlConfig maatXmlConfig, Object obj, ConfigCompile configCompile) {
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
String[] valArr = null;
String key = null;
@@ -141,12 +138,12 @@ public class MaatTestServiceimpl {
valList.add(valStr);
}
}
String val = redisTemplate.opsForValue().get(key);
String val = JedisUtils.get(key, redisDb);
valArr = val.split("\\t");
break;
}
}
if (sysoLog(valArr, valList, obj, redisDb, key, configCompile)) {
if (sysoLog(valArr, valList, obj, redisDb, key, configCompile,service)) {
FileUtils
.addStrToFile(
"\t" + sdf.format(new Date()) + " 编译配置id为" + compileId + "的配置中,在" + redisDb + "号redis库中key="
@@ -156,7 +153,26 @@ public class MaatTestServiceimpl {
}
private boolean sysoLog(String[] valArr, List<String> valList, Object obj, Integer redisDb, String key,
ConfigCompile configCompile) {
ConfigCompile configCompile,Integer service) {
if (valList == null || valList.size() == 0) {
FileUtils.addStrToFile(
"\t" + sdf.format(new Date()) + " error:service="+service +"时拼接value属性名,value表达式为空请检查\n",
Configurations.getStringProperty("maatTestLogPath", ""), true);
return false;
}
if (valArr == null || valArr.length == 0) {
FileUtils.addStrToFile(
"\t" + sdf.format(new Date()) + " error:service="+service +"时拼接value值错误,value数组为空\n",
Configurations.getStringProperty("maatTestLogPath", ""), true);
return false;
}
if (valList == null || key.trim().equals("")) {
FileUtils.addStrToFile(
"\t" + sdf.format(new Date()) + " error:service="+service +"时拼接key=null请检查\n",
Configurations.getStringProperty("maatTestLogPath", ""), true);
return false;
}
boolean bool = true;
for (int i = 0; i < valList.size(); i++) {
String attrName = valList.get(i);
@@ -165,9 +181,9 @@ public class MaatTestServiceimpl {
String beanVal = null;
if (filedName.toLowerCase().equals("service") || filedName.toLowerCase().equals("action")
|| filedName.toLowerCase().equals("userregion")) {
beanVal=getFieldValueByFieldName(filedName, configCompile);
}else {
beanVal=getFieldValueByFieldName(filedName, obj);
beanVal = getFieldValueByFieldName(filedName, configCompile);
} else {
beanVal = getFieldValueByFieldName(filedName, obj);
}
String redisVal = valArr[i];
if (!beanVal.trim().equals(redisVal.trim())) {