(1)dns欺骗ip模板替换,不和dnsip共用

(2)导入一行格式错误不终止导入,略过该行继续导入
This commit is contained in:
wangxin
2018-12-20 15:53:02 +06:00
parent 87e3a77d7e
commit 81ddac4f9f
9 changed files with 157 additions and 83 deletions

View File

@@ -339,16 +339,30 @@ public class ExportExcel {
}
if("group".equals(headerStr)) {
commentStr="";
//查询ip复用地址池配置的policyGroup列表
List<PolicyGroupInfo> list=policyGroupInfoDao.findPolicyGroupInfosByType(2);
if(!StringUtil.isEmpty(list)){
for (PolicyGroupInfo policyGroupInfo : list) {
commentStr=commentStr+policyGroupInfo.getGroupId()+""+policyGroupInfo.getGroupName()+"\n";
index++;
if(region.getFunctionId()==401) {
//查询dns fake ip policyGroup列表
List<PolicyGroupInfo> list=policyGroupInfoDao.findPolicyGroupInfosByType(1);
if(!StringUtil.isEmpty(list)){
for (PolicyGroupInfo policyGroupInfo : list) {
commentStr=commentStr+policyGroupInfo.getGroupId()+""+policyGroupInfo.getGroupName()+"\n";
index++;
}
}
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
}else {
//查询ip复用地址池配置的policyGroup列表
List<PolicyGroupInfo> list=policyGroupInfoDao.findPolicyGroupInfosByType(2);
if(!StringUtil.isEmpty(list)){
for (PolicyGroupInfo policyGroupInfo : list) {
commentStr=commentStr+policyGroupInfo.getGroupId()+""+policyGroupInfo.getGroupName()+"\n";
index++;
}
}
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
}
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
}
if("isp".equals(headerStr)) {
commentStr="";

View File

@@ -480,7 +480,7 @@ public class ImportBigExcel extends XLSXCovertCSVReader{
}
}
} catch (Exception ex) {
log.info("Get cell value ["+i+","+column+"] error: " + ex.toString());
log.debug("Get cell value ["+i+","+column+"] error: " + ex.toString());
val = null;
}
// set entity value

View File

@@ -42,24 +42,26 @@ public class CheckComplexStringFormatThread implements Callable<String>{
@Override
public String call() throws Exception {
List<Object> dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
String msg=null;
StringBuffer msg=new StringBuffer();
while(!srcQueue.isEmpty()) {
int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE);
if(regionDict.getRegionType().intValue()==3) {
try {
List<ComplexkeywordCfg> cfgs=this.checkComplexStringCfg(dataList);
List<ComplexkeywordCfg> cfgs=this.checkComplexStringCfg(msg,dataList);
destQueue.addAll(cfgs);
}catch (Exception e) {
logger.error("checkComplexStringCfg error,",e);
// TODO: handle exception
msg=e.getMessage();
break;
//msg=e.getMessage();
//msg.append(e.getMessage());
//break;
}
}
dataList.clear();
}
return msg;
return msg.toString();
}
public List<ComplexkeywordCfg> checkComplexStringCfg(
public List<ComplexkeywordCfg> checkComplexStringCfg(StringBuffer msg,
List<?> list) throws ServiceException {
logger.warn("start to validate complexString data...");
long start=System.currentTimeMillis();
@@ -233,9 +235,9 @@ public class CheckComplexStringFormatThread implements Callable<String>{
Integer isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
if (isHex == null || isCaseInsenstive == null) {
if (isHex == null) {
if (hexP.equals("0") || hexP.equals("2")) {
if (hexP.indexOf("0")>-1 || hexP.indexOf("2")>-1) {
baseStringCfg.setIsHex(0);
} else if (hexP.equals("1")) {
} else if (hexP.indexOf("1")>-1) {
baseStringCfg.setIsHex(1);
} else {
errInfo.append(
@@ -243,9 +245,9 @@ public class CheckComplexStringFormatThread implements Callable<String>{
}
}
if (isCaseInsenstive == null) {
if (hexP.equals("0") || hexP.equals("1")) {
if (hexP.indexOf("0")>-1 || hexP.indexOf("1")>-1) {
baseStringCfg.setIsCaseInsenstive(0);
} else if (hexP.equals("2")) {
} else if (hexP.indexOf("2")>-1) {
baseStringCfg.setIsCaseInsenstive(1);
} else {
errInfo.append(String.format(prop.getProperty("can_not_null"),
@@ -299,11 +301,13 @@ public class CheckComplexStringFormatThread implements Callable<String>{
errTip.append(String.format(prop.getProperty("line"), baseStringCfg.getIndex()) + ",");
errTip.append(errInfo);
errTip.append("<br>");
}else {
stringList.add(baseStringCfg);
}
stringList.add(baseStringCfg);
}
if (errTip.toString().length() > 0) {
throw new ServiceException(errTip.toString());
msg.append(errTip);
//throw new ServiceException(errTip.toString());
}
long end=System.currentTimeMillis();
logger.warn("validate complexString data finish,cost:"+(end-start));

View File

@@ -41,24 +41,25 @@ public class CheckDnsResStrategyFormatThread implements Callable<String>{
@Override
public String call() throws Exception {
List<Object> dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
String msg=null;
StringBuffer msg=new StringBuffer();
while(!srcQueue.isEmpty()) {
int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE);
if(regionDict.getRegionType().intValue()==6) {
try {
List<DnsResStrategy> cfgs=this.checkDnsResStrategyCfg(dataList);
List<DnsResStrategy> cfgs=this.checkDnsResStrategyCfg(msg,dataList);
destQueue.addAll(cfgs);
}catch (Exception e) {
logger.error("checkDnsResStrategyCfg error",e);
// TODO: handle exception
msg=e.getMessage();
break;
//msg=e.getMessage();
//break;
}
}
dataList.clear();
}
return msg;
return msg.toString();
}
public List<DnsResStrategy> checkDnsResStrategyCfg(List<?> list)
public List<DnsResStrategy> checkDnsResStrategyCfg(StringBuffer msg,List<?> list)
throws ServiceException {
List<DnsResStrategy> dnsResStrategies=Lists.newArrayList();
StringBuffer errTip = new StringBuffer();
@@ -129,11 +130,14 @@ public class CheckDnsResStrategyFormatThread implements Callable<String>{
errTip.append(String.format(prop.getProperty("line"), dnsResStrategy.getIndex()) + ",");
errTip.append(errInfo);
errTip.append("<br>");
}else {
dnsResStrategies.add(dnsResStrategy);
}
dnsResStrategies.add(dnsResStrategy);
}
if (errTip.toString().length() > 0) {
throw new ServiceException(errTip.toString());
msg.append(errTip);
//throw new ServiceException(errTip.toString());
}
return dnsResStrategies;
}

View File

@@ -18,6 +18,7 @@ import com.beust.jcommander.internal.Lists;
import com.nis.domain.FunctionRegionDict;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.SysDataDictionaryItem;
import com.nis.domain.basics.PolicyGroupInfo;
import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.DnsResStrategy;
import com.nis.domain.configuration.IpPortCfg;
@@ -48,25 +49,26 @@ public class CheckIpFormatThread implements Callable<String>{
@Override
public String call() throws Exception {
List<Object> dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
String msg=null;
StringBuffer msg=new StringBuffer();
while(!srcQueue.isEmpty()) {
int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE);
if(regionDict.getRegionType().intValue()==1) {
try {
List<BaseIpCfg> ipcfgs=this.checkIpCfg(asnNoMaps, dataList);
List<BaseIpCfg> ipcfgs=this.checkIpCfg(msg,asnNoMaps, dataList);
boolean success=destQueue.addAll(ipcfgs);
}catch (Exception e) {
logger.error("checkIpCfg error,",e);
e.printStackTrace();
// TODO: handle exception
msg=e.getMessage();
break;
//msg.append(e.getMessage());
//break;
}
}
dataList.clear();
}
return msg;
return msg.toString();
}
public List<BaseIpCfg> checkIpCfg(List<Map<Long,Integer>> asnNos, List<Object> list)
public List<BaseIpCfg> checkIpCfg(StringBuffer msg,List<Map<Long,Integer>> asnNos, List<Object> list)
throws ServiceException {
logger.warn("start to validate ip...");
long start=System.currentTimeMillis();
@@ -188,10 +190,10 @@ public class CheckIpFormatThread implements Callable<String>{
Integer dnsStrategyId = baseIpCfg.getDnsStrategyId();
if (dnsStrategyId != null) {
if(dnsStrategyId>0) {
List<DnsResStrategy> dnsStrategys = DictUtils.getDnsResStrategyList(Long.valueOf(dnsStrategyId));
if (dnsStrategys == null || dnsStrategys.size() == 0) {
PolicyGroupInfo dnsStrategy = DictUtils.getDnsGroups(dnsStrategyId);
if (dnsStrategy == null ) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("dns_res_strategy"))
String.format(prop.getProperty("is_incorrect"), prop.getProperty("group"))
+ ";");
}
}
@@ -649,11 +651,13 @@ public class CheckIpFormatThread implements Callable<String>{
errTip.append(String.format(prop.getProperty("line"), baseIpCfg.getIndex()) + ",");
errTip.append(errInfo);
errTip.append("<br>");
}else {
ipList.add(baseIpCfg);
}
ipList.add(baseIpCfg);
}
if (errTip.toString().length() > 0) {
throw new ServiceException(errTip.toString());
msg.append(errTip);
//throw new ServiceException(errTip.toString());
}
long end=System.currentTimeMillis();
logger.warn("validate ip finish,cost:"+(end-start));

View File

@@ -42,25 +42,26 @@ public class CheckStringFormatThread implements Callable<String>{
@Override
public String call() throws Exception {
List<Object> dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
String msg=null;
StringBuffer msg=new StringBuffer();
while(!srcQueue.isEmpty()) {
int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE);
if(regionDict.getRegionType().intValue()==2) {
try {
List<BaseStringCfg<?>> cfgs=this.checkStringCfg(dataList);
List<BaseStringCfg<?>> cfgs=this.checkStringCfg(msg,dataList);
destQueue.addAll(cfgs);
}catch (Exception e) {
logger.error("checkStringCfg error",e);
// TODO: handle exception
msg=e.getMessage();
break;
//msg=e.getMessage();
//break;
}
}
dataList.clear();
}
return msg;
return msg.toString();
}
public List<BaseStringCfg<?>> checkStringCfg(List<?> list) throws ServiceException {
public List<BaseStringCfg<?>> checkStringCfg(StringBuffer msg,List<?> list) throws ServiceException {
logger.warn("start to validate stringCfg data...");
long start=System.currentTimeMillis();
List<BaseStringCfg<?>> stringList = new ArrayList<BaseStringCfg<?>>();
@@ -276,9 +277,9 @@ public class CheckStringFormatThread implements Callable<String>{
Integer isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
if (isHex == null || isCaseInsenstive == null) {
if (isHex == null) {
if (hexP.equals("0") || hexP.equals("2")) {
if (hexP.indexOf("0")>-1 || hexP.indexOf("2")>-1) {
baseStringCfg.setIsHex(0);
} else if (hexP.equals("1")) {
} else if (hexP.indexOf("1")>-1) {
baseStringCfg.setIsHex(1);
} else {
errInfo.append(
@@ -286,9 +287,9 @@ public class CheckStringFormatThread implements Callable<String>{
}
}
if (isCaseInsenstive == null) {
if (hexP.equals("0") || hexP.equals("1")) {
if (hexP.indexOf("0")>-1 || hexP.indexOf("1")>-1) {
baseStringCfg.setIsCaseInsenstive(0);
} else if (hexP.equals("2")) {
} else if (hexP.indexOf("2")>-1) {
baseStringCfg.setIsCaseInsenstive(1);
} else {
errInfo.append(String.format(prop.getProperty("can_not_null"),
@@ -343,11 +344,14 @@ public class CheckStringFormatThread implements Callable<String>{
errTip.append(String.format(prop.getProperty("line"), baseStringCfg.getIndex()) + ",");
errTip.append(errInfo);
errTip.append("<br>");
}else {
stringList.add(baseStringCfg);
}
stringList.add(baseStringCfg);
}
if (errTip.toString().length() > 0) {
throw new ServiceException(errTip.toString());
msg.append(errTip);
//throw new ServiceException(errTip.toString());
}
long end=System.currentTimeMillis();
logger.warn("validate stringCfg data finish,cost:"+(end-start));