主题网站增加配置导入.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -448,6 +448,41 @@ public class ExportExcel {
|
||||
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
|
||||
index++;
|
||||
}
|
||||
/*** 主题网站 ***/
|
||||
if(("topic".equals(headerStr)) && (region.getFunctionId().equals(560))){
|
||||
commentStr="";
|
||||
List<SysDataDictionaryItem> 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信息
|
||||
|
||||
@@ -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<String>{
|
||||
private Logger logger=Logger.getLogger(CheckTopicWebsiteFormatThread.class);
|
||||
private BlockingQueue<? extends Object> srcQueue;
|
||||
private BlockingQueue<AppTopicDomainCfg> destQueue;
|
||||
private Properties prop;
|
||||
private FunctionServiceDict serviceDict;
|
||||
private FunctionRegionDict regionDict;
|
||||
|
||||
public CheckTopicWebsiteFormatThread(FunctionServiceDict serviceDict,FunctionRegionDict regionDict,Properties prop,BlockingQueue<? extends Object> srcQueue,BlockingQueue<AppTopicDomainCfg> destQueue) {
|
||||
this.serviceDict=serviceDict;
|
||||
this.regionDict=regionDict;
|
||||
this.srcQueue=srcQueue;
|
||||
this.destQueue=destQueue;
|
||||
this.prop=prop;
|
||||
|
||||
}
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
List<Object> 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<AppTopicDomainCfg> 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<AppTopicDomainCfg> checkTopicWebsiteCfg(StringBuffer msg,List<?> list) throws ServiceException {
|
||||
logger.warn("start to validate topicDomainCfg data...");
|
||||
long start=System.currentTimeMillis();
|
||||
List<AppTopicDomainCfg> stringList = new ArrayList<AppTopicDomainCfg>();
|
||||
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("<br>");
|
||||
}else {
|
||||
// 保存到域名关联表中
|
||||
AppCfgService appCfgService = SpringContextHolder.getBean(AppCfgService.class);
|
||||
WebsiteDomainTopic websiteDomainTopic = new WebsiteDomainTopic();
|
||||
websiteDomainTopic.setDomain(baseStringCfg.getCfgKeywords());
|
||||
|
||||
List<WebsiteDomainTopic> 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;
|
||||
}
|
||||
}
|
||||
@@ -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<AppTopicDomainCfg> checkTopicWebsiteCfgMulity(StringBuffer _msg,FunctionServiceDict serviceDict, FunctionRegionDict regionDict, BlockingQueue<? extends Object> list) throws InterruptedException, ExecutionException, ServiceException{
|
||||
logger.warn("start checkTopicWebsiteCfgMulity ,size "+list.size());
|
||||
long start=System.currentTimeMillis();
|
||||
BlockingQueue<AppTopicDomainCfg> queue=new ArrayBlockingQueue<>(list.size());
|
||||
ExecutorService service=Executors.newFixedThreadPool(Constants.MULITY_THREAD_SIZE);
|
||||
List<Future<String>> futures=new ArrayList<>();
|
||||
for(int i=0;i<Constants.MULITY_THREAD_SIZE;i++) {
|
||||
CheckTopicWebsiteFormatThread t=new CheckTopicWebsiteFormatThread(serviceDict,regionDict, this.getMsgProp(), list, queue);
|
||||
futures.add(service.submit(t));
|
||||
|
||||
}
|
||||
service.shutdown();
|
||||
while(!service.isTerminated()) {
|
||||
try {
|
||||
Thread.sleep(10);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
for(Future<String> 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<ComplexkeywordCfg> complexkeywordCfgs =null;
|
||||
BlockingQueue<DnsResStrategy> dnsResStrategies=null;
|
||||
BlockingQueue<AppComplexFeatureCfg> appComplexFeatureCfgs=null;
|
||||
BlockingQueue<AppTopicDomainCfg> appTopicDomainCfgs=null;// 主题网站
|
||||
List<CfgIndexInfo> cfgIndexInfos = new ArrayList<CfgIndexInfo>();
|
||||
List<AppPolicyCfg> appPolicyCfgs = new ArrayList<AppPolicyCfg>();
|
||||
List<AppFeatureIndex> appFeatureIndexs= new ArrayList<AppFeatureIndex>();
|
||||
@@ -1402,6 +1447,9 @@ public class BaseController {
|
||||
}else if(regionDict.getFunctionId().equals(209)){// HTTP(s)替换
|
||||
BlockingQueue<HttpsReplaceTemplate> list = ei.getDataList(HttpsReplaceTemplate.class);
|
||||
stringCfgs=this.checkStringCfgMulity(errTip,serviceDict, regionDict, list);
|
||||
}else if(regionDict.getFunctionId().equals(560)){// 主题网站
|
||||
BlockingQueue<TopicWebsiteTemplate> list = ei.getDataList(TopicWebsiteTemplate.class);
|
||||
appTopicDomainCfgs=this.checkTopicWebsiteCfgMulity(errTip,serviceDict, regionDict, list);
|
||||
}else {
|
||||
BlockingQueue<StringAllTemplate> 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<BaseStringCfg> _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<AppTopicDomainCfg> _topicDomainCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||
while(!appTopicDomainCfgs.isEmpty()) {
|
||||
appTopicDomainCfgs.drainTo(_topicDomainCfgs, Constants.MAAT_JSON_SEND_SIZE);
|
||||
List<Integer> compileIds=Lists.newArrayList();
|
||||
List<Integer> groupIds=Lists.newArrayList();
|
||||
List<Integer> 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("<spring:message code=\"request_service_failed\"/>:"+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<ComplexkeywordCfg> _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);
|
||||
}
|
||||
|
||||
@@ -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<TopicWebsiteTemplate> classList=new ArrayList<TopicWebsiteTemplate>();
|
||||
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<StringAllTemplate> classList=new ArrayList<StringAllTemplate>();
|
||||
ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, StringAllTemplate.class, 2);
|
||||
|
||||
@@ -70,6 +70,7 @@ public interface AppCfgDao {
|
||||
public List<AppTopicDomainCfg> 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<AppByteCfg> findAppByteList(AppByteCfg entity) ;
|
||||
|
||||
@@ -1855,6 +1855,20 @@
|
||||
#{isHexbin,jdbcType=INTEGER},#{doLog,jdbcType=INTEGER}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertAppTopicDomainCfgBatch" parameterType="com.nis.domain.configuration.AppTopicDomainCfg" >
|
||||
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 (
|
||||
<include refid="AppTopicCommonCfg_Value_List" />,
|
||||
#{cfgKeywords,jdbcType=VARCHAR},#{exprType,jdbcType=INTEGER},#{matchMethod,jdbcType=INTEGER},
|
||||
#{isHexbin,jdbcType=INTEGER},#{doLog,jdbcType=INTEGER}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertAppByteCfg" parameterType="com.nis.domain.configuration.AppByteCfg" >
|
||||
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
|
||||
SELECT LAST_INSERT_ID()
|
||||
|
||||
@@ -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<AppComplexFeatureCfg> listPage = (List<AppComplexFeatureCfg>) list;
|
||||
this.saveAppComplexFeatureBatch(regionDict,serviceDict,listPage,send);
|
||||
}else if("AppTopicDomain".equals(type)) {// 主题网站
|
||||
List<AppTopicDomainCfg> listPage = (List<AppTopicDomainCfg>) list;
|
||||
this.saveTopicDomainCfgBatch(listPage);
|
||||
}else if("BaseStringCfg".equals(type)) {
|
||||
List<BaseStringCfg<?>> listPage = (List<BaseStringCfg<?>>) list;
|
||||
// 调用对应配置的service
|
||||
@@ -1924,6 +1930,29 @@ public abstract class BaseService {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入配置时数据批量入库
|
||||
* @param data
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveTopicDomainCfgBatch(List<AppTopicDomainCfg> 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
|
||||
|
||||
@@ -1464,3 +1464,4 @@ protocol_statistics=Protocol Statistics
|
||||
app_statistics=App Statistics
|
||||
service_statistics=Service Statistics
|
||||
website_statistics=Website Statistics
|
||||
not_exist=not exist
|
||||
@@ -1468,3 +1468,4 @@ protocol_statistics=\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043A\u0430
|
||||
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
|
||||
not_exist=not exist
|
||||
@@ -1464,3 +1464,4 @@ protocol_statistics=\u534F\u8BAE\u7EDF\u8BA1
|
||||
app_statistics=App\u7EDF\u8BA1
|
||||
service_statistics=\u670D\u52A1\u7EDF\u8BA1
|
||||
website_statistics=\u7F51\u7AD9\u7EDF\u8BA1
|
||||
not_exist=\u4E0D\u5B58\u5728
|
||||
@@ -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;
|
||||
@@ -95,10 +95,12 @@
|
||||
<div for="action"></div>
|
||||
</div>
|
||||
<!-- 600 asn ip、 3:IP白名单、 405:APP协议IP、 403:APP域名特征、 563 APP Payload、 565 APP HTTP、 564 APP DNS、 566 APP SSL -->
|
||||
<c:if test="${(cfg.functionId eq 600) || (cfg.functionId eq 3) || (cfg.functionId eq 405) || (cfg.functionId eq 403) || (cfg.functionId eq 563) || (cfg.functionId eq 565) || (cfg.functionId eq 564) || (cfg.functionId eq 566) }">
|
||||
<c:if test="${(cfg.functionId eq 600) || (cfg.functionId eq 3) || (cfg.functionId eq 405) || (cfg.functionId eq 403) || (cfg.functionId eq 563) || (cfg.functionId eq 565) || (cfg.functionId eq 564) || (cfg.functionId eq 566) ||
|
||||
(cfg.functionId eq 560) }">
|
||||
<div class="row hidden requestIdSel">
|
||||
</c:if>
|
||||
<c:if test="${(cfg.functionId ne 600) && (cfg.functionId ne 3) && (cfg.functionId ne 405) && (cfg.functionId ne 403) && (cfg.functionId ne 563) && (cfg.functionId ne 565) && (cfg.functionId ne 564) && (cfg.functionId ne 566)}">
|
||||
<c:if test="${(cfg.functionId ne 600) && (cfg.functionId ne 3) && (cfg.functionId ne 405) && (cfg.functionId ne 403) && (cfg.functionId ne 563) && (cfg.functionId ne 565) && (cfg.functionId ne 564) && (cfg.functionId ne 566) &&
|
||||
(cfg.functionId ne 560) }">
|
||||
<div class="row requestIdSel">
|
||||
</c:if>
|
||||
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="letter"/></label>
|
||||
|
||||
@@ -57,6 +57,24 @@
|
||||
onClick="javascript:window.location='${ctx}/app/topicDomainCfgForm?functionId=${cfg.functionId}'">
|
||||
<i class="fa fa-plus"></i>
|
||||
<spring:message code="add"></spring:message></button>
|
||||
|
||||
<c:set var="serviceImport" value="false"></c:set>
|
||||
<c:set var="regionImport" value="false"></c:set>
|
||||
<c:forEach items="${serviceList}" var="service" >
|
||||
<c:if test="${(cfg.functionId eq service.functionId) && service.isImport eq 1}">
|
||||
<c:set var="serviceImport" value="true"></c:set>
|
||||
</c:if>
|
||||
</c:forEach>
|
||||
<c:forEach items="${regionList}" var="region" >
|
||||
<c:if test="${(cfg.functionId eq region.functionId) && region.isImport eq 1}">
|
||||
<c:set var="regionImport" value="true"></c:set>
|
||||
</c:if>
|
||||
</c:forEach>
|
||||
<c:if test="${serviceImport eq 'true' && regionImport eq 'true'}">
|
||||
<button type="button" class="btn btn-primary import" >
|
||||
<i class="fa fa-plus"></i>
|
||||
<spring:message code="import"></spring:message></button>
|
||||
</c:if>
|
||||
</shiro:hasPermission>
|
||||
</div>
|
||||
|
||||
@@ -477,6 +495,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<c:set var="importPath" value="/app/topicDomainCfgList?functionId=${cfg.functionId}"/>
|
||||
<!-- 模板导入,start -->
|
||||
<%@include file="/WEB-INF/include/excel/importModal.jsp" %>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user