diff --git a/src/main/java/com/nis/web/controller/BaseController.java b/src/main/java/com/nis/web/controller/BaseController.java index e2d9cf115..e6c3f921c 100644 --- a/src/main/java/com/nis/web/controller/BaseController.java +++ b/src/main/java/com/nis/web/controller/BaseController.java @@ -12,10 +12,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.management.RuntimeErrorException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -34,6 +34,7 @@ import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import com.beust.jcommander.internal.Lists; +import com.beust.jcommander.internal.Sets; import com.nis.domain.FunctionRegionDict; import com.nis.domain.FunctionServiceDict; import com.nis.domain.SysDataDictionaryItem; @@ -58,15 +59,14 @@ import com.nis.domain.configuration.template.AsnIpTemplate; import com.nis.domain.configuration.template.ComplexStringAllTemplate; import com.nis.domain.configuration.template.DnsComplexStringTemplate; import com.nis.domain.configuration.template.IpAllTemplate; -import com.nis.domain.configuration.template.P2pHashStringTemplate; -import com.nis.domain.configuration.template.P2pIpTemplate; import com.nis.domain.configuration.template.IpCfgTemplate; import com.nis.domain.configuration.template.IpPayloadTemplate; import com.nis.domain.configuration.template.IpRateLimitTemplate; +import com.nis.domain.configuration.template.P2pHashStringTemplate; +import com.nis.domain.configuration.template.P2pIpTemplate; import com.nis.domain.configuration.template.StringAllTemplate; import com.nis.domain.log.BaseLogEntity; import com.nis.domain.log.SearchReport; -import com.nis.domain.specific.ConfigGroupInfo; import com.nis.domain.specific.SpecificServiceCfg; import com.nis.exceptions.MaatConvertException; import com.nis.util.Configurations; @@ -124,8 +124,6 @@ import com.nis.web.service.specific.SpecificServiceCfgService; import com.nis.web.service.specific.SpecificServiceHostCfgService; import com.nis.web.service.systemService.ServiceConfigInfoService; -import jdk.nashorn.internal.runtime.regexp.joni.Regex; - public class BaseController { @Autowired @@ -888,6 +886,7 @@ public class BaseController { } } else { boolean has = false; + Set keywordSet=Sets.newHashSet(); for (String key : keyword.split("\n")) { Matcher m = pattern.matcher(key); if (m.find()) { @@ -896,10 +895,20 @@ public class BaseController { 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) { - String reWord = keyword.replaceAll("\n", Constants.KEYWORD_EXPR); - baseStringCfg.setCfgKeywords(reWord); + if(keyword.split("\n").length>4) { + 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(); @@ -1121,6 +1130,8 @@ public class BaseController { } } else { boolean has = false; + Set keywordSet=Sets.newHashSet(); + for (String key : keyword.split("\n")) { Matcher m = pattern.matcher(key); if (m.find()) { @@ -1129,10 +1140,20 @@ public class BaseController { 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) { - String reWord = keyword.replaceAll("\n", Constants.KEYWORD_EXPR); - baseStringCfg.setCfgKeywords(reWord); + if(keyword.split("\n").length>4) { + 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(); @@ -3297,7 +3318,7 @@ public class BaseController { } } else { CfgIndexInfo cfgIndexInfo = new CfgIndexInfo(); - BeanUtils.copyProperties(cfg, cfgIndexInfo); + BeanUtils.copyProperties(cfg, cfgIndexInfo, new String[] {"cfgId"}); cfgIndexInfos.add(cfgIndexInfo); } } @@ -3320,6 +3341,9 @@ public class BaseController { /* } */ } + if (regionDict.getFunctionId().equals(61)) { + bgpCfgService.saveBgpAsCfg(stringCfgs); + } } else if (regionDict.getRegionType().equals(3)) { for (ComplexkeywordCfg cfg : complexkeywordCfgs) { cfg.setAction(serviceDict.getAction()); diff --git a/src/main/java/com/nis/web/service/configuration/BgpCfgService.java b/src/main/java/com/nis/web/service/configuration/BgpCfgService.java index 5570ad7be..b0f4c0cbd 100644 --- a/src/main/java/com/nis/web/service/configuration/BgpCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/BgpCfgService.java @@ -11,8 +11,8 @@ import org.springframework.stereotype.Service; import com.nis.domain.Page; import com.nis.domain.configuration.AreaIpCfg; +import com.nis.domain.configuration.BaseStringCfg; import com.nis.domain.configuration.CfgIndexInfo; -import com.nis.domain.configuration.ComplexkeywordCfg; import com.nis.domain.configuration.IpPortCfg; import com.nis.domain.configuration.NtcBgpAsCfg; import com.nis.domain.configuration.NtcSubscribeIdCfg; @@ -86,7 +86,15 @@ public class BgpCfgService extends CrudService { return entity; } - + public void saveBgpAsCfg(List> cfgs) { + for(BaseStringCfg cfg:cfgs){ + NtcBgpAsCfg _cfg=new NtcBgpAsCfg(); + BeanUtils.copyProperties(cfg, _cfg); + if(cfg.getCfgKeywords()!=null && !"".equals(cfg.getCfgKeywords())){ + bgpCfgDao.saveNtcBgpAsCfg(_cfg); + } + } + } /** * 保存配置 * @param entity diff --git a/src/main/resources/messages/message_en.properties b/src/main/resources/messages/message_en.properties index bab6a3b21..a20905bef 100644 --- a/src/main/resources/messages/message_en.properties +++ b/src/main/resources/messages/message_en.properties @@ -1299,4 +1299,4 @@ av_protocol_note=Note:Recognizable Protocols Include RTSP,RTMP. ip_range_in_the_same=Start IP and end IP in a IP range must with in the same subnet log_to_url=To HTTP URL source_compile_id=Configuration Source -ip_range_in_the_same=Start IP and end IP in a IP range must with in the same subnet +most_keywords=%s can have four keywords at most \ No newline at end of file diff --git a/src/main/resources/messages/message_ru.properties b/src/main/resources/messages/message_ru.properties index b3ed5f249..17647abf6 100644 --- a/src/main/resources/messages/message_ru.properties +++ b/src/main/resources/messages/message_ru.properties @@ -1297,3 +1297,4 @@ av_protocol_note=Note:Recognizable Protocols Include RTSP,RTMP. log_to_url=To HTTP URL source_compile_id=Configuration Source av_protocol_note=Note:Recognizable Protocols Include RTSP,RTMP. +most_keywords=%s can have four keywords at most \ No newline at end of file diff --git a/src/main/resources/messages/message_zh_CN.properties b/src/main/resources/messages/message_zh_CN.properties index 1d99fe046..13112e527 100644 --- a/src/main/resources/messages/message_zh_CN.properties +++ b/src/main/resources/messages/message_zh_CN.properties @@ -1291,4 +1291,4 @@ av_protocol_note=\u6CE8\uFF1A\u53EF\u8BC6\u522B\u534F\u8BAE\u5305\u62EC RTSP\u30 ip_range_in_the_same=IP\u8303\u56F4\u7684\u8D77\u59CBIP\u4E0E\u7EC8\u6B62IP\u5FC5\u987B\u5728\u76F8\u540C\u7F51\u6BB5 log_to_url=\u8F6CHTTP URL\u914D\u7F6E source_compile_id=\u914D\u7F6E\u6765\u6E90 -ip_range_in_the_same=IP\u8303\u56F4\u7684\u8D77\u59CBIP\u4E0E\u7EC8\u6B62IP\u5FC5\u987B\u5728\u76F8\u540C\u7F51\u6BB5 +most_keywords=%s\u6700\u591A\u5305\u542B\u56DB\u4E2A\u5173\u952E\u8BCD \ No newline at end of file diff --git a/src/main/resources/sql/20181030/update_region.sql b/src/main/resources/sql/20181030/update_region.sql index c363a69bf..0ba27213e 100644 --- a/src/main/resources/sql/20181030/update_region.sql +++ b/src/main/resources/sql/20181030/update_region.sql @@ -1,2 +1,7 @@ +#ip白名单导入 update function_region_dict set is_import=1 where function_id=3 and dict_id=7; -UPDATE function_service_dict SET is_import=1 WHERE function_id=3 AND dict_id=15; \ No newline at end of file +UPDATE function_service_dict SET is_import=1 WHERE function_id=3 AND dict_id=15; +#bgp导入 +update function_region_dict set is_import=1 where function_id=61 and dict_id=48; +update function_region_dict set is_import=1 where function_id=61 and dict_id=168; +UPDATE function_service_dict SET is_import=1 WHERE function_id=61 ; \ No newline at end of file