1:为公共组添加域配置和修改域配置的的接口拼接字符串时判断是否为空,如果为空给出提示

2:为公共组添加域配置和修改域配置的的接口判断是否有域配置,如果没有域域配置给出提示
3:新增或修改公共组域配置时添加从增强字符串,文件,ip范围等集合中获取内容
This commit is contained in:
renkaige
2019-02-25 09:13:21 +08:00
parent c258b14bba
commit 0672181a93

View File

@@ -72,14 +72,23 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
for (String keyStr : keySplit) {
if (!StringUtils.isEmpty(keyStr) && keyStr.trim().startsWith("[")) {
keyStr = keyStr.trim().replace("[", "").replace("]", "");
keyBF.append(map.get(keyStr));
String keyVal = map.get(keyStr);
if (keyVal != null && !keyVal.equals("")) {
keyBF.append(keyVal);
} else {
throw new ServiceRuntimeException(
"未从map中获取到" + keyStr + "的值,请检查数据或配置文件是否正确",
RestBusinessCode.NotFoundValueByKey.getValue());
}
} else if (!StringUtils.isEmpty(keyStr)
&& keyStr.trim().startsWith("{")) {
keyStr = keyStr.trim().replace("{", "").replace("}", "");
if (keyStr.toLowerCase().contains("table_name")) {
String maatTableName = ServiceAndRDBIndexReal
.getUnMaatTableName(service);
if (maatTableName == null) {
if (maatTableName == null
|| maatTableName.trim().equals("")) {
throw new ServiceRuntimeException(
"无法从applicationConfig-rule.properties配置文件中,找到回调类配置service为"
+ service + "对应的真实表名",
@@ -332,7 +341,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
if (!StringUtils.isEmpty(valStr) && valStr.trim().startsWith("[")) {
valStr = valStr.trim().replace("[", "").replace("]", "");
String val = compileMap.get(valStr.toLowerCase());
if (val != null) {
if (val != null && !val.trim().equals("")) {
valBF.append(val);
} else {
// 编译配置或分组配置 所有在maat.xml中配置的属性都不可以为空
@@ -638,7 +647,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
if (!StringUtils.isEmpty(valStr) && valStr.trim().startsWith("[")) {
valStr = valStr.trim().replace("[", "").replace("]", "");
String val = map.get(valStr);
if (val != null) {
if (val != null && !val.trim().equals("")) {
if ((Constants.TAPREDISDB == redisDBIndex || Constants.WEBFOCUSREDISDB == redisDBIndex)
&& type != 10 && type != 11 && valStr.toLowerCase().equals("op_time")) {// 域配置并且是op_time时在op_time前面添加如下内容
Map<String, String[]> map2 = ServiceAndRDBIndexReal.getMaatToValveMap()
@@ -1674,7 +1683,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
keyStr = keyStr.trim().replace("{", "").replace("}", "");
if (keyStr.toLowerCase().contains("table_name")) {
String argTableName = map.get("table_name");
if (argTableName == null) {
if (argTableName == null || argTableName.trim().equals("")) {
throw new ServiceRuntimeException("添加公共组域配置时,必须要传入表名,请检查参数,配置类型:" + type + ",对应的真实表名",
RestBusinessCode.NotFoundTableName.getValue());
} else {
@@ -1696,7 +1705,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
valBF.append(user_region + "\t");
}
String val = map.get(valStr);
if (val != null) {
if (val != null && !val.trim().equals("")) {
valBF.append(val);
if (valStr.equals("group_id")) {
groupId = val;
@@ -1839,7 +1848,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
keyBF.append(keyStr.trim());
}
}
String groupId = null;
// String groupId = null;
StringBuffer valBF = new StringBuffer();
String[] valSplit = maatXmlExpr.getValueExpression().split(";");
for (String valStr : valSplit) {
@@ -1850,11 +1859,8 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
valBF.append(user_region + "\t");
}
String val = map.get(valStr);
if (val != null) {
if (val != null && !val.trim().equals("")) {
valBF.append(val);
if (valStr.equals("group_id")) {
groupId = val;
}
} else {
// 所有在maat.xml中配置的属性都不可以为空
throw new ServiceRuntimeException("未从map中获取到" + valStr + "的值,无法拼接redisValue,请检查数据或配置文件是否正确",
@@ -1908,6 +1914,10 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
MaatXmlExpr maatXmlExpr12 = null;
MaatXmlExpr maatXmlExpr13 = null;
MaatXmlExpr maatXmlExpr14 = null;
MaatXmlExpr maatXmlExpr15 = null;
MaatXmlExpr maatXmlExpr16 = null;
MaatXmlExpr maatXmlExpr17 = null;
MaatXmlExpr maatXmlExpr18 = null;
if (maatXmlConfig != null) {
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
if (expressionList != null && expressionList.size() > 0) {
@@ -1918,17 +1928,59 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
maatXmlExpr13 = maatXmlExpr;
} else if (maatXmlExpr.getType().intValue() == 14) {
maatXmlExpr14 = maatXmlExpr;
} else if (maatXmlExpr.getType().intValue() == 15) {
maatXmlExpr15 = maatXmlExpr;
} else if (maatXmlExpr.getType().intValue() == 16) {
maatXmlExpr16 = maatXmlExpr;
} else if (maatXmlExpr.getType().intValue() == 17) {
maatXmlExpr17 = maatXmlExpr;
} else if (maatXmlExpr.getType().intValue() == 18) {
maatXmlExpr18 = maatXmlExpr;
}
}
}
int count = 0;
for (MaatConfig maatConfig : configList) {
addReionToCommonGroup(maatConfig.getIpRegionMapList(), maatXmlExpr12, transaction, 12,
idRelaRedisDBIndex, expressionList, isAdd);
addReionToCommonGroup(maatConfig.getNumRegionMapList(), maatXmlExpr13, transaction, 13,
idRelaRedisDBIndex, expressionList, isAdd);
addReionToCommonGroup(maatConfig.getStrRegionMapList(), maatXmlExpr14, transaction, 14,
idRelaRedisDBIndex, expressionList, isAdd);
if (maatConfig.getIpRegionMapList() != null && maatConfig.getIpRegionMapList().size() > 0) {
count += maatConfig.getIpRegionMapList().size();
addReionToCommonGroup(maatConfig.getIpRegionMapList(), maatXmlExpr12, transaction, 12,
idRelaRedisDBIndex, expressionList, isAdd);
}
if (maatConfig.getNumRegionMapList() != null && maatConfig.getNumRegionMapList().size() > 0) {
count += maatConfig.getNumRegionMapList().size();
addReionToCommonGroup(maatConfig.getNumRegionMapList(), maatXmlExpr13, transaction, 13,
idRelaRedisDBIndex, expressionList, isAdd);
}
if (maatConfig.getStrRegionMapList() != null && maatConfig.getStrRegionMapList().size() > 0) {
count += maatConfig.getStrRegionMapList().size();
addReionToCommonGroup(maatConfig.getStrRegionMapList(), maatXmlExpr14, transaction, 14,
idRelaRedisDBIndex, expressionList, isAdd);
}
if (maatConfig.getStrStrRegionMapList() != null && maatConfig.getStrStrRegionMapList().size() > 0) {
count += maatConfig.getStrStrRegionMapList().size();
addReionToCommonGroup(maatConfig.getStrStrRegionMapList(), maatXmlExpr15, transaction, 15,
idRelaRedisDBIndex, expressionList, isAdd);
}
if (maatConfig.getFileDigestRegionMapList() != null && maatConfig.getFileDigestRegionMapList().size() > 0) {
count += maatConfig.getFileDigestRegionMapList().size();
addReionToCommonGroup(maatConfig.getFileDigestRegionMapList(), maatXmlExpr16, transaction,
16, idRelaRedisDBIndex, expressionList, isAdd);
}
if (maatConfig.getFileLikeRegionMapList() != null && maatConfig.getFileLikeRegionMapList().size() > 0) {
count += maatConfig.getFileLikeRegionMapList().size();
addReionToCommonGroup(maatConfig.getFileLikeRegionMapList(), maatXmlExpr17, transaction, 17,
idRelaRedisDBIndex, expressionList, isAdd);
}
if (maatConfig.getIpClientRangeMapList() != null && maatConfig.getIpClientRangeMapList().size() > 0) {
count += maatConfig.getIpClientRangeMapList().size();
addReionToCommonGroup(maatConfig.getIpClientRangeMapList(), maatXmlExpr18, transaction, 18,
idRelaRedisDBIndex, expressionList, isAdd);
}
}
if (count == 0) {
throw new ServiceRuntimeException("添加公共组域配置时,未发现对应的配置信息,请检查配置参数是否正确",
RestBusinessCode.ConfigSourceIsNull.getValue());
}
for (String db : Constants.COMMONGROUPDBARR) {
transaction.select(Integer.parseInt(db));
@@ -1971,6 +2023,10 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
MaatXmlExpr maatXmlExpr12 = null;
MaatXmlExpr maatXmlExpr13 = null;
MaatXmlExpr maatXmlExpr14 = null;
MaatXmlExpr maatXmlExpr15 = null;
MaatXmlExpr maatXmlExpr16 = null;
MaatXmlExpr maatXmlExpr17 = null;
MaatXmlExpr maatXmlExpr18 = null;
if (maatXmlConfig != null) {
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
if (expressionList != null && expressionList.size() > 0) {
@@ -1981,19 +2037,65 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
maatXmlExpr13 = maatXmlExpr;
} else if (maatXmlExpr.getType().intValue() == 14) {
maatXmlExpr14 = maatXmlExpr;
} else if (maatXmlExpr.getType().intValue() == 15) {
maatXmlExpr15 = maatXmlExpr;
} else if (maatXmlExpr.getType().intValue() == 16) {
maatXmlExpr16 = maatXmlExpr;
} else if (maatXmlExpr.getType().intValue() == 17) {
maatXmlExpr17 = maatXmlExpr;
} else if (maatXmlExpr.getType().intValue() == 18) {
maatXmlExpr18 = maatXmlExpr;
}
}
}
int count = 0;
for (MaatConfig maatConfig : configList) {
updateCommonGroupRegion(maatConfig.getIpRegionMapList(), maatXmlExpr12, transaction, 12,
idRelaRedisDBIndex, expressionList);
updateCommonGroupRegion(maatConfig.getNumRegionMapList(), maatXmlExpr13, transaction, 13,
idRelaRedisDBIndex, expressionList);
updateCommonGroupRegion(maatConfig.getStrRegionMapList(), maatXmlExpr14, transaction, 14,
idRelaRedisDBIndex, expressionList);
if (maatConfig.getIpRegionMapList() != null && maatConfig.getIpRegionMapList().size() > 0) {
count += maatConfig.getIpRegionMapList().size();
updateCommonGroupRegion(maatConfig.getIpRegionMapList(), maatXmlExpr12, transaction, 12,
idRelaRedisDBIndex, expressionList);
}
if (maatConfig.getNumRegionMapList() != null && maatConfig.getNumRegionMapList().size() > 0) {
count += maatConfig.getNumRegionMapList().size();
updateCommonGroupRegion(maatConfig.getNumRegionMapList(), maatXmlExpr13, transaction, 13,
idRelaRedisDBIndex, expressionList);
}
if (maatConfig.getStrRegionMapList() != null && maatConfig.getStrRegionMapList().size() > 0) {
count += maatConfig.getStrRegionMapList().size();
updateCommonGroupRegion(maatConfig.getStrRegionMapList(), maatXmlExpr14, transaction, 14,
idRelaRedisDBIndex, expressionList);
}
if (maatConfig.getStrStrRegionMapList() != null
&& maatConfig.getStrStrRegionMapList().size() > 0) {
count += maatConfig.getStrStrRegionMapList().size();
updateCommonGroupRegion(maatConfig.getStrStrRegionMapList(), maatXmlExpr15, transaction, 15,
idRelaRedisDBIndex, expressionList);
}
if (maatConfig.getFileDigestRegionMapList() != null
&& maatConfig.getFileDigestRegionMapList().size() > 0) {
count += maatConfig.getFileDigestRegionMapList().size();
updateCommonGroupRegion(maatConfig.getFileDigestRegionMapList(), maatXmlExpr16, transaction,
16, idRelaRedisDBIndex, expressionList);
}
if (maatConfig.getFileLikeRegionMapList() != null
&& maatConfig.getFileLikeRegionMapList().size() > 0) {
count += maatConfig.getFileLikeRegionMapList().size();
updateCommonGroupRegion(maatConfig.getFileLikeRegionMapList(), maatXmlExpr17, transaction,
17, idRelaRedisDBIndex, expressionList);
}
if (maatConfig.getIpClientRangeMapList() != null
&& maatConfig.getIpClientRangeMapList().size() > 0) {
count += maatConfig.getIpClientRangeMapList().size();
updateCommonGroupRegion(maatConfig.getIpClientRangeMapList(), maatXmlExpr18, transaction,
18, idRelaRedisDBIndex, expressionList);
}
}
if (count == 0) {
throw new ServiceRuntimeException("修改公共组域配置时,未发现对应的配置信息,请检查配置参数是否正确",
RestBusinessCode.ConfigSourceIsNull.getValue());
}
for (String db : Constants.COMMONGROUPDBARR) {
transaction.select(Integer.parseInt(db));
transaction.incrBy("MAAT_VERSION", 1l);
@@ -2003,7 +2105,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
}
} else {
throw new ServiceRuntimeException("添加公共组域配置时,未发现对应的配置信息,请检查配置参数是否正确",
throw new ServiceRuntimeException("修改公共组域配置时,未发现对应的配置信息,请检查配置参数是否正确",
RestBusinessCode.ConfigSourceIsNull.getValue());
}
transaction.exec();
@@ -2436,7 +2538,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
}
if (replaceKey != null) {
String val = resource.get(replaceKey);
if (val != null) {
if (val != null && !val.trim().equals("")) {
if (map.containsKey(index)) {
Map<String, String> map2 = map.get(index);
map2.put(replaceKey, val);