导入去掉组织、国家、详情非空校验,为空取ASN
This commit is contained in:
@@ -29,6 +29,7 @@ import com.nis.domain.specific.ConfigGroupInfo;
|
|||||||
//import com.nis.util.AsnCacheUtils;
|
//import com.nis.util.AsnCacheUtils;
|
||||||
import com.nis.util.Constants;
|
import com.nis.util.Constants;
|
||||||
import com.nis.util.DictUtils;
|
import com.nis.util.DictUtils;
|
||||||
|
import com.nis.util.StringUtil;
|
||||||
|
|
||||||
public class CheckIpFormatThread implements Callable<String>{
|
public class CheckIpFormatThread implements Callable<String>{
|
||||||
private Logger logger=Logger.getLogger(CheckIpFormatThread.class);
|
private Logger logger=Logger.getLogger(CheckIpFormatThread.class);
|
||||||
@@ -269,11 +270,7 @@ public class CheckIpFormatThread implements Callable<String>{
|
|||||||
if (regionDict.getFunctionId().equals(600)) {//asn
|
if (regionDict.getFunctionId().equals(600)) {//asn
|
||||||
//组织的非空和长度校验
|
//组织的非空和长度校验
|
||||||
String organization=baseIpCfg.getOrganization();
|
String organization=baseIpCfg.getOrganization();
|
||||||
if(StringUtils.isBlank(organization)) {
|
if(!StringUtils.isBlank(organization)) {
|
||||||
errInfo.append(
|
|
||||||
String.format(prop.getProperty("can_not_null"), prop.getProperty("organization","Organization"))
|
|
||||||
+ ";");
|
|
||||||
}else {
|
|
||||||
if(organization.length() > 1024){
|
if(organization.length() > 1024){
|
||||||
errInfo.append(prop.getProperty("asn_name")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("max_length")+":1024") + ";");
|
errInfo.append(prop.getProperty("asn_name")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("max_length")+":1024") + ";");
|
||||||
}else {
|
}else {
|
||||||
@@ -282,7 +279,6 @@ public class CheckIpFormatThread implements Callable<String>{
|
|||||||
}
|
}
|
||||||
baseIpCfg.setOrganization(organization.trim().toUpperCase());
|
baseIpCfg.setOrganization(organization.trim().toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//国家的非空和长度校验
|
//国家的非空和长度校验
|
||||||
String country=baseIpCfg.getCountry();
|
String country=baseIpCfg.getCountry();
|
||||||
@@ -293,18 +289,14 @@ public class CheckIpFormatThread implements Callable<String>{
|
|||||||
baseIpCfg.setCountry(country.trim().toUpperCase());
|
baseIpCfg.setCountry(country.trim().toUpperCase());
|
||||||
}
|
}
|
||||||
//详情可以为空
|
//详情可以为空
|
||||||
/*String detail=baseIpCfg.getDetail();
|
String detail=baseIpCfg.getDetail();
|
||||||
if(StringUtils.isBlank(detail)) {
|
if(!StringUtils.isBlank(detail)) {
|
||||||
errInfo.append(
|
|
||||||
String.format(prop.getProperty("can_not_null"), prop.getProperty("detail"))
|
|
||||||
+ ";");
|
|
||||||
}else {
|
|
||||||
if(detail.length() > 1024||detail.length()<4){
|
if(detail.length() > 1024||detail.length()<4){
|
||||||
errInfo.append(prop.getProperty("details")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("min_length")+":4,"+prop.getProperty("max_length")+":1024") + ";");
|
errInfo.append(prop.getProperty("details")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("min_length")+":4,"+prop.getProperty("max_length")+":1024") + ";");
|
||||||
}else {
|
}else {
|
||||||
baseIpCfg.setDetail(detail.trim());
|
baseIpCfg.setDetail(detail.trim());
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
//asn id 校验
|
//asn id 校验
|
||||||
String userRegion1 = baseIpCfg.getUserRegion1();
|
String userRegion1 = baseIpCfg.getUserRegion1();
|
||||||
if(StringUtils.isBlank(userRegion1)) {
|
if(StringUtils.isBlank(userRegion1)) {
|
||||||
@@ -319,21 +311,25 @@ public class CheckIpFormatThread implements Callable<String>{
|
|||||||
String.format(prop.getProperty("must_between"),"1","4294967295" )
|
String.format(prop.getProperty("must_between"),"1","4294967295" )
|
||||||
+ ";");
|
+ ";");
|
||||||
}else {
|
}else {
|
||||||
|
if(StringUtil.isEmpty(baseIpCfg.getOrganization())){
|
||||||
|
baseIpCfg.setOrganization(asnNo.toString());
|
||||||
|
baseIpCfg.setCfgDesc(asnNo.toString());
|
||||||
|
}
|
||||||
if(asnNos!=null) {
|
if(asnNos!=null) {
|
||||||
//数据库中是否已经存在
|
//数据库中是否已经存在
|
||||||
AsnGroupInfo asnGroupInfo=asnNos.get(1)==null?null:asnNos.get(1).get(asnNo);
|
AsnGroupInfo asnGroupInfo=asnNos.get(1)==null?null:asnNos.get(1).get(asnNo);
|
||||||
if(asnGroupInfo==null) {
|
if(asnGroupInfo==null) {
|
||||||
synchronized (Constants.IMPORT_LOCK) {
|
synchronized (Constants.IMPORT_LOCK) {
|
||||||
if(StringUtils.isNotBlank(baseIpCfg.getOrganization())&&StringUtils.isNotBlank(baseIpCfg.getCountry())) {
|
if(StringUtils.isNotBlank(baseIpCfg.getOrganization())) {
|
||||||
AsnGroupInfo groupInfo=new AsnGroupInfo();
|
AsnGroupInfo groupInfo=new AsnGroupInfo();
|
||||||
groupInfo.setOrganization(baseIpCfg.getOrganization().trim().toUpperCase());
|
groupInfo.setOrganization(baseIpCfg.getOrganization().trim().toUpperCase());
|
||||||
groupInfo.setCountry(baseIpCfg.getCountry());
|
groupInfo.setCountry(StringUtil.isEmpty(baseIpCfg.getCountry()) ? "":baseIpCfg.getCountry().trim().toUpperCase());
|
||||||
groupInfo.setDetail(baseIpCfg.getDetail().trim());
|
groupInfo.setDetail(StringUtil.isEmpty(baseIpCfg.getDetail()) ? "":baseIpCfg.getDetail().trim().toUpperCase());
|
||||||
groupInfo.setIsUsed(0);
|
groupInfo.setIsUsed(0);
|
||||||
groupInfo.setIsValid(0);
|
groupInfo.setIsValid(0);
|
||||||
groupInfo.setAsnId(asnNo);
|
groupInfo.setAsnId(asnNo);
|
||||||
if(asnNos.get(2).containsKey(asnNo)) {
|
if(asnNos.get(2).containsKey(asnNo)) {
|
||||||
if(!asnNos.get(2).get(asnNo).getOrganization().equals(baseIpCfg.getOrganization().trim().toUpperCase())) {
|
if(!asnNos.get(2).get(asnNo).getOrganization().equalsIgnoreCase(baseIpCfg.getOrganization().trim())) {
|
||||||
//一个asn号不能被两个组织拥有
|
//一个asn号不能被两个组织拥有
|
||||||
logger.error("ASN "+asnNo+" Found two Organization "+asnNos.get(2).get(asnNo).getOrganization()+" "+baseIpCfg.getOrganization().trim().toUpperCase());
|
logger.error("ASN "+asnNo+" Found two Organization "+asnNos.get(2).get(asnNo).getOrganization()+" "+baseIpCfg.getOrganization().trim().toUpperCase());
|
||||||
errInfo.append(asnNos.get(2).get(asnNo).getOrganization()+" "+baseIpCfg.getOrganization().trim().toUpperCase()+" "+prop.getProperty("asn_no")+" "+asnNo+" "+prop.getProperty("repeat")
|
errInfo.append(asnNos.get(2).get(asnNo).getOrganization()+" "+baseIpCfg.getOrganization().trim().toUpperCase()+" "+prop.getProperty("asn_no")+" "+asnNo+" "+prop.getProperty("repeat")
|
||||||
@@ -357,14 +353,6 @@ public class CheckIpFormatThread implements Callable<String>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}else {
|
|
||||||
if(StringUtils.isNotBlank(baseIpCfg.getOrganization())) {
|
|
||||||
logger.error("ASN "+asnNo+" Organization is Null");
|
|
||||||
}
|
|
||||||
/*if(StringUtils.isNotBlank(baseIpCfg.getCountry())) {
|
|
||||||
logger.error("ASN "+asnNo+" Country is Null");
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -372,12 +360,7 @@ public class CheckIpFormatThread implements Callable<String>{
|
|||||||
if(!asnGroupInfo.getOrganization().equalsIgnoreCase(baseIpCfg.getOrganization().trim())) {
|
if(!asnGroupInfo.getOrganization().equalsIgnoreCase(baseIpCfg.getOrganization().trim())) {
|
||||||
errInfo.append(prop.getProperty("organization","Organization")+" "+prop.getProperty("mismatch","Mismatch"));
|
errInfo.append(prop.getProperty("organization","Organization")+" "+prop.getProperty("mismatch","Mismatch"));
|
||||||
}
|
}
|
||||||
/*if(!asnGroupInfo.getCountry().equalsIgnoreCase(baseIpCfg.getCountry().trim())) {
|
|
||||||
errInfo.append(prop.getProperty("country","Country")+" "+prop.getProperty("mismatch","Mismatch"));
|
|
||||||
}
|
|
||||||
if(!asnGroupInfo.getDetail().equalsIgnoreCase(baseIpCfg.getDetail().trim())) {
|
|
||||||
errInfo.append(prop.getProperty("detail","Detail")+" "+prop.getProperty("mismatch","Mismatch"));
|
|
||||||
}*/
|
|
||||||
if(StringUtils.isBlank(errInfo.toString())) {
|
if(StringUtils.isBlank(errInfo.toString())) {
|
||||||
//已下发过的asn no
|
//已下发过的asn no
|
||||||
if(asnGroupInfo.getIsValid() ==1){
|
if(asnGroupInfo.getIsValid() ==1){
|
||||||
@@ -386,6 +369,9 @@ public class CheckIpFormatThread implements Callable<String>{
|
|||||||
asnNos.get(1).put(asnNo,asnGroupInfo);
|
asnNos.get(1).put(asnNo,asnGroupInfo);
|
||||||
asnGroupInfo.setIsValid(0);
|
asnGroupInfo.setIsValid(0);
|
||||||
asnGroupInfo.setIssuedIPs(0l);
|
asnGroupInfo.setIssuedIPs(0l);
|
||||||
|
asnGroupInfo.setOrganization(organization);
|
||||||
|
asnGroupInfo.setCountry(baseIpCfg.getCountry());
|
||||||
|
asnGroupInfo.setDetail(baseIpCfg.getDetail());
|
||||||
asnNos.get(2).put(asnNo,asnGroupInfo);
|
asnNos.get(2).put(asnNo,asnGroupInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user