app payload导入L3_header特征配置时增加固定属性值;相关属性校验修改;导入模板批注修改

This commit is contained in:
zhangwenqing
2019-01-03 15:30:14 +08:00
parent 1e0fc76160
commit 55243010b7
7 changed files with 233 additions and 190 deletions

View File

@@ -133,5 +133,23 @@ public class AppFeatureIndex extends BaseCfg<AppFeatureIndex> {
public void setNumCfgList(List<AppTcpCfg> numCfgList) {
this.numCfgList = numCfgList;
}
public Integer getExprType() {
return exprType;
}
public void setExprType(Integer exprType) {
this.exprType = exprType;
}
public Integer getMatchMethod() {
return matchMethod;
}
public void setMatchMethod(Integer matchMethod) {
this.matchMethod = matchMethod;
}
public Integer getIsHexbin() {
return isHexbin;
}
public void setIsHexbin(Integer isHexbin) {
this.isHexbin = isHexbin;
}
}

View File

@@ -1038,7 +1038,12 @@ public class ExportExcel {
}
// APP Payload
if(region.getFunctionId().equals(563)) {
commentStr=commentStr+""+"L3_header:"+msgProp.getProperty("need_input")+"'headerType'"+"\n";
commentStr=commentStr+""+"L3_header:"+msgProp.getProperty("need_input")+"'headerType', "+
msgProp.getProperty("no_need_input")+"'"+
msgProp.getProperty("key_word")+"'、'"+
msgProp.getProperty("match_method")+"'、'"+
msgProp.getProperty("is_hex")+"'、'"+
msgProp.getProperty("is_case_insenstive")+"'"+"\n";
index++;
}
}

View File

@@ -92,21 +92,63 @@ public class CheckAppFeatureComplexStringFormatThread implements Callable<String
StringBuffer errInfo = new StringBuffer();
AppComplexFeatureCfg baseStringCfg = new AppComplexFeatureCfg();
BeanUtils.copyProperties(list.get(i), baseStringCfg);
// 配置描述、关键字长度限制
// 配置描述长度限制
if(baseStringCfg.getCfgDesc().length() > 128) {
errInfo.append(prop.getProperty("config_describe")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("max_length")+":128") + ";");
}
if(baseStringCfg.getCfgKeywords().length() < 4 || baseStringCfg.getCfgKeywords().length() > 1024){
errInfo.append(prop.getProperty("key_word")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("min_length")+":4,"+prop.getProperty("max_length")+":1024") + ";");
}
if (regionDict.getRegionType().equals(3)) {
String keyword = baseStringCfg.getCfgKeywords();
String district = baseStringCfg.getDistrict();
if (StringUtils.isBlank(keyword)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("key_word") + " ") + ";");
if(!district.equals("L3_header")) {// district="L3_header"时 不校验keyword
if (StringUtils.isBlank(keyword)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("key_word") + " ") + ";");
}else if(keyword.length() < 4 || keyword.length() > 1024){// 关键字长度限制
errInfo.append(prop.getProperty("key_word")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("min_length")+":4,"+prop.getProperty("max_length")+":1024") + ";");
}
if (mulityKeywordsP.equals("0")) {
if (keyword.indexOf("\n") > -1) {
errInfo.append(
String.format(prop.getProperty("not_multiple"), prop.getProperty("key_word")) + ";");
}
Matcher m = pattern.matcher(keyword);
if (m.find()) {
errInfo.append(String.format(prop.getProperty("has_invisible_char"),
prop.getProperty("key_word") + " '" + keyword + "'") + ";");
}
} else {
boolean has = false;
Set<String> keywordSet=Sets.newHashSet();
for (String key : keyword.split("\n")) {
Matcher m = pattern.matcher(key);
if (m.find()) {
has = true;
errInfo.append(String.format(prop.getProperty("has_invisible_char"),
prop.getProperty("key_word") + " '" + key + "'") + ";");
break;
}
if(!keywordSet.contains(key)) {
keywordSet.add(key);
}else {
errInfo.append(prop.getProperty("key_word") + " '" + key + "'"+" "+prop.getProperty("repeat") + ";");
}
}
if (!has) {
if(keyword.replaceAll("\n","").length()>1024) {
errInfo.append(String.format(prop.getProperty("most_keywords"),
prop.getProperty("key_word")) + ";");
}else {
String reWord = keyword.replaceAll("\n", Constants.KEYWORD_EXPR);
baseStringCfg.setCfgKeywords(reWord);
}
}
}
}
if (StringUtils.isNotBlank(dirtrictP)) {
if (StringUtils.isBlank(district)) {
if (dirtrictP.indexOf(",") == -1) {
@@ -127,185 +169,149 @@ public class CheckAppFeatureComplexStringFormatThread implements Callable<String
String.format(prop.getProperty("can_not_be"), " 'others'")+ ";");
}
}
if (mulityKeywordsP.equals("0")) {
if (keyword.indexOf("\n") > -1) {
errInfo.append(
String.format(prop.getProperty("not_multiple"), prop.getProperty("key_word")) + ";");
}
Matcher m = pattern.matcher(keyword);
if (m.find()) {
errInfo.append(String.format(prop.getProperty("has_invisible_char"),
prop.getProperty("key_word") + " '" + keyword + "'") + ";");
}
} else {
boolean has = false;
Set<String> keywordSet=Sets.newHashSet();
for (String key : keyword.split("\n")) {
Matcher m = pattern.matcher(key);
if (m.find()) {
has = true;
errInfo.append(String.format(prop.getProperty("has_invisible_char"),
prop.getProperty("key_word") + " '" + key + "'") + ";");
break;
}
if(!keywordSet.contains(key)) {
keywordSet.add(key);
}else {
errInfo.append(prop.getProperty("key_word") + " '" + key + "'"+" "+prop.getProperty("repeat") + ";");
}
}
if (!has) {
if(keyword.replaceAll("\n","").length()>1024) {
errInfo.append(String.format(prop.getProperty("most_keywords"),
prop.getProperty("key_word")) + ";");
}else {
String reWord = keyword.replaceAll("\n", Constants.KEYWORD_EXPR);
baseStringCfg.setCfgKeywords(reWord);
}
}
}
Integer exprType = baseStringCfg.getExprType();
boolean has = false;
if (exprType == null) {
if (exprTypeP.indexOf(",") == -1) {
if (mulityKeywordsP.equals("0") && exprTypeP.equals("1")) {
throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId());
}
baseStringCfg.setExprType(Integer.parseInt(exprTypeP));
} else if (exprTypeP.indexOf("0") > -1 && mulityKeywordsP.equals("0")) {
baseStringCfg.setExprType(0);
} else if (exprTypeP.indexOf("1") > -1 && mulityKeywordsP.equals("1")
&& keyword.indexOf("\n") > -1) {
baseStringCfg.setExprType(1);
} else if (exprTypeP.indexOf("0") > -1 && mulityKeywordsP.equals("1")
&& keyword.indexOf("\n") == -1) {
baseStringCfg.setExprType(0);
} else {
baseStringCfg.setExprType(Integer.parseInt(exprTypeP.split(",")[0]));
}
// errInfo.append(String.format(prop.getProperty("can_not_null"),
// prop.getProperty("expression_type"))+";");
} else {
for (String exp : exprTypeP.split(",")) {
if (exp.equals(exprType.toString())) {
has = true;
break;
}
}
if (!has) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("expression_type"))
+ ";");
}
has = false;
}
exprType = baseStringCfg.getExprType();
Integer matchMethod = baseStringCfg.getMatchMethod();
if (matchMethod == null) {
if (matchMethodP.indexOf(",") == -1) {
if (exprTypeP.equals("1") && !matchMethodP.equals("0")) {
throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId());
}
baseStringCfg.setMatchMethod(Integer.parseInt(matchMethodP));
} else if (exprType != null && exprType.intValue() == 1) {
if (matchMethodP.indexOf("0") > -1) {
baseStringCfg.setMatchMethod(0);
} else {
throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId());
}
} else {
baseStringCfg.setMatchMethod(Integer.parseInt(matchMethodP.split(",")[0]));
}
// errInfo.append(String.format(prop.getProperty("can_not_null"),
// prop.getProperty("match_method"))+";");
} else {
for (String exp : matchMethodP.split(",")) {
if (exp.equals(matchMethod.toString())) {
has = true;
break;
}
}
if (!has) {
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("match_method"))
+ ";");
}
}
Integer isHex = baseStringCfg.getIsHex();
Integer isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
if (isHex == null || isCaseInsenstive == null) {
if (isHex == null) {
if (hexP.indexOf("0")>-1 || hexP.indexOf("2")>-1) {
baseStringCfg.setIsHex(0);
} else if (hexP.indexOf("1")>-1) {
baseStringCfg.setIsHex(1);
} else {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("is_hex")) + ";");
}
}
if (isCaseInsenstive == null) {
if (hexP.indexOf("0")>-1 || hexP.indexOf("1")>-1) {
baseStringCfg.setIsCaseInsenstive(0);
} else if (hexP.indexOf("2")>-1) {
baseStringCfg.setIsCaseInsenstive(1);
} else {
errInfo.append(String.format(prop.getProperty("can_not_null"),
prop.getProperty("is_case_insenstive")) + ";");
}
}
} else {
if (isHex.intValue() != 0 && isHex.intValue() != 1) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
}
if (isCaseInsenstive.intValue() != 0 && isCaseInsenstive.intValue() != 1) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive"))
+ ";");
}
if (hexP.indexOf("1") == -1 && isHex.intValue() == 1) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
}
if (hexP.equals("1") && isHex.intValue() == 0) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
}
if (hexP.indexOf("2") == -1 && isCaseInsenstive.intValue() == 1) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive"))
+ ";");
}
if (hexP.equals("2") && isCaseInsenstive.intValue() == 0) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive"))
+ ";");
}
// 关键字十六进制校验
if (hexP.indexOf("1") != -1 && isHex.intValue() == 1) {
boolean bl = Pattern.compile("^([0-9|a-f|A-F]*)$").matcher(keyword).matches();
if(!bl) {
errInfo.append(
prop.getProperty("key_word") + " '" + keyword + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
}
}
}
isHex = baseStringCfg.getIsHex();
isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
if (isHex != null && isCaseInsenstive != null) {
if (isHex.intValue() == 0 && isCaseInsenstive.intValue() == 0) {
baseStringCfg.setIsHexbin(0);
} else if (isHex.intValue() == 1 && isCaseInsenstive.intValue() == 0) {
baseStringCfg.setIsHexbin(1);
} else if (isHex.intValue() == 0 && isCaseInsenstive.intValue() == 1) {
baseStringCfg.setIsHexbin(2);
} else if (hexP.indexOf("1") != -1 && isHex.intValue() == 1 && isCaseInsenstive.intValue() == 1) {// 只有是十六进制且取值正确的时候, 才进行(十六进制)与(大小写敏感)的校验
errInfo.append(prop.getProperty("hex_case_insensitive")+ ";");
}
}
if(!district.equals("L3_header")) {// district="L3_header"时 不校验exprType、matchMethod、isHex、isCaseInsenstive为固定值
Integer exprType = baseStringCfg.getExprType();
boolean has = false;
if (exprType == null) {
if (exprTypeP.indexOf(",") == -1) {
if (mulityKeywordsP.equals("0") && exprTypeP.equals("1")) {
throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId());
}
baseStringCfg.setExprType(Integer.parseInt(exprTypeP));
} else if (exprTypeP.indexOf("0") > -1 && mulityKeywordsP.equals("0")) {
baseStringCfg.setExprType(0);
} else if (exprTypeP.indexOf("1") > -1 && mulityKeywordsP.equals("1")
&& keyword.indexOf("\n") > -1) {
baseStringCfg.setExprType(1);
} else if (exprTypeP.indexOf("0") > -1 && mulityKeywordsP.equals("1")
&& keyword.indexOf("\n") == -1) {
baseStringCfg.setExprType(0);
} else {
baseStringCfg.setExprType(Integer.parseInt(exprTypeP.split(",")[0]));
}
// errInfo.append(String.format(prop.getProperty("can_not_null"),
// prop.getProperty("expression_type"))+";");
} else {
for (String exp : exprTypeP.split(",")) {
if (exp.equals(exprType.toString())) {
has = true;
break;
}
}
if (!has) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("expression_type"))
+ ";");
}
has = false;
}
exprType = baseStringCfg.getExprType();
Integer matchMethod = baseStringCfg.getMatchMethod();
if (matchMethod == null) {
if (matchMethodP.indexOf(",") == -1) {
if (exprTypeP.equals("1") && !matchMethodP.equals("0")) {
throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId());
}
baseStringCfg.setMatchMethod(Integer.parseInt(matchMethodP));
} else if (exprType != null && exprType.intValue() == 1) {
if (matchMethodP.indexOf("0") > -1) {
baseStringCfg.setMatchMethod(0);
} else {
throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId());
}
} else {
baseStringCfg.setMatchMethod(Integer.parseInt(matchMethodP.split(",")[0]));
}
// errInfo.append(String.format(prop.getProperty("can_not_null"),
// prop.getProperty("match_method"))+";");
} else {
for (String exp : matchMethodP.split(",")) {
if (exp.equals(matchMethod.toString())) {
has = true;
break;
}
}
if (!has) {
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("match_method"))
+ ";");
}
}
Integer isHex = baseStringCfg.getIsHex();
Integer isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
if (isHex == null || isCaseInsenstive == null) {
if (isHex == null) {
if (hexP.indexOf("0")>-1 || hexP.indexOf("2")>-1) {
baseStringCfg.setIsHex(0);
} else if (hexP.indexOf("1")>-1) {
baseStringCfg.setIsHex(1);
} else {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("is_hex")) + ";");
}
}
if (isCaseInsenstive == null) {
if (hexP.indexOf("0")>-1 || hexP.indexOf("1")>-1) {
baseStringCfg.setIsCaseInsenstive(0);
} else if (hexP.indexOf("2")>-1) {
baseStringCfg.setIsCaseInsenstive(1);
} else {
errInfo.append(String.format(prop.getProperty("can_not_null"),
prop.getProperty("is_case_insenstive")) + ";");
}
}
} else {
if (isHex.intValue() != 0 && isHex.intValue() != 1) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
}
if (isCaseInsenstive.intValue() != 0 && isCaseInsenstive.intValue() != 1) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive"))
+ ";");
}
if (hexP.indexOf("1") == -1 && isHex.intValue() == 1) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
}
if (hexP.equals("1") && isHex.intValue() == 0) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
}
if (hexP.indexOf("2") == -1 && isCaseInsenstive.intValue() == 1) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive"))
+ ";");
}
if (hexP.equals("2") && isCaseInsenstive.intValue() == 0) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive"))
+ ";");
}
// 关键字十六进制校验
if (hexP.indexOf("1") != -1 && isHex.intValue() == 1) {
boolean bl = Pattern.compile("^([0-9|a-f|A-F]*)$").matcher(keyword).matches();
if(!bl) {
errInfo.append(
prop.getProperty("key_word") + " '" + keyword + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
}
}
}
isHex = baseStringCfg.getIsHex();
isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
if (isHex != null && isCaseInsenstive != null) {
if (isHex.intValue() == 0 && isCaseInsenstive.intValue() == 0) {
baseStringCfg.setIsHexbin(0);
} else if (isHex.intValue() == 1 && isCaseInsenstive.intValue() == 0) {
baseStringCfg.setIsHexbin(1);
} else if (isHex.intValue() == 0 && isCaseInsenstive.intValue() == 1) {
baseStringCfg.setIsHexbin(2);
} else if (hexP.indexOf("1") != -1 && isHex.intValue() == 1 && isCaseInsenstive.intValue() == 1) {// 只有是十六进制且取值正确的时候, 才进行(十六进制)与(大小写敏感)的校验
errInfo.append(prop.getProperty("hex_case_insensitive")+ ";");
}
}
}
// APP Payload L3_HEADER的特殊属性限制
if(baseStringCfg.getDistrict().equals("L3_header")) {
String headerType = baseStringCfg.getHeaderType();
@@ -318,7 +324,13 @@ public class CheckAppFeatureComplexStringFormatThread implements Callable<String
}else{
appMultiFeatureCfgService.checkImportAppPayload(baseStringCfg, errInfo, prop);
}
appMultiFeatureCfgService.setL3HeaderKeyword(baseStringCfg);
if (errInfo.toString().length() == 0) {
appMultiFeatureCfgService.setL3HeaderKeyword(baseStringCfg);
}
baseStringCfg.setIsHexbin(1);
baseStringCfg.setIsCaseInsenstive(0);
baseStringCfg.setExprType(3);
baseStringCfg.setMatchMethod(0);
}else {
baseStringCfg.setHeaderType(null);
baseStringCfg.setVer(null);

View File

@@ -2048,6 +2048,11 @@ public class BaseController {
appfeature.setCfgRegionValue(regionDict.getConfigRegionValue());
appfeature.setCfgRegionType(String.valueOf(regionDict.getRegionType()));
}
if(cfg.getDistrict().equals("L3_header")) {
appfeature.setIsHexbin(1);
appfeature.setExprType(3);
appfeature.setMatchMethod(0);
}
appFeatureIndexs.add(appfeature);
ind++;

View File

@@ -1444,4 +1444,5 @@ hex_minlength_4=Please enter a hexadecimal string of length 4
hex_minlength_8=Please enter a hexadecimal string of length 8
hex_minlength_16=Please enter a hexadecimal string of length 16
need_input=Attributes need to be filled in
max_input=Fill in at most four
max_input=Fill in at most four
no_need_input=Attributes no need to be filled in

View File

@@ -1448,4 +1448,5 @@ hex_minlength_4=Please enter a hexadecimal string of length 4
hex_minlength_8=Please enter a hexadecimal string of length 8
hex_minlength_16=Please enter a hexadecimal string of length 16
need_input=Attributes need to be filled in
max_input=Fill in at most four
max_input=Fill in at most four
no_need_input=Attributes no need to be filled in

View File

@@ -1444,4 +1444,5 @@ hex_minlength_4=\u8BF7\u8F93\u5165\u957F\u5EA6\u4E3A4\u7684\u5341\u516D\u8FDB\u5
hex_minlength_8=\u8BF7\u8F93\u5165\u957F\u5EA6\u4E3A8\u7684\u5341\u516D\u8FDB\u5236\u5B57\u7B26\u4E32
hex_minlength_16=\u8BF7\u8F93\u5165\u957F\u5EA6\u4E3A16\u7684\u5341\u516D\u8FDB\u5236\u5B57\u7B26\u4E32
need_input=\u9700\u8981\u586B\u5199\u5C5E\u6027
max_input=\u6700\u591A\u586B\u5199\u56DB\u4E2A
max_input=\u6700\u591A\u586B\u5199\u56DB\u4E2A
no_need_input=\u65E0\u9700\u586B\u5199\u5C5E\u6027