voip界面去掉无用的检索条件
摘要文件类型增加音视频文件类 ip和http增加配置导出
This commit is contained in:
@@ -7,6 +7,7 @@ import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
@@ -20,12 +21,14 @@ import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jets3t.service.ServiceException;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.beust.jcommander.internal.Lists;
|
||||
@@ -39,9 +42,12 @@ import com.nis.domain.configuration.AreaBean;
|
||||
import com.nis.domain.configuration.AreaIpCfg;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.ComplexStringCfgTemplate;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.RequestInfo;
|
||||
import com.nis.domain.configuration.StringCfgTemplate;
|
||||
import com.nis.domain.configuration.template.IpAllTemplate;
|
||||
import com.nis.domain.configuration.template.IpCfgTemplate;
|
||||
import com.nis.domain.log.BaseLogEntity;
|
||||
import com.nis.domain.log.SearchReport;
|
||||
@@ -54,6 +60,9 @@ import com.nis.util.DictUtils;
|
||||
import com.nis.util.JsonMapper;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.excel.ExportExcel;
|
||||
import com.nis.util.excel.ImportExcel;
|
||||
import com.nis.web.dao.configuration.IpCfgDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
import com.nis.web.service.ArchiveServcie;
|
||||
import com.nis.web.service.AreaService;
|
||||
import com.nis.web.service.DictService;
|
||||
@@ -605,17 +614,17 @@ public class BaseController {
|
||||
if(dict.getRegionType()==1){
|
||||
List<IpCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new IpCfgTemplate());
|
||||
new ExportExcel(msgProp,null, IpCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
||||
new ExportExcel(new FunctionRegionDict(),msgProp,null, IpCfgTemplate.class, 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, StringCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
||||
new ExportExcel(new FunctionRegionDict(),msgProp,null, StringCfgTemplate.class, 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, ComplexStringCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
||||
new ExportExcel(new FunctionRegionDict(),msgProp,null, ComplexStringCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
||||
write(request,response, fileName).dispose();
|
||||
}
|
||||
}
|
||||
@@ -637,17 +646,17 @@ public class BaseController {
|
||||
if(dict.getRegionType()==1){
|
||||
List<IpCfgTemplate> list = Lists.newArrayList();
|
||||
list.add((IpCfgTemplate)clazz.newInstance());
|
||||
new ExportExcel(msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
new ExportExcel(new FunctionRegionDict(),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).
|
||||
new ExportExcel(new FunctionRegionDict(),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).
|
||||
new ExportExcel(new FunctionRegionDict(),msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
write(request,response, fileName).dispose();
|
||||
}
|
||||
}
|
||||
@@ -778,6 +787,572 @@ public class BaseController {
|
||||
params.put("searchCfgId", entry.getCfgId());
|
||||
}
|
||||
}
|
||||
|
||||
public List<BaseIpCfg> checkIpCfg(FunctionServiceDict serviceDict,FunctionRegionDict regionDict,List<IpAllTemplate> list) throws ServiceException{
|
||||
List<BaseIpCfg> ipList=new ArrayList<BaseIpCfg>();
|
||||
Properties prop=this.getMsgProp();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
IpAllTemplate ipCfg=list.get(i);
|
||||
IpPortCfg baseIpCfg=new IpPortCfg();
|
||||
baseIpCfg.setCfgDesc(ipCfg.getCfgDesc());
|
||||
if(regionDict.getIsMaat().equals(1)){
|
||||
if(regionDict.getRegionType().equals(1)){
|
||||
boolean srcIpEmpty=false;
|
||||
boolean srcPortEmpty=false;
|
||||
if(StringUtil.isEmpty(ipCfg.getSrcIpAddress())){
|
||||
srcIpEmpty=true;
|
||||
}
|
||||
if(StringUtil.isEmpty(ipCfg.getDestIpAddress())){
|
||||
if(srcIpEmpty){
|
||||
baseIpCfg.setSrcIpAddress("0.0.0.0");
|
||||
baseIpCfg.setDestIpAddress("0.0.0.0");
|
||||
baseIpCfg.setIpPattern(3);
|
||||
baseIpCfg.setIpType(4);
|
||||
}else{
|
||||
if(ipCfg.getSrcIpAddress().indexOf(":") > -1){
|
||||
if(ipCfg.getSrcIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress("::-::");
|
||||
baseIpCfg.setIpPattern(2);
|
||||
}else if(ipCfg.getSrcIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress("::/128");
|
||||
baseIpCfg.setIpPattern(1);
|
||||
}else{
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress("::");
|
||||
baseIpCfg.setIpPattern(3);
|
||||
}
|
||||
baseIpCfg.setIpType(6);
|
||||
}else{
|
||||
if(ipCfg.getSrcIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setSrcIpAddress("0.0.0.0-"+ipCfg.getSrcIpAddress().split("-")[0].substring(0,ipCfg.getSrcIpAddress().indexOf("-")+1)+ipCfg.getSrcIpAddress().split("-")[1]);
|
||||
baseIpCfg.setDestIpAddress("0.0.0.0-0.0.0.0");
|
||||
baseIpCfg.setIpPattern(2);
|
||||
}else if(ipCfg.getSrcIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress("0.0.0.0/16");
|
||||
baseIpCfg.setIpPattern(1);
|
||||
}else{
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress("0.0.0.0");
|
||||
baseIpCfg.setIpPattern(3);
|
||||
}
|
||||
baseIpCfg.setIpType(4);
|
||||
}
|
||||
}
|
||||
} else{
|
||||
if(srcIpEmpty){
|
||||
if(ipCfg.getDestIpAddress().indexOf(":") > -1){
|
||||
if(ipCfg.getDestIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress("::-::");
|
||||
baseIpCfg.setIpPattern(2);
|
||||
}else if(ipCfg.getDestIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress("::/128");
|
||||
baseIpCfg.setIpPattern(1);
|
||||
}else{
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress("::");
|
||||
baseIpCfg.setIpPattern(3);
|
||||
}
|
||||
baseIpCfg.setIpType(6);
|
||||
}else{
|
||||
if(ipCfg.getDestIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setDestIpAddress("0.0.0.0-"+ipCfg.getDestIpAddress().split("-")[0].substring(0,ipCfg.getDestIpAddress().indexOf("-")+1)+ipCfg.getDestIpAddress().split("-")[1]);
|
||||
baseIpCfg.setSrcIpAddress("0.0.0.0-0.0.0.0");
|
||||
baseIpCfg.setIpPattern(2);
|
||||
}else if(ipCfg.getDestIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress("0.0.0.0/16");
|
||||
baseIpCfg.setIpPattern(1);
|
||||
}else{
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress("0.0.0.0");
|
||||
baseIpCfg.setIpPattern(3);
|
||||
}
|
||||
baseIpCfg.setIpType(4);
|
||||
}
|
||||
}else{
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
if(ipCfg.getSrcIpAddress().indexOf(":") > -1){
|
||||
baseIpCfg.setIpType(6);
|
||||
}else{
|
||||
baseIpCfg.setIpType(4);
|
||||
}
|
||||
if(ipCfg.getSrcIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setIpPattern(2);
|
||||
}else if(ipCfg.getSrcIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setIpPattern(1);
|
||||
}else{
|
||||
baseIpCfg.setIpPattern(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO 判断源IP和目的IP的值
|
||||
//TODO 判断源IP和目的IP格式
|
||||
|
||||
if(StringUtil.isEmpty(ipCfg.getSrcPort())){
|
||||
srcPortEmpty=true;
|
||||
}
|
||||
if(StringUtil.isEmpty(ipCfg.getDestPort())){
|
||||
if(srcPortEmpty){
|
||||
baseIpCfg.setSrcPort("0");
|
||||
baseIpCfg.setDestPort("0");
|
||||
baseIpCfg.setPortPattern(1);
|
||||
}else{
|
||||
if(ipCfg.getSrcPort().indexOf("/") > -1){
|
||||
baseIpCfg.setDestPort("0/0");
|
||||
baseIpCfg.setPortPattern(2);
|
||||
}else{
|
||||
baseIpCfg.setDestPort("0");
|
||||
baseIpCfg.setPortPattern(1);
|
||||
}
|
||||
baseIpCfg.setSrcPort(ipCfg.getSrcPort());
|
||||
}
|
||||
}else{
|
||||
if(srcPortEmpty){
|
||||
if(ipCfg.getDestPort().indexOf("/") > -1){
|
||||
baseIpCfg.setSrcPort("0/0");
|
||||
baseIpCfg.setPortPattern(2);
|
||||
}else{
|
||||
baseIpCfg.setSrcPort("0");
|
||||
baseIpCfg.setPortPattern(1);
|
||||
}
|
||||
baseIpCfg.setDestPort(ipCfg.getSrcPort());
|
||||
}else{
|
||||
if(ipCfg.getSrcPort().indexOf("/") > -1){
|
||||
baseIpCfg.setPortPattern(2);
|
||||
}else{
|
||||
baseIpCfg.setPortPattern(1);
|
||||
}
|
||||
baseIpCfg.setSrcPort(ipCfg.getSrcPort());
|
||||
baseIpCfg.setDestPort(ipCfg.getDestPort());
|
||||
|
||||
}
|
||||
}
|
||||
//TODO 判断源端口和目的端口格式
|
||||
//TODO 判断源和目的端口的值
|
||||
|
||||
if(StringUtil.isEmpty(ipCfg.getProtocol())){
|
||||
if(StringUtil.isEmpty(regionDict.getConfigProtocol())){
|
||||
baseIpCfg.setProtocol(0);
|
||||
}else{
|
||||
baseIpCfg.setProtocol(Integer.parseInt(regionDict.getConfigProtocol().split(",")[0]));
|
||||
}
|
||||
baseIpCfg.setProtocolId(serviceDict.getProtocolId());
|
||||
}else{
|
||||
baseIpCfg.setProtocol(ipCfg.getProtocol());
|
||||
baseIpCfg.setProtocolId(serviceDict.getProtocolId());
|
||||
}
|
||||
//TODO 判断Protocol的值
|
||||
|
||||
if(StringUtil.isEmpty(ipCfg.getDirection())){
|
||||
if(StringUtil.isEmpty(regionDict.getConfigDirection())){
|
||||
baseIpCfg.setDirection(0);
|
||||
}else{
|
||||
baseIpCfg.setDirection(Integer.parseInt(regionDict.getConfigDirection().split(",")[0]));
|
||||
}
|
||||
}else{
|
||||
baseIpCfg.setDirection(ipCfg.getDirection());
|
||||
}
|
||||
|
||||
//TODO 判断Direction的值
|
||||
}
|
||||
}
|
||||
ipList.add(baseIpCfg);
|
||||
}
|
||||
return ipList;
|
||||
|
||||
/*List<SysDataDictionaryItem> ipTypeList = DictUtils.getDictList("IP_TYPE");
|
||||
List<SysDataDictionaryItem> ipPatternList = DictUtils.getDictList("IP_PATTERN");
|
||||
List<SysDataDictionaryItem> portPatternList = DictUtils.getDictList("PORT_PATTERN");
|
||||
List<SysDataDictionaryItem> directionList = DictUtils.getDictList("DIRECTION");
|
||||
List<SysDataDictionaryItem> protocolList = DictUtils.getDictList("PROTOCOL");
|
||||
List<SysDataDictionaryItem> ipsecProrocolList = DictUtils.getDictList("IPSEC_PROTOCOL");
|
||||
List<SysDataDictionaryItem> tunnelProrocolList = DictUtils.getDictList("TUNNEL_PROTOCOL");
|
||||
List<SysDataDictionaryItem> specialFunctionIdList = DictUtils.getDictList("SPECIAL_FUNCTION_ID");
|
||||
List<SysDataDictionaryItem> irTypeList = DictUtils.getDictList("IR_TYPE");
|
||||
String specialItem=null;
|
||||
for(SysDataDictionaryItem sfuncItem:specialFunctionIdList){
|
||||
if(functionId==Integer.parseInt(sfuncItem.getItemCode())){
|
||||
specialItem=sfuncItem.getItemValue();
|
||||
}
|
||||
}
|
||||
if("ipaddr".equals(specialItem)){
|
||||
List<SysDataDictionaryItem> icmpprotocolList = DictUtils.getDictList("ICMP_PROTOCOL");
|
||||
if(action==Constants.DROP_ACTION) {
|
||||
protocolList.addAll(icmpprotocolList);
|
||||
}
|
||||
}
|
||||
StringBuffer msg=new StringBuffer();
|
||||
int line=1;
|
||||
for(IpCfgTemplate value:list){
|
||||
String lineStart=String.format(prop.getProperty("line"), line)+":";
|
||||
StringBuffer errInfo=new StringBuffer();
|
||||
// ip_type check start
|
||||
Integer ipType=value.getIpType();
|
||||
if(ipType==null){
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ip_type"))+";");
|
||||
}else{
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem ipTypeItem:ipTypeList){
|
||||
if(ipType==Integer.parseInt(ipTypeItem.getItemCode())){
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ip_type"))+";");
|
||||
}
|
||||
}
|
||||
// ip_type check end
|
||||
// ip_pattern check start
|
||||
Integer ipPattern=value.getIpPattern();
|
||||
if(ipPattern==null){
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ip_pattern"))+";");
|
||||
}else{
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem ipPatternItem:ipPatternList){
|
||||
if(ipPattern==Integer.parseInt(ipPatternItem.getItemCode())){
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ip_pattern"))+";");
|
||||
}
|
||||
}
|
||||
// ip_pattern check end
|
||||
//client_ip check start
|
||||
String srcIp=value.getSrcIpAddress();
|
||||
String _msg="";
|
||||
if("ipmulitiplex".equals(specialItem)) {
|
||||
_msg=checkIP(prop,prop.getProperty("IP"),srcIp,ipType,ipPattern);
|
||||
}else {
|
||||
_msg=checkIP(prop,prop.getProperty("client_ip"),srcIp,ipType,ipPattern);
|
||||
}
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
//client_ip check end
|
||||
//server_ip check start
|
||||
String destIp=value.getDestIpAddress();
|
||||
if("ipmulitiplex".equals(specialItem)) {//set 默认值
|
||||
if(ipPattern!=null&&ipType!=null) {
|
||||
if(1==ipPattern.intValue()) {
|
||||
if(4==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if(6==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if(46==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if(64==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if(10==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||
}
|
||||
}else if(2==ipPattern.intValue()) {
|
||||
if(4==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if(6==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if(46==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if(64==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if(10==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||
}
|
||||
}else if(3==ipPattern.intValue()) {
|
||||
if(4==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||
}else if(6==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
||||
}else if(46==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
||||
}else if(64==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||
}else if(10==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}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,ipType,ipPattern);
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
}
|
||||
if(!"ipmulitiplex".equals(specialItem)&&(46==ipType.intValue()||64==ipType.intValue()||10==ipType.intValue())) {
|
||||
_msg=checkIp(prop, prop.getProperty("client_ip"), srcIp, prop.getProperty("server_ip"), destIp, ipType, ipPattern);
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
}
|
||||
//server_ip check end
|
||||
//port_pattern check start
|
||||
Integer portPattern=value.getPortPattern();
|
||||
if(portPattern==null){
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("port_pattern"))+";");
|
||||
}else{
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem portPatternItem:portPatternList){
|
||||
if(portPattern==Integer.parseInt(portPatternItem.getItemCode())){
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("port_pattern"))+";");
|
||||
}
|
||||
}
|
||||
//port_pattern check end
|
||||
//src_port check start
|
||||
String srcPort=value.getSrcPort();
|
||||
if("ipmulitiplex".equals(specialItem)) {
|
||||
_msg=checkPort(prop,prop.getProperty("port"), srcPort, portPattern);
|
||||
}else {
|
||||
_msg=checkPort(prop,prop.getProperty("client_port"), srcPort, portPattern);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
//src_port check end
|
||||
//dest_port check start
|
||||
String destPort=value.getDestPort();
|
||||
if("ipmulitiplex".equals(specialItem)) {//set 默认值
|
||||
if(portPattern!=null) {
|
||||
if(2==portPattern.intValue()) {
|
||||
value.setDestPort(Constants.PORT_MASK_DEFAULT);
|
||||
}else if(1==portPattern.intValue()) {
|
||||
value.setDestPort(Constants.PORT_DEFAULT);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
_msg=checkPort(prop,prop.getProperty("server_port"), destPort, portPattern);
|
||||
}
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
//dest_port check end
|
||||
//direction check start
|
||||
Integer direction=value.getDirection();
|
||||
if(direction==null){
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("direction"))+";");
|
||||
}else{
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem directionItem:directionList){
|
||||
if(Integer.parseInt(directionItem.getItemCode())==direction.intValue()){
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("direction"))+";");
|
||||
}
|
||||
}
|
||||
//direction check end
|
||||
//protocol check start
|
||||
Integer protocol= value.getProtocol();
|
||||
if(protocol==null){
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("protocol"))+";");
|
||||
}else{
|
||||
if(specialItem!=null&&("ipsec".equals(specialItem)||"tunnel".equals(specialItem))){
|
||||
if("ipsec".equals(specialItem)){
|
||||
if(action==Constants.DROP_ACTION.intValue()) {
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem protocolItem:ipsecProrocolList){
|
||||
if(Integer.parseInt(protocolItem.getItemCode())==protocol.intValue()){
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol"))+";");
|
||||
}
|
||||
}else {
|
||||
if(protocol!=0) {
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol"))+";");
|
||||
}
|
||||
}
|
||||
}else if("tunnel".equals(specialItem)){
|
||||
for(SysDataDictionaryItem protocolItem:tunnelProrocolList){
|
||||
if("default".equals(protocolItem.getItemValue())){
|
||||
if(protocol.intValue()!=Integer.parseInt(protocolItem.getItemCode())){
|
||||
errInfo.append(String.format(prop.getProperty("must_be"), prop.getProperty("protocol"),Integer.parseInt(protocolItem.getItemCode()))+";");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem protocolItem:protocolList){
|
||||
if(Integer.parseInt(protocolItem.getItemCode())==protocol.intValue()){
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol"))+";");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//protocol check end
|
||||
// requestId check start
|
||||
Integer requestId=value.getRequestId();
|
||||
if(requestId==null){
|
||||
if("whitelistip".equals(specialItem)) {
|
||||
value.setRequestId(0);
|
||||
}else {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("letter"))+";");
|
||||
}
|
||||
|
||||
}else{//查询数据库是否存在ID
|
||||
if("whitelistip".equals(specialItem)) {
|
||||
value.setRequestId(0);
|
||||
}else {
|
||||
RequestInfo info=requestInfoService.getRequestInfoById((long)requestId.intValue());
|
||||
if(info==null){
|
||||
errInfo.append(String.format(prop.getProperty("id_not_exists"),requestId, prop.getProperty("letter"))+";");
|
||||
}else if(info.getIsValid()==Constants.VALID_NO||info.getIsValid()==Constants.VALID_DEL){
|
||||
errInfo.append(String.format(prop.getProperty("id_not_valid"),requestId, prop.getProperty("letter"))+";");
|
||||
}
|
||||
}
|
||||
}
|
||||
// requestId check end
|
||||
//classification check start
|
||||
String classification=value.getClassify();
|
||||
if(StringUtils.isNotBlank(classification)){
|
||||
try{
|
||||
for(String classify:classification.split(",")){
|
||||
if(StringUtils.isNotBlank(classify)){
|
||||
int c=Integer.parseInt(classify);
|
||||
ServiceDictInfo dict=serviceDictInfoService.getDictById(c);
|
||||
if(dict==null){
|
||||
errInfo.append(String.format(prop.getProperty("id_not_exists"),classify, prop.getProperty("classification"))+";");
|
||||
}else if(dict.getIsValid()==Constants.VALID_NO||dict.getIsValid()==Constants.VALID_DEL){
|
||||
errInfo.append(String.format(prop.getProperty("id_not_valid"),classify, prop.getProperty("classification"))+";");
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
errInfo.append(String.format(prop.getProperty("num_split_by_comma"), prop.getProperty("classification"))+";");
|
||||
}
|
||||
}
|
||||
//classification check end
|
||||
//attribute check start
|
||||
String attributes=value.getAttribute();
|
||||
if(StringUtils.isNotBlank(attributes)){
|
||||
try{
|
||||
for(String attribute:attributes.split(",")){
|
||||
if(StringUtils.isNotBlank(attribute)){
|
||||
int c=Integer.parseInt(attribute);
|
||||
ServiceDictInfo dict=serviceDictInfoService.getDictById(c);
|
||||
if(dict==null){
|
||||
errInfo.append(String.format(prop.getProperty("id_not_exists"),attribute, prop.getProperty("attribute"))+";");
|
||||
}else if(dict.getIsValid()==Constants.VALID_NO||dict.getIsValid()==Constants.VALID_DEL){
|
||||
errInfo.append(String.format(prop.getProperty("id_not_valid"),attribute, prop.getProperty("attribute"))+";");
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
errInfo.append(String.format(prop.getProperty("num_split_by_comma"), prop.getProperty("attribute"))+";");
|
||||
}
|
||||
}
|
||||
//attribute check end
|
||||
//attribute check start
|
||||
String labels=value.getLable();
|
||||
if(StringUtils.isNotBlank(labels)){
|
||||
try{
|
||||
for(String label:labels.split(",")){
|
||||
if(StringUtils.isNotBlank(label)){
|
||||
int c=Integer.parseInt(label);
|
||||
ServiceDictInfo dict=serviceDictInfoService.getDictById(c);
|
||||
if(dict==null){
|
||||
errInfo.append(String.format(prop.getProperty("id_not_exists"),label, prop.getProperty("label"))+";");
|
||||
}else if(dict.getIsValid()==Constants.VALID_NO||dict.getIsValid()==Constants.VALID_DEL){
|
||||
errInfo.append(String.format(prop.getProperty("id_not_valid"),label, prop.getProperty("label"))+";");
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
errInfo.append(String.format(prop.getProperty("num_split_by_comma"), prop.getProperty("label"))+";");
|
||||
}
|
||||
}
|
||||
//group and ir_type check start
|
||||
if("ipmulitiplex".equals(specialItem)) {
|
||||
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())==irType.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)) {
|
||||
String ratelimit=value.getRatelimit();
|
||||
if(ratelimit==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ratelimit"))+";");
|
||||
}else {
|
||||
try {
|
||||
if(Double.parseDouble(ratelimit)<0||Double.parseDouble(ratelimit)>1) {
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ratelimit_limit"))+";");
|
||||
}
|
||||
}catch (Exception e) {
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ratelimit_limit"))+";");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//attribute check end
|
||||
if(StringUtils.isNotBlank(errInfo.toString())){
|
||||
msg.append(lineStart).append(errInfo);
|
||||
if(line<list.size()){
|
||||
msg.append("<br/>");
|
||||
}
|
||||
}
|
||||
//group and ir_type check end
|
||||
line++;
|
||||
}
|
||||
if(StringUtils.isNotBlank(msg.toString())){
|
||||
throw new MaatConvertException(prop.getProperty("save_failed")+"<br/>"+msg.toString());
|
||||
}*/
|
||||
}
|
||||
|
||||
public void checkIpCfg(int action,int functionId ,List<IpCfgTemplate> list) throws ServiceException{
|
||||
Properties prop=this.getMsgProp();
|
||||
List<SysDataDictionaryItem> ipTypeList = DictUtils.getDictList("IP_TYPE");
|
||||
@@ -1562,4 +2137,97 @@ public class BaseController {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多域导入
|
||||
* @param redirectAttributes
|
||||
* @param files
|
||||
* @param serviceDictId
|
||||
* @param regionDictIds
|
||||
* @param requestId
|
||||
*/
|
||||
public void _import(RedirectAttributes redirectAttributes,MultipartFile[] files
|
||||
,Integer serviceDictId
|
||||
,String regionDictIds
|
||||
,Integer requestId) {
|
||||
try {
|
||||
FunctionServiceDict serviceDict=DictUtils.getFunctionServiceDict(serviceDictId);
|
||||
List<BaseIpCfg> ipPortCfgs=new ArrayList<BaseIpCfg>();
|
||||
List<CfgIndexInfo> cfgIndexInfos=new ArrayList<CfgIndexInfo>();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
MultipartFile file = files[i];
|
||||
ImportExcel ei = new ImportExcel(file, 0, 0);
|
||||
|
||||
FunctionRegionDict regionDict=DictUtils.getFunctionRegionDict(Integer.parseInt(regionDictIds.split(",")[i]));
|
||||
|
||||
if(regionDict.getIsMaat().equals(1)){
|
||||
if(regionDict.getRegionType().equals(1)){
|
||||
List<IpAllTemplate> list = ei.getDataList(IpAllTemplate.class);
|
||||
ipPortCfgs=this.checkIpCfg(serviceDict,regionDict,list);
|
||||
Date date=new Date();
|
||||
for(BaseIpCfg cfg : ipPortCfgs){
|
||||
CfgIndexInfo cfgIndexInfo=new CfgIndexInfo();
|
||||
cfg.setAction(serviceDict.getAction());
|
||||
cfg.setAuditorId(UserUtils.getUser().getId());
|
||||
cfg.setAuditTime(date);
|
||||
cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
|
||||
cfg.setCfgType(regionDict.getConfigRegionValue());
|
||||
cfg.setCreateTime(date);
|
||||
cfg.setCreatorId(UserUtils.getUser().getId());
|
||||
cfg.setDoLog(1);
|
||||
cfg.setFunctionId(regionDict.getFunctionId());
|
||||
cfg.setIsAudit(0);
|
||||
cfg.setIsValid(0);
|
||||
cfg.setIsAreaEffective(0);
|
||||
cfg.setAttribute("0");
|
||||
cfg.setClassify("0");
|
||||
cfg.setLable("0");
|
||||
cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0:requestId);
|
||||
cfg.setServiceId(serviceDict.getServiceId());
|
||||
cfg.setTableName("ip_port_cfg");
|
||||
cfg.setCompileId(ipCfgService.getCompileId());
|
||||
|
||||
BeanUtils.copyProperties(cfg, cfgIndexInfo);
|
||||
cfgIndexInfos.add(cfgIndexInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ipCfgService.saveBatch(ipPortCfgs, IpCfgDao.class);
|
||||
ipCfgService.saveCfgIndexOf(cfgIndexInfos);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
addMessage(redirectAttributes, e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 多域配置导出
|
||||
* @param columns
|
||||
* @param model
|
||||
* @param request
|
||||
* @param response
|
||||
* @param entity
|
||||
* @param ids
|
||||
* @param redirectAttributes
|
||||
*/
|
||||
public void _export(Model model,HttpServletRequest request,HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes
|
||||
,String functionName
|
||||
,List<String> titleList,Map<String, Class<?>> classMap,Map<String,List> dataMap
|
||||
,Map<String, String> noExportMap) throws Exception{
|
||||
//获取国际化配置
|
||||
Properties msgProp = getMsgProp();
|
||||
//获取分类、性质、标签
|
||||
List<ServiceDictInfo> fls=serviceDictInfoService.findAllFlDict();
|
||||
List<ServiceDictInfo> xzs=serviceDictInfoService.findAllXzDict();
|
||||
List<ServiceDictInfo> labels=serviceDictInfoService.findAllLableDict();
|
||||
Map<Object, Object> map=new HashMap<Object, Object>();
|
||||
map.put("fls", fls);
|
||||
map.put("xzs", xzs);
|
||||
map.put("labels", labels);
|
||||
|
||||
String fileName = msgProp.getProperty(functionName, functionName)+"_"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
|
||||
new ExportExcel(msgProp,titleList,noExportMap,classMap,1).setDataList(msgProp,dataMap,map).write(response, fileName).dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ package com.nis.web.controller.configuration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
@@ -18,26 +19,38 @@ import java.util.Properties;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.axis2.databinding.types.soapencoding.Array;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.nis.domain.FunctionRegionDict;
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.basics.ServiceDictInfo;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.HttpBodyCfg;
|
||||
import com.nis.domain.configuration.HttpReqHeadCfg;
|
||||
import com.nis.domain.configuration.HttpResHeadCfg;
|
||||
import com.nis.domain.configuration.HttpUrlCfg;
|
||||
import com.nis.domain.configuration.template.IpAllTemplate;
|
||||
import com.nis.domain.configuration.template.IpCfgTemplate;
|
||||
import com.nis.domain.specific.ConfigGroupInfo;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.NtcSubscribeIdCfg;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.excel.ExportExcel;
|
||||
import com.nis.util.excel.ImportExcel;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.dao.configuration.IpCfgDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
/**
|
||||
* @ClassName: CommonController.java
|
||||
@@ -213,8 +226,7 @@ public class CommonController extends BaseController {
|
||||
addMessage(redirectAttributes, "audit_failed");
|
||||
}
|
||||
}
|
||||
public void _importIp(String cfgName,RedirectAttributes redirectAttributes,MultipartFile file,IpPortCfg ipCfg) {
|
||||
redirectAttributes.addAttribute("cfgName", cfgName);
|
||||
public void _importIp(RedirectAttributes redirectAttributes,MultipartFile file,IpPortCfg ipCfg) {
|
||||
try {
|
||||
ImportExcel ei = new ImportExcel(file, 0, 0);
|
||||
List<IpCfgTemplate> list = ei.getDataList(IpCfgTemplate.class);
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.nis.web.controller.configuration.ntc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -18,18 +20,27 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.nis.domain.FunctionRegionDict;
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.SysDataDictionaryItem;
|
||||
import com.nis.domain.basics.PolicyGroupInfo;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.NtcSubscribeIdCfg;
|
||||
import com.nis.domain.configuration.template.IpAddrTemplate;
|
||||
import com.nis.domain.configuration.template.IpAllTemplate;
|
||||
import com.nis.domain.configuration.template.IpsecTemplate;
|
||||
import com.nis.domain.configuration.template.TunnelIpTemplate;
|
||||
import com.nis.domain.specific.ConfigGroupInfo;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.excel.ExcelField;
|
||||
import com.nis.util.excel.ExportExcel;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.controller.configuration.CommonController;
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
@@ -40,7 +51,7 @@ import com.nis.web.security.UserUtils;
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/ntc/iplist")
|
||||
public class IpController extends CommonController{
|
||||
public class IpController extends BaseController{
|
||||
@RequestMapping(value = {"list"})
|
||||
// @RequiresPermissions(value={"iplist:config","iplist:confirm"},logical=Logical.OR)
|
||||
public String list(Model model,@ModelAttribute("cfg")CfgIndexInfo cfg,HttpServletRequest request,HttpServletResponse response) {
|
||||
@@ -140,7 +151,7 @@ public class IpController extends CommonController{
|
||||
}
|
||||
return "redirect:" + adminPath +"/ntc/iplist/list?functionId="+functionId;
|
||||
}
|
||||
//ip配置导入
|
||||
/*//ip配置导入
|
||||
@RequestMapping(value = "import", method=RequestMethod.POST)
|
||||
public String importIp(String cfgName,RedirectAttributes redirectAttributes,
|
||||
@RequestParam("file") MultipartFile file,IpPortCfg cfg) {
|
||||
@@ -198,5 +209,137 @@ public class IpController extends CommonController{
|
||||
public void exportIp(String columns,Model model,HttpServletRequest request,HttpServletResponse response,
|
||||
@ModelAttribute("cfg")IpPortCfg entity,String ids,RedirectAttributes redirectAttributes){
|
||||
this._exportIp(columns,model, request, response, entity, ids, redirectAttributes);
|
||||
}*/
|
||||
|
||||
//模板下载
|
||||
@RequestMapping(value = "import/template")
|
||||
public void importFileTemplate(HttpServletRequest request,HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes
|
||||
,Integer serviceDictId
|
||||
,Integer regionDictId
|
||||
,Integer requestId
|
||||
) {
|
||||
try {
|
||||
FunctionRegionDict regionDict=DictUtils.getFunctionRegionDict(regionDictId);
|
||||
FunctionServiceDict serviceDict=DictUtils.getFunctionServiceDict(serviceDictId);
|
||||
exportTemplate(request,response,redirectAttributes,regionDict,serviceDict,requestId);
|
||||
} catch (Exception e) {
|
||||
logger.error("export_failed", e);
|
||||
}
|
||||
|
||||
}
|
||||
public void exportTemplate(HttpServletRequest request,HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes
|
||||
,FunctionRegionDict regionDict
|
||||
,FunctionServiceDict serviceDict
|
||||
,Integer requestId) throws Exception{
|
||||
String fileName = "test.xlsx";
|
||||
//maat导入模板
|
||||
if(regionDict.getIsMaat().equals(1)){
|
||||
//ip类模板
|
||||
if(regionDict.getRegionType().equals(1)){
|
||||
List<IpAllTemplate> classList=new ArrayList<IpAllTemplate>();
|
||||
ExportExcel excel=new ExportExcel(regionDict,this.getMsgProp(),null, IpAllTemplate.class, 2);
|
||||
excel.setDataList(this.getMsgProp(),classList,null).
|
||||
write(request,response, fileName).dispose();
|
||||
}
|
||||
//str类模板
|
||||
if(regionDict.getRegionType().equals(2)){
|
||||
/*List<IpAllTemplate> classList=new ArrayList<IpAllTemplate>();
|
||||
ExportExcel excel=new ExportExcel(this.getMsgProp(),null, IpAllTemplate.class, 2,regionDict);
|
||||
excel.setDataList(this.getMsgProp(),classList,null).
|
||||
write(request,response, fileName).dispose();*/
|
||||
}
|
||||
//district类模板
|
||||
if(regionDict.getRegionType().equals(2)){
|
||||
/*ExportExcel excel=new ExportExcel(this.getMsgProp(),null, IpAllTemplate.class, 2,regionDict);
|
||||
excel.setDataList(this.getMsgProp(),classList,null).
|
||||
write(request,response, fileName).dispose();*/
|
||||
}
|
||||
}else{
|
||||
//非maat导入模板
|
||||
}
|
||||
}
|
||||
|
||||
//ip配置导入
|
||||
@RequestMapping(value = "import", method=RequestMethod.POST)
|
||||
public String importIp(RedirectAttributes redirectAttributes,
|
||||
@RequestParam("files") MultipartFile[] files
|
||||
,Integer serviceDictId
|
||||
,Integer requestId
|
||||
,String regionDictIds) {
|
||||
this._import(redirectAttributes, files,serviceDictId,regionDictIds,requestId);
|
||||
|
||||
return "redirect:" + adminPath +"/ntc/iplist/list?functionId="+5;
|
||||
}
|
||||
|
||||
//ip配置导出
|
||||
@RequestMapping(value = "exportIpAddr")
|
||||
public void exportIp(Model model,HttpServletRequest request,HttpServletResponse response,
|
||||
@ModelAttribute("cfg")CfgIndexInfo entity,String ids,RedirectAttributes redirectAttributes){
|
||||
try {
|
||||
//export data info
|
||||
List<String> titleList=new ArrayList<String>();
|
||||
Map<String, Class<?>> classMap=new HashMap<String, Class<?>>();
|
||||
Map<String, List> dataMap=new HashMap<String, List>();
|
||||
Map<String, String> noExportMap=new HashMap<String, String>();
|
||||
|
||||
|
||||
/*//导出选中记录
|
||||
* if(!StringUtil.isEmpty(ids)){
|
||||
for(String id:ids.split(",")){
|
||||
Long.parseLong(id);
|
||||
}
|
||||
//List<CfgIndexInfo> list=ipCfgService.getListByCfgIdWithName(IpPortCfg.getTablename(), entity.getFunctionId(), ids);
|
||||
}else{*/
|
||||
//条件导出数据大于最大导出数,只导出最大导出条数
|
||||
entity.setTableName(IpPortCfg.getTablename());
|
||||
Page<CfgIndexInfo> pageInfo=new Page<CfgIndexInfo>(request, response,"a");
|
||||
if(pageInfo.getCount()>Constants.MAX_EXPORT_SIZE){
|
||||
pageInfo.setPageNo(1);
|
||||
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
|
||||
}else{
|
||||
pageInfo.setPageNo(1);
|
||||
pageInfo.setPageSize(-1);
|
||||
}
|
||||
Page<CfgIndexInfo> page = ipCfgService.getIpCfgList(pageInfo, entity);
|
||||
titleList.add(entity.getMenuNameCode());
|
||||
titleList.add("ip_addr");
|
||||
titleList.add("asn_policy");
|
||||
classMap.put(entity.getMenuNameCode(), CfgIndexInfo.class);
|
||||
classMap.put("ip_port_cfg", IpPortCfg.class);
|
||||
classMap.put("asn_policy", ConfigGroupInfo.class);
|
||||
String cfgIndexInfoNoExport=",group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
|
||||
String ipPortInfoNoExport=",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
|
||||
+ ",config_time,editor,edit_time,auditor,audit_time"
|
||||
+",letter,whether_area_block,classification,attribute,label"
|
||||
+",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,group_name,";
|
||||
String asnGroupInfoNoExport="";
|
||||
noExportMap.put(entity.getMenuNameCode(),cfgIndexInfoNoExport);
|
||||
noExportMap.put("ip_addr", ipPortInfoNoExport);
|
||||
noExportMap.put("asn_policy", asnGroupInfoNoExport);
|
||||
List<IpPortCfg> ipList=new ArrayList<IpPortCfg>();
|
||||
List<ConfigGroupInfo> groupInfoList=new ArrayList<ConfigGroupInfo>();
|
||||
for (CfgIndexInfo cfg : page.getList()) {
|
||||
CfgIndexInfo cfgIndexInfo=ipCfgService.exportIpInfo(cfg);
|
||||
ipList.addAll(cfgIndexInfo.getIpPortList());
|
||||
if(!StringUtil.isEmpty(cfgIndexInfo.getAsnIpGroupName())){
|
||||
ConfigGroupInfo group=new ConfigGroupInfo();
|
||||
group.setCompileId(cfgIndexInfo.getCompileId());
|
||||
group.setGroupName(cfgIndexInfo.getAsnIpGroupName());
|
||||
groupInfoList.add(group);
|
||||
}
|
||||
}
|
||||
dataMap.put(entity.getMenuNameCode(), page.getList());
|
||||
dataMap.put("ip_addr", ipList);
|
||||
dataMap.put("asn_policy", groupInfoList);
|
||||
|
||||
/*}*/
|
||||
this._export(model, request, response, redirectAttributes,entity.getMenuNameCode(),titleList,classMap,dataMap,noExportMap);
|
||||
} catch (Exception e) {
|
||||
logger.error("ip addr export failed",e);
|
||||
addMessage(redirectAttributes, "export_failed");
|
||||
}
|
||||
//return "redirect:" + adminPath +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.nis.web.controller.configuration.ntc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -19,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.nis.domain.FunctionRegionDict;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
@@ -26,6 +29,7 @@ import com.nis.domain.configuration.ComplexkeywordCfg;
|
||||
import com.nis.domain.configuration.DnsResStrategy;
|
||||
import com.nis.domain.configuration.ComplexStringCfgTemplate;
|
||||
import com.nis.domain.configuration.template.IpCfgTemplate;
|
||||
import com.nis.domain.specific.ConfigGroupInfo;
|
||||
import com.nis.domain.configuration.StringCfgTemplate;
|
||||
import com.nis.domain.configuration.HttpBodyCfg;
|
||||
import com.nis.domain.configuration.HttpReqHeadCfg;
|
||||
@@ -35,6 +39,8 @@ import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.NtcSubscribeIdCfg;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.excel.ImportExcel;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.security.UserUtils;
|
||||
@@ -511,4 +517,128 @@ public class WebsiteController extends BaseController{
|
||||
return "redirect:" + adminPath +"/ntc/website/httpList?functionId="+cfgIndex.getFunctionId();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//ip配置导出
|
||||
@RequestMapping(value = "exportHttp")
|
||||
public String exportIp(Model model,HttpServletRequest request,HttpServletResponse response,
|
||||
@ModelAttribute("cfg")CfgIndexInfo entity,String ids,RedirectAttributes redirectAttributes){
|
||||
try {
|
||||
//export data info
|
||||
List<String> titleList=new ArrayList<String>();
|
||||
Map<String, Class<?>> classMap=new HashMap<String, Class<?>>();
|
||||
Map<String, List> dataMap=new HashMap<String, List>();
|
||||
Map<String, String> noExportMap=new HashMap<String, String>();
|
||||
|
||||
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(entity.getFunctionId());
|
||||
|
||||
/*//导出选中记录
|
||||
if(!StringUtil.isEmpty(ids)){
|
||||
for(String id:ids.split(",")){
|
||||
Long.parseLong(id);
|
||||
}
|
||||
//List<CfgIndexInfo> list=ipCfgService.getListByCfgIdWithName(IpPortCfg.getTablename(), entity.getFunctionId(), ids);
|
||||
}else{*/
|
||||
//条件导出数据大于最大导出数,只导出最大导出条数
|
||||
Page<CfgIndexInfo> pageInfo=new Page<CfgIndexInfo>(request, response,"a");
|
||||
if(pageInfo.getCount()>Constants.MAX_EXPORT_SIZE){
|
||||
pageInfo.setPageNo(1);
|
||||
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
|
||||
}else{
|
||||
pageInfo.setPageNo(1);
|
||||
pageInfo.setPageSize(-1);
|
||||
}
|
||||
Page<CfgIndexInfo> page = websiteCfgService.getWebsiteList(pageInfo, entity);
|
||||
|
||||
titleList.add(entity.getMenuNameCode());
|
||||
titleList.add("NTC_HTTP_URL");
|
||||
titleList.add("NTC_HTTP_REQ_HDR");
|
||||
titleList.add("NTC_HTTP_RES_HDR");
|
||||
titleList.add("NTC_HTTP_REQ_BODY");
|
||||
titleList.add("NTC_HTTP_RES_BODY");
|
||||
titleList.add("NTC_UNIVERSAL_IP");
|
||||
titleList.add("NTC_SUBSCRIBE_ID");
|
||||
classMap.put(entity.getMenuNameCode(), CfgIndexInfo.class);
|
||||
classMap.put("NTC_HTTP_URL", HttpUrlCfg.class);
|
||||
classMap.put("NTC_HTTP_REQ_HDR", HttpReqHeadCfg.class);
|
||||
classMap.put("NTC_HTTP_RES_HDR", HttpResHeadCfg.class);
|
||||
classMap.put("NTC_HTTP_REQ_BODY", HttpBodyCfg.class);
|
||||
classMap.put("NTC_HTTP_RES_BODY", HttpBodyCfg.class);
|
||||
classMap.put("NTC_UNIVERSAL_IP", IpPortCfg.class);
|
||||
classMap.put("NTC_SUBSCRIBE_ID", NtcSubscribeIdCfg.class);
|
||||
String cfgIndexInfoNoExport=",group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
|
||||
String httpUrlCfgNoExport=",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
|
||||
+ ",config_time,editor,edit_time,auditor,audit_time"
|
||||
+",letter,whether_area_block,classification,attribute,label"
|
||||
+",userregion1,userregion2,userregion3,userregion4,userregion5,";
|
||||
String httpReqHeadCfgNoExport=",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
|
||||
+ ",config_time,editor,edit_time,auditor,audit_time"
|
||||
+",letter,whether_area_block,classification,attribute,label"
|
||||
+",userregion1,userregion2,userregion3,userregion4,userregion5,";
|
||||
String httpResHeadCfgNoExport=",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
|
||||
+ ",config_time,editor,edit_time,auditor,audit_time"
|
||||
+",letter,whether_area_block,classification,attribute,label"
|
||||
+",userregion1,userregion2,userregion3,userregion4,userregion5,";
|
||||
String httpReqBodyCfgNoExport=",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
|
||||
+ ",config_time,editor,edit_time,auditor,audit_time"
|
||||
+",letter,whether_area_block,classification,attribute,label"
|
||||
+",userregion1,userregion2,userregion3,userregion4,userregion5,";
|
||||
String httpResBodyCfgNoExport=",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
|
||||
+ ",config_time,editor,edit_time,auditor,audit_time"
|
||||
+",letter,whether_area_block,classification,attribute,label"
|
||||
+",userregion1,userregion2,userregion3,userregion4,userregion5,";
|
||||
String ipPortCfgNoExport=",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
|
||||
+ ",config_time,editor,edit_time,auditor,audit_time"
|
||||
+",letter,whether_area_block,classification,attribute,label"
|
||||
+",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,group_name,";
|
||||
String ntcSubscribeIdCfgNoExport=",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
|
||||
+ ",config_time,editor,edit_time,auditor,audit_time"
|
||||
+",letter,whether_area_block,classification,attribute,label"
|
||||
+",userregion1,userregion2,userregion3,userregion4,userregion5,";
|
||||
noExportMap.put(entity.getMenuNameCode(),cfgIndexInfoNoExport);
|
||||
noExportMap.put("NTC_HTTP_URL", httpUrlCfgNoExport);
|
||||
noExportMap.put("NTC_HTTP_REQ_HDR", httpReqHeadCfgNoExport);
|
||||
noExportMap.put("NTC_HTTP_RES_HDR", httpResHeadCfgNoExport);
|
||||
noExportMap.put("NTC_HTTP_REQ_BODY", httpReqBodyCfgNoExport);
|
||||
noExportMap.put("NTC_HTTP_RES_BODY", httpResBodyCfgNoExport);
|
||||
noExportMap.put("NTC_UNIVERSAL_IP", ipPortCfgNoExport);
|
||||
noExportMap.put("NTC_SUBSCRIBE_ID", ntcSubscribeIdCfgNoExport);
|
||||
|
||||
List<HttpUrlCfg> httpUrlList = new ArrayList<>();
|
||||
List<HttpReqHeadCfg> httpReqHdrList = new ArrayList<>();
|
||||
List<HttpResHeadCfg> httpResHdrList = new ArrayList<>();
|
||||
List<HttpBodyCfg> httpReqBodyList = new ArrayList<>();
|
||||
List<HttpBodyCfg> httpResBodyList = new ArrayList<>();
|
||||
List<IpPortCfg> ipPortList = new ArrayList<>();
|
||||
List<NtcSubscribeIdCfg> subscribeIdList = new ArrayList<>();
|
||||
for (CfgIndexInfo cfg : page.getList()) {
|
||||
Map<String, List> maps=websiteCfgService.exportHttpCfg(cfg);
|
||||
httpUrlList.addAll(maps.get("NTC_HTTP_URL"));
|
||||
httpReqHdrList.addAll(maps.get("NTC_HTTP_REQ_HDR"));
|
||||
httpResHdrList.addAll(maps.get("NTC_HTTP_RES_HDR"));
|
||||
httpReqBodyList.addAll(maps.get("NTC_HTTP_REQ_BODY"));
|
||||
httpResBodyList.addAll(maps.get("NTC_HTTP_RES_BODY"));
|
||||
ipPortList.addAll(maps.get("NTC_UNIVERSAL_IP"));
|
||||
subscribeIdList.addAll(maps.get("NTC_SUBSCRIBE_ID"));
|
||||
}
|
||||
|
||||
dataMap.put(entity.getMenuNameCode(), page.getList());
|
||||
dataMap.put("NTC_HTTP_URL", httpUrlList);
|
||||
dataMap.put("NTC_HTTP_REQ_HDR", httpReqHdrList);
|
||||
dataMap.put("NTC_HTTP_RES_HDR", httpResHdrList);
|
||||
dataMap.put("NTC_HTTP_REQ_BODY", httpReqBodyList);
|
||||
dataMap.put("NTC_HTTP_RES_BODY", httpResBodyList);
|
||||
dataMap.put("NTC_UNIVERSAL_IP", ipPortList);
|
||||
dataMap.put("NTC_SUBSCRIBE_ID",subscribeIdList);
|
||||
|
||||
/*}*/
|
||||
this._export(model, request, response, redirectAttributes,entity.getMenuNameCode(),titleList,classMap,dataMap,noExportMap);
|
||||
} catch (Exception e) {
|
||||
logger.error("http export failed",e);
|
||||
addMessage(redirectAttributes, "export_failed");
|
||||
}
|
||||
return "redirect:" + adminPath +"/ntc/website/httpList?functionId="+entity.getFunctionId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class ControlController extends CommonController {
|
||||
@RequestMapping(value = "/ip/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);
|
||||
redirectAttributes.addAttribute("urlPrefix","/proxy/control/ip");
|
||||
redirectAttributes.addAttribute("requiresPermissionPrefix","control:ip");
|
||||
return "redirect:" + adminPath +"/proxy/control/ip/list?functionId="+cfg.getFunctionId();
|
||||
|
||||
@@ -895,6 +895,15 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
public CfgIndexInfo exportIpInfo(CfgIndexInfo entity){
|
||||
List<IpPortCfg> ipPortList = ipCfgDao.getIpPortList(entity);
|
||||
entity.setIpPortList(ipPortList);
|
||||
if(StringUtils.isNotBlank(entity.getUserRegion4())) {
|
||||
ConfigGroupInfo info=specificServiceCfgDao.getConfigGroupInfoByGroupId(Integer.parseInt(entity.getUserRegion4().trim()));
|
||||
entity.setAsnIpGroupName(info.getGroupName());
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
public BaseIpCfg getIpCfgById(String tableName,long id){
|
||||
return ipCfgDao.getById(tableName, id);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.nis.web.service.configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -10,6 +11,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.FunctionRegionDict;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.configuration.AreaIpCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
@@ -76,6 +78,27 @@ public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
|
||||
entity.setNtcSubscribeIdCfgList(subscribeIdList);
|
||||
return entity;
|
||||
}
|
||||
public Map<String, List> exportHttpCfg(CfgIndexInfo entity){
|
||||
Map<String, List> dataMap=new HashMap<String, List>();
|
||||
List<IpPortCfg> ipPortList = websiteCfgDao.getIpPortList(entity);
|
||||
List<HttpUrlCfg> httpUrlList = websiteCfgDao.getHttpUrlList(entity);
|
||||
List<HttpReqHeadCfg> httpReqHdrList = websiteCfgDao.getHttpReqHdrList(entity);
|
||||
List<HttpResHeadCfg> httpResHdrList = websiteCfgDao.getHttpResHdrList(entity);
|
||||
List<NtcSubscribeIdCfg> subscribeIdList = stringCfgDao.findSubscribeIdCfgListByCfgIndexInfo(entity);
|
||||
entity.setCfgType(Constants.HTTP_REQ_BODY_REGION);
|
||||
List<HttpBodyCfg> httpReqBodyList = websiteCfgDao.getHttpReqBodyList(entity);
|
||||
entity.setCfgType(Constants.HTTP_RES_BODY_REGION);
|
||||
List<HttpBodyCfg> httpResBodyList = websiteCfgDao.getHttpResBodyList(entity);
|
||||
dataMap.put("NTC_UNIVERSAL_IP", ipPortList);
|
||||
dataMap.put("NTC_HTTP_URL", httpUrlList);
|
||||
dataMap.put("NTC_HTTP_REQ_HDR", httpReqHdrList);
|
||||
dataMap.put("NTC_HTTP_RES_HDR", httpResHdrList);
|
||||
dataMap.put("NTC_HTTP_REQ_BODY", httpReqBodyList);
|
||||
dataMap.put("NTC_HTTP_RES_BODY", httpResBodyList);
|
||||
dataMap.put("NTC_SUBSCRIBE_ID", subscribeIdList);
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
public CfgIndexInfo getSslCfg(Long cfgId){
|
||||
CfgIndexInfo entity = websiteCfgDao.getCfgIndexInfo(cfgId);
|
||||
List<IpPortCfg> ipPortList = websiteCfgDao.getIpPortList(entity);
|
||||
|
||||
Reference in New Issue
Block a user