2017-12-29 16:18:40 +08:00
|
|
|
|
package com.nis.web.controller;
|
|
|
|
|
|
import java.beans.PropertyEditorSupport;
|
|
|
|
|
|
import java.io.IOException;
|
2018-07-10 13:33:28 +08:00
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import java.util.ArrayList;
|
2018-07-10 13:33:28 +08:00
|
|
|
|
import java.util.Calendar;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import java.util.Date;
|
2018-06-05 17:52:26 +08:00
|
|
|
|
import java.util.HashMap;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import java.util.List;
|
2018-06-05 17:52:26 +08:00
|
|
|
|
import java.util.Map;
|
2018-06-13 09:30:03 +08:00
|
|
|
|
import java.util.Properties;
|
2018-07-02 16:04:41 +08:00
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
|
import java.util.regex.Pattern;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
|
2018-06-13 09:58:13 +08:00
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringEscapeUtils;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import org.apache.log4j.Logger;
|
2018-07-02 16:04:41 +08:00
|
|
|
|
import org.jets3t.service.ServiceException;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
2018-06-13 09:30:03 +08:00
|
|
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
|
|
import org.springframework.web.bind.WebDataBinder;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.InitBinder;
|
|
|
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
|
2018-06-13 09:58:13 +08:00
|
|
|
|
import com.beust.jcommander.internal.Lists;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
import com.nis.domain.FunctionRegionDict;
|
|
|
|
|
|
import com.nis.domain.FunctionServiceDict;
|
2018-07-02 16:04:41 +08:00
|
|
|
|
import com.nis.domain.SysDataDictionaryItem;
|
2018-07-27 10:16:32 +08:00
|
|
|
|
import com.nis.domain.basics.PolicyGroupInfo;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import com.nis.domain.basics.ServiceDictInfo;
|
|
|
|
|
|
import com.nis.domain.basics.SysDictInfo;
|
|
|
|
|
|
import com.nis.domain.configuration.AreaBean;
|
|
|
|
|
|
import com.nis.domain.configuration.AreaIpCfg;
|
|
|
|
|
|
import com.nis.domain.configuration.BaseCfg;
|
|
|
|
|
|
import com.nis.domain.configuration.BaseIpCfg;
|
2018-06-13 09:58:13 +08:00
|
|
|
|
import com.nis.domain.configuration.ComplexStringCfgTemplate;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import com.nis.domain.configuration.RequestInfo;
|
2018-06-13 09:58:13 +08:00
|
|
|
|
import com.nis.domain.configuration.StringCfgTemplate;
|
2018-07-30 14:41:27 +08:00
|
|
|
|
import com.nis.domain.configuration.template.IpCfgTemplate;
|
2018-06-13 14:36:58 +08:00
|
|
|
|
import com.nis.domain.log.BaseLogEntity;
|
2018-07-06 16:51:23 +08:00
|
|
|
|
import com.nis.domain.log.SearchReport;
|
2018-07-02 16:04:41 +08:00
|
|
|
|
import com.nis.exceptions.MaatConvertException;
|
2018-06-13 09:30:03 +08:00
|
|
|
|
import com.nis.util.Configurations;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
//import com.nis.main.ConvertTool;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import com.nis.util.Constants;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import com.nis.util.DateUtils;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
import com.nis.util.DictUtils;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import com.nis.util.JsonMapper;
|
2018-08-18 14:59:49 +08:00
|
|
|
|
import com.nis.util.StringUtil;
|
2018-06-13 09:58:13 +08:00
|
|
|
|
import com.nis.util.excel.ExportExcel;
|
2018-08-21 11:42:33 +08:00
|
|
|
|
import com.nis.web.dao.configuration.InterceptCfgDao;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import com.nis.web.service.ArchiveServcie;
|
|
|
|
|
|
import com.nis.web.service.AreaService;
|
|
|
|
|
|
import com.nis.web.service.DictService;
|
|
|
|
|
|
import com.nis.web.service.LogService;
|
|
|
|
|
|
import com.nis.web.service.MenuService;
|
|
|
|
|
|
import com.nis.web.service.OfficeService;
|
|
|
|
|
|
import com.nis.web.service.RoleService;
|
|
|
|
|
|
import com.nis.web.service.SystemService;
|
|
|
|
|
|
import com.nis.web.service.UserService;
|
2018-06-20 13:33:46 +08:00
|
|
|
|
import com.nis.web.service.basics.PolicyGroupInfoService;
|
2018-03-06 10:31:18 +08:00
|
|
|
|
import com.nis.web.service.basics.ServiceDictInfoService;
|
|
|
|
|
|
import com.nis.web.service.basics.SysDictInfoService;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
import com.nis.web.service.configuration.AppCfgService;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
import com.nis.web.service.configuration.AvCfgService;
|
2018-05-22 17:30:52 +08:00
|
|
|
|
import com.nis.web.service.configuration.AvContentCfgService;
|
2018-06-13 09:30:03 +08:00
|
|
|
|
import com.nis.web.service.configuration.BgpCfgService;
|
2018-02-28 12:16:37 +08:00
|
|
|
|
import com.nis.web.service.configuration.ComplexStringCfgService;
|
2018-06-23 14:08:53 +08:00
|
|
|
|
import com.nis.web.service.configuration.ControlPolicyService;
|
2018-06-29 15:39:11 +08:00
|
|
|
|
import com.nis.web.service.configuration.DdosCfgService;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import com.nis.web.service.configuration.DnsIpCfgService;
|
2018-06-22 10:12:54 +08:00
|
|
|
|
import com.nis.web.service.configuration.DnsResStrategyService;
|
2018-07-06 17:13:46 +08:00
|
|
|
|
import com.nis.web.service.configuration.DomainService;
|
2018-06-05 11:06:37 +08:00
|
|
|
|
import com.nis.web.service.configuration.FileTransferCfgService;
|
2018-06-29 13:56:08 +08:00
|
|
|
|
import com.nis.web.service.configuration.HttpRedirectCfgService;
|
2018-08-21 11:42:33 +08:00
|
|
|
|
import com.nis.web.service.configuration.InterceptCfgService;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
import com.nis.web.service.configuration.IpCfgService;
|
2018-07-01 16:08:55 +08:00
|
|
|
|
import com.nis.web.service.configuration.IpMultiplexPoolCfgService;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
import com.nis.web.service.configuration.MailCfgService;
|
2018-02-28 12:16:37 +08:00
|
|
|
|
import com.nis.web.service.configuration.NumCfgService;
|
2018-08-21 11:42:33 +08:00
|
|
|
|
import com.nis.web.service.configuration.ProxyFileStrategyService;
|
2018-02-25 18:43:20 +08:00
|
|
|
|
import com.nis.web.service.configuration.RequestInfoService;
|
2018-05-25 13:25:21 +08:00
|
|
|
|
import com.nis.web.service.configuration.WebsiteCfgService;
|
2018-06-13 10:18:06 +08:00
|
|
|
|
import com.nis.web.service.configuration.XmppCfgService;
|
2018-07-11 16:15:23 +08:00
|
|
|
|
import com.nis.web.service.configuration.statistics.ConfigureStatisticsService;
|
2018-03-17 17:09:19 +08:00
|
|
|
|
import com.nis.web.service.specific.SpecificServiceCfgService;
|
|
|
|
|
|
import com.nis.web.service.specific.SpecificServiceHostCfgService;
|
2018-02-23 09:16:32 +08:00
|
|
|
|
import com.nis.web.service.systemService.ServiceConfigInfoService;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
|
|
|
|
|
|
public class BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected UserService userService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected SystemService systemService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected OfficeService officeService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected AreaService areaService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected RoleService roleService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected MenuService menuService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected LogService logService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected ArchiveServcie archiveServcie;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected DictService dictService;
|
|
|
|
|
|
|
2018-01-09 16:50:39 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected IpCfgService ipCfgService;
|
|
|
|
|
|
|
2018-03-22 14:41:10 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected DnsIpCfgService dnsIpCfgService;
|
|
|
|
|
|
|
2018-01-09 16:50:39 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected MailCfgService mailCfgService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2018-06-05 11:06:37 +08:00
|
|
|
|
protected FileTransferCfgService fileTransferCfgService;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected AppCfgService appCfgService;
|
2018-06-23 14:08:53 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected ControlPolicyService controlPolicyService;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
|
2018-02-09 16:50:27 +08:00
|
|
|
|
|
2018-02-23 09:16:32 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected ServiceDictInfoService serviceDictInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected SysDictInfoService sysDictInfoService;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
|
2018-02-23 09:16:32 +08:00
|
|
|
|
protected final Logger logger = Logger.getLogger(this.getClass());
|
2017-12-29 16:18:40 +08:00
|
|
|
|
|
2018-02-23 09:16:32 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected ServiceConfigInfoService serviceConfigInfoService;
|
2018-02-25 18:43:20 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected RequestInfoService requestInfoService;
|
2018-02-27 15:31:30 +08:00
|
|
|
|
@Autowired
|
2018-06-29 12:44:33 +08:00
|
|
|
|
protected DomainService domainService;
|
2018-02-28 12:16:37 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected NumCfgService numCfgService;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected ComplexStringCfgService complexStringCfgService;
|
2018-03-17 17:09:19 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected SpecificServiceCfgService specificServiceCfgService;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected SpecificServiceHostCfgService specificServiceHostCfgService;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected AvCfgService avCfgService;
|
2018-05-22 17:30:52 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected AvContentCfgService avContentCfgService;
|
2018-05-25 13:25:21 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected WebsiteCfgService websiteCfgService;
|
2018-06-13 09:30:03 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected BgpCfgService bgpCfgService;
|
2018-06-13 10:18:06 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected XmppCfgService xmppCfgService;
|
2018-06-20 13:33:46 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected PolicyGroupInfoService policyGroupInfoService;
|
2018-06-22 10:12:54 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected DnsResStrategyService dnsResStrategyService;
|
2018-06-29 13:56:08 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected HttpRedirectCfgService httpRedirectCfgService;
|
2018-06-29 15:39:11 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected DdosCfgService ddosCfgService;
|
2018-07-01 16:08:55 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected IpMultiplexPoolCfgService ipMultiplexPoolCfgService;
|
2018-07-11 16:15:23 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected ConfigureStatisticsService configureStatisticsService;
|
2018-08-21 11:42:33 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected InterceptCfgService interceptCfgService;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected ProxyFileStrategyService proxyFileStrategyService;//代理文件策略service
|
|
|
|
|
|
|
2017-12-29 16:18:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 管理基础路径
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Value("${adminPath}")
|
|
|
|
|
|
protected String adminPath;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 前端基础路径
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Value("${frontPath}")
|
|
|
|
|
|
protected String frontPath;
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 前端URL后缀
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Value("${urlSuffix}")
|
|
|
|
|
|
protected String urlSuffix;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 客户端返回JSON字符串
|
|
|
|
|
|
* @param response
|
|
|
|
|
|
* @param object
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected String renderString(HttpServletResponse response, Object object) {
|
|
|
|
|
|
return renderString(response, JsonMapper.toJsonString(object), "application/json");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 客户端返回字符串
|
|
|
|
|
|
* @param response
|
|
|
|
|
|
* @param string
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected String renderString(HttpServletResponse response, String string, String type) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
response.reset();
|
|
|
|
|
|
response.setContentType(type);
|
|
|
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
|
|
|
response.getWriter().print(string);
|
|
|
|
|
|
return null;
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 添加Model消息
|
|
|
|
|
|
* @param message
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected void addMessage(Model model, String... messages) {
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
for (String message : messages){
|
|
|
|
|
|
sb.append(message).append(messages.length>1?"<br/>":"");
|
|
|
|
|
|
}
|
|
|
|
|
|
model.addAttribute("message", sb.toString());
|
|
|
|
|
|
}
|
2018-08-03 10:59:20 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 添加Model消息 日志用
|
|
|
|
|
|
* @param message
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected void addMessageLog(Model model, String status) {
|
|
|
|
|
|
//status 接口状态码
|
|
|
|
|
|
String messages="search_error";
|
|
|
|
|
|
if(null!=status){
|
|
|
|
|
|
if("400".equals(status)){
|
|
|
|
|
|
messages="data_format_error";
|
|
|
|
|
|
}else if("500".equals(status)){
|
|
|
|
|
|
messages="server_internal_error";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
model.addAttribute("message",messages);
|
|
|
|
|
|
}
|
2017-12-29 16:18:40 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 添加Flash消息
|
|
|
|
|
|
* @param message
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected void addMessage(RedirectAttributes redirectAttributes, String... messages) {
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
for (String message : messages){
|
|
|
|
|
|
sb.append(message).append(messages.length>1?"<br/>":"");
|
|
|
|
|
|
}
|
|
|
|
|
|
redirectAttributes.addFlashAttribute("message", sb.toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 初始化数据绑定
|
|
|
|
|
|
* 1. 将所有传递进来的String进行HTML编码,防止XSS攻击
|
|
|
|
|
|
* 2. 将字段中Date类型转换为String类型
|
|
|
|
|
|
*/
|
|
|
|
|
|
@InitBinder
|
|
|
|
|
|
protected void initBinder(WebDataBinder binder) {
|
|
|
|
|
|
// String类型转换,将所有传递进来的String进行HTML编码,防止XSS攻击
|
|
|
|
|
|
binder.registerCustomEditor(String.class, new PropertyEditorSupport() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void setAsText(String text) {
|
|
|
|
|
|
setValue(text == null ? null : StringEscapeUtils.escapeHtml4(text.trim()));
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String getAsText() {
|
|
|
|
|
|
Object value = getValue();
|
|
|
|
|
|
return value != null ? value.toString() : "";
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
// Date 类型转换
|
|
|
|
|
|
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void setAsText(String text) {
|
|
|
|
|
|
setValue(DateUtils.parseDate(text));
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
protected void initPageCondition(Model model){
|
|
|
|
|
|
List<RequestInfo> requestInfos=requestInfoService.getAllRequestInfo();
|
|
|
|
|
|
model.addAttribute("requestInfos", requestInfos);
|
|
|
|
|
|
List<ServiceDictInfo> fls=serviceDictInfoService.findAllFlDict();
|
2018-07-06 17:13:46 +08:00
|
|
|
|
String pNames="";
|
|
|
|
|
|
for (ServiceDictInfo serviceDictInfo : fls) {
|
|
|
|
|
|
pNames="";
|
|
|
|
|
|
pNames=serviceDictInfo.getPNames(fls, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("fls", fls);
|
|
|
|
|
|
List<ServiceDictInfo> xzs=serviceDictInfoService.findAllXzDict();
|
2018-07-06 17:13:46 +08:00
|
|
|
|
for (ServiceDictInfo serviceDictInfo : xzs) {
|
|
|
|
|
|
pNames="";
|
|
|
|
|
|
pNames=serviceDictInfo.getPNames(xzs, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("xzs", xzs);
|
|
|
|
|
|
List<ServiceDictInfo> lables=serviceDictInfoService.findAllLableDict();
|
2018-07-06 17:13:46 +08:00
|
|
|
|
for (ServiceDictInfo serviceDictInfo : lables) {
|
|
|
|
|
|
pNames="";
|
|
|
|
|
|
pNames=serviceDictInfo.getPNames(lables, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("lables", lables);
|
|
|
|
|
|
}
|
2018-05-21 19:42:24 +08:00
|
|
|
|
protected void initPageCondition(Model model,BaseCfg cfg){
|
|
|
|
|
|
List<RequestInfo> requestInfos=requestInfoService.getAllRequestInfo();
|
|
|
|
|
|
model.addAttribute("requestInfos", requestInfos);
|
|
|
|
|
|
List<ServiceDictInfo> fls=serviceDictInfoService.findAllFlDict();
|
2018-07-06 17:13:46 +08:00
|
|
|
|
String pNames="";
|
|
|
|
|
|
for (ServiceDictInfo serviceDictInfo : fls) {
|
|
|
|
|
|
pNames="";
|
|
|
|
|
|
pNames=serviceDictInfo.getPNames(fls, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-05-21 19:42:24 +08:00
|
|
|
|
model.addAttribute("fls", fls);
|
|
|
|
|
|
List<ServiceDictInfo> xzs=serviceDictInfoService.findAllXzDict();
|
2018-07-06 17:13:46 +08:00
|
|
|
|
for (ServiceDictInfo serviceDictInfo : xzs) {
|
|
|
|
|
|
pNames="";
|
|
|
|
|
|
pNames=serviceDictInfo.getPNames(xzs, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-05-21 19:42:24 +08:00
|
|
|
|
model.addAttribute("xzs", xzs);
|
|
|
|
|
|
List<ServiceDictInfo> lables=serviceDictInfoService.findAllLableDict();
|
2018-07-06 17:13:46 +08:00
|
|
|
|
for (ServiceDictInfo serviceDictInfo : lables) {
|
|
|
|
|
|
pNames="";
|
|
|
|
|
|
pNames=serviceDictInfo.getPNames(lables, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-05-21 19:42:24 +08:00
|
|
|
|
model.addAttribute("lables", lables);
|
|
|
|
|
|
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("regionList", regionList);
|
|
|
|
|
|
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("serviceList", serviceList);
|
|
|
|
|
|
}
|
2018-07-06 16:51:23 +08:00
|
|
|
|
protected void initReportCondition(Model model,SearchReport report){
|
|
|
|
|
|
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(report.getFunctionId());
|
2018-05-21 19:42:24 +08:00
|
|
|
|
model.addAttribute("serviceList", serviceList);
|
2018-07-11 16:15:23 +08:00
|
|
|
|
if (StringUtils.isBlank(report.getReportTime())) {
|
|
|
|
|
|
report.setReportTime(DateUtils.formatDate(new Date(), "yyyy-MM-dd"));
|
|
|
|
|
|
}
|
2018-07-12 15:28:46 +08:00
|
|
|
|
if (report.getReportType() == null) {
|
|
|
|
|
|
report.setReportType(1);
|
|
|
|
|
|
}
|
2018-05-21 19:42:24 +08:00
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
protected void initFormCondition(Model model){
|
|
|
|
|
|
List<RequestInfo> requestInfos=requestInfoService.getValidRequestInfo();
|
|
|
|
|
|
model.addAttribute("requestInfos", requestInfos);
|
|
|
|
|
|
List<ServiceDictInfo> fls=serviceDictInfoService.findFlDict();
|
2018-07-06 17:13:46 +08:00
|
|
|
|
String pNames="";
|
|
|
|
|
|
for (ServiceDictInfo serviceDictInfo : fls) {
|
|
|
|
|
|
pNames="";
|
|
|
|
|
|
pNames=serviceDictInfo.getPNames(fls, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("fls", fls);
|
|
|
|
|
|
List<ServiceDictInfo> xzs=serviceDictInfoService.findXzDict();
|
2018-07-06 17:13:46 +08:00
|
|
|
|
for (ServiceDictInfo serviceDictInfo : xzs) {
|
|
|
|
|
|
pNames="";
|
|
|
|
|
|
pNames=serviceDictInfo.getPNames(xzs, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("xzs", xzs);
|
|
|
|
|
|
List<ServiceDictInfo> lables=serviceDictInfoService.findLableDict();
|
2018-07-06 17:13:46 +08:00
|
|
|
|
for (ServiceDictInfo serviceDictInfo : lables) {
|
|
|
|
|
|
pNames="";
|
|
|
|
|
|
pNames=serviceDictInfo.getPNames(lables, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("lables", lables);
|
|
|
|
|
|
List<Integer> itTypeList=new ArrayList<Integer>();
|
|
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_AREA);
|
|
|
|
|
|
List<SysDictInfo> areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
|
|
|
|
|
|
model.addAttribute("areas", areas);
|
|
|
|
|
|
itTypeList.clear();
|
|
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_ISP);
|
|
|
|
|
|
List<SysDictInfo> isps = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
|
|
|
|
|
|
model.addAttribute("isps", isps);
|
|
|
|
|
|
//初始化一个默认的地域ip给界面
|
|
|
|
|
|
AreaIpCfg areaIpCfg=new AreaIpCfg();
|
|
|
|
|
|
areaIpCfg.initDefaultValue();
|
|
|
|
|
|
model.addAttribute("_areaCfg", areaIpCfg);
|
|
|
|
|
|
}
|
2018-05-18 16:46:46 +08:00
|
|
|
|
protected void initFormCondition(Model model,BaseCfg cfg){
|
|
|
|
|
|
List<RequestInfo> requestInfos=requestInfoService.getValidRequestInfo();
|
|
|
|
|
|
model.addAttribute("requestInfos", requestInfos);
|
|
|
|
|
|
List<ServiceDictInfo> fls=serviceDictInfoService.findFlDict();
|
2018-07-06 17:13:46 +08:00
|
|
|
|
String pNames="";
|
|
|
|
|
|
for (ServiceDictInfo serviceDictInfo : fls) {
|
|
|
|
|
|
pNames="";
|
|
|
|
|
|
pNames=serviceDictInfo.getPNames(fls, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-05-18 16:46:46 +08:00
|
|
|
|
model.addAttribute("fls", fls);
|
|
|
|
|
|
List<ServiceDictInfo> xzs=serviceDictInfoService.findXzDict();
|
2018-07-06 17:13:46 +08:00
|
|
|
|
for (ServiceDictInfo serviceDictInfo : xzs) {
|
|
|
|
|
|
pNames="";
|
|
|
|
|
|
pNames=serviceDictInfo.getPNames(xzs, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-05-18 16:46:46 +08:00
|
|
|
|
model.addAttribute("xzs", xzs);
|
|
|
|
|
|
List<ServiceDictInfo> lables=serviceDictInfoService.findLableDict();
|
2018-07-06 17:13:46 +08:00
|
|
|
|
for (ServiceDictInfo serviceDictInfo : lables) {
|
|
|
|
|
|
pNames="";
|
|
|
|
|
|
pNames=serviceDictInfo.getPNames(lables, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-05-18 16:46:46 +08:00
|
|
|
|
model.addAttribute("lables", lables);
|
|
|
|
|
|
List<Integer> itTypeList=new ArrayList<Integer>();
|
|
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_AREA);
|
|
|
|
|
|
List<SysDictInfo> areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
|
|
|
|
|
|
model.addAttribute("areas", areas);
|
|
|
|
|
|
itTypeList.clear();
|
|
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_ISP);
|
|
|
|
|
|
List<SysDictInfo> isps = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
|
|
|
|
|
|
model.addAttribute("isps", isps);
|
|
|
|
|
|
//初始化一个默认的地域ip给界面
|
|
|
|
|
|
AreaIpCfg areaIpCfg=new AreaIpCfg();
|
|
|
|
|
|
areaIpCfg.initDefaultValue();
|
|
|
|
|
|
model.addAttribute("_areaCfg", areaIpCfg);
|
|
|
|
|
|
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("regionList", regionList);
|
|
|
|
|
|
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("serviceList", serviceList);
|
2018-05-25 16:01:01 +08:00
|
|
|
|
//ip配置设置protocolId
|
|
|
|
|
|
if(cfg instanceof BaseIpCfg){
|
|
|
|
|
|
for(FunctionServiceDict dict:serviceList){
|
|
|
|
|
|
if(cfg.getFunctionId().intValue()==dict.getFunctionId().intValue()){
|
|
|
|
|
|
((BaseIpCfg) cfg).setProtocolId(dict.getProtocolId().intValue());
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-05-18 16:46:46 +08:00
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
protected void initUpdateFormCondition(Model model,BaseCfg cfg){
|
2018-06-01 18:13:07 +08:00
|
|
|
|
List<Integer> itTypeList=new ArrayList<Integer>();
|
|
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_AREA);
|
|
|
|
|
|
List<SysDictInfo> areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
|
|
|
|
|
|
model.addAttribute("areas", areas);
|
|
|
|
|
|
itTypeList.clear();
|
|
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_ISP);
|
|
|
|
|
|
List<SysDictInfo> isps = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
|
|
|
|
|
|
model.addAttribute("isps", isps);
|
|
|
|
|
|
|
2018-04-09 16:38:45 +08:00
|
|
|
|
//查询配置对应的地域ip
|
|
|
|
|
|
List<AreaIpCfg> areaCfgs=ipCfgService.getAreaCfgByCompileId(cfg.getCompileId());
|
|
|
|
|
|
model.addAttribute("areaCfgs", areaCfgs);
|
|
|
|
|
|
StringBuffer areaCfgIds=new StringBuffer();
|
|
|
|
|
|
for(AreaIpCfg areaCfg:areaCfgs){
|
|
|
|
|
|
areaCfgIds.append(areaCfg.getCfgId()+",");
|
|
|
|
|
|
}
|
|
|
|
|
|
//update时判断是否有删除地域ip
|
|
|
|
|
|
model.addAttribute("areaCfgIds", areaCfgIds.toString());
|
|
|
|
|
|
//初始化一个默认的地域ip给界面
|
|
|
|
|
|
AreaIpCfg areaIpCfg=new AreaIpCfg();
|
|
|
|
|
|
areaIpCfg.initDefaultValue();
|
|
|
|
|
|
model.addAttribute("_areaCfg", areaIpCfg);
|
|
|
|
|
|
//从区域生效ID中获取区域与运营商
|
|
|
|
|
|
String areaEffectiveIds=cfg.getAreaEffectiveIds();
|
|
|
|
|
|
List<AreaBean> areaIspList=new ArrayList<AreaBean>();
|
2018-06-05 17:52:26 +08:00
|
|
|
|
getAreaIsps(areaEffectiveIds,areaIspList,isps,areas);
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("_areaIsps", areaIspList);
|
2018-06-30 15:32:56 +08:00
|
|
|
|
List<RequestInfo> requestInfos=requestInfoService.getValidRequestInfo();//只查询有效的
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("requestInfos", requestInfos);
|
2018-06-30 15:32:56 +08:00
|
|
|
|
List<ServiceDictInfo> fls=serviceDictInfoService.findFlDict();//只查询有效分类字典
|
2018-07-06 17:13:46 +08:00
|
|
|
|
String pNames="";
|
|
|
|
|
|
for (ServiceDictInfo serviceDictInfo : fls) {
|
|
|
|
|
|
pNames="";
|
|
|
|
|
|
pNames=serviceDictInfo.getPNames(fls, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("fls", fls);
|
2018-06-30 15:32:56 +08:00
|
|
|
|
List<ServiceDictInfo> xzs=serviceDictInfoService.findXzDict();//只查询有效性质字典
|
2018-07-06 17:13:46 +08:00
|
|
|
|
for (ServiceDictInfo serviceDictInfo : xzs) {
|
|
|
|
|
|
pNames="";
|
|
|
|
|
|
pNames=serviceDictInfo.getPNames(xzs, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("xzs", xzs);
|
2018-06-30 15:32:56 +08:00
|
|
|
|
List<ServiceDictInfo> lables=serviceDictInfoService.findLableDict();//只查询有效标签字典
|
2018-07-06 17:13:46 +08:00
|
|
|
|
for (ServiceDictInfo serviceDictInfo : lables) {
|
|
|
|
|
|
pNames="";
|
|
|
|
|
|
pNames=serviceDictInfo.getPNames(lables, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("lables", lables);
|
2018-05-18 16:46:46 +08:00
|
|
|
|
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("regionList", regionList);
|
|
|
|
|
|
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("serviceList", serviceList);
|
2018-04-09 16:38:45 +08:00
|
|
|
|
}
|
2018-06-05 17:52:26 +08:00
|
|
|
|
public List<AreaBean> getAreaIsps(String areaEffectiveIds,List<AreaBean> areaIspList,List<SysDictInfo> isps,List<SysDictInfo> areas) {
|
|
|
|
|
|
Map<String, SysDictInfo> areaMap=new HashMap<String, SysDictInfo>();
|
|
|
|
|
|
for (SysDictInfo areaDict : areas) {
|
|
|
|
|
|
areaMap.put(areaDict.getItemCode(), areaDict);
|
|
|
|
|
|
}
|
|
|
|
|
|
Map<String, SysDictInfo> ispMap=new HashMap<String, SysDictInfo>();
|
|
|
|
|
|
for (SysDictInfo ispDict : isps) {
|
|
|
|
|
|
ispMap.put(ispDict.getItemCode(), ispDict);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// : 存在冒号,则冒号前为area后为isp;不存在冒号,判断id是否为isp,否则为area
|
|
|
|
|
|
if(StringUtils.isNotBlank(areaEffectiveIds)){
|
|
|
|
|
|
String[] areaIsps=areaEffectiveIds.split(",");
|
|
|
|
|
|
for(String areaIsp:areaIsps){
|
|
|
|
|
|
AreaBean area=new AreaBean();
|
|
|
|
|
|
if(areaIsp.contains(":")){
|
|
|
|
|
|
area.setArea(areaIsp.split(":")[0]);
|
|
|
|
|
|
area.setIsp(areaIsp.split(":")[1]);
|
|
|
|
|
|
area.setAreaName(areaMap.get(areaIsp.split(":")[0]).getItemValue());
|
|
|
|
|
|
area.setIspName(ispMap.get(areaIsp.split(":")[1]).getItemValue());
|
|
|
|
|
|
}else{
|
|
|
|
|
|
if(ispMap.keySet().contains(areaIsp)){
|
|
|
|
|
|
area.setIsp(areaIsp);
|
|
|
|
|
|
area.setIspName(ispMap.get(areaIsp).getItemValue());
|
|
|
|
|
|
area.setAreaName("");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
area.setArea(areaIsp);
|
|
|
|
|
|
area.setIspName("");
|
|
|
|
|
|
area.setAreaName(areaMap.get(areaIsp).getItemValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
areaIspList.add(area);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return areaIspList;
|
|
|
|
|
|
}
|
2018-06-13 09:30:03 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取国际化配置文件
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public Properties getMsgProp(){
|
|
|
|
|
|
Properties msgProp = new Properties();
|
|
|
|
|
|
try {
|
|
|
|
|
|
String language = LocaleContextHolder.getLocale().getLanguage();
|
|
|
|
|
|
if(language.equals("zh_cn")||language.equals("zh")){
|
|
|
|
|
|
msgProp.load(Configurations.class.getResourceAsStream("/messages/message_zh_CN.properties"));
|
|
|
|
|
|
}else if(language.equals("ru")){
|
|
|
|
|
|
msgProp.load(Configurations.class.getResourceAsStream("/messages/message_ru.properties"));
|
|
|
|
|
|
}else{
|
|
|
|
|
|
msgProp.load(Configurations.class.getResourceAsStream("/messages/message_en.properties"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
msgProp = null;
|
|
|
|
|
|
logger.error("未知i18n消息配置文件,请确定文件是否存在!",e);
|
|
|
|
|
|
}
|
|
|
|
|
|
return msgProp;
|
|
|
|
|
|
}
|
2018-06-13 09:58:13 +08:00
|
|
|
|
public void importCfgTemplate(HttpServletRequest request,HttpServletResponse response,
|
|
|
|
|
|
RedirectAttributes redirectAttributes,Integer functionId,Integer cfgRegionCode){
|
|
|
|
|
|
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(new IpCfgTemplate());
|
2018-06-15 09:33:53 +08:00
|
|
|
|
new ExportExcel(msgProp,null, IpCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
2018-06-13 09:58:13 +08:00
|
|
|
|
write(request,response, fileName).dispose();
|
|
|
|
|
|
}else if(dict.getRegionType()==2){
|
|
|
|
|
|
List<StringCfgTemplate> list = Lists.newArrayList();
|
|
|
|
|
|
list.add(new StringCfgTemplate());
|
2018-06-15 09:33:53 +08:00
|
|
|
|
new ExportExcel(msgProp,null, StringCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
2018-06-13 09:58:13 +08:00
|
|
|
|
write(request,response, fileName).dispose();
|
|
|
|
|
|
}else if(dict.getRegionType()==3){
|
|
|
|
|
|
List<ComplexStringCfgTemplate> list = Lists.newArrayList();
|
|
|
|
|
|
list.add(new ComplexStringCfgTemplate());
|
2018-06-15 09:33:53 +08:00
|
|
|
|
new ExportExcel(msgProp,null, ComplexStringCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
2018-06-13 09:58:13 +08:00
|
|
|
|
write(request,response, fileName).dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
msgProp = null;
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-27 10:16:32 +08:00
|
|
|
|
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();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-06-13 14:36:58 +08:00
|
|
|
|
|
2018-08-18 14:59:49 +08:00
|
|
|
|
public void setLogAction(BaseLogEntity log,List<FunctionServiceDict> serviceList) {
|
|
|
|
|
|
if(!StringUtil.isEmpty(serviceList)){
|
|
|
|
|
|
for (FunctionServiceDict dict : serviceList) {
|
|
|
|
|
|
if (dict.getServiceId().intValue() == log.getService()) {
|
|
|
|
|
|
log.setAction(dict.getAction());
|
|
|
|
|
|
}
|
2018-06-14 10:37:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-06-13 14:36:58 +08:00
|
|
|
|
}
|
2018-06-14 10:37:59 +08:00
|
|
|
|
|
2018-06-13 16:25:00 +08:00
|
|
|
|
//初始化查询值判断
|
|
|
|
|
|
public void initLogSearchValue(BaseLogEntity entry,Map<String, Object> params){
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(entry.getSearchFoundStartTime())&&StringUtils.isNotBlank(entry.getSearchFoundEndTime())) {
|
|
|
|
|
|
params.put("searchFoundStartTime", entry.getSearchFoundStartTime());
|
|
|
|
|
|
params.put("searchFoundEndTime", entry.getSearchFoundEndTime());
|
|
|
|
|
|
}else{
|
|
|
|
|
|
//设置默认查询当前时间及前五分钟
|
2018-06-14 10:37:59 +08:00
|
|
|
|
String endTime = DateUtils.getDateTime();
|
|
|
|
|
|
Date dateStart = new Date(new Date().getTime() - Constants.LOG_TIME_RANGE);
|
|
|
|
|
|
String startTime = DateUtils.formatDateTime(dateStart);
|
2018-06-13 16:25:00 +08:00
|
|
|
|
params.put("searchFoundStartTime", startTime);
|
|
|
|
|
|
params.put("searchFoundEndTime",endTime );
|
|
|
|
|
|
entry.setSearchFoundStartTime(startTime);
|
|
|
|
|
|
entry.setSearchFoundEndTime(endTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-03 12:46:06 +08:00
|
|
|
|
if (StringUtils.isNotBlank(entry.getTransProto())) {
|
|
|
|
|
|
params.put("searchTransProto", entry.getTransProto());
|
2018-06-13 16:25:00 +08:00
|
|
|
|
}
|
2018-07-03 12:46:06 +08:00
|
|
|
|
if (entry.getService()!=null) {
|
|
|
|
|
|
params.put("searchService", entry.getService());
|
2018-07-18 19:31:55 +08:00
|
|
|
|
} else if (entry.getAction()!=null) {
|
|
|
|
|
|
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(entry.getFunctionId());
|
|
|
|
|
|
for (FunctionServiceDict dict : serviceList) {
|
|
|
|
|
|
if (dict.getAction().intValue() == entry.getAction().intValue()
|
|
|
|
|
|
&& dict.getFunctionId().intValue() == entry.getFunctionId().intValue()) {
|
|
|
|
|
|
entry.setService(dict.getServiceId());
|
|
|
|
|
|
params.put("searchService", dict.getServiceId());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-06-13 16:25:00 +08:00
|
|
|
|
}
|
2018-07-03 12:46:06 +08:00
|
|
|
|
if (StringUtils.isNotBlank(entry.getdIp())) {
|
|
|
|
|
|
params.put("searchDIp", entry.getdIp());
|
2018-06-13 16:25:00 +08:00
|
|
|
|
}
|
2018-07-03 12:46:06 +08:00
|
|
|
|
if (StringUtils.isNotBlank(entry.getsIp())) {
|
|
|
|
|
|
params.put("searchSIp", entry.getsIp());
|
2018-06-13 16:25:00 +08:00
|
|
|
|
}
|
2018-07-03 12:46:06 +08:00
|
|
|
|
if (StringUtils.isNotBlank(entry.getCapIp())) {
|
|
|
|
|
|
params.put("searchCapIp", entry.getCapIp());
|
2018-06-13 16:25:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (entry.getDirection()!=null) {
|
|
|
|
|
|
params.put("searchDirection", entry.getDirection());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (entry.getEntranceId()!=null) {
|
|
|
|
|
|
params.put("searchEntranceId", entry.getEntranceId());
|
|
|
|
|
|
}
|
2018-06-20 13:33:46 +08:00
|
|
|
|
if (entry.getCfgId()!=null) {
|
|
|
|
|
|
params.put("searchCfgId", entry.getCfgId());
|
|
|
|
|
|
}
|
2018-06-13 16:25:00 +08:00
|
|
|
|
}
|
2018-07-31 12:18:34 +08:00
|
|
|
|
public void checkIpCfg(int action,int functionId ,List<IpCfgTemplate> list) throws ServiceException{
|
2018-07-02 16:04:41 +08:00
|
|
|
|
Properties prop=this.getMsgProp();
|
|
|
|
|
|
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");
|
2018-07-06 17:13:46 +08:00
|
|
|
|
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");
|
2018-08-01 15:27:21 +08:00
|
|
|
|
List<SysDataDictionaryItem> irTypeList = DictUtils.getDictList("IR_TYPE");
|
2018-07-06 17:13:46 +08:00
|
|
|
|
String specialItem=null;
|
|
|
|
|
|
for(SysDataDictionaryItem sfuncItem:specialFunctionIdList){
|
|
|
|
|
|
if(functionId==Integer.parseInt(sfuncItem.getItemCode())){
|
|
|
|
|
|
specialItem=sfuncItem.getItemValue();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-08-01 15:27:21 +08:00
|
|
|
|
if("ipaddr".equals(specialItem)){
|
|
|
|
|
|
List<SysDataDictionaryItem> icmpprotocolList = DictUtils.getDictList("ICMP_PROTOCOL");
|
|
|
|
|
|
if(action==Constants.DROP_ACTION) {
|
|
|
|
|
|
protocolList.addAll(icmpprotocolList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-02 16:04:41 +08:00
|
|
|
|
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();
|
2018-07-27 10:16:32 +08:00
|
|
|
|
String _msg="";
|
|
|
|
|
|
if("ipmulitiplex".equals(specialItem)) {
|
2018-08-21 11:42:33 +08:00
|
|
|
|
_msg=checkIP(prop,prop.getProperty("IP"),srcIp,ipType,ipPattern);
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}else {
|
2018-08-21 11:42:33 +08:00
|
|
|
|
_msg=checkIP(prop,prop.getProperty("client_ip"),srcIp,ipType,ipPattern);
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}
|
2018-07-02 16:04:41 +08:00
|
|
|
|
if(StringUtils.isNotBlank(_msg)){
|
|
|
|
|
|
errInfo.append(_msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
//client_ip check end
|
|
|
|
|
|
//server_ip check start
|
|
|
|
|
|
String destIp=value.getDestIpAddress();
|
2018-07-27 10:16:32 +08:00
|
|
|
|
if("ipmulitiplex".equals(specialItem)) {//set 默认值
|
|
|
|
|
|
if(ipPattern!=null&&ipType!=null) {
|
2018-08-21 11:42:33 +08:00
|
|
|
|
if(1==ipPattern.intValue()) {
|
|
|
|
|
|
if(4==ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(6==ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(46==ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(64==ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(10==ipType.intValue()) {
|
2018-08-13 10:38:04 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(2==ipPattern.intValue()) {
|
|
|
|
|
|
if(4==ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(6==ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(46==ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(64==ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(10==ipType.intValue()) {
|
2018-08-13 10:38:04 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(3==ipPattern.intValue()) {
|
|
|
|
|
|
if(4==ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(6==ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(46==ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(64==ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(10==ipType.intValue()) {
|
2018-08-13 10:38:04 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}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+";");
|
|
|
|
|
|
}
|
2018-08-21 11:42:33 +08:00
|
|
|
|
_msg=checkIP(prop,prop.getProperty("server_ip"),destIp,ipType,ipPattern);
|
2018-07-27 10:16:32 +08:00
|
|
|
|
if(StringUtils.isNotBlank(_msg)){
|
|
|
|
|
|
errInfo.append(_msg);
|
|
|
|
|
|
}
|
2018-07-02 16:04:41 +08:00
|
|
|
|
}
|
2018-08-21 11:42:33 +08:00
|
|
|
|
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);
|
2018-08-13 10:38:04 +08:00
|
|
|
|
if(StringUtils.isNotBlank(_msg)){
|
|
|
|
|
|
errInfo.append(_msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-02 16:04:41 +08:00
|
|
|
|
//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();
|
2018-07-27 10:16:32 +08:00
|
|
|
|
if("ipmulitiplex".equals(specialItem)) {
|
2018-08-21 11:42:33 +08:00
|
|
|
|
_msg=checkPort(prop,prop.getProperty("port"), srcPort, portPattern);
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}else {
|
2018-08-21 11:42:33 +08:00
|
|
|
|
_msg=checkPort(prop,prop.getProperty("client_port"), srcPort, portPattern);
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-02 16:04:41 +08:00
|
|
|
|
if(StringUtils.isNotBlank(_msg)){
|
|
|
|
|
|
errInfo.append(_msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
//src_port check end
|
|
|
|
|
|
//dest_port check start
|
|
|
|
|
|
String destPort=value.getDestPort();
|
2018-07-27 10:16:32 +08:00
|
|
|
|
if("ipmulitiplex".equals(specialItem)) {//set 默认值
|
|
|
|
|
|
if(portPattern!=null) {
|
2018-08-21 11:42:33 +08:00
|
|
|
|
if(2==portPattern.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestPort(Constants.PORT_MASK_DEFAULT);
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(1==portPattern.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestPort(Constants.PORT_DEFAULT);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}else {
|
2018-08-21 11:42:33 +08:00
|
|
|
|
_msg=checkPort(prop,prop.getProperty("server_port"), destPort, portPattern);
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}
|
2018-07-02 16:04:41 +08:00
|
|
|
|
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){
|
2018-07-06 17:13:46 +08:00
|
|
|
|
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)){
|
2018-07-31 12:18:34 +08:00
|
|
|
|
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"))+";");
|
2018-07-06 17:13:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}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"))+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-02 16:04:41 +08:00
|
|
|
|
}
|
2018-07-03 15:54:14 +08:00
|
|
|
|
//protocol check end
|
2018-07-03 17:16:54 +08:00
|
|
|
|
// requestId check start
|
|
|
|
|
|
Integer requestId=value.getRequestId();
|
|
|
|
|
|
if(requestId==null){
|
2018-07-26 11:04:57 +08:00
|
|
|
|
if("whitelistip".equals(specialItem)) {
|
|
|
|
|
|
value.setRequestId(0);
|
|
|
|
|
|
}else {
|
|
|
|
|
|
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("letter"))+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-03 17:16:54 +08:00
|
|
|
|
}else{//查询数据库是否存在ID
|
2018-07-26 11:04:57 +08:00
|
|
|
|
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"))+";");
|
|
|
|
|
|
}
|
2018-07-03 17:16:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 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"))+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-27 10:16:32 +08:00
|
|
|
|
//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){
|
2018-07-31 12:18:34 +08:00
|
|
|
|
if(Integer.parseInt(irTypeItem.getItemCode())==irType.intValue()){
|
2018-07-27 10:16:32 +08:00
|
|
|
|
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")+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-03 17:16:54 +08:00
|
|
|
|
//attribute check end
|
2018-07-02 16:04:41 +08:00
|
|
|
|
if(StringUtils.isNotBlank(errInfo.toString())){
|
|
|
|
|
|
msg.append(lineStart).append(errInfo);
|
|
|
|
|
|
if(line<list.size()){
|
|
|
|
|
|
msg.append("<br/>");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-27 10:16:32 +08:00
|
|
|
|
//group and ir_type check end
|
2018-07-02 16:04:41 +08:00
|
|
|
|
line++;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(StringUtils.isNotBlank(msg.toString())){
|
|
|
|
|
|
throw new MaatConvertException(prop.getProperty("save_failed")+"<br/>"+msg.toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* checkIP(IP格式验证)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @param ipName
|
|
|
|
|
|
* @param ip
|
|
|
|
|
|
* @param ipType
|
|
|
|
|
|
* @param ipPattern
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*String
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static String checkIP(Properties prop,String ipName,String ip,String ipType,String ipPattern){
|
|
|
|
|
|
StringBuffer msg=new StringBuffer();
|
|
|
|
|
|
if(StringUtils.isBlank(ip)){
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("can_not_null"), ipName)+";");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
if("ipv4".equals(ipType)){
|
|
|
|
|
|
if("ip_subnet".equals(ipPattern)){
|
|
|
|
|
|
Pattern pattern=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
|
|
|
|
|
Matcher matcher=pattern.matcher(ip);
|
|
|
|
|
|
if(!matcher.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}else if("ip_range".equals(ipPattern)){
|
|
|
|
|
|
Pattern pattern=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
|
|
|
|
|
|
Matcher matcher=pattern.matcher(ip);
|
|
|
|
|
|
if(!matcher.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}else if("ip".equals(ipPattern)){
|
|
|
|
|
|
Pattern pattern=Pattern.compile(Constants.IPV4_IP_REGEXP);
|
|
|
|
|
|
Matcher matcher=pattern.matcher(ip);
|
|
|
|
|
|
if(!matcher.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}else if("ipv6".equals(ipType)){
|
|
|
|
|
|
if("ip_subnet".equals(ipPattern)){
|
|
|
|
|
|
Pattern pattern=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
|
|
|
|
|
Matcher matcher=pattern.matcher(ip);
|
|
|
|
|
|
if(!matcher.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}else if("ip_range".equals(ipPattern)){
|
|
|
|
|
|
Pattern pattern=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
|
|
|
|
|
Matcher matcher=pattern.matcher(ip);
|
|
|
|
|
|
if(!matcher.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}else if("ip".equals(ipPattern)){
|
|
|
|
|
|
Pattern pattern=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
|
|
|
|
|
Matcher matcher=pattern.matcher(ip);
|
|
|
|
|
|
if(!matcher.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return msg.toString();
|
|
|
|
|
|
}
|
2018-08-21 11:42:33 +08:00
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* checkIP(IP格式验证)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @param ipName
|
|
|
|
|
|
* @param ip
|
|
|
|
|
|
* @param ipType
|
|
|
|
|
|
* @param ipPattern
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*String
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static String checkIP(Properties prop,String ipName,String ip,Integer ipType,Integer ipPattern){
|
|
|
|
|
|
StringBuffer msg=new StringBuffer();
|
|
|
|
|
|
if(StringUtils.isBlank(ip)){
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("can_not_null"), ipName)+";");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
if(4==ipType.intValue()){
|
|
|
|
|
|
if(1==ipPattern.intValue()){
|
|
|
|
|
|
Pattern pattern=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
|
|
|
|
|
Matcher matcher=pattern.matcher(ip);
|
|
|
|
|
|
if(!matcher.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}else if(2==ipPattern.intValue()){
|
|
|
|
|
|
Pattern pattern=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
|
|
|
|
|
|
Matcher matcher=pattern.matcher(ip);
|
|
|
|
|
|
if(!matcher.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}else if(3==ipPattern.intValue()){
|
|
|
|
|
|
Pattern pattern=Pattern.compile(Constants.IPV4_IP_REGEXP);
|
|
|
|
|
|
Matcher matcher=pattern.matcher(ip);
|
|
|
|
|
|
if(!matcher.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}else if(6==ipType.intValue()){
|
|
|
|
|
|
if(1==ipPattern.intValue()){
|
|
|
|
|
|
Pattern pattern=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
|
|
|
|
|
Matcher matcher=pattern.matcher(ip);
|
|
|
|
|
|
if(!matcher.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}else if(2==ipPattern.intValue()){
|
|
|
|
|
|
Pattern pattern=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
|
|
|
|
|
Matcher matcher=pattern.matcher(ip);
|
|
|
|
|
|
if(!matcher.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}else if(3==ipPattern.intValue()){
|
|
|
|
|
|
Pattern pattern=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
|
|
|
|
|
Matcher matcher=pattern.matcher(ip);
|
|
|
|
|
|
if(!matcher.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return msg.toString();
|
|
|
|
|
|
}
|
|
|
|
|
|
public static String checkIp(Properties prop,String srcIpName,String srcIp,String destIpName,String destIp,Integer ipType,Integer ipPattern) {
|
2018-08-13 10:38:04 +08:00
|
|
|
|
StringBuffer msg=new StringBuffer();
|
2018-08-21 11:42:33 +08:00
|
|
|
|
if(46==ipType.intValue()){
|
|
|
|
|
|
if(1==ipPattern.intValue()){
|
2018-08-13 10:38:04 +08:00
|
|
|
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
|
|
|
|
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
|
|
|
|
|
Matcher matcherV4=patternV4.matcher(srcIp);
|
|
|
|
|
|
Matcher matcherV6=patternV6.matcher(destIp);
|
|
|
|
|
|
if(!matcherV4.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!matcherV6.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
|
|
|
|
|
}
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(2==ipPattern.intValue()){
|
2018-08-13 10:38:04 +08:00
|
|
|
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
|
|
|
|
|
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
|
|
|
|
|
Matcher matcherV4=patternV4.matcher(srcIp);
|
|
|
|
|
|
Matcher matcherV6=patternV6.matcher(destIp);
|
|
|
|
|
|
if(!matcherV4.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!matcherV6.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
|
|
|
|
|
}
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(3==ipPattern.intValue()){
|
2018-08-13 10:38:04 +08:00
|
|
|
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
|
|
|
|
|
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
|
|
|
|
|
Matcher matcherV4=patternV4.matcher(srcIp);
|
|
|
|
|
|
Matcher matcherV6=patternV6.matcher(destIp);
|
|
|
|
|
|
if(!matcherV4.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!matcherV6.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(64==ipType.intValue()) {
|
|
|
|
|
|
if(1==ipPattern.intValue()){
|
2018-08-13 10:38:04 +08:00
|
|
|
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
|
|
|
|
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
|
|
|
|
|
Matcher matcherV4=patternV4.matcher(destIp);
|
|
|
|
|
|
Matcher matcherV6=patternV6.matcher(srcIp);
|
|
|
|
|
|
if(!matcherV4.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!matcherV6.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
|
|
|
|
|
}
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(2==ipPattern.intValue()){
|
2018-08-13 10:38:04 +08:00
|
|
|
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
|
|
|
|
|
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
|
|
|
|
|
Matcher matcherV4=patternV4.matcher(destIp);
|
|
|
|
|
|
Matcher matcherV6=patternV6.matcher(srcIp);
|
|
|
|
|
|
if(!matcherV4.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"),destIpName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!matcherV6.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName )+";");
|
|
|
|
|
|
}
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(3==ipPattern.intValue()){
|
2018-08-13 10:38:04 +08:00
|
|
|
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
|
|
|
|
|
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
|
|
|
|
|
Matcher matcherV4=patternV4.matcher(destIp);
|
|
|
|
|
|
Matcher matcherV6=patternV6.matcher(srcIp);
|
|
|
|
|
|
if(!matcherV4.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!matcherV6.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(10==ipType.intValue()) {
|
|
|
|
|
|
if(1==ipPattern.intValue()){
|
2018-08-13 10:38:04 +08:00
|
|
|
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
|
|
|
|
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
|
|
|
|
|
Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
|
|
|
|
|
|
Matcher matcherSrcIpV6=patternV6.matcher(srcIp);
|
|
|
|
|
|
Matcher matcherDestIpV4=patternV4.matcher(destIp);
|
|
|
|
|
|
Matcher matcherDestIpV6=patternV6.matcher(destIp);
|
|
|
|
|
|
if(!matcherSrcIpV4.matches()&&!matcherSrcIpV6.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!matcherDestIpV4.matches()&&!matcherDestIpV6.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
|
|
|
|
|
}
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(2==ipPattern.intValue()){
|
2018-08-13 10:38:04 +08:00
|
|
|
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
|
|
|
|
|
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
|
|
|
|
|
Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
|
|
|
|
|
|
Matcher matcherSrcIpV6=patternV6.matcher(srcIp);
|
|
|
|
|
|
Matcher matcherDestIpV4=patternV4.matcher(destIp);
|
|
|
|
|
|
Matcher matcherDestIpV6=patternV6.matcher(destIp);
|
|
|
|
|
|
if(!matcherSrcIpV4.matches()&&!matcherSrcIpV6.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!matcherDestIpV4.matches()&&!matcherDestIpV6.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
|
|
|
|
|
}
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(3==ipPattern.intValue()){
|
2018-08-13 10:38:04 +08:00
|
|
|
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
|
|
|
|
|
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
|
|
|
|
|
Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
|
|
|
|
|
|
Matcher matcherSrcIpV6=patternV6.matcher(srcIp);
|
|
|
|
|
|
Matcher matcherDestIpV4=patternV4.matcher(destIp);
|
|
|
|
|
|
Matcher matcherDestIpV6=patternV6.matcher(destIp);
|
|
|
|
|
|
if(!matcherSrcIpV4.matches()&&!matcherSrcIpV6.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!matcherDestIpV4.matches()&&!matcherDestIpV6.matches()){//完全匹配
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return msg.toString();
|
|
|
|
|
|
}
|
2018-08-21 11:42:33 +08:00
|
|
|
|
public static String checkPort(Properties prop,String portName,String port,Integer portPattern){
|
2018-07-02 16:04:41 +08:00
|
|
|
|
StringBuffer msg=new StringBuffer();
|
|
|
|
|
|
if(StringUtils.isBlank(port)){
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("can_not_null"), portName)+";");
|
|
|
|
|
|
}else{
|
2018-08-21 11:42:33 +08:00
|
|
|
|
if(1==portPattern.intValue()){
|
2018-07-02 16:04:41 +08:00
|
|
|
|
try{
|
|
|
|
|
|
Integer portInt=Integer.parseInt(port);
|
|
|
|
|
|
if(portInt<0||portInt>65535){
|
|
|
|
|
|
msg.append(portName+" "+String.format(prop.getProperty("must_between"), "0","65535")+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("not_number"), portName)+";");
|
|
|
|
|
|
}
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}else if(2==portPattern.intValue()){
|
2018-07-02 16:04:41 +08:00
|
|
|
|
if(port.indexOf("/")==-1){
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), portName)+";");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
int index=0;
|
|
|
|
|
|
String[] portArray=port.split("/");
|
|
|
|
|
|
for(String portPart:portArray){
|
|
|
|
|
|
try{
|
|
|
|
|
|
Integer portInt=Integer.parseInt(portPart);
|
|
|
|
|
|
if(portInt<0||portInt>65535){
|
|
|
|
|
|
if(index==0){
|
|
|
|
|
|
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("must_between"), portName+" port")+";");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("must_between"), portName+" mask")+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
|
if(index==0){
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("not_number"), portName+" port")+";");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("not_number"), portName+" mask")+";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
index++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return msg.toString();
|
|
|
|
|
|
}
|
2018-07-10 13:33:28 +08:00
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* setReportSearchTime(报表查询设置开始时间与结束时间)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @param bean
|
|
|
|
|
|
* @throws ParseException
|
|
|
|
|
|
*void
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void setReportSearchTime(SearchReport bean) throws ParseException{
|
|
|
|
|
|
SimpleDateFormat sdf=new SimpleDateFormat(Constants.SEARCH_DATEFORMAT);
|
|
|
|
|
|
String reportTime=bean.getReportTime();
|
|
|
|
|
|
if(StringUtils.isNotBlank(reportTime)){
|
|
|
|
|
|
Calendar startCal=Calendar.getInstance();
|
|
|
|
|
|
startCal.setTime(getReportTime(reportTime));
|
|
|
|
|
|
startCal.set(Calendar.MINUTE, 0);
|
|
|
|
|
|
startCal.set(Calendar.SECOND, 0);
|
|
|
|
|
|
startCal.set(Calendar.MILLISECOND, 0);
|
|
|
|
|
|
Calendar endCal=Calendar.getInstance();
|
|
|
|
|
|
endCal.setTime(getReportTime(reportTime));
|
|
|
|
|
|
endCal.set(Calendar.MINUTE, 59);
|
|
|
|
|
|
endCal.set(Calendar.SECOND, 59);
|
|
|
|
|
|
endCal.set(Calendar.MILLISECOND, 0);
|
|
|
|
|
|
if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){
|
|
|
|
|
|
startCal.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
|
|
endCal.set(Calendar.HOUR_OF_DAY, 23);
|
|
|
|
|
|
}else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){
|
|
|
|
|
|
startCal.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
|
|
startCal.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
|
|
|
endCal.set(Calendar.HOUR_OF_DAY, 23);
|
|
|
|
|
|
DateUtils.setLastDayOfMonth(endCal);
|
|
|
|
|
|
}else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){
|
|
|
|
|
|
startCal.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
|
|
startCal.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
|
|
|
startCal.set(Calendar.MONTH, 0);
|
|
|
|
|
|
endCal.set(Calendar.HOUR_OF_DAY, 23);
|
|
|
|
|
|
DateUtils.setLastDayOfMonth(endCal);
|
|
|
|
|
|
endCal.set(Calendar.MONTH, 11);
|
|
|
|
|
|
}
|
|
|
|
|
|
bean.setReportStartTime(startCal.getTime());
|
|
|
|
|
|
bean.setReportEndTime(endCal.getTime());
|
|
|
|
|
|
bean.setSearchReportStartTime(sdf.format(startCal.getTime()));
|
|
|
|
|
|
bean.setSearchReportEndTime(sdf.format(endCal.getTime()));
|
|
|
|
|
|
}else{
|
|
|
|
|
|
Date date=new Date();
|
|
|
|
|
|
bean.setReportEndTime(date);
|
|
|
|
|
|
bean.setSearchReportEndTime(sdf.format(date));
|
|
|
|
|
|
Calendar startCal=Calendar.getInstance();
|
|
|
|
|
|
startCal.setTime(date);
|
|
|
|
|
|
startCal.set(Calendar.MINUTE, 0);
|
|
|
|
|
|
startCal.set(Calendar.SECOND, 0);
|
|
|
|
|
|
startCal.set(Calendar.MILLISECOND, 0);
|
|
|
|
|
|
if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){
|
|
|
|
|
|
startCal.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
|
|
}else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){
|
|
|
|
|
|
startCal.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
|
|
startCal.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
|
|
|
}else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){
|
|
|
|
|
|
startCal.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
|
|
startCal.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
|
|
|
startCal.set(Calendar.MONTH, 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
bean.setReportStartTime(startCal.getTime());
|
|
|
|
|
|
bean.setSearchReportStartTime(sdf.format(startCal.getTime()));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
logger.info("search start time "+bean.getSearchReportStartTime());
|
|
|
|
|
|
logger.info("search end time "+bean.getSearchReportEndTime());
|
|
|
|
|
|
}
|
|
|
|
|
|
public List<String> getDateTitiles(SearchReport bean){
|
|
|
|
|
|
SimpleDateFormat sdf=new SimpleDateFormat(Constants.SEARCH_DATEFORMAT);
|
|
|
|
|
|
List<String> titles=new ArrayList<String>();
|
|
|
|
|
|
Calendar cal=Calendar.getInstance();
|
|
|
|
|
|
cal.setTime(bean.getReportStartTime());
|
|
|
|
|
|
while(cal.getTimeInMillis()<bean.getReportEndTime().getTime()){//构造标题
|
|
|
|
|
|
//报表时间单位加一
|
|
|
|
|
|
if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){
|
|
|
|
|
|
titles.add(sdf.format(cal.getTime()).substring(0,13));
|
|
|
|
|
|
cal.add(Calendar.HOUR_OF_DAY, 1);
|
|
|
|
|
|
}else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){
|
|
|
|
|
|
titles.add(sdf.format(cal.getTime()).substring(0,10));
|
|
|
|
|
|
cal.add(Calendar.DAY_OF_MONTH, 1);
|
|
|
|
|
|
}else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){
|
|
|
|
|
|
titles.add(sdf.format(cal.getTime()).substring(0,7));
|
|
|
|
|
|
cal.add(Calendar.MONTH, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return titles;
|
|
|
|
|
|
}
|
|
|
|
|
|
public Date getReportTime(String reportTime) throws ParseException{
|
|
|
|
|
|
Pattern datePattern=Pattern.compile("^[0-9]{4}-[0-9]{2}-[0-9]{2}$");
|
|
|
|
|
|
Pattern monthPattern=Pattern.compile("^[0-9]{4}-[0-9]{2}$");
|
|
|
|
|
|
Pattern yearPattern=Pattern.compile("^[0-9]{4}$");
|
|
|
|
|
|
Matcher matcher=datePattern.matcher(reportTime);
|
|
|
|
|
|
if(matcher.matches()){
|
|
|
|
|
|
return new SimpleDateFormat("yyyy-MM-dd").parse(reportTime);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
matcher=monthPattern.matcher(reportTime);
|
|
|
|
|
|
if(matcher.matches()){
|
|
|
|
|
|
return new SimpleDateFormat("yyyy-MM").parse(reportTime);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
matcher=yearPattern.matcher(reportTime);
|
|
|
|
|
|
if(matcher.matches()){
|
|
|
|
|
|
return new SimpleDateFormat("yyyy").parse(reportTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2017-12-29 16:18:40 +08:00
|
|
|
|
}
|