From 6d56cc0d2ba89f7e864948fc075ddb296782f441 Mon Sep 17 00:00:00 2001 From: wangxin Date: Tue, 30 Oct 2018 14:52:51 +0800 Subject: [PATCH] =?UTF-8?q?=EF=BC=881=EF=BC=89=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=BC=BA=E5=AD=97=E7=AC=A6=E4=B8=B2=E5=BD=93?= =?UTF-8?q?=E5=8F=AF=E9=85=8D=E7=BD=AE=E5=A4=9A=E4=B8=AA=E5=85=B3=E9=94=AE?= =?UTF-8?q?=E8=AF=8D=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E6=9C=80=E5=A4=9A4=E4=B8=AA=E8=AF=8D=E9=99=90=E5=88=B6?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E4=B8=94=E5=85=B3=E9=94=AE=E8=AF=8D=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E9=87=8D=E5=A4=8D=20=EF=BC=882=EF=BC=89bgp=20as?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=8F=90=E4=BA=A4=20=EF=BC=883=EF=BC=89?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=87=8D=E5=A4=8D=E7=9A=84ip=5Frange=5Fin=5F?= =?UTF-8?q?the=5Fsame=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nis/web/controller/BaseController.java | 46 ++++++++++++++----- .../service/configuration/BgpCfgService.java | 12 ++++- .../resources/messages/message_en.properties | 2 +- .../resources/messages/message_ru.properties | 1 + .../messages/message_zh_CN.properties | 2 +- .../resources/sql/20181030/update_region.sql | 7 ++- 6 files changed, 54 insertions(+), 16 deletions(-) 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