@@ -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 ) ;