diff --git a/src/main/java/com/nis/domain/configuration/template/TopicWebsiteTemplate.java b/src/main/java/com/nis/domain/configuration/template/TopicWebsiteTemplate.java new file mode 100644 index 000000000..08fed256f --- /dev/null +++ b/src/main/java/com/nis/domain/configuration/template/TopicWebsiteTemplate.java @@ -0,0 +1,40 @@ +package com.nis.domain.configuration.template; + +import com.nis.util.excel.ExcelField; + +/** + * 主题网站配置导入模板类 + * @author dell + * + */ +public class TopicWebsiteTemplate extends StringAllTemplate{ + + private Long topicId; // 主题 + private Long websiteServiceId; // 网站 + private String cfgKeywords; // 域名 + + @ExcelField(title="topic",dictType="TOPIC",sort=2) + public Long getTopicId() { + return topicId; + } + public void setTopicId(Long topicId) { + this.topicId = topicId; + } + + @ExcelField(title="website_server",dictType="WEBSITE_SERVER",sort=3) + public Long getWebsiteServiceId() { + return websiteServiceId; + } + public void setWebsiteServiceId(Long websiteServiceId) { + this.websiteServiceId = websiteServiceId; + } + + @ExcelField(title="domain_name",sort=4) + public String getCfgKeywords() { + return cfgKeywords; + } + public void setCfgKeywords(String cfgKeywords) { + this.cfgKeywords = cfgKeywords; + } + +} diff --git a/src/main/java/com/nis/util/excel/ExportExcel.java b/src/main/java/com/nis/util/excel/ExportExcel.java index 539271b52..1d7daf7a1 100644 --- a/src/main/java/com/nis/util/excel/ExportExcel.java +++ b/src/main/java/com/nis/util/excel/ExportExcel.java @@ -448,6 +448,41 @@ public class ExportExcel { commentStr=msgProp.getProperty("select")+":\n"+commentStr; index++; } + /*** 主题网站 ***/ + if(("topic".equals(headerStr)) && (region.getFunctionId().equals(560))){ + commentStr=""; + List dict=DictUtils.getDictList("TOPIC"); + if(dict !=null && dict.size()>0){ + for (SysDataDictionaryItem sysDataDictionaryItem : dict) { + commentStr=commentStr+" "+msgProp.getProperty(sysDataDictionaryItem.getItemValue(),sysDataDictionaryItem.getItemValue())+"\n"; + index++; + } + } + commentStr=msgProp.getProperty("select")+":\n"+commentStr; + index++; + commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n"; + index++; + //1、非空 + commentStr=commentStr+"▶"+msgProp.getProperty("required")+"\n"; + index++; + index++; + + } + if(("website_server".equals(headerStr)) && (region.getFunctionId().equals(560))){ + commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; + index++; + //1、非空 + commentStr=commentStr+"▶"+msgProp.getProperty("required")+"\n"; + index++; + } + if(("domain_name".equals(headerStr)) && (region.getFunctionId().equals(560))){ + commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; + index++; + //1、非空 + commentStr=commentStr+"▶"+msgProp.getProperty("required")+"\n"; + index++; + } + if(region.getRegionType().equals(1)){//IP配置 //ip配置需要导入的信息:srcIp srcPort destIp destPort Protocol Direction //确定需要导入的srcIp srcPort destIp destPort信息 diff --git a/src/main/java/com/nis/util/excel/thread/CheckTopicWebsiteFormatThread.java b/src/main/java/com/nis/util/excel/thread/CheckTopicWebsiteFormatThread.java new file mode 100644 index 000000000..bc22c1337 --- /dev/null +++ b/src/main/java/com/nis/util/excel/thread/CheckTopicWebsiteFormatThread.java @@ -0,0 +1,307 @@ +package com.nis.util.excel.thread; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Properties; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.Callable; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import org.jets3t.service.ServiceException; +import org.springframework.beans.BeanUtils; + +import com.beust.jcommander.internal.Lists; +import com.nis.domain.FunctionRegionDict; +import com.nis.domain.FunctionServiceDict; +import com.nis.domain.configuration.AppTopicDomainCfg; +import com.nis.domain.configuration.WebsiteDomainTopic; +import com.nis.util.Constants; +import com.nis.web.security.UserUtils; +import com.nis.web.service.SpringContextHolder; +import com.nis.web.service.configuration.AppCfgService; + +public class CheckTopicWebsiteFormatThread implements Callable{ + private Logger logger=Logger.getLogger(CheckTopicWebsiteFormatThread.class); + private BlockingQueue srcQueue; + private BlockingQueue destQueue; + private Properties prop; + private FunctionServiceDict serviceDict; + private FunctionRegionDict regionDict; + + public CheckTopicWebsiteFormatThread(FunctionServiceDict serviceDict,FunctionRegionDict regionDict,Properties prop,BlockingQueue srcQueue,BlockingQueue destQueue) { + this.serviceDict=serviceDict; + this.regionDict=regionDict; + this.srcQueue=srcQueue; + this.destQueue=destQueue; + this.prop=prop; + + } + @Override + public String call() throws Exception { + List dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE); + StringBuffer msg=new StringBuffer(); + while(!srcQueue.isEmpty()) { + int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE); + if(regionDict.getRegionType().intValue()==2) { + try { + List cfgs=this.checkTopicWebsiteCfg(msg,dataList); + destQueue.addAll(cfgs); + }catch (Exception e) { + logger.error("check topicDomainCfg error",e); + // TODO: handle exception + //msg=e.getMessage(); + //break; + } + } + dataList.clear(); + } + return msg.toString(); + } + + public List checkTopicWebsiteCfg(StringBuffer msg,List list) throws ServiceException { + logger.warn("start to validate topicDomainCfg data..."); + long start=System.currentTimeMillis(); + List stringList = new ArrayList(); + String exprTypeP = regionDict.getConfigExprType(); + if (StringUtils.isBlank(exprTypeP)) { + throw new RuntimeException("Found String region,but exprType is Empty"); + } + String matchMethodP = regionDict.getConfigMatchMethod(); + if (StringUtils.isBlank(matchMethodP)) { + throw new RuntimeException("Found String region,but matchMethod is Empty"); + } + String hexP = regionDict.getConfigHex(); + if (StringUtils.isBlank(hexP)) { + throw new RuntimeException("Found String region,but hex is Empty"); + } + String mulityKeywordsP = regionDict.getConfigMultiKeywords(); + if (StringUtils.isBlank(mulityKeywordsP)) { + throw new RuntimeException("Found String region,but mulityKeywords is Empty"); + } + StringBuffer errTip = new StringBuffer(); + Pattern pattern = Pattern.compile("\t|\r|\n|\b|\f"); + Pattern domainPattern = Pattern.compile(Constants.DOMAIN_REGEXP); + for (int i = 0; i < list.size(); i++) { + StringBuffer errInfo = new StringBuffer(); + AppTopicDomainCfg baseStringCfg = new AppTopicDomainCfg(); + 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 (regionDict.getRegionType().equals(2)) { + // 主题、网站校验 + Long topicId = baseStringCfg.getTopicId(); + Long websiteServiceId = baseStringCfg.getWebsiteServiceId(); + + if (topicId == null) { + errInfo.append(prop.getProperty("topic") +" "+ prop.getProperty("not_exist") + ";"); + } + + if (websiteServiceId == null) { + errInfo.append(prop.getProperty("website_server") +" "+ prop.getProperty("not_exist") + ";"); + } + + String keyword = baseStringCfg.getCfgKeywords(); + if (StringUtils.isBlank(keyword)) { + errInfo.append( + String.format(prop.getProperty("can_not_null"), prop.getProperty("domain_name") + " ") + ";"); + }else if(keyword.length() < 4 || keyword.length() > 1024){ + errInfo.append(prop.getProperty("domain_name")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("min_length")+":4,"+prop.getProperty("max_length")+":1024") + ";"); + }else { + Matcher m = pattern.matcher(keyword); + if (m.find()) { + errInfo.append(String.format(prop.getProperty("has_invisible_char"), + prop.getProperty("domain_name") + " '" + keyword + "'") + ";"); + }else { + m = domainPattern.matcher(keyword); + if(!m.matches()) { + errInfo.append(String.format(prop.getProperty("not_valid_domain"), + prop.getProperty("domain_name") + " '" + keyword + "'") + ";"); + }/*else { + baseStringCfg.setDomain(keyword); + }*/ + + } + } + + 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 (errInfo.toString().length() > 0) { + errTip.append(String.format(prop.getProperty("line"), baseStringCfg.getIndex()) + ","); + errTip.append(errInfo); + errTip.append("
"); + }else { + // 保存到域名关联表中 + AppCfgService appCfgService = SpringContextHolder.getBean(AppCfgService.class); + WebsiteDomainTopic websiteDomainTopic = new WebsiteDomainTopic(); + websiteDomainTopic.setDomain(baseStringCfg.getCfgKeywords()); + + List dictList = appCfgService.getDomainDict(websiteDomainTopic); + if(dictList.size() == 0) { + websiteDomainTopic.setWebsiteServiceId(baseStringCfg.getWebsiteServiceId()); + websiteDomainTopic.setTopicId(baseStringCfg.getTopicId()); + websiteDomainTopic.setCreateTime(new Date()); + websiteDomainTopic.setCreatorId(Integer.valueOf(UserUtils.getUser().getId().toString())); + websiteDomainTopic.setIsValid(Constants.VALID_YES); + appCfgService.saveDomainDict(websiteDomainTopic); + } + stringList.add(baseStringCfg); + } + + } + if (errTip.toString().length() > 0) { + msg.append(errTip); + //throw new ServiceException(errTip.toString()); + } + long end=System.currentTimeMillis(); + logger.warn("validate topicDomainCfg data finish,cost:"+(end-start)); + return stringList; + } +} diff --git a/src/main/java/com/nis/web/controller/BaseController.java b/src/main/java/com/nis/web/controller/BaseController.java index cc8854bda..04c401581 100644 --- a/src/main/java/com/nis/web/controller/BaseController.java +++ b/src/main/java/com/nis/web/controller/BaseController.java @@ -105,6 +105,7 @@ 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.configuration.template.TopicWebsiteTemplate; import com.nis.domain.log.BaseLogEntity; import com.nis.domain.log.SearchReport; import com.nis.domain.maat.MaatCfg; @@ -135,6 +136,7 @@ import com.nis.util.excel.thread.CheckComplexStringFormatThread; import com.nis.util.excel.thread.CheckDnsResStrategyFormatThread; import com.nis.util.excel.thread.CheckIpFormatThread; import com.nis.util.excel.thread.CheckStringFormatThread; +import com.nis.util.excel.thread.CheckTopicWebsiteFormatThread; import com.nis.web.security.UserUtils; import com.nis.web.service.ArchiveServcie; import com.nis.web.service.AreaService; @@ -1143,6 +1145,48 @@ public class BaseController { return queue; } + /** + * 多线程验证 + * @param serviceDict + * @param regionDict + * @param list + * @return + * @throws InterruptedException + * @throws ExecutionException + * @throws ServiceException + */ + public BlockingQueue checkTopicWebsiteCfgMulity(StringBuffer _msg,FunctionServiceDict serviceDict, FunctionRegionDict regionDict, BlockingQueue list) throws InterruptedException, ExecutionException, ServiceException{ + logger.warn("start checkTopicWebsiteCfgMulity ,size "+list.size()); + long start=System.currentTimeMillis(); + BlockingQueue queue=new ArrayBlockingQueue<>(list.size()); + ExecutorService service=Executors.newFixedThreadPool(Constants.MULITY_THREAD_SIZE); + List> futures=new ArrayList<>(); + for(int i=0;i future:futures) { + String msg = future.get(); + if(StringUtils.isNotBlank(msg)) { + //throw new ServiceException(msg); + _msg.append(msg); + } + } + long end=System.currentTimeMillis(); + logger.warn("checkTopicWebsiteCfgMulity finish,cost:"+(end-start)+",size:"+queue.size()); + return queue; + } + /** * * setReportSearchTime(报表查询设置开始时间与结束时间) (这里描述这个方法适用条件 – 可选) @@ -1280,6 +1324,7 @@ public class BaseController { BlockingQueue complexkeywordCfgs =null; BlockingQueue dnsResStrategies=null; BlockingQueue appComplexFeatureCfgs=null; + BlockingQueue appTopicDomainCfgs=null;// 主题网站 List cfgIndexInfos = new ArrayList(); List appPolicyCfgs = new ArrayList(); List appFeatureIndexs= new ArrayList(); @@ -1402,6 +1447,9 @@ public class BaseController { }else if(regionDict.getFunctionId().equals(209)){// HTTP(s)替换 BlockingQueue list = ei.getDataList(HttpsReplaceTemplate.class); stringCfgs=this.checkStringCfgMulity(errTip,serviceDict, regionDict, list); + }else if(regionDict.getFunctionId().equals(560)){// 主题网站 + BlockingQueue list = ei.getDataList(TopicWebsiteTemplate.class); + appTopicDomainCfgs=this.checkTopicWebsiteCfgMulity(errTip,serviceDict, regionDict, list); }else { BlockingQueue list = ei.getDataList(StringAllTemplate.class ); stringCfgs=this.checkStringCfgMulity(errTip,serviceDict, regionDict, list); @@ -1720,6 +1768,7 @@ public class BaseController { // } // } // } + if(!regionDict.getFunctionId().equals(560)) { List _stringCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE); while(!stringCfgs.isEmpty()) { stringCfgs.drainTo(_stringCfgs, Constants.MAAT_JSON_SEND_SIZE); @@ -1802,10 +1851,6 @@ public class BaseController { } else { if(!regionDict.getFunctionId().equals(403)) { CfgIndexInfo cfgIndexInfo = new CfgIndexInfo(); - // 因域名阻断 -限速 -丢包率 - if(serviceDict.getFunctionId().equals(201) && serviceDict.getAction().equals(64)){ - cfg.setUserRegion1("0"); - } BeanUtils.copyProperties(cfg, cfgIndexInfo, new String[] {"cfgId"}); cfgIndexInfos.add(cfgIndexInfo); } @@ -1818,6 +1863,65 @@ public class BaseController { appPolicyCfgs.clear(); _stringCfgs.clear(); } + }else { + // 主题网站 + List _topicDomainCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE); + while(!appTopicDomainCfgs.isEmpty()) { + appTopicDomainCfgs.drainTo(_topicDomainCfgs, Constants.MAAT_JSON_SEND_SIZE); + List compileIds=Lists.newArrayList(); + List groupIds=Lists.newArrayList(); + List regionIds=Lists.newArrayList(); + try { + compileIds = ConfigServiceUtil.getId(1,_topicDomainCfgs.size()); + if(isSend.equals("1")) { + groupIds = ConfigServiceUtil.getId(2,_topicDomainCfgs.size()); + regionIds = ConfigServiceUtil.getId(3,_topicDomainCfgs.size()); + } + } catch (Exception e) { + e.printStackTrace(); + logger.info("获取编译ID出错"); + throw new MaatConvertException(":"+e.getMessage()); + } + int ind=0; + for (AppTopicDomainCfg cfg : _topicDomainCfgs) { + cfg.setAction(serviceDict.getAction()); + cfg.setCfgRegionCode(regionDict.getConfigRegionCode()); + cfg.setCfgType(regionDict.getConfigRegionValue()); + cfg.setCreateTime(date); + cfg.setCreatorId(UserUtils.getUser().getId()); + cfg.setDoLog(2); + cfg.setFunctionId(regionDict.getFunctionId()); + /*if(isSend.equals("1")) { + cfg.setIsAudit(Constants.AUDIT_YES); + cfg.setIsValid(Constants.VALID_YES); + cfg.setAuditorId(UserUtils.getUser().getId()); + cfg.setAuditTime(date); + if(groupIds!=null&&groupIds.size()==_topicDomainCfgs.size()) { + cfg.setGroupId(groupIds.get(ind)); + } + if(regionIds!=null&®ionIds.size()==_topicDomainCfgs.size()) { + cfg.setRegionId(regionIds.get(ind)); + } + }else {*/ + cfg.setIsAudit(Constants.AUDIT_NOT_YET); + cfg.setIsValid(Constants.VALID_NO); + //} + cfg.setIsAreaEffective(0); + cfg.setLable("0"); + cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId); + cfg.setAttribute(attribute); + cfg.setClassify(classify); + cfg.setServiceId(serviceDict.getServiceId()); + if(compileIds!=null&&compileIds.size()==_topicDomainCfgs.size()) { + cfg.setCompileId(compileIds.get(ind)); + } + ind++; + } + ipCfgService.saveAndSend(regionDict, serviceDict, specificServiceCfg, _topicDomainCfgs, cfgIndexInfos, appPolicyCfgs,appFeatureIndexs,asnNoMaps,isSend.equals("1")); + cfgIndexInfos.clear(); + _topicDomainCfgs.clear(); + } + } } else if (regionDict.getRegionType().equals(3)) { if(!regionDict.getFunctionId().equals(563)) { List _complexkeywordCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE); @@ -2178,6 +2282,8 @@ public class BaseController { ei.loadInitParams(HttpsRedirectTemplate.class, this.getMsgProp(), regionDict, serviceDict); }else if(regionDict.getFunctionId().equals(209)){// HTTP(s)替换 ei.loadInitParams(HttpsReplaceTemplate.class, this.getMsgProp(), regionDict, serviceDict); + }else if(regionDict.getFunctionId().equals(560)){// 主题网站 + ei.loadInitParams(TopicWebsiteTemplate.class, this.getMsgProp(), regionDict, serviceDict); }else { ei.loadInitParams(StringAllTemplate.class, msgProp, regionDict, serviceDict); } diff --git a/src/main/java/com/nis/web/controller/configuration/ntc/IpController.java b/src/main/java/com/nis/web/controller/configuration/ntc/IpController.java index a6a6a3dab..0d52779db 100644 --- a/src/main/java/com/nis/web/controller/configuration/ntc/IpController.java +++ b/src/main/java/com/nis/web/controller/configuration/ntc/IpController.java @@ -58,6 +58,7 @@ import com.nis.domain.configuration.template.P2pHashStringTemplate; import com.nis.domain.configuration.template.P2pIpTemplate; import com.nis.domain.configuration.template.SnatTemplate; import com.nis.domain.configuration.template.StringAllTemplate; +import com.nis.domain.configuration.template.TopicWebsiteTemplate; import com.nis.exceptions.MaatConvertException; import com.nis.util.Constants; import com.nis.util.DictUtils; @@ -440,6 +441,11 @@ public class IpController extends BaseController{ ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsReplaceTemplate.class, 2); excel.setDataList(this.getMsgProp(),classList,null). write(request,response, fileName).dispose(); + }else if(regionDict.getFunctionId().equals(560)) {// 主题网站 + List classList=new ArrayList(); + ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, TopicWebsiteTemplate.class, 2); + excel.setDataList(this.getMsgProp(),classList,null). + write(request,response, fileName).dispose(); }else{ List classList=new ArrayList(); ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, StringAllTemplate.class, 2); diff --git a/src/main/java/com/nis/web/dao/configuration/AppCfgDao.java b/src/main/java/com/nis/web/dao/configuration/AppCfgDao.java index 3257fa471..f8f525f37 100644 --- a/src/main/java/com/nis/web/dao/configuration/AppCfgDao.java +++ b/src/main/java/com/nis/web/dao/configuration/AppCfgDao.java @@ -70,6 +70,7 @@ public interface AppCfgDao { public List findAppTopicDomainList(AppTopicDomainCfg entity) ; public AppTopicDomainCfg getAppTopicDomainCfg(Long cfgId) ; public int insertAppTopicDomainCfg(AppTopicDomainCfg entity); + public int insertAppTopicDomainCfgBatch(AppTopicDomainCfg entity); public int updateAppTopicDomainCfg(AppTopicDomainCfg entity); //app 字节特征增删改查 public List findAppByteList(AppByteCfg entity) ; diff --git a/src/main/java/com/nis/web/dao/configuration/AppCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/AppCfgDao.xml index e5f448047..638f888ec 100644 --- a/src/main/java/com/nis/web/dao/configuration/AppCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/AppCfgDao.xml @@ -1855,6 +1855,20 @@ #{isHexbin,jdbcType=INTEGER},#{doLog,jdbcType=INTEGER} ) + + insert into app_topic_domain_cfg ( + TOPIC_ID,WEBSITE_SERVICE_ID,SPEC_SERVICE_ID,CFG_DESC,ACTION,IS_VALID,IS_AUDIT, + CREATOR_ID,CREATE_TIME,EDITOR_ID,EDIT_TIME,AUDITOR_ID,AUDIT_TIME, + SERVICE_ID,REQUEST_ID,COMPILE_ID,IS_AREA_EFFECTIVE,CLASSIFY, + ATTRIBUTE,LABLE,AREA_EFFECTIVE_IDS,RATELIMIT,FUNCTION_ID,CFG_TYPE,CFG_REGION_CODE, + DOMAIN,EXPR_TYPE,MATCH_METHOD,IS_HEXBIN,DO_LOG + )values ( + , + #{cfgKeywords,jdbcType=VARCHAR},#{exprType,jdbcType=INTEGER},#{matchMethod,jdbcType=INTEGER}, + #{isHexbin,jdbcType=INTEGER},#{doLog,jdbcType=INTEGER} + ) + + SELECT LAST_INSERT_ID() diff --git a/src/main/java/com/nis/web/service/BaseService.java b/src/main/java/com/nis/web/service/BaseService.java index 5acb8d4a7..e8dd02dde 100644 --- a/src/main/java/com/nis/web/service/BaseService.java +++ b/src/main/java/com/nis/web/service/BaseService.java @@ -54,6 +54,7 @@ import com.nis.domain.configuration.AppFeatureIndex; import com.nis.domain.configuration.AppHttpCfg; import com.nis.domain.configuration.AppIpCfg; import com.nis.domain.configuration.AppPolicyCfg; +import com.nis.domain.configuration.AppTopicDomainCfg; import com.nis.domain.configuration.AreaBean; import com.nis.domain.configuration.AreaIpCfg; import com.nis.domain.configuration.BaseCfg; @@ -1621,6 +1622,8 @@ public abstract class BaseService { type="AsnIpCfg"; }else if(list.get(0) instanceof AppComplexFeatureCfg) { type="AppComplexFeature"; + }else if(list.get(0) instanceof AppTopicDomainCfg) { + type="AppTopicDomain"; } if (cfgIndexInfos != null && cfgIndexInfos.size() > 0) { this.saveCfgIndexOf(cfgIndexInfos); @@ -1645,6 +1648,9 @@ public abstract class BaseService { }else if("AppComplexFeature".equals(type)) {// APP Payload List listPage = (List) list; this.saveAppComplexFeatureBatch(regionDict,serviceDict,listPage,send); + }else if("AppTopicDomain".equals(type)) {// 主题网站 + List listPage = (List) list; + this.saveTopicDomainCfgBatch(listPage); }else if("BaseStringCfg".equals(type)) { List> listPage = (List>) list; // 调用对应配置的service @@ -1924,6 +1930,29 @@ public abstract class BaseService { } + /** + * 导入配置时数据批量入库 + * @param data + */ + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public void saveTopicDomainCfgBatch(List data) { + SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); + SqlSession batchSqlSession = null; + try{ + batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); + for(int index = 0; index < data.size();index++){ + AppTopicDomainCfg cfg = data.get(index); + ((AppCfgDao) batchSqlSession.getMapper(AppCfgDao.class)).insertAppTopicDomainCfgBatch(cfg); + } + batchSqlSession.commit(); + }finally { + if(batchSqlSession != null){ + batchSqlSession.close(); + } + } + + } + /** * APP Payload导入配置时数据批量入库 * @param serviceDict diff --git a/src/main/resources/messages/message_en.properties b/src/main/resources/messages/message_en.properties index 5a10e134f..f82483fe9 100644 --- a/src/main/resources/messages/message_en.properties +++ b/src/main/resources/messages/message_en.properties @@ -1463,4 +1463,5 @@ active_ip_statistics=Active IP Statistics protocol_statistics=Protocol Statistics app_statistics=App Statistics service_statistics=Service Statistics -website_statistics=Website Statistics \ No newline at end of file +website_statistics=Website Statistics +not_exist=not exist \ 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 d75ae52b2..c2bc79c45 100644 --- a/src/main/resources/messages/message_ru.properties +++ b/src/main/resources/messages/message_ru.properties @@ -1467,4 +1467,5 @@ active_ip_statistics= \u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043A\u04 protocol_statistics=\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043A\u0430 \u041F\u0440\u043E\u0442\u043E\u043A\u043E\u043B\u043E\u0432 app_statistics=\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043A\u0430 \u041F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0439 service_statistics=\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043A\u0430 \u0421\u0435\u0440\u0432\u0438\u0441\u043E\u0432 -website_statistics=\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043A\u0430 \u0412\u0435\u0431-\u0441\u0430\u0439\u0442\u043E\u0432 \ No newline at end of file +website_statistics=\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043A\u0430 \u0412\u0435\u0431-\u0441\u0430\u0439\u0442\u043E\u0432 +not_exist=not exist \ 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 6a75188ea..e519c8197 100644 --- a/src/main/resources/messages/message_zh_CN.properties +++ b/src/main/resources/messages/message_zh_CN.properties @@ -1463,4 +1463,5 @@ active_ip_statistics=\u6D3B\u8DC3IP\u7EDF\u8BA1 protocol_statistics=\u534F\u8BAE\u7EDF\u8BA1 app_statistics=App\u7EDF\u8BA1 service_statistics=\u670D\u52A1\u7EDF\u8BA1 -website_statistics=\u7F51\u7AD9\u7EDF\u8BA1 \ No newline at end of file +website_statistics=\u7F51\u7AD9\u7EDF\u8BA1 +not_exist=\u4E0D\u5B58\u5728 \ No newline at end of file diff --git a/src/main/resources/sql/20190109/update_function_dicts.sql b/src/main/resources/sql/20190109/update_function_dicts.sql new file mode 100644 index 000000000..8dbe2b6a2 --- /dev/null +++ b/src/main/resources/sql/20190109/update_function_dicts.sql @@ -0,0 +1,2 @@ +UPDATE function_region_dict SET is_import = 1 WHERE function_id = 560; +UPDATE function_service_dict SET is_import = 1 WHERE function_id = 560; \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/include/excel/importModal.jsp b/src/main/webapp/WEB-INF/include/excel/importModal.jsp index 3a4d947a3..39b6c1f9e 100644 --- a/src/main/webapp/WEB-INF/include/excel/importModal.jsp +++ b/src/main/webapp/WEB-INF/include/excel/importModal.jsp @@ -95,10 +95,12 @@
- + - - + + + + <%@include file="/WEB-INF/include/excel/importModal.jsp" %> \ No newline at end of file