(1)ip导入调整,子类的同名字段覆盖父类的,用于某些字段的注解重写
(2)新建package template,将IP的template入 (3)IP复用策略配置导入模板调整,由于界面只有IP,端口,所以模板的注解进行了响应调整 (4)配置文件加入了IP和端口的默认值设置 (5)导入IP加入了IP复用策略和限速比例的验证
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
*@date 2018年2月5日 下午5:26:02
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.domain.configuration;
|
||||
package com.nis.domain.configuration.template;
|
||||
|
||||
import com.nis.util.excel.ExcelField;
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.nis.domain.configuration.template;
|
||||
|
||||
import com.nis.util.excel.ExcelField;
|
||||
/**
|
||||
* wx 将部分字段的标题改变,或者不需要的字段隐藏
|
||||
* 隐藏方法,对于不需要的字段或者方法,Override该字段方法,但是@ExcelField注解不需要加上了
|
||||
* @author dell
|
||||
*
|
||||
*/
|
||||
public class IpMultiplexPolicyTemplate extends IpCfgTemplate {
|
||||
@Override
|
||||
@ExcelField(title="IP",align=2,sort=3)
|
||||
public String getSrcIpAddress() {
|
||||
return super.getSrcIpAddress();
|
||||
}
|
||||
@ExcelField(title="port",align=2,sort=6)
|
||||
@Override
|
||||
public String getSrcPort() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getSrcPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ExcelField(title="group_name",align=2,sort=75)
|
||||
public Integer getDnsStrategyId() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getDnsStrategyId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getRatelimit() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getRatelimit();
|
||||
}
|
||||
@Override
|
||||
public String getDestPort() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getDestPort();
|
||||
}
|
||||
@Override
|
||||
public String getDestIpAddress() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getDestIpAddress();
|
||||
}
|
||||
|
||||
public String getUserRegion1() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getUserRegion1();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserRegion2() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getUserRegion2();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserRegion3() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getUserRegion3();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserRegion4() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getUserRegion4();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserRegion5() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getUserRegion5();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,21 @@ import com.google.gson.GsonBuilder;
|
||||
|
||||
public final class Constants {
|
||||
/**
|
||||
*
|
||||
* iP默认值
|
||||
*/
|
||||
public static String IPV4_DEFAULT_IP_VALUE=Configurations.getStringProperty("ipv4_default_ip_value", "0.0.0.0");
|
||||
public static String IPV6_DEFAULT_IP_VALUE=Configurations.getStringProperty("ipv4_default_ip_value", "::");
|
||||
public static String IPV4_DEFAULT_IP_SUBNET_VALUE=Configurations.getStringProperty("ipv4_default_ip_subnet_value", "0.0.0.0/32");
|
||||
public static String IPV6_DEFAULT_IP_SUBNET_VALUE=Configurations.getStringProperty("ipv6_default_ip_subnet_value", "::/64");
|
||||
public static String IPV4_DEFAULT_IP_RANGE_VALUE=Configurations.getStringProperty("ipv4_default_ip_range_value", "0.0.0.0-0.0.0.0");
|
||||
public static String IPV6_DEFAULT_IP_RANGE_VALUE=Configurations.getStringProperty("ipv6_default_ip_range_value", "::-::");
|
||||
/**
|
||||
* port默认值
|
||||
*/
|
||||
public static String PORT_DEFAULT=Configurations.getStringProperty("port_default", "0");
|
||||
public static String PORT_MASK_DEFAULT=Configurations.getStringProperty("port_mask_default", "0/65535");
|
||||
/**
|
||||
*特定服务类型
|
||||
*/
|
||||
public static String SPECIFIC_SERVICE_CFG_TYPE_APP=Configurations.getStringProperty("specific_service_cfg_type_app", "social_app");
|
||||
public static String SPECIFIC_SERVICE_CFG_TYPE_ENCRYPTED_TUNNEL_BEHAVIOR=Configurations.getStringProperty("specific_service_cfg_type_encrypted_tunnel_behavior", "encrypted_tunnel_behavior");
|
||||
|
||||
@@ -22,7 +22,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.derby.tools.sysinfo;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.ss.usermodel.Comment;
|
||||
@@ -45,7 +44,6 @@ import com.nis.util.DictUtils;
|
||||
import com.nis.util.Encodes;
|
||||
import com.nis.util.Reflections;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.excel.fieldtype.RoleListType;
|
||||
|
||||
/**
|
||||
* 导出Excel文件(导出“XLSX”格式,支持大数据量导出 @see org.apache.poi.ss.SpreadsheetVersion)
|
||||
@@ -83,15 +81,31 @@ public class ExportExcel {
|
||||
|
||||
/**
|
||||
* //递归获取cls实体对象及父级对象的属性
|
||||
* wx:修改,子类覆盖父类的同名方法
|
||||
* @param list
|
||||
* @param cls
|
||||
*/
|
||||
public void getFields(List<Field> list,Class<?> cls) {
|
||||
Field[] fields=cls.getDeclaredFields();
|
||||
if(fields != null && fields.length > 0){
|
||||
List<Field> tempList=new ArrayList<>();
|
||||
for (Field field : fields) {
|
||||
list.add(field);
|
||||
if(list.size()==0) {
|
||||
tempList.add(field);
|
||||
}else {
|
||||
boolean has=false;
|
||||
for(Field checkF:list) {
|
||||
if(checkF.getName().equals(field.getName())) {
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has) {
|
||||
tempList.add(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
list.addAll(tempList);
|
||||
}
|
||||
if(cls.getSuperclass() != null){
|
||||
getFields(list,cls.getSuperclass());
|
||||
@@ -105,9 +119,24 @@ public class ExportExcel {
|
||||
public void getMethods(List<Method> list,Class<?> cls) {
|
||||
Method[] methods=cls.getDeclaredMethods();
|
||||
if(methods != null && methods.length > 0){
|
||||
List<Method> tempList=new ArrayList<>();
|
||||
for (Method method : methods) {
|
||||
list.add(method);
|
||||
if(list.size()==0) {
|
||||
tempList.add(method);
|
||||
}else {
|
||||
boolean has=false;
|
||||
for(Method checkM:list) {
|
||||
if(checkM.getName().equals(method.getName())) {
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has) {
|
||||
tempList.add(method);
|
||||
}
|
||||
}
|
||||
}
|
||||
list.addAll(tempList);
|
||||
}
|
||||
if(cls.getSuperclass() != null){
|
||||
getMethods(list,cls.getSuperclass());
|
||||
@@ -254,6 +283,9 @@ public class ExportExcel {
|
||||
if(!StringUtil.isEmpty(ms)){
|
||||
for (Method m : ms){
|
||||
ExcelField ef = m.getAnnotation(ExcelField.class);
|
||||
if(m.getName().equals("getSrcIpAddress")) {
|
||||
System.out.println(ef.title());
|
||||
}
|
||||
if (ef != null && (ef.type()==0 || ef.type()==type)){
|
||||
if (groups!=null && groups.length>0){
|
||||
boolean inGroup = false;
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
@@ -211,7 +212,69 @@ public class ImportExcel {
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* //递归获取cls实体对象及父级对象的属性
|
||||
* wx:修改,子类覆盖父类的同名方法
|
||||
* @param list
|
||||
* @param cls
|
||||
*/
|
||||
public void getFields(List<Field> list,Class<?> cls) {
|
||||
Field[] fields=cls.getDeclaredFields();
|
||||
if(fields != null && fields.length > 0){
|
||||
List<Field> tempList=new ArrayList<>();
|
||||
for (Field field : fields) {
|
||||
if(list.size()==0) {
|
||||
tempList.add(field);
|
||||
}else {
|
||||
boolean has=false;
|
||||
for(Field checkF:list) {
|
||||
if(checkF.getName().equals(field.getName())) {
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has) {
|
||||
tempList.add(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
list.addAll(tempList);
|
||||
}
|
||||
if(cls.getSuperclass() != null){
|
||||
getFields(list,cls.getSuperclass());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* //递归获取cls实体对象及父级对象的method
|
||||
* @param list
|
||||
* @param cls
|
||||
*/
|
||||
public void getMethods(List<Method> list,Class<?> cls) {
|
||||
Method[] methods=cls.getDeclaredMethods();
|
||||
if(methods != null && methods.length > 0){
|
||||
List<Method> tempList=new ArrayList<>();
|
||||
for (Method method : methods) {
|
||||
if(list.size()==0) {
|
||||
tempList.add(method);
|
||||
}else {
|
||||
boolean has=false;
|
||||
for(Method checkM:list) {
|
||||
if(checkM.getName().equals(method.getName())) {
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has) {
|
||||
tempList.add(method);
|
||||
}
|
||||
}
|
||||
}
|
||||
list.addAll(tempList);
|
||||
}
|
||||
if(cls.getSuperclass() != null){
|
||||
getMethods(list,cls.getSuperclass());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取导入数据列表
|
||||
* @param cls 导入对象类型
|
||||
@@ -220,7 +283,11 @@ public class ImportExcel {
|
||||
public <E> List<E> getDataList(Class<E> cls, int... groups) throws InstantiationException, IllegalAccessException{
|
||||
List<Object[]> annotationList = Lists.newArrayList();
|
||||
// Get annotation field
|
||||
Field[] fs = cls.getDeclaredFields();
|
||||
// Field[] fs = cls.getDeclaredFields();
|
||||
List<Field> fs=new ArrayList<Field>();
|
||||
// Get annotation field
|
||||
//递归获取cls实体对象及父级对象的属性
|
||||
getFields(fs, cls);
|
||||
for (Field f : fs){
|
||||
ExcelField ef = f.getAnnotation(ExcelField.class);
|
||||
if (ef != null && (ef.type()==0 || ef.type()==2)){
|
||||
@@ -244,7 +311,11 @@ public class ImportExcel {
|
||||
}
|
||||
}
|
||||
// Get annotation method
|
||||
Method[] ms = cls.getDeclaredMethods();
|
||||
// Method[] ms = cls.getDeclaredMethods();
|
||||
List<Method> ms=new ArrayList<Method>();
|
||||
// Get annotation method
|
||||
//递归获取cls实体对象及父级对象的属性
|
||||
getMethods(ms, cls);
|
||||
for (Method m : ms){
|
||||
ExcelField ef = m.getAnnotation(ExcelField.class);
|
||||
if (ef != null && (ef.type()==0 || ef.type()==2)){
|
||||
|
||||
@@ -32,6 +32,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.basics.ServiceDictInfo;
|
||||
import com.nis.domain.basics.SysDictInfo;
|
||||
import com.nis.domain.configuration.AreaBean;
|
||||
@@ -39,7 +40,7 @@ import com.nis.domain.configuration.AreaIpCfg;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.ComplexStringCfgTemplate;
|
||||
import com.nis.domain.configuration.IpCfgTemplate;
|
||||
import com.nis.domain.configuration.template.IpCfgTemplate;
|
||||
import com.nis.domain.configuration.RequestInfo;
|
||||
import com.nis.domain.configuration.StringCfgTemplate;
|
||||
import com.nis.domain.log.BaseLogEntity;
|
||||
@@ -584,6 +585,38 @@ public class BaseController {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void importCfgTemplate(HttpServletRequest request,HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes,Integer functionId,Integer cfgRegionCode,Class clazz){
|
||||
Properties msgProp = getMsgProp();
|
||||
try {
|
||||
List<FunctionRegionDict> dictList = DictUtils.getFunctionRegionDictList(functionId);
|
||||
for(FunctionRegionDict dict:dictList){
|
||||
if(dict.getConfigRegionCode()==cfgRegionCode){
|
||||
String fileName = dict.getConfigRegionValue()+".xlsx";
|
||||
if(dict.getRegionType()==1){
|
||||
List<IpCfgTemplate> list = Lists.newArrayList();
|
||||
list.add((IpCfgTemplate)clazz.newInstance());
|
||||
new ExportExcel(msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
write(request,response, fileName).dispose();
|
||||
}else if(dict.getRegionType()==2){
|
||||
List<StringCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new StringCfgTemplate());
|
||||
new ExportExcel(msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
write(request,response, fileName).dispose();
|
||||
}else if(dict.getRegionType()==3){
|
||||
List<ComplexStringCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new ComplexStringCfgTemplate());
|
||||
new ExportExcel(msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
write(request,response, fileName).dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
msgProp = null;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setLogAction(BaseLogEntity log) {
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
|
||||
@@ -706,20 +739,67 @@ public class BaseController {
|
||||
// ip_pattern check end
|
||||
//client_ip check start
|
||||
String srcIp=value.getSrcIpAddress();
|
||||
String _msg=checkIP(prop,prop.getProperty("client_ip"),srcIp,ipTypeString,ipPatternString);
|
||||
String _msg="";
|
||||
if("ipmulitiplex".equals(specialItem)) {
|
||||
_msg=checkIP(prop,prop.getProperty("IP"),srcIp,ipTypeString,ipPatternString);
|
||||
}else {
|
||||
_msg=checkIP(prop,prop.getProperty("client_ip"),srcIp,ipTypeString,ipPatternString);
|
||||
}
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
//client_ip check end
|
||||
//server_ip check start
|
||||
String destIp=value.getDestIpAddress();
|
||||
if(srcIp.equals(destIp)){
|
||||
String info=String.format(prop.getProperty("are_the_same"),prop.getProperty("client_ip"),prop.getProperty("server_ip"));
|
||||
errInfo.append(info+";");
|
||||
}
|
||||
_msg=checkIP(prop,prop.getProperty("server_ip"),destIp,ipTypeString,ipPatternString);
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
if("ipmulitiplex".equals(specialItem)) {//set 默认值
|
||||
if(ipPattern!=null&&ipType!=null) {
|
||||
if("ip_subnet".equals(ipPatternString)) {
|
||||
if("ipv4".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if("ipv6".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if("4over6".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if("6over4".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if("all".equals(ipTypeString)) {
|
||||
|
||||
}
|
||||
}else if("ip_range".equals(ipPatternString)) {
|
||||
if("ipv4".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if("ipv6".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if("4over6".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if("6over4".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if("all".equals(ipTypeString)) {
|
||||
|
||||
}
|
||||
}else if("ip".equals(ipPatternString)) {
|
||||
if("ipv4".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||
}else if("ipv6".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
||||
}else if("4over6".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
||||
}else if("6over4".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||
}else if("all".equals(ipTypeString)) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if(srcIp.equals(destIp)){
|
||||
String info=String.format(prop.getProperty("are_the_same"),prop.getProperty("client_ip"),prop.getProperty("server_ip"));
|
||||
errInfo.append(info+";");
|
||||
}
|
||||
_msg=checkIP(prop,prop.getProperty("server_ip"),destIp,ipTypeString,ipPatternString);
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
}
|
||||
//server_ip check end
|
||||
//port_pattern check start
|
||||
@@ -743,14 +823,29 @@ public class BaseController {
|
||||
//port_pattern check end
|
||||
//src_port check start
|
||||
String srcPort=value.getSrcPort();
|
||||
_msg=checkPort(prop,prop.getProperty("client_port"), srcPort, portPatternString);
|
||||
if("ipmulitiplex".equals(specialItem)) {
|
||||
_msg=checkPort(prop,prop.getProperty("port"), srcPort, portPatternString);
|
||||
}else {
|
||||
_msg=checkPort(prop,prop.getProperty("client_port"), srcPort, portPatternString);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
//src_port check end
|
||||
//dest_port check start
|
||||
String destPort=value.getDestPort();
|
||||
_msg=checkPort(prop,prop.getProperty("server_port"), destPort, portPatternString);
|
||||
if("ipmulitiplex".equals(specialItem)) {//set 默认值
|
||||
if(portPattern!=null) {
|
||||
if("port_mask".equals(portPatternString)) {
|
||||
value.setDestPort(Constants.PORT_MASK_DEFAULT);
|
||||
}else if("port".equals(portPatternString)) {
|
||||
value.setDestPort(Constants.PORT_DEFAULT);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
_msg=checkPort(prop,prop.getProperty("server_port"), destPort, portPatternString);
|
||||
}
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
@@ -899,6 +994,46 @@ public class BaseController {
|
||||
errInfo.append(String.format(prop.getProperty("num_split_by_comma"), prop.getProperty("label"))+";");
|
||||
}
|
||||
}
|
||||
//group and ir_type check start
|
||||
if("ipmulitiplex".equals(specialItem)) {
|
||||
List<SysDataDictionaryItem> irTypeList = DictUtils.getDictList("IR_TYPE");
|
||||
Integer irType= value.getIrType();
|
||||
if(irType==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ir_type"))+";");
|
||||
}else {
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem irTypeItem:irTypeList){
|
||||
if(Integer.parseInt(irTypeItem.getItemCode())==protocol.intValue()){
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ir_type"))+";");
|
||||
}
|
||||
}
|
||||
Integer dnsStrategyId=value.getDnsStrategyId();
|
||||
if(dnsStrategyId==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("group_name"))+";");
|
||||
}else {
|
||||
PolicyGroupInfo group=policyGroupInfoService.getById(dnsStrategyId.intValue());
|
||||
if(group==null) {
|
||||
errInfo.append(String.format(prop.getProperty("id_not_exists"),dnsStrategyId, prop.getProperty("group_name"))+";");
|
||||
}else if(group.getIsValid()==Constants.VALID_DEL||group.getIsValid()==Constants.VALID_NO) {
|
||||
errInfo.append(String.format(prop.getProperty("id_not_valid"),dnsStrategyId, prop.getProperty("group_name"))+";");
|
||||
}
|
||||
}
|
||||
}
|
||||
if("ipratelimit".equals(specialItem)) {
|
||||
Integer ratelimit=value.getRatelimit();
|
||||
if(ratelimit==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ratelimit"))+";");
|
||||
}else {
|
||||
if(ratelimit.intValue()<0||ratelimit.intValue()>100) {
|
||||
errInfo.append(prop.getProperty("ratelimit_limit")+";");
|
||||
}
|
||||
}
|
||||
}
|
||||
//attribute check end
|
||||
if(StringUtils.isNotBlank(errInfo.toString())){
|
||||
msg.append(lineStart).append(errInfo);
|
||||
@@ -906,6 +1041,7 @@ public class BaseController {
|
||||
msg.append("<br/>");
|
||||
}
|
||||
}
|
||||
//group and ir_type check end
|
||||
line++;
|
||||
}
|
||||
if(StringUtils.isNotBlank(msg.toString())){
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.nis.domain.Page;
|
||||
import com.nis.domain.basics.ServiceDictInfo;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.HttpUrlCfg;
|
||||
import com.nis.domain.configuration.IpCfgTemplate;
|
||||
import com.nis.domain.configuration.template.IpCfgTemplate;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
@@ -240,10 +240,42 @@ public class CommonController extends BaseController {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void _importIp(String cfgName,RedirectAttributes redirectAttributes,MultipartFile file,IpPortCfg ipCfg,Class clazz) {
|
||||
redirectAttributes.addAttribute("cfgName", cfgName);
|
||||
try {
|
||||
ImportExcel ei = new ImportExcel(file, 0, 0);
|
||||
List<IpCfgTemplate> list = ei.getDataList(clazz);
|
||||
this.checkIpCfg(ipCfg.getFunctionId(),list);
|
||||
List<BaseIpCfg> ipList = new ArrayList<>();
|
||||
Date date=new Date();
|
||||
for(IpCfgTemplate cfg : list){
|
||||
IpPortCfg ip = new IpPortCfg();
|
||||
BeanUtils.copyProperties(ipCfg, ip);
|
||||
BeanUtils.copyProperties(cfg, ip);
|
||||
ip.setTableName(IpPortCfg.getTablename());
|
||||
ip.setIsAreaEffective(0);
|
||||
ip.setIsValid(Constants.VALID_NO);
|
||||
ip.setIsAudit(Constants.AUDIT_NOT_YET);
|
||||
ip.setCreatorId(ipCfg.getCurrentUser().getId());
|
||||
ip.setCreateTime(date);
|
||||
ip.setCompileId(ipCfgService.getCompileId());
|
||||
ip.setDnsStrategyId((long)cfg.getDnsStrategyId().intValue());
|
||||
ipList.add(ip);
|
||||
}
|
||||
ipCfgService.saveBatch(ipList, IpCfgDao.class);
|
||||
} catch (Exception e) {
|
||||
addMessage(redirectAttributes, e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void _importFileTemplate(HttpServletRequest request,HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes,Integer functionId,Integer cfgRegionCode) {
|
||||
this.importCfgTemplate(request, response, redirectAttributes, functionId, cfgRegionCode);
|
||||
}
|
||||
public void _importFileTemplate(HttpServletRequest request,HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes,Integer functionId,Integer cfgRegionCode,Class clazz) {
|
||||
this.importCfgTemplate(request, response, redirectAttributes, functionId, cfgRegionCode,clazz);
|
||||
}
|
||||
//ip配置导出
|
||||
public void _exportIp(String columns,Model model,HttpServletRequest request,HttpServletResponse response,
|
||||
IpPortCfg entity,String ids,RedirectAttributes redirectAttributes){
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.nis.domain.SysDataDictionaryItem;
|
||||
import com.nis.domain.basics.PolicyGroupInfo;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.template.IpMultiplexPolicyTemplate;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.web.controller.configuration.CommonController;
|
||||
|
||||
@@ -93,7 +94,7 @@ public class IpMultiplexController extends CommonController {
|
||||
@RequestMapping(value = "/import", method=RequestMethod.POST)
|
||||
public String importIp(String cfgName,RedirectAttributes redirectAttributes,
|
||||
@RequestParam("file") MultipartFile file,IpPortCfg cfg) {
|
||||
this._importIp(cfgName,redirectAttributes, file,cfg);
|
||||
this._importIp(cfgName,redirectAttributes, file,cfg,IpMultiplexPolicyTemplate.class);
|
||||
redirectAttributes.addAttribute("urlPrefix","/manipulation/ipmulitiplex");
|
||||
redirectAttributes.addAttribute("requiresPermissionPrefix","ip:mulitiplex");
|
||||
return "redirect:" + adminPath +"/manipulation/ipmulitiplex/list?functionId="+cfg.getFunctionId();
|
||||
@@ -102,7 +103,7 @@ public class IpMultiplexController extends CommonController {
|
||||
@RequestMapping(value = "import/template")
|
||||
public void importFileTemplate(HttpServletRequest request,HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes,Integer functionId,Integer cfgRegionCode) {
|
||||
this._importFileTemplate(request, response, redirectAttributes, functionId, cfgRegionCode);
|
||||
this._importFileTemplate(request, response, redirectAttributes, functionId, cfgRegionCode,IpMultiplexPolicyTemplate.class);
|
||||
}
|
||||
//ip配置导出
|
||||
@RequestMapping(value = "export")
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.ComplexkeywordCfg;
|
||||
import com.nis.domain.configuration.DnsResStrategy;
|
||||
import com.nis.domain.configuration.ComplexStringCfgTemplate;
|
||||
import com.nis.domain.configuration.IpCfgTemplate;
|
||||
import com.nis.domain.configuration.template.IpCfgTemplate;
|
||||
import com.nis.domain.configuration.StringCfgTemplate;
|
||||
import com.nis.domain.configuration.HttpBodyCfg;
|
||||
import com.nis.domain.configuration.HttpReqHeadCfg;
|
||||
|
||||
@@ -1043,3 +1043,4 @@ traffic_website_list=Website List TOP10
|
||||
traffic_website_type_chart=Website Type
|
||||
website=Website
|
||||
#===============dashboard end===================================
|
||||
ratelimit_limit=Limit Rate must between 0 and 100
|
||||
@@ -856,3 +856,4 @@ dest_ip_report=Destination Country IP Report
|
||||
isp_report=Isp Report
|
||||
#=============about report===================
|
||||
show_more=Show More
|
||||
ratelimit_limit=Limit Rate must between 0 and 100
|
||||
@@ -1040,3 +1040,4 @@ traffic_website_list=\u7F51\u7AD9\u6D41\u91CF\u7EDF\u8BA1\u5217\u8868
|
||||
traffic_website_type_chart=\u7F51\u7AD9\u5206\u7C7B\u6D41\u91CF\u7EDF\u8BA1\u56FE
|
||||
website=\u7F51\u7AD9\u540D\u79F0
|
||||
#===============dashboard end===================================
|
||||
ratelimit_limit=\u9650\u901F\u6BD4\u4F8B\u5FC5\u987B\u4ECB\u4E8E0\u5230100
|
||||
@@ -415,3 +415,12 @@ specific_service_cfg_type_encrypted_tunnel_behavior=encrypted_tunnel_behavior
|
||||
specific_service_cfg_type_basic_protocol=basic_protocol
|
||||
#基础协议自定义域
|
||||
proto_id_region=PROTO_ID
|
||||
#IP默认值
|
||||
ipv4_default_ip_value=0.0.0.0
|
||||
ipv4_default_ip_value=::
|
||||
ipv4_default_ip_subnet_value=0.0.0.0/32
|
||||
ipv6_default_ip_subnet_value=::/64
|
||||
ipv4_default_ip_range_value=0.0.0.0-0.0.0.0
|
||||
ipv6_default_ip_range_value=::-::
|
||||
port_default=0
|
||||
port_mask_default=0/65535
|
||||
Reference in New Issue
Block a user