(1)getList方法改名,原先版本的是根据编译ID获取配置列表,这里改成两个方法,getListByCfgId和getListByCompileId
(2)调整后台返回给界面的提示信息 (3)修复几处functionId没有传递的bug (4)nis.properties调整url (5)白名单的审核提交 (6)注释掉CrudService的sendTomaat的方法实现,在后续代码没有用到该方法时删除该方法
This commit is contained in:
@@ -239,7 +239,7 @@ public class IpCfgController extends BaseController{
|
||||
maatTable=serviceConfigInfo.getMaatTable();
|
||||
}
|
||||
if(StringUtils.isNotBlank(ids)){
|
||||
List<BaseIpCfg> beans=ipCfgService.getList(tableName,ids);
|
||||
List<BaseIpCfg> beans=ipCfgService.getListByComileId(tableName,ids);
|
||||
List<BaseIpCfg> auditBeans=new ArrayList<>();
|
||||
List<BaseIpCfg> auditAreaBeans=new ArrayList<>();
|
||||
Date date=new Date();
|
||||
@@ -284,7 +284,7 @@ public class IpCfgController extends BaseController{
|
||||
}
|
||||
auditBeans.add(auditBean);
|
||||
}
|
||||
ipCfgService.auditIpCfg(isAudit,auditBeans,auditAreaBeans,beans);
|
||||
// ipCfgService.auditIpCfg(isAudit,auditBeans,auditAreaBeans,beans);
|
||||
}
|
||||
addMessage(model,"audit_success");
|
||||
}catch(Exception e){
|
||||
|
||||
@@ -220,7 +220,7 @@ public class StringCfgController extends BaseController{
|
||||
maatTable=serviceConfigInfo.getMaatTable();
|
||||
}
|
||||
if(StringUtils.isNotBlank(ids)){
|
||||
List<BaseStringCfg> beans=stringCfgService.getList(tableName,ids);
|
||||
List<BaseStringCfg> beans=stringCfgService.getListByCompileId(tableName,ids);
|
||||
List<BaseStringCfg> auditBeans=new ArrayList<>();
|
||||
List<BaseIpCfg> auditAreaBeans=new ArrayList<>();
|
||||
Date date=new Date();
|
||||
@@ -265,7 +265,7 @@ public class StringCfgController extends BaseController{
|
||||
}
|
||||
auditBeans.add(auditBean);
|
||||
}
|
||||
stringCfgService.auditStringCfg(isAudit,auditBeans,auditAreaBeans,beans);
|
||||
// stringCfgService.auditStringCfg(isAudit,auditBeans,auditAreaBeans,beans);
|
||||
}
|
||||
addMessage(model,"audit_success");
|
||||
}catch (Exception e) {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.nis.web.controller.configuration.ntc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -14,17 +12,15 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
import com.nis.domain.configuration.DnsDomainCfg;
|
||||
import com.nis.domain.configuration.HttpUrlCfg;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.main.ConvertTool;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.dao.configuration.StringCfgDao;
|
||||
|
||||
/**
|
||||
* 白名单
|
||||
@@ -92,14 +88,10 @@ public class WhiteListController extends BaseController{
|
||||
return "/cfg/whitelist/domainForm";
|
||||
}
|
||||
@RequestMapping(value = {"saveOrUpdateIp"})
|
||||
public String saveOrUpdateIp(Model model, IpPortCfg cfg) {
|
||||
public String saveOrUpdateIp(RedirectAttributes model, IpPortCfg cfg) {
|
||||
cfg.setTableName(IpPortCfg.getTablename());
|
||||
logger.info("saveOrUpdateIp loaded");
|
||||
try{
|
||||
if(cfg.getCompileId()==null){
|
||||
int compileId=0;
|
||||
cfg.setCompileId(compileId);
|
||||
}
|
||||
Date date=new Date();
|
||||
cfg.setIsValid(Constants.VALID_NO);
|
||||
cfg.setIsAudit(Constants.AUDIT_NOT_YET);
|
||||
@@ -120,14 +112,10 @@ public class WhiteListController extends BaseController{
|
||||
return "redirect:" + adminPath +"/ntc/whitelist/ipList?functionId="+cfg.getFunctionId();
|
||||
}
|
||||
@RequestMapping(value = {"saveOrUpdateDomain"})
|
||||
public String saveOrUpdateDomain(Model model, HttpUrlCfg cfg) {
|
||||
public String saveOrUpdateDomain(RedirectAttributes model, HttpUrlCfg cfg) {
|
||||
cfg.setTableName(HttpUrlCfg.getTablename());
|
||||
logger.info("saveOrUpdateIp loaded");
|
||||
try{
|
||||
if(cfg.getCompileId()==null){
|
||||
int compileId=0;
|
||||
cfg.setCompileId(compileId);
|
||||
}
|
||||
Date date=new Date();
|
||||
cfg.setIsValid(Constants.VALID_NO);
|
||||
cfg.setIsAudit(Constants.AUDIT_NOT_YET);
|
||||
@@ -150,24 +138,9 @@ public class WhiteListController extends BaseController{
|
||||
|
||||
@RequestMapping(value = {"deleteIp"})
|
||||
@RequiresPermissions("whitelist:config")
|
||||
public String deleteIp(Integer isAudit,Integer isValid,String ids,Integer functionId,Model model) {
|
||||
public String deleteIp(String ids,Integer functionId,RedirectAttributes model) {
|
||||
try{
|
||||
List<BaseIpCfg> ipCfgs=new ArrayList<BaseIpCfg>();
|
||||
Date date =new Date();
|
||||
if(StringUtils.isNotBlank(ids)){
|
||||
for(String idStr:ids.split(",")){
|
||||
if(StringUtils.isNotBlank(idStr)){
|
||||
BaseIpCfg cfg=new BaseIpCfg();
|
||||
cfg.setCfgId(Long.parseLong(idStr));
|
||||
cfg.setTableName(IpPortCfg.getTablename());
|
||||
cfg.setEditorId(cfg.getCurrentUser().getId());
|
||||
cfg.setEditTime(date);
|
||||
cfg.setIsValid(Constants.VALID_DEL);
|
||||
ipCfgs.add(cfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
ipCfgService.deleteIpCfg(ipCfgs,null);
|
||||
ipCfgService.deleteWhiteIp(ids);
|
||||
addMessage(model,"delete_success");
|
||||
}catch(Exception e){
|
||||
logger.error("删除失败", e);
|
||||
@@ -177,24 +150,9 @@ public class WhiteListController extends BaseController{
|
||||
}
|
||||
@RequestMapping(value = {"deleteDomain"})
|
||||
@RequiresPermissions("whitelist:config")
|
||||
public String deleteDomain(Integer isAudit,Integer isValid,String ids,Integer functionId,Model model) {
|
||||
public String deleteDomain(String ids,Integer functionId,RedirectAttributes model) {
|
||||
try{
|
||||
List<BaseStringCfg> cfgs=new ArrayList<BaseStringCfg>();
|
||||
Date date =new Date();
|
||||
if(StringUtils.isNotBlank(ids)){
|
||||
for(String idStr:ids.split(",")){
|
||||
if(StringUtils.isNotBlank(idStr)){
|
||||
BaseStringCfg cfg=new BaseStringCfg();
|
||||
cfg.setCfgId(Long.parseLong(idStr));
|
||||
cfg.setTableName(HttpUrlCfg.getTablename());
|
||||
cfg.setEditorId(cfg.getCurrentUser().getId());
|
||||
cfg.setEditTime(date);
|
||||
cfg.setIsValid(Constants.VALID_DEL);
|
||||
cfgs.add(cfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
stringCfgService.deleteBatch(cfgs, StringCfgDao.class);
|
||||
stringCfgService.deleteWhiteDomain(ids);
|
||||
addMessage(model,"delete_success");
|
||||
}catch(Exception e){
|
||||
logger.error("删除失败", e);
|
||||
@@ -202,23 +160,28 @@ public class WhiteListController extends BaseController{
|
||||
}
|
||||
return "redirect:" + adminPath +"/ntc/whitelist/domainList?functionId="+functionId;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* getCompileId(获取编译ID)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @return
|
||||
*long
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected long getCompileId(BaseIpCfg cfg){
|
||||
long compileId=0l;
|
||||
@RequestMapping(value = {"auditIp"})
|
||||
// @RequiresPermissions("whitelist:aduit")
|
||||
public String auditIp(String ids,IpPortCfg cfg,RedirectAttributes redirectAttributes) {
|
||||
try{
|
||||
compileId = cfg.getCompileId()==null?new ConvertTool().getCompileId():cfg.getCompileId();
|
||||
ipCfgService.auditWhiteIp(ids, cfg);
|
||||
addMessage(redirectAttributes,"audit_success");
|
||||
}catch(Exception e){
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
logger.error("审核失败", e);
|
||||
addMessage(redirectAttributes, "audit_failed");
|
||||
}
|
||||
return compileId;
|
||||
return "redirect:" + adminPath +"/ntc/whitelist/ipList?functionId="+cfg.getFunctionId();
|
||||
}
|
||||
@RequestMapping(value = {"auditDomain"})
|
||||
// @RequiresPermissions("whitelist:aduit")
|
||||
public String auditDomain(String ids,HttpUrlCfg cfg,RedirectAttributes redirectAttributes) {
|
||||
try{
|
||||
stringCfgService.auditWhiteDomain(ids, cfg);
|
||||
addMessage(redirectAttributes,"audit_success");
|
||||
}catch(Exception e){
|
||||
logger.error("审核失败", e);
|
||||
addMessage(redirectAttributes, "audit_failed");
|
||||
}
|
||||
return "redirect:" + adminPath +"/ntc/whitelist/domainList?functionId="+cfg.getFunctionId();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ public interface IpCfgDao extends CrudDao<BaseIpCfg>{
|
||||
public BaseIpCfg getById(@Param("tableName")String tableName,@Param("cfgId")Long id) ;
|
||||
public BaseIpCfg get(BaseIpCfg entity) ;
|
||||
public List<BaseIpCfg> findList(BaseIpCfg entity) ;
|
||||
public List<BaseIpCfg> getList(@Param("tableName")String tableName,@Param("ids")String ids) ;
|
||||
public List<BaseIpCfg> getListByCfgId(@Param("tableName")String tableName,@Param("ids")String ids) ;
|
||||
public List<BaseIpCfg> getListByComileId(@Param("tableName")String tableName,@Param("ids")String ids) ;
|
||||
public int insert(BaseIpCfg entity) ;
|
||||
public int update(BaseIpCfg entity) ;
|
||||
public int updateValid(BaseIpCfg entity) ;
|
||||
|
||||
@@ -114,6 +114,16 @@
|
||||
AND IS_VALID!=-1
|
||||
</trim>
|
||||
</select>
|
||||
<select id="getListByComileId" resultMap="BaseIpMap" >
|
||||
SELECT
|
||||
<include refid="BaseIpCfg_Column_List_with_id" />
|
||||
FROM ${tableName} WHERE IS_VALID!=-1 AND COMPILE_ID in (${ids})
|
||||
</select>
|
||||
<select id="getListByCfgId" resultMap="BaseIpMap" >
|
||||
SELECT
|
||||
<include refid="BaseIpCfg_Column_List_with_id" />
|
||||
FROM ${tableName} WHERE IS_VALID!=-1 AND CFG_ID in (${ids})
|
||||
</select>
|
||||
<select id="getList" resultMap="BaseIpMap" >
|
||||
SELECT
|
||||
<include refid="BaseIpCfg_Column_List_with_id" />
|
||||
|
||||
@@ -27,5 +27,6 @@ public interface StringCfgDao extends CrudDao<BaseStringCfg>{
|
||||
public int getIsAudit(@Param("tableName")String tableName,@Param("cfgId")Long id);
|
||||
public int getIsAudit(BaseStringCfg entity);
|
||||
public int deleteByCompileId(BaseStringCfg entity);
|
||||
public List<BaseStringCfg> getList(@Param("tableName")String tableName, @Param("ids")String ids);
|
||||
public List<BaseStringCfg> getListByCfgId(@Param("tableName")String tableName, @Param("ids")String ids);
|
||||
public List<BaseStringCfg> getListByCompileId(@Param("tableName")String tableName, @Param("ids")String ids);
|
||||
}
|
||||
|
||||
@@ -101,11 +101,16 @@
|
||||
AND IS_VALID!=-1
|
||||
</trim>
|
||||
</select>
|
||||
<select id="getList" resultMap="BaseStringMap">
|
||||
<select id="getListByCompileId" resultMap="BaseStringMap">
|
||||
SELECT
|
||||
<include refid="BaseStringCfg_Column_List_with_id" />
|
||||
FROM ${tableName} WHERE IS_VALID!=-1 AND COMPILE_ID in (${ids})
|
||||
</select>
|
||||
<select id="getListByCfgId" resultMap="BaseStringMap">
|
||||
SELECT
|
||||
<include refid="BaseStringCfg_Column_List_with_id" />
|
||||
FROM ${tableName} WHERE IS_VALID!=-1 AND CFG_ID in (${ids})
|
||||
</select>
|
||||
|
||||
<select id="findList" resultMap="BaseStringMapWithUser">
|
||||
select
|
||||
|
||||
@@ -3,31 +3,18 @@
|
||||
*/
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.nis.domain.BaseEntity;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.configuration.AreaIpCfg;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
import com.nis.domain.configuration.ComplexkeywordCfg;
|
||||
import com.nis.domain.configuration.NumBoundaryCfg;
|
||||
import com.nis.domain.maat.MaatCfg;
|
||||
import com.nis.domain.maat.ToMaatBean;
|
||||
import com.nis.domain.maat.ToMaatUnAuditBean;
|
||||
import com.nis.domain.maat.UnAuditBean;
|
||||
import com.nis.main.ConvertTool;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.dao.CrudDao;
|
||||
import com.nis.web.dao.configuration.IpCfgDao;
|
||||
|
||||
@@ -206,7 +193,6 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* deleteBatch(批量删除全部数据)
|
||||
@@ -311,8 +297,8 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
|
||||
}
|
||||
/**
|
||||
*
|
||||
* sendToMaatConvertorBatch(批量转换配置到maat转换工具)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* sendToMaatConvertorBatch(单域配置下发maat)
|
||||
* (cfgs里每条为一条配置,每条配置可能包含区域IP)
|
||||
* @param operation
|
||||
* @param cfgs
|
||||
* @return
|
||||
@@ -321,218 +307,11 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public boolean sendToMaatConvertorBatch(int operation,List<List<BaseCfg>> cfgs) throws Exception{
|
||||
if(cfgs==null){
|
||||
throw new RuntimeException("转换出错,配置为空");
|
||||
}
|
||||
Gson gson=new GsonBuilder().disableHtmlEscaping()
|
||||
/*.setPrettyPrinting().serializeNulls()*/
|
||||
.excludeFieldsWithoutExposeAnnotation()
|
||||
.create();
|
||||
if(Constants.AUDIT_NOT_YES==operation){
|
||||
List<ToMaatUnAuditBean> beans=new ArrayList<ToMaatUnAuditBean>();
|
||||
for(List<BaseCfg> cfg:cfgs){
|
||||
ToMaatUnAuditBean toMaatUnAuditBean=new ToMaatUnAuditBean();
|
||||
toMaatUnAuditBean.setServiceCfg(new ArrayList<UnAuditBean>());
|
||||
for(BaseCfg c:cfg){
|
||||
if(c.getCompileId()==null||c.getCompileId()==0){
|
||||
throw new RuntimeException("转换出错,未获取到正确的compileId");
|
||||
}
|
||||
// if(StringUtils.isBlank(c.getMaatTable())){
|
||||
// throw new RuntimeException("转换出错,未获取到正确的maatTalbe");
|
||||
// }
|
||||
//针对含有多个maatTable的表
|
||||
// if(c.getMaatTable().contains(",")){
|
||||
// for(String maatTable:c.getMaatTable().split(",")){
|
||||
// UnAuditBean bean=new UnAuditBean();
|
||||
// bean.setCompileId(c.getCompileId());
|
||||
// bean.setMaatTable(maatTable);
|
||||
// toMaatUnAuditBean.getServiceCfg().add(bean);
|
||||
// }
|
||||
// }else{
|
||||
// UnAuditBean bean=new UnAuditBean();
|
||||
// bean.setCompileId(c.getCompileId());
|
||||
// toMaatUnAuditBean.getServiceCfg().add(bean);
|
||||
// }
|
||||
@Deprecated
|
||||
public boolean sendToMaatConvertorBatch(int operation,List<? extends BaseCfg> cfgs) throws Exception{
|
||||
|
||||
}
|
||||
beans.add(toMaatUnAuditBean);
|
||||
}
|
||||
String json=gson.toJson(beans);
|
||||
logger.info("to maat json:"+json);
|
||||
//发送至maat,待完成
|
||||
return new ConvertTool().setConfigInValid(json);
|
||||
}else{
|
||||
List<ToMaatBean> beans=new ArrayList<ToMaatBean>();
|
||||
for(List<BaseCfg> cfg:cfgs){
|
||||
int compileId=0;
|
||||
ToMaatBean toMaatBean=new ToMaatBean();
|
||||
// toMaatBean.setServiceCfg(new ArrayList<MaatCfg>());
|
||||
MaatCfg maatCfg=new MaatCfg();
|
||||
for(BaseCfg c:cfg){
|
||||
if(c instanceof BaseIpCfg){
|
||||
compileId=compileId==0?c.getCompileId():compileId;
|
||||
int protocolId= ((BaseIpCfg) c).getProtocolId().intValue();
|
||||
// String maatTable=c.getMaatTable();
|
||||
// if(maatTable.contains(",")){
|
||||
// if(protocolId!=0){
|
||||
// for(String _maatTable:maatTable.split(",")){
|
||||
// if(_maatTable.toLowerCase().indexOf("ip")>-1){
|
||||
// BaseIpCfg ipCfg=(BaseIpCfg)c.clone();
|
||||
// ipCfg.setMaatTable(_maatTable);
|
||||
// if(maatCfg.getIpCfg()==null){
|
||||
// List<BaseIpCfg> list=new ArrayList<>();
|
||||
// list.add(ipCfg);
|
||||
// maatCfg.setIpCfg(list);
|
||||
// }else{
|
||||
// List<BaseIpCfg> list=maatCfg.getIpCfg();
|
||||
// list.add(ipCfg);
|
||||
// }
|
||||
// }else{
|
||||
// NumBoundaryCfg numCfg=new NumBoundaryCfg();
|
||||
// numCfg.initDefaultValue();
|
||||
// numCfg.setLowBounadry((long)protocolId);
|
||||
// numCfg.setUpBoundary((long)protocolId);
|
||||
// numCfg.setMaatTable(_maatTable);
|
||||
// if(maatCfg.getNumCfg()==null){
|
||||
// List<NumBoundaryCfg> numlist=new ArrayList<>();
|
||||
// numlist.add(numCfg);
|
||||
// maatCfg.setNumCfg(numlist);
|
||||
// }else{
|
||||
// List<NumBoundaryCfg> numlist=maatCfg.getNumCfg();
|
||||
// numlist.add(numCfg);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// throw new RuntimeException("protocolId等于0,却对应两个maat_table "+maatTable);
|
||||
// }
|
||||
// }else{
|
||||
// if(maatCfg.getIpCfg()==null){
|
||||
// List<BaseIpCfg> list=new ArrayList<>();
|
||||
// list.add((BaseIpCfg)c);
|
||||
// maatCfg.setIpCfg(list);
|
||||
// }else{
|
||||
// List<BaseIpCfg> list=maatCfg.getIpCfg();
|
||||
// list.add((BaseIpCfg)c);
|
||||
// }
|
||||
// }
|
||||
}else if(c instanceof BaseStringCfg){
|
||||
compileId=compileId==0?c.getCompileId():compileId;
|
||||
// String maatTable=c.getMaatTable();
|
||||
// if(maatTable.contains(",")){
|
||||
// for(String _maatTable:maatTable.split(",")){
|
||||
// BaseStringCfg strCfg=(BaseStringCfg)c.clone();
|
||||
// strCfg.setMaatTable(_maatTable);
|
||||
// if(maatCfg.getStrCfg()==null){
|
||||
// List<BaseStringCfg> list=new ArrayList<BaseStringCfg>();
|
||||
// list.add(strCfg);
|
||||
// maatCfg.setStrCfg(list);
|
||||
// }else{
|
||||
// List<BaseStringCfg> list=maatCfg.getStrCfg();
|
||||
// list.add(strCfg);
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// if(maatCfg.getStrCfg()==null){
|
||||
// List<BaseStringCfg> list=new ArrayList<BaseStringCfg>();
|
||||
// list.add((BaseStringCfg)c);
|
||||
// maatCfg.setStrCfg(list);
|
||||
// }else{
|
||||
// List<BaseStringCfg> list=maatCfg.getStrCfg();
|
||||
// list.add((BaseStringCfg)c);
|
||||
// }
|
||||
// }
|
||||
}else if(c instanceof ComplexkeywordCfg){
|
||||
compileId=compileId==0?c.getCompileId():compileId;
|
||||
// String maatTable=c.getMaatTable();
|
||||
// if(maatTable.contains(",")){
|
||||
// for(String _maatTable:maatTable.split(",")){
|
||||
// ComplexkeywordCfg complexCfg=(ComplexkeywordCfg)c.clone();
|
||||
// complexCfg.setMaatTable(_maatTable);
|
||||
// if(maatCfg.getComplexStrCfg()==null){
|
||||
// List<ComplexkeywordCfg> list=new ArrayList<ComplexkeywordCfg>();
|
||||
// list.add(complexCfg);
|
||||
// maatCfg.setComplexStrCfg(list);
|
||||
// }else{
|
||||
// List<ComplexkeywordCfg> list=maatCfg.getComplexStrCfg();
|
||||
// list.add(complexCfg);
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// if(maatCfg.getComplexStrCfg()==null){
|
||||
// List<ComplexkeywordCfg> list=new ArrayList<ComplexkeywordCfg>();
|
||||
// list.add((ComplexkeywordCfg)c);
|
||||
// maatCfg.setComplexStrCfg(list);
|
||||
// }else{
|
||||
// List<ComplexkeywordCfg> list=maatCfg.getComplexStrCfg();
|
||||
// list.add((ComplexkeywordCfg)c);
|
||||
// }
|
||||
// }
|
||||
|
||||
}else if(c instanceof NumBoundaryCfg){
|
||||
compileId=compileId==0?c.getCompileId():compileId;
|
||||
/*if(maatCfg.getNumCfg()==null){
|
||||
List<NumBoundaryCfg> list=new ArrayList<NumBoundaryCfg>();
|
||||
list.add((NumBoundaryCfg)c);
|
||||
maatCfg.setNumCfg(list);
|
||||
}else{
|
||||
List<NumBoundaryCfg> list=maatCfg.getNumCfg();
|
||||
list.add((NumBoundaryCfg)c);
|
||||
}*/
|
||||
}
|
||||
if(c.getAreaCfg()!=null){
|
||||
/*if(toMaatBean.getAreaCfg()!=null){
|
||||
toMaatBean.getAreaCfg().addAll(c.getAreaCfg());
|
||||
}else{
|
||||
toMaatBean.setAreaCfg(new ArrayList<AreaIpCfg>());
|
||||
toMaatBean.getAreaCfg().addAll(c.getAreaCfg());
|
||||
}*/
|
||||
}
|
||||
}
|
||||
// toMaatBean.getServiceCfg().add(maatCfg);
|
||||
BaseCfg baseCfg=cfg.get(0);
|
||||
if(compileId==0){
|
||||
throw new RuntimeException("转换出错,未获取到正确的compileId");
|
||||
}else{
|
||||
// toMaatBean.setCompileId(compileId);
|
||||
}
|
||||
if(baseCfg.getAction()==null){
|
||||
throw new RuntimeException("转换出错,未获取到正确的action");
|
||||
}else{
|
||||
// toMaatBean.setAction(baseCfg.getAction());
|
||||
}
|
||||
if(baseCfg.getIsAreaEffective()==null){
|
||||
throw new RuntimeException("转换出错,未获取到正确的isAreaEffective");
|
||||
}else{
|
||||
// toMaatBean.setIsAreaEffective(baseCfg.getIsAreaEffective());
|
||||
}
|
||||
if(baseCfg.getIsValid()==null){
|
||||
throw new RuntimeException("转换出错,未获取到正确的isValid");
|
||||
}else{
|
||||
// toMaatBean.setIsValid(baseCfg.getIsValid());
|
||||
}
|
||||
if(baseCfg.getRequestId()==null){
|
||||
throw new RuntimeException("转换出错,未获取到正确的requestId");
|
||||
}else{
|
||||
// toMaatBean.setRequestId(baseCfg.getRequestId());
|
||||
}
|
||||
if(baseCfg.getServiceId()==null){
|
||||
throw new RuntimeException("转换出错,未获取到正确的serviceId");
|
||||
}else{
|
||||
// toMaatBean.setServiceId(baseCfg.getServiceId());
|
||||
}
|
||||
// toMaatBean.setAreaEffectiveIds(baseCfg.getAreaEffectiveIds()==null?"":baseCfg.getAreaEffectiveIds());
|
||||
// toMaatBean.setAttribute(baseCfg.getAttribute()==null?"":baseCfg.getAttribute());
|
||||
// toMaatBean.setClassify(baseCfg.getClassify()==null?"":baseCfg.getClassify());
|
||||
// toMaatBean.setLable(baseCfg.getLable()==null?"":baseCfg.getLable());
|
||||
beans.add(toMaatBean);
|
||||
}
|
||||
String json=gson.toJson(beans);
|
||||
logger.info("to maat json:"+json);
|
||||
//发送至maat,待完成
|
||||
return new ConvertTool().saveConfig(json);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
*
|
||||
@@ -546,209 +325,8 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Deprecated
|
||||
public boolean sendToMaatConvertor(int operation,List<AreaIpCfg> areaCfg,BaseCfg ... cfg) throws Exception{
|
||||
if(cfg==null){
|
||||
throw new RuntimeException("转换出错,配置为空");
|
||||
}
|
||||
Gson gson=new GsonBuilder().disableHtmlEscaping()
|
||||
/*.setPrettyPrinting().serializeNulls()*/
|
||||
.excludeFieldsWithoutExposeAnnotation()
|
||||
.create();
|
||||
if(Constants.AUDIT_NOT_YES==operation){
|
||||
ToMaatUnAuditBean toMaatUnAuditBean=new ToMaatUnAuditBean();
|
||||
toMaatUnAuditBean.setServiceCfg(new ArrayList<UnAuditBean>());
|
||||
for(BaseCfg c:cfg){
|
||||
|
||||
if(c.getCompileId()==null||c.getCompileId()==0){
|
||||
throw new RuntimeException("转换出错,未获取到正确的compileId");
|
||||
}
|
||||
// if(StringUtils.isBlank(c.getMaatTable())){
|
||||
// throw new RuntimeException("转换出错,未获取到正确的maatTalbe");
|
||||
// }
|
||||
//针对含有多个maatTable的表
|
||||
// if(c.getMaatTable().contains(",")){
|
||||
// for(String maatTable:c.getMaatTable().split(",")){
|
||||
// UnAuditBean bean=new UnAuditBean();
|
||||
// bean.setCompileId(c.getCompileId());
|
||||
// bean.setMaatTable(maatTable);
|
||||
// toMaatUnAuditBean.getServiceCfg().add(bean);
|
||||
// }
|
||||
// }else{
|
||||
// UnAuditBean bean=new UnAuditBean();
|
||||
// bean.setCompileId(c.getCompileId());
|
||||
// bean.setMaatTable(c.getMaatTable());
|
||||
// toMaatUnAuditBean.getServiceCfg().add(bean);
|
||||
// }
|
||||
|
||||
}
|
||||
String json=gson.toJson(toMaatUnAuditBean);
|
||||
logger.info("to maat json:"+json);
|
||||
//发送至maat,待完成
|
||||
return new ConvertTool().setConfigInValid(json);
|
||||
}else{
|
||||
int compileId=0;
|
||||
ToMaatBean toMaatBean=new ToMaatBean();
|
||||
// toMaatBean.setServiceCfg(new ArrayList<MaatCfg>());
|
||||
MaatCfg maatCfg=new MaatCfg();
|
||||
for(BaseCfg c:cfg){
|
||||
if(c instanceof BaseIpCfg){
|
||||
compileId=compileId==0?c.getCompileId():compileId;
|
||||
int protocolId= ((BaseIpCfg) c).getProtocolId().intValue();
|
||||
// String maatTable=c.getMaatTable();
|
||||
// if(maatTable.contains(",")){
|
||||
// if(protocolId!=0){
|
||||
// for(String _maatTable:maatTable.split(",")){
|
||||
// if(_maatTable.toLowerCase().indexOf("ip")>-1){
|
||||
// BaseIpCfg ipCfg=(BaseIpCfg)c.clone();
|
||||
// ipCfg.setMaatTable(_maatTable);
|
||||
// if(maatCfg.getIpCfg()==null){
|
||||
// List<BaseIpCfg> list=new ArrayList<>();
|
||||
// list.add(ipCfg);
|
||||
// maatCfg.setIpCfg(list);
|
||||
// }else{
|
||||
// List<BaseIpCfg> list=maatCfg.getIpCfg();
|
||||
// list.add(ipCfg);
|
||||
// }
|
||||
// }else{
|
||||
// NumBoundaryCfg numCfg=new NumBoundaryCfg();
|
||||
// numCfg.initDefaultValue();
|
||||
// numCfg.setLowBounadry((long)protocolId);
|
||||
// numCfg.setUpBoundary((long)protocolId);
|
||||
// numCfg.setMaatTable(_maatTable);
|
||||
// if(maatCfg.getNumCfg()==null){
|
||||
// List<NumBoundaryCfg> numlist=new ArrayList<>();
|
||||
// numlist.add(numCfg);
|
||||
// maatCfg.setNumCfg(numlist);
|
||||
// }else{
|
||||
// List<NumBoundaryCfg> numlist=maatCfg.getNumCfg();
|
||||
// numlist.add(numCfg);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// throw new RuntimeException("protocolId等于0,却对应两个maat_table "+maatTable);
|
||||
// }
|
||||
// }else{
|
||||
// if(maatCfg.getIpCfg()==null){
|
||||
// List<BaseIpCfg> list=new ArrayList<>();
|
||||
// list.add((BaseIpCfg)c);
|
||||
// maatCfg.setIpCfg(list);
|
||||
// }else{
|
||||
// List<BaseIpCfg> list=maatCfg.getIpCfg();
|
||||
// list.add((BaseIpCfg)c);
|
||||
// }
|
||||
// }
|
||||
}else if(c instanceof BaseStringCfg){
|
||||
compileId=compileId==0?c.getCompileId():compileId;
|
||||
// String maatTable=c.getMaatTable();
|
||||
// if(maatTable.contains(",")){
|
||||
// for(String _maatTable:maatTable.split(",")){
|
||||
// BaseStringCfg strCfg=(BaseStringCfg)c.clone();
|
||||
// strCfg.setMaatTable(_maatTable);
|
||||
// if(maatCfg.getStrCfg()==null){
|
||||
// List<BaseStringCfg> list=new ArrayList<BaseStringCfg>();
|
||||
// list.add(strCfg);
|
||||
// maatCfg.setStrCfg(list);
|
||||
// }else{
|
||||
// List<BaseStringCfg> list=maatCfg.getStrCfg();
|
||||
// list.add(strCfg);
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// if(maatCfg.getStrCfg()==null){
|
||||
// List<BaseStringCfg> list=new ArrayList<BaseStringCfg>();
|
||||
// list.add((BaseStringCfg)c);
|
||||
// maatCfg.setStrCfg(list);
|
||||
// }else{
|
||||
// List<BaseStringCfg> list=maatCfg.getStrCfg();
|
||||
// list.add((BaseStringCfg)c);
|
||||
// }
|
||||
// }
|
||||
}else if(c instanceof ComplexkeywordCfg){
|
||||
compileId=compileId==0?c.getCompileId():compileId;
|
||||
// String maatTable=c.getMaatTable();
|
||||
// if(maatTable.contains(",")){
|
||||
// for(String _maatTable:maatTable.split(",")){
|
||||
// ComplexkeywordCfg complexCfg=(ComplexkeywordCfg)c.clone();
|
||||
// complexCfg.setMaatTable(_maatTable);
|
||||
// if(maatCfg.getComplexStrCfg()==null){
|
||||
// List<ComplexkeywordCfg> list=new ArrayList<ComplexkeywordCfg>();
|
||||
// list.add(complexCfg);
|
||||
// maatCfg.setComplexStrCfg(list);
|
||||
// }else{
|
||||
// List<ComplexkeywordCfg> list=maatCfg.getComplexStrCfg();
|
||||
// list.add(complexCfg);
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// if(maatCfg.getComplexStrCfg()==null){
|
||||
// List<ComplexkeywordCfg> list=new ArrayList<ComplexkeywordCfg>();
|
||||
// list.add((ComplexkeywordCfg)c);
|
||||
// maatCfg.setComplexStrCfg(list);
|
||||
// }else{
|
||||
// List<ComplexkeywordCfg> list=maatCfg.getComplexStrCfg();
|
||||
// list.add((ComplexkeywordCfg)c);
|
||||
// }
|
||||
// }
|
||||
|
||||
}else if(c instanceof NumBoundaryCfg){
|
||||
/*compileId=compileId==0?c.getCompileId():compileId;
|
||||
if(maatCfg.getNumCfg()==null){
|
||||
List<NumBoundaryCfg> list=new ArrayList<NumBoundaryCfg>();
|
||||
list.add((NumBoundaryCfg)c);
|
||||
maatCfg.setNumCfg(list);
|
||||
}else{
|
||||
List<NumBoundaryCfg> list=maatCfg.getNumCfg();
|
||||
list.add((NumBoundaryCfg)c);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
/*if(areaCfg!=null){
|
||||
toMaatBean.setAreaCfg(areaCfg);
|
||||
}else{
|
||||
toMaatBean.setAreaCfg(new ArrayList<AreaIpCfg>());
|
||||
}
|
||||
toMaatBean.getServiceCfg().add(maatCfg);
|
||||
BaseCfg baseCfg=(BaseCfg)cfg[0];
|
||||
if(compileId==0){
|
||||
throw new RuntimeException("转换出错,未获取到正确的compileId");
|
||||
}else{
|
||||
toMaatBean.setCompileId(compileId);
|
||||
}
|
||||
if(baseCfg.getAction()==null){
|
||||
throw new RuntimeException("转换出错,未获取到正确的action");
|
||||
}else{
|
||||
toMaatBean.setAction(baseCfg.getAction());
|
||||
}
|
||||
if(baseCfg.getIsAreaEffective()==null){
|
||||
throw new RuntimeException("转换出错,未获取到正确的isAreaEffective");
|
||||
}else{
|
||||
toMaatBean.setIsAreaEffective(baseCfg.getIsAreaEffective());
|
||||
}
|
||||
if(baseCfg.getIsValid()==null){
|
||||
throw new RuntimeException("转换出错,未获取到正确的isValid");
|
||||
}else{
|
||||
toMaatBean.setIsValid(baseCfg.getIsValid());
|
||||
}
|
||||
if(baseCfg.getRequestId()==null){
|
||||
throw new RuntimeException("转换出错,未获取到正确的requestId");
|
||||
}else{
|
||||
toMaatBean.setRequestId(baseCfg.getRequestId());
|
||||
}
|
||||
if(baseCfg.getServiceId()==null){
|
||||
throw new RuntimeException("转换出错,未获取到正确的serviceId");
|
||||
}else{
|
||||
toMaatBean.setServiceId(baseCfg.getServiceId());
|
||||
}
|
||||
toMaatBean.setAreaEffectiveIds(baseCfg.getAreaEffectiveIds()==null?"":baseCfg.getAreaEffectiveIds());
|
||||
toMaatBean.setAttribute(baseCfg.getAttribute()==null?"":baseCfg.getAttribute());
|
||||
toMaatBean.setClassify(baseCfg.getClassify()==null?"":baseCfg.getClassify());
|
||||
toMaatBean.setLable(baseCfg.getLable()==null?"":baseCfg.getLable());*/
|
||||
|
||||
String json=gson.toJson(toMaatBean);
|
||||
logger.info("to maat json:"+json);
|
||||
//发送至maat,待完成
|
||||
return new ConvertTool().saveConfig(json);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,26 +78,26 @@ public class ComplexStringCfgService extends CrudService<ComplexStringCfgDao,Com
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void auditStringCfg(int isAduit,List<ComplexkeywordCfg> auditCfg,List<BaseIpCfg> areaCfg,List<ComplexkeywordCfg> sendCfg) throws Exception{
|
||||
List<List<BaseCfg>> sendCfgs=new ArrayList<List<BaseCfg>>();
|
||||
for(ComplexkeywordCfg c:sendCfg){
|
||||
List<BaseCfg> cArr=new ArrayList<>();
|
||||
cArr.add(c);
|
||||
sendCfgs.add(cArr);
|
||||
}
|
||||
if(Constants.AUDIT_NOT_YES==isAduit||
|
||||
Constants.AUDIT_YES==isAduit){//审核通过,取消审核通过需要发到maat
|
||||
if(sendToMaatConvertorBatch(isAduit,sendCfgs)){
|
||||
if(areaCfg!=null&&areaCfg.size()>0){
|
||||
this.auditIpBatch(areaCfg);
|
||||
}
|
||||
this.auditBatch(auditCfg, ComplexStringCfgDao.class);
|
||||
}
|
||||
}else{
|
||||
if(areaCfg!=null&&areaCfg.size()>0){
|
||||
this.auditIpBatch(areaCfg);
|
||||
}
|
||||
this.auditBatch(auditCfg, ComplexStringCfgDao.class);
|
||||
}
|
||||
// List<List<BaseCfg>> sendCfgs=new ArrayList<List<BaseCfg>>();
|
||||
// for(ComplexkeywordCfg c:sendCfg){
|
||||
// List<BaseCfg> cArr=new ArrayList<>();
|
||||
// cArr.add(c);
|
||||
// sendCfgs.add(cArr);
|
||||
// }
|
||||
// if(Constants.AUDIT_NOT_YES==isAduit||
|
||||
// Constants.AUDIT_YES==isAduit){//审核通过,取消审核通过需要发到maat
|
||||
// if(sendToMaatConvertorBatch(isAduit,sendCfgs)){
|
||||
// if(areaCfg!=null&&areaCfg.size()>0){
|
||||
// this.auditIpBatch(areaCfg);
|
||||
// }
|
||||
// this.auditBatch(auditCfg, ComplexStringCfgDao.class);
|
||||
// }
|
||||
// }else{
|
||||
// if(areaCfg!=null&&areaCfg.size()>0){
|
||||
// this.auditIpBatch(areaCfg);
|
||||
// }
|
||||
// this.auditBatch(auditCfg, ComplexStringCfgDao.class);
|
||||
// }
|
||||
}
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
package com.nis.web.service.configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.nis.domain.configuration.AreaIpCfg;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.maat.ToMaatResult;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.configuration.AreaIpCfgDao;
|
||||
import com.nis.web.dao.configuration.IpCfgDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
@@ -41,7 +47,25 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
if(areaIpCfgs!=null&&areaIpCfgs.size()>0){
|
||||
this.saveIpBatch(areaIpCfgs);
|
||||
}
|
||||
//调用服务接口获取compileId
|
||||
Integer compileId = 0;
|
||||
try {
|
||||
List<Integer> compileIds = ConfigServiceUtil.getId(1,1);
|
||||
if(!StringUtil.isEmpty(compileIds)){
|
||||
compileId = compileIds.get(0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("获取编译ID出错");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
if(compileId!=0){
|
||||
baseIpCfg.setCompileId(compileId);
|
||||
return ipCfgDao.insert(baseIpCfg);
|
||||
}else{
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
@@ -66,6 +90,48 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
}
|
||||
return ipCfgDao.update(baseIpCfg);
|
||||
}
|
||||
public void auditWhiteIp(String ids,IpPortCfg cfg) throws Exception{
|
||||
for(String id:ids.split(",")){
|
||||
Long.parseLong(id);
|
||||
}
|
||||
List<BaseIpCfg> beans=this.getListByCfgId(IpPortCfg.getTablename(),ids);
|
||||
Date date=new Date();
|
||||
for(BaseIpCfg bean:beans){
|
||||
bean.setTableName(IpPortCfg.getTablename());
|
||||
bean.setAuditorId(bean.getCurrentUser().getId());
|
||||
bean.setAuditTime(date);
|
||||
bean.setIsAudit(cfg.getIsAudit());
|
||||
bean.setIsValid(cfg.getIsValid());
|
||||
}
|
||||
this.auditBatch(beans, IpCfgDao.class);
|
||||
if(cfg.getIsAudit()==1){
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(beans);
|
||||
logger.info("IP白名单下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.postCallbackCfg(json);
|
||||
logger.info("IP白名单配置下发响应信息:"+result.getMsg());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("IP白名单配置下发失败");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
}else if(cfg.getIsAudit()==3){
|
||||
//调用服务接口取消配置
|
||||
String json=gsonToJson(beans);
|
||||
logger.info("IP白名单配置参数:"+json);
|
||||
//调用服务接口取消配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.put(json, 2);
|
||||
logger.info("IP白名单取消配置响应信息:"+result.getMsg());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("IP白名单取消配置失败");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* auditIpCfg(审核IP类配置)
|
||||
@@ -78,16 +144,16 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void auditIpCfg(int isAduit,List<BaseIpCfg> auditCfg,List<BaseIpCfg> areaCfg,List<BaseIpCfg> sendCfg) throws Exception{
|
||||
List<List<BaseCfg>> sendCfgs=new ArrayList<List<BaseCfg>>();
|
||||
for(BaseIpCfg c:sendCfg){
|
||||
List<BaseCfg> cArr=new ArrayList<>();
|
||||
cArr.add(c);
|
||||
sendCfgs.add(cArr);
|
||||
public void auditIpCfg(int isAduit,List<BaseIpCfg> auditCfg) throws Exception{
|
||||
List<BaseIpCfg> areaCfg=new ArrayList<>();
|
||||
for(BaseIpCfg c:auditCfg){
|
||||
if(c.getAreaCfg()!=null){
|
||||
areaCfg.addAll(c.getAreaCfg());
|
||||
}
|
||||
}
|
||||
if(Constants.AUDIT_NOT_YES==isAduit||
|
||||
Constants.AUDIT_YES==isAduit){//审核通过,取消审核通过需要发到maat
|
||||
if(sendToMaatConvertorBatch(isAduit,sendCfgs)){
|
||||
if(sendToMaatConvertorBatch(isAduit,auditCfg)){
|
||||
if(areaCfg!=null&&areaCfg.size()>0){
|
||||
this.auditIpBatch(areaCfg);
|
||||
}
|
||||
@@ -101,6 +167,25 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
}
|
||||
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void deleteWhiteIp(String ids){
|
||||
List<BaseIpCfg> ipCfgs=new ArrayList<BaseIpCfg>();
|
||||
Date date =new Date();
|
||||
if(StringUtils.isNotBlank(ids)){
|
||||
for(String idStr:ids.split(",")){
|
||||
if(StringUtils.isNotBlank(idStr)){
|
||||
BaseIpCfg cfg=new BaseIpCfg();
|
||||
cfg.setCfgId(Long.parseLong(idStr));
|
||||
cfg.setTableName(IpPortCfg.getTablename());
|
||||
cfg.setEditorId(cfg.getCurrentUser().getId());
|
||||
cfg.setEditTime(date);
|
||||
cfg.setIsValid(Constants.VALID_DEL);
|
||||
ipCfgs.add(cfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.deleteBatch(ipCfgs, IpCfgDao.class);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* deleteIpCfg(删除IP类配置)
|
||||
@@ -155,7 +240,10 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
public List<AreaIpCfg> getAreaCfgByCompileId(int compileId){
|
||||
return areaIpCfgDao.getByCompileId(compileId);
|
||||
}
|
||||
public List<BaseIpCfg> getList(String tableName,String ids){
|
||||
return ipCfgDao.getList(tableName,ids);
|
||||
public List<BaseIpCfg> getListByComileId(String tableName,String ids){
|
||||
return ipCfgDao.getListByComileId(tableName,ids);
|
||||
}
|
||||
public List<BaseIpCfg> getListByCfgId(String tableName,String ids){
|
||||
return ipCfgDao.getListByCfgId(tableName,ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,22 +211,22 @@ public class MultipleCfgService extends CrudService<MultipleCfgDao,MultipleSearc
|
||||
}
|
||||
cfgs.add(cfg);
|
||||
}
|
||||
if(this.sendToMaatConvertorBatch(isAudit, cfgs)){
|
||||
if(auduitIpCfgs!=null&&auduitIpCfgs.size()>0){
|
||||
this.auditIpBatch(auduitIpCfgs);
|
||||
}
|
||||
if(auduitStringCfgs!=null&&auduitStringCfgs.size()>0){
|
||||
this.auditStringBatch(auduitStringCfgs);
|
||||
}
|
||||
if(auduitNumCfgs!=null&&auduitNumCfgs.size()>0){
|
||||
this.auditNumBatch(auduitNumCfgs);
|
||||
}
|
||||
if(auduitComplexCfgs!=null&&auduitComplexCfgs.size()>0){
|
||||
this.auditComplexBatch(auduitComplexCfgs);
|
||||
}
|
||||
}else{
|
||||
throw new RuntimeException("发送至maat失败,返回false!");
|
||||
}
|
||||
// if(this.sendToMaatConvertorBatch(isAudit, cfgs)){
|
||||
// if(auduitIpCfgs!=null&&auduitIpCfgs.size()>0){
|
||||
// this.auditIpBatch(auduitIpCfgs);
|
||||
// }
|
||||
// if(auduitStringCfgs!=null&&auduitStringCfgs.size()>0){
|
||||
// this.auditStringBatch(auduitStringCfgs);
|
||||
// }
|
||||
// if(auduitNumCfgs!=null&&auduitNumCfgs.size()>0){
|
||||
// this.auditNumBatch(auduitNumCfgs);
|
||||
// }
|
||||
// if(auduitComplexCfgs!=null&&auduitComplexCfgs.size()>0){
|
||||
// this.auditComplexBatch(auduitComplexCfgs);
|
||||
// }
|
||||
// }else{
|
||||
// throw new RuntimeException("发送至maat失败,返回false!");
|
||||
// }
|
||||
}else{
|
||||
if(auduitIpCfgs!=null&&auduitIpCfgs.size()>0){
|
||||
this.auditIpBatch(auduitIpCfgs);
|
||||
|
||||
@@ -1,18 +1,23 @@
|
||||
package com.nis.web.service.configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.nis.domain.configuration.AreaIpCfg;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
import com.nis.domain.configuration.HttpUrlCfg;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.maat.ToMaatResult;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.dao.configuration.IpCfgDao;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.configuration.StringCfgDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
|
||||
@@ -40,7 +45,26 @@ public class StringCfgService extends CrudService<StringCfgDao,BaseStringCfg> {
|
||||
if(areaIpCfgs!=null&&areaIpCfgs.size()>0){
|
||||
this.saveIpBatch(areaIpCfgs);
|
||||
}
|
||||
//调用服务接口获取compileId
|
||||
Integer compileId = 0;
|
||||
try {
|
||||
List<Integer> compileIds = ConfigServiceUtil.getId(1,1);
|
||||
if(!StringUtil.isEmpty(compileIds)){
|
||||
compileId = compileIds.get(0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("获取编译ID出错");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
if(compileId!=0){
|
||||
baseStringCfg.setCompileId(compileId);
|
||||
return stringCfgDao.insert(baseStringCfg);
|
||||
}else{
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
// baseStringCfg.setCompileId(0);
|
||||
// return stringCfgDao.insert(baseStringCfg);
|
||||
}
|
||||
/**
|
||||
*
|
||||
@@ -65,6 +89,48 @@ public class StringCfgService extends CrudService<StringCfgDao,BaseStringCfg> {
|
||||
}
|
||||
return stringCfgDao.update(baseStringCfg);
|
||||
}
|
||||
public void auditWhiteDomain(String ids,HttpUrlCfg cfg) throws Exception{
|
||||
for(String id:ids.split(",")){
|
||||
Long.parseLong(id);
|
||||
}
|
||||
List<BaseStringCfg> beans=stringCfgDao.getListByCfgId(HttpUrlCfg.getTablename(),ids);
|
||||
Date date=new Date();
|
||||
for(BaseStringCfg bean:beans){
|
||||
bean.setTableName(IpPortCfg.getTablename());
|
||||
bean.setAuditorId(bean.getCurrentUser().getId());
|
||||
bean.setAuditTime(date);
|
||||
bean.setIsAudit(cfg.getIsAudit());
|
||||
bean.setIsValid(cfg.getIsValid());
|
||||
}
|
||||
this.auditBatch(beans, StringCfgDao.class);
|
||||
if(cfg.getIsAudit()==1){
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(beans);
|
||||
logger.info("文件样例下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.postCallbackCfg(json);
|
||||
logger.info("IP白名单配置下发响应信息:"+result.getMsg());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("IP白名单配置下发失败");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
}else if(cfg.getIsAudit()==3){
|
||||
//调用服务接口取消配置
|
||||
String json=gsonToJson(beans);
|
||||
logger.info("IP白名单配置参数:"+json);
|
||||
//调用服务接口取消配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.put(json, 2);
|
||||
logger.info("IP白名单取消配置响应信息:"+result.getMsg());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("IP白名单取消配置失败");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* auditStringCfg(审核IP类配置)
|
||||
@@ -77,16 +143,16 @@ public class StringCfgService extends CrudService<StringCfgDao,BaseStringCfg> {
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void auditStringCfg(int isAduit,List<BaseStringCfg> auditCfg,List<BaseIpCfg> areaCfg,List<BaseStringCfg> sendCfg) throws Exception{
|
||||
List<List<BaseCfg>> sendCfgs=new ArrayList<List<BaseCfg>>();
|
||||
for(BaseStringCfg c:sendCfg){
|
||||
List<BaseCfg> cArr=new ArrayList<>();
|
||||
cArr.add(c);
|
||||
sendCfgs.add(cArr);
|
||||
public void auditStringCfg(int isAduit,List<BaseStringCfg> auditCfg,List<BaseStringCfg> sendCfg) throws Exception{
|
||||
List<BaseIpCfg> areaCfg=new ArrayList<>();
|
||||
for(BaseStringCfg c:auditCfg){
|
||||
if(c.getAreaCfg()!=null){
|
||||
areaCfg.addAll(c.getAreaCfg());
|
||||
}
|
||||
}
|
||||
if(Constants.AUDIT_NOT_YES==isAduit||
|
||||
Constants.AUDIT_YES==isAduit){//审核通过,取消审核通过需要发到maat
|
||||
if(sendToMaatConvertorBatch(isAduit,sendCfgs)){
|
||||
if(sendToMaatConvertorBatch(isAduit,sendCfg)){
|
||||
if(areaCfg!=null&&areaCfg.size()>0){
|
||||
this.auditIpBatch(areaCfg);
|
||||
}
|
||||
@@ -96,6 +162,25 @@ public class StringCfgService extends CrudService<StringCfgDao,BaseStringCfg> {
|
||||
this.auditBatch(auditCfg, StringCfgDao.class);
|
||||
}
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void deleteWhiteDomain(String ids){
|
||||
List<BaseStringCfg> cfgs=new ArrayList<BaseStringCfg>();
|
||||
Date date =new Date();
|
||||
if(StringUtils.isNotBlank(ids)){
|
||||
for(String idStr:ids.split(",")){
|
||||
if(StringUtils.isNotBlank(idStr)){
|
||||
BaseStringCfg cfg=new BaseStringCfg();
|
||||
cfg.setCfgId(Long.parseLong(idStr));
|
||||
cfg.setTableName(HttpUrlCfg.getTablename());
|
||||
cfg.setEditorId(cfg.getCurrentUser().getId());
|
||||
cfg.setEditTime(date);
|
||||
cfg.setIsValid(Constants.VALID_DEL);
|
||||
cfgs.add(cfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.deleteBatch(cfgs, StringCfgDao.class);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* deleteStringCfg(删除IP类配置)
|
||||
@@ -152,8 +237,8 @@ public class StringCfgService extends CrudService<StringCfgDao,BaseStringCfg> {
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public List<BaseStringCfg> getList(String tableName, String ids) {
|
||||
public List<BaseStringCfg> getListByCompileId(String tableName, String ids) {
|
||||
// TODO Auto-generated method stub
|
||||
return stringCfgDao.getList(tableName,ids);
|
||||
return stringCfgDao.getListByCompileId(tableName,ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,12 +219,12 @@ clusterBStartTime=1503504000725
|
||||
isCommit=true
|
||||
############################################################################################################################################
|
||||
############################################################################################################################################
|
||||
httpUrl=http://10.0.6.30:8080/maatRest/service/cfg/v1/
|
||||
httpUrl=http://10.0.6.201:8090/galaxy/service/cfg/v1/
|
||||
maatCfg=configSources
|
||||
fileUploadCfg=fileUploadSources
|
||||
callbackCfg=commonSources
|
||||
fileDigestCfg=fileDigestSources
|
||||
configIdSources=getCompileId
|
||||
configIdSources=configPzIdSources
|
||||
client_connect_timeout=1000
|
||||
client_read_timeout=1000
|
||||
#use elasticsearch or not#
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
<div class="portlet-body">
|
||||
<div class="row" >
|
||||
<form:form id="searchForm" modelAttribute="cfg" action="${ctx}/ntc/whitelist/domainList" method="post" class="form-search">
|
||||
<input id="functionId" name="functionId" type="hidden" value="${audit}"/>
|
||||
<input id="functionId" name="functionId" type="hidden" value="${cfg.functionId}"/>
|
||||
<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
|
||||
<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
|
||||
<sys:tableSort id="orderBy" name="orderBy" value="${page.orderBy}"
|
||||
@@ -115,7 +115,7 @@
|
||||
<div class="pull-right">
|
||||
<shiro:hasPermission name="whitelist:config">
|
||||
<sys:delRow url="${ctx}/ntc/whitelist/domainForm?functionId=${cfg.functionId}" id="contentTable" label="update"></sys:delRow>
|
||||
<sys:delRow url="${ctx}/ntc/whitelist/deleteDomain?isValid=-1&functionId=${cfg.functionId}" id="contentTable" label="delete"></sys:delRow>
|
||||
<sys:delRow url="${ctx}/ntc/whitelist/deleteDomain?functionId=${cfg.functionId}" id="contentTable" label="delete"></sys:delRow>
|
||||
</shiro:hasPermission>
|
||||
<!-- <button type="button" class="btn btn-default">
|
||||
<i class="fa fa-download"></i> 导出</button> -->
|
||||
@@ -194,6 +194,7 @@
|
||||
</form:form>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<sys:message content="${message}"/>
|
||||
<table id="contentTable" class="table table-striped table-bordered table-condensed text-nowrap">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -138,7 +138,7 @@ $(function(){
|
||||
<div class="col-md-6">
|
||||
<select name="portPattern" class="selectpicker show-tick form-control required">
|
||||
<option value="1" <c:if test="${_cfg.portPattern==1}">selected</c:if> ><spring:message code="port"/></option>
|
||||
<option value="2" <c:if test="${_cfg.portPattern==2}">selected</c:if>><spring:message code="port_range"/></option>
|
||||
<option value="2" <c:if test="${_cfg.portPattern==2}">selected</c:if>><spring:message code="subnet"/></option>
|
||||
</select>
|
||||
</div>
|
||||
<div for="portPattern"></div>
|
||||
@@ -150,7 +150,7 @@ $(function(){
|
||||
<div class="form-group ">
|
||||
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="client_ip"/></label>
|
||||
<div class="col-md-6">
|
||||
<input class="form-control required" type="text" name="srcIpAddress" value="${_cfg.srcIpAddress}">
|
||||
<input class="form-control required ipCheck" type="text" name="srcIpAddress" value="${_cfg.srcIpAddress}">
|
||||
</div>
|
||||
<div for="srcIpAddress"></div>
|
||||
</div>
|
||||
|
||||
@@ -120,19 +120,19 @@
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<shiro:hasPermission name="whitelist:config">
|
||||
<sys:delRow url="${ctx}/ntc/whitelist/ipForm" id="contentTable" label="update"></sys:delRow>
|
||||
<sys:delRow url="${ctx}/ntc/whitelist/deleteIp?isValid=-1&functionId=${cfg.functionId}" id="contentTable" label="delete"></sys:delRow>
|
||||
<sys:delRow url="${ctx}/ntc/whitelist/ipForm?functionId=${cfg.functionId}" id="contentTable" label="update"></sys:delRow>
|
||||
<sys:delRow url="${ctx}/ntc/whitelist/deleteIp?functionId=${cfg.functionId}" id="contentTable" label="delete"></sys:delRow>
|
||||
</shiro:hasPermission>
|
||||
<shiro:hasPermission name="whitelist:audit">
|
||||
<shiro:hasPermission name="whitelist:config">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-wrench"></i> <spring:message code="examine"></spring:message>
|
||||
<i class="fa fa-angle-down"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu pull-right">
|
||||
<li><sys:delRow url="${ctx}/ntc/whitelist/auditIp?isAudit=1&isValid=1" id="contentTable" label="approved"></sys:delRow></li>
|
||||
<li><sys:delRow url="${ctx}/ntc/whitelist/auditIp?isAudit=2&isValid=0" id="contentTable" label="unapproved"></sys:delRow></li>
|
||||
<li><sys:delRow url="${ctx}/ntc/whitelist/auditIp?isAudit=3&isValid=0" id="contentTable" label="cancelPass"></sys:delRow></li>
|
||||
<li><sys:delRow url="${ctx}/ntc/whitelist/auditIp?isAudit=1&isValid=1&functionId=${cfg.functionId}" id="contentTable" label="approved"></sys:delRow></li>
|
||||
<li><sys:delRow url="${ctx}/ntc/whitelist/auditIp?isAudit=2&isValid=0&functionId=${cfg.functionId}" id="contentTable" label="unapproved"></sys:delRow></li>
|
||||
<li><sys:delRow url="${ctx}/ntc/whitelist/auditIp?isAudit=3&isValid=0&functionId=${cfg.functionId}" id="contentTable" label="cancelPass"></sys:delRow></li>
|
||||
</ul>
|
||||
</div>
|
||||
</shiro:hasPermission>
|
||||
@@ -202,6 +202,7 @@
|
||||
</form:form>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<sys:message content="${message}"/>
|
||||
<table id="contentTable" class="table table-striped table-bordered table-condensed text-nowrap">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
Reference in New Issue
Block a user