package com.nis.web.service.configuration; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.nis.domain.Page; import com.nis.domain.callback.ProxyFileHijackCfg; import com.nis.domain.callback.ProxyFileInsertScriptCfg; import com.nis.domain.callback.ProxyFileStrategyCfg; import com.nis.domain.configuration.AreaIpCfg; import com.nis.domain.configuration.BaseCfg; import com.nis.domain.configuration.CfgIndexInfo; import com.nis.domain.configuration.HttpBodyCfg; import com.nis.domain.configuration.HttpReqHeadCfg; import com.nis.domain.configuration.HttpResHeadCfg; import com.nis.domain.configuration.HttpUrlCfg; import com.nis.domain.configuration.IpPortCfg; import com.nis.domain.configuration.NtcSubscribeIdCfg; import com.nis.domain.maat.MaatCfg; import com.nis.domain.maat.MaatCfg.DigestCfg; import com.nis.domain.maat.MaatCfg.GroupCfg; import com.nis.domain.maat.MaatCfg.IpCfg; import com.nis.domain.maat.MaatCfg.NumBoundaryCfg; import com.nis.domain.maat.MaatCfg.StringCfg; import com.nis.domain.maat.ManipulatActionParam; import com.nis.domain.maat.ManipulatActionParam.ReplaceCfg; import com.nis.domain.maat.ToMaatBean; 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.ProxyFileHijackDao; import com.nis.web.dao.configuration.ProxyFileInsertScriptDao; import com.nis.web.dao.configuration.ProxyFileStrategyDao; import com.nis.web.dao.configuration.StringCfgDao; import com.nis.web.dao.configuration.WebsiteCfgDao; import com.nis.web.security.UserUtils; import com.nis.web.service.CrudService; /** * 代理控制策略操控业务 事务类 */ @Service public class ManipulatPolicyService extends CrudService { @Autowired protected WebsiteCfgDao websiteCfgDao; @Autowired protected AreaIpCfgDao areaIpCfgDao; @Autowired protected StringCfgDao stringCfgDao; @Autowired protected ProxyFileStrategyDao proxyFileDao; @Autowired protected ProxyFileHijackDao proxyFileHijackDao; @Autowired protected ProxyFileInsertScriptDao proxyFileInsertDao; public List getCfgIndexInfos(CfgIndexInfo entity){ return websiteCfgDao.getCfgIndexInfos(entity); } public CfgIndexInfo getPolicyCfg(Long cfgId,Integer compileId){ CfgIndexInfo entity = websiteCfgDao.getCfgIndexInfo(cfgId,compileId); List httpUrlList = websiteCfgDao.getHttpUrlList(entity); List httpReqHdrList = websiteCfgDao.getHttpReqHdrList(entity); List httpResHdrList = websiteCfgDao.getHttpResHdrList(entity); List ipPortCfgList = websiteCfgDao.getIpPortList(entity); entity.setCfgType(Constants.HTTP_REDIRECT_REQ_BODY_REGION); List httpReqBodyList = websiteCfgDao.getHttpReqBodyList(entity); entity.setCfgType(Constants.HTTP_REDIRECT_RES_BODY_REGION); List httpResBodyList = websiteCfgDao.getHttpResBodyList(entity); List subscribeIdList = stringCfgDao.findSubscribeIdCfgListByCfgIndexInfo(entity); entity.setHttpReqBodyList(httpReqBodyList); entity.setHttpReqHdrList(httpReqHdrList); entity.setHttpResBodyList(httpResBodyList); entity.setHttpResHdrList(httpResHdrList); entity.setHttpUrlList(httpUrlList); entity.setIpPortList(ipPortCfgList); entity.setNtcSubscribeIdCfgList(subscribeIdList); return entity; } public Map exportHttpCfg(CfgIndexInfo entity){ Map dataMap=new HashMap(); List httpUrlList = websiteCfgDao.getHttpUrlList(entity); List httpReqHdrList = websiteCfgDao.getHttpReqHdrList(entity); List httpResHdrList = websiteCfgDao.getHttpResHdrList(entity); List ipPortCfgList = websiteCfgDao.getIpPortList(entity); entity.setCfgType(Constants.HTTP_REDIRECT_REQ_BODY_REGION); List httpReqBodyList = websiteCfgDao.getHttpReqBodyList(entity); entity.setCfgType(Constants.HTTP_REDIRECT_RES_BODY_REGION); List httpResBodyList = websiteCfgDao.getHttpResBodyList(entity); List subscribeIdList = stringCfgDao.findSubscribeIdCfgListByCfgIndexInfo(entity); dataMap.put("NTC_UNIVERSAL_IP", ipPortCfgList); dataMap.put("NTC_HTTP_URL", httpUrlList); dataMap.put("NTC_HTTP_REQ_HDR", httpReqHdrList); dataMap.put("NTC_HTTP_RES_HDR", httpResHdrList); dataMap.put("NTC_HTTP_REQ_BODY", httpReqBodyList); dataMap.put("NTC_HTTP_RES_BODY", httpResBodyList); dataMap.put("NTC_SUBSCRIBE_ID", subscribeIdList); return dataMap; } public Page getPolicyList(Page page, CfgIndexInfo entity){ // 生成数据权限过滤条件(dsf为dataScopeFilter的简写,在xml中使用 ${sqlMap.dsf}调用权限SQL) entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"a")); entity.setPage(page); // 设置cfg_type,用于列表检索时区分 if(entity.getHttpReqHdr() != null){ entity.getHttpReqHdr().setCfgType(Constants.HTTP_REDIRECT_REQ_HEAD_REGION); } if(entity.getHttpReqBody() != null){ entity.getHttpReqBody().setCfgType(Constants.HTTP_REDIRECT_REQ_BODY_REGION); } if(entity.getHttpResHdr() != null){ entity.getHttpResHdr().setCfgType(Constants.HTTP_REDIRECT_RES_HEAD_REGION); } if(entity.getHttpResBody() != null){ entity.getHttpResBody().setCfgType(Constants.HTTP_REDIRECT_RES_BODY_REGION); } List list = websiteCfgDao.getWebsiteList(entity); page.setList(list); return page; } public void savePolicyCfg(CfgIndexInfo entity){ //设置区域运营商信息 setAreaEffectiveIds(entity); int isValid=0; if(!StringUtil.isEmpty(entity.getIsValid()) && entity.getIsValid()==1) { isValid=1; } entity.setIsValid(0); entity.setIsAudit(0); if(entity.getCfgId()==null){ Integer compileId = 0; try { List idList = ConfigServiceUtil.getId(1, 1); if(idList!=null && idList.size()>0){ compileId = idList.get(0); } } catch (Exception e) { e.printStackTrace(); logger.info("获取编译ID出错"); throw new MaatConvertException(":"+e.getMessage()); } entity.setCompileId(compileId); entity.setCreateTime(new Date()); entity.setCreatorId(entity.getCurrentUser().getId()); websiteCfgDao.saveCfgIndex(entity); if(entity.getHttpUrlList()!=null){ for(HttpUrlCfg cfg:entity.getHttpUrlList()){ BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); websiteCfgDao.saveHttpUrlCfg(cfg); } } if(entity.getHttpReqHdrList()!=null){ for(HttpReqHeadCfg cfg:entity.getHttpReqHdrList()){ BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); if(StringUtils.isNoneBlank(cfg.getDistrictShowName()) && cfg.getDistrict().equals("others")){ cfg.setDistrict(cfg.getDistrictShowName()); } websiteCfgDao.saveHttpReqHdrCfg(cfg); } } if(entity.getHttpResHdrList()!=null){ for(HttpResHeadCfg cfg:entity.getHttpResHdrList()){ BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); if(StringUtils.isNoneBlank(cfg.getDistrictShowName()) && cfg.getDistrict().equals("others")){ cfg.setDistrict(cfg.getDistrictShowName()); } websiteCfgDao.saveHttpResHdrCfg(cfg); } } if(entity.getHttpReqBodyList()!=null){ for(HttpBodyCfg cfg:entity.getHttpReqBodyList()){ BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); websiteCfgDao.saveHttpBodyCfg(cfg); } } if(entity.getHttpResBodyList()!=null){ for(HttpBodyCfg cfg:entity.getHttpResBodyList()){ BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); websiteCfgDao.saveHttpBodyCfg(cfg); } } if(entity.getIpPortList()!=null){ for(IpPortCfg cfg:entity.getIpPortList()){ BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); websiteCfgDao.saveIpPortCfg(cfg); } } if(entity.getNtcSubscribeIdCfgList()!=null){ for(NtcSubscribeIdCfg cfg:entity.getNtcSubscribeIdCfgList()){ BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); stringCfgDao.saveSubscribeIdCfg(cfg); } } //保存区域IP信息 if(entity.getAreaCfg()!=null){ for(AreaIpCfg cfg:entity.getAreaCfg()){ cfg.initDefaultValue(); BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); areaIpCfgDao.saveAreaIpCfg(cfg); } } // 处理定时任务 handelScheduleCfg(entity, entity.getIndexTable(), entity); if(isValid==1) { entity.setIsAudit(1); entity.setIsValid(1); auditPolicyCfg(entity, entity.getIsAudit(),Constants.INSERT_ACTION); } }else{ entity.setEditorId(UserUtils.getUser().getId()); entity.setEditTime(new Date()); websiteCfgDao.updateCfgIndex(entity); //无效子配置后,再新增子配置 websiteCfgDao.deleteHttpUrlCfg(entity); websiteCfgDao.deleteHttpReqHdrCfg(entity); websiteCfgDao.deleteHttpResHdrCfg(entity); websiteCfgDao.deleteHttpBodyCfg(entity); websiteCfgDao.deleteHttpIpCfg(entity); stringCfgDao.deleteSubscribeIdCfgByCfgIndexInfo(entity); AreaIpCfg area = new AreaIpCfg(); area.setCompileId(entity.getCompileId()); area.setFunctionId(entity.getFunctionId()); areaIpCfgDao.deleteAreaIpCfg(area); entity.setCreateTime(new Date()); entity.setCreatorId(entity.getCurrentUser().getId()); if(entity.getHttpUrlList()!=null){ for(HttpUrlCfg cfg:entity.getHttpUrlList()){ BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); websiteCfgDao.saveHttpUrlCfg(cfg); } } if(entity.getHttpReqHdrList()!=null){ for(HttpReqHeadCfg cfg:entity.getHttpReqHdrList()){ BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); if(StringUtils.isNoneBlank(cfg.getDistrictShowName()) && cfg.getDistrict().equals("others")){ cfg.setDistrict(cfg.getDistrictShowName()); } websiteCfgDao.saveHttpReqHdrCfg(cfg); } } if(entity.getHttpResHdrList()!=null){ for(HttpResHeadCfg cfg:entity.getHttpResHdrList()){ BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); if(StringUtils.isNoneBlank(cfg.getDistrictShowName()) && cfg.getDistrict().equals("others")){ cfg.setDistrict(cfg.getDistrictShowName()); } websiteCfgDao.saveHttpResHdrCfg(cfg); } } if(entity.getHttpReqBodyList()!=null){ for(HttpBodyCfg cfg:entity.getHttpReqBodyList()){ BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); websiteCfgDao.saveHttpBodyCfg(cfg); } } if(entity.getHttpResBodyList()!=null){ for(HttpBodyCfg cfg:entity.getHttpResBodyList()){ BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); websiteCfgDao.saveHttpBodyCfg(cfg); } } if(entity.getIpPortList()!=null){ for(IpPortCfg cfg:entity.getIpPortList()){ BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); websiteCfgDao.saveIpPortCfg(cfg); } } if(entity.getNtcSubscribeIdCfgList()!=null){ for(NtcSubscribeIdCfg cfg:entity.getNtcSubscribeIdCfgList()){ BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); stringCfgDao.saveSubscribeIdCfg(cfg); } } //保存区域IP信息 if(entity.getAreaCfg()!=null){ for(AreaIpCfg cfg:entity.getAreaCfg()){ cfg.initDefaultValue(); BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"}); areaIpCfgDao.saveAreaIpCfg(cfg); } } // 处理定时任务 handelScheduleCfg(entity, entity.getIndexTable(), entity); if(isValid==1) { entity.setIsAudit(1); entity.setIsValid(1); auditPolicyCfg(entity, entity.getIsAudit(),Constants.UPDATE_ACTION); } } } public void updatePolicyCfgValid(Integer isValid,String ids,Integer functionId){ String[] idArray = ids.split(","); for(String id :idArray){ CfgIndexInfo entity = new CfgIndexInfo(); entity.setCfgId(Long.parseLong(id)); entity.setIsValid(isValid); entity.setEditorId(UserUtils.getUser().getId()); entity.setEditTime(new Date()); entity.setTableName(CfgIndexInfo.getTablename()); entity.setFunctionId(functionId); websiteCfgDao.updateCfgValid(entity); //查询子配置 entity = this.getPolicyCfg(Long.parseLong(id),entity.getCompileId()); if(entity.getIpPortList()!=null && entity.getIpPortList().size()>0){ IpPortCfg cfg = new IpPortCfg(); BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); cfg.setTableName(IpPortCfg.getTablename()); websiteCfgDao.updateCfgValid(cfg); } if(entity.getHttpUrlList()!=null && entity.getHttpUrlList().size()>0){ HttpUrlCfg cfg = new HttpUrlCfg(); BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); cfg.setTableName(HttpUrlCfg.getTablename()); websiteCfgDao.updateCfgValid(cfg); } if(entity.getHttpReqHdrList()!=null && entity.getHttpReqHdrList().size()>0){ HttpReqHeadCfg cfg = new HttpReqHeadCfg(); BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); cfg.setTableName(HttpReqHeadCfg.getTablename()); websiteCfgDao.updateCfgValid(cfg); } if(entity.getHttpResHdrList()!=null && entity.getHttpResHdrList().size()>0){ HttpResHeadCfg cfg = new HttpResHeadCfg(); BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); cfg.setTableName(HttpResHeadCfg.getTablename()); websiteCfgDao.updateCfgValid(cfg); } if((entity.getHttpReqBodyList()!=null && entity.getHttpReqBodyList().size()>0) || (entity.getHttpResBodyList()!=null && entity.getHttpResBodyList().size()>0)){ HttpBodyCfg cfg = new HttpBodyCfg(); BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); cfg.setTableName(HttpBodyCfg.getTablename()); websiteCfgDao.updateCfgValid(cfg); } if((entity.getNtcSubscribeIdCfgList()!=null && entity.getNtcSubscribeIdCfgList().size()>0)){ NtcSubscribeIdCfg cfg = new NtcSubscribeIdCfg(); BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); cfg.setTableName(NtcSubscribeIdCfg.getTablename()); websiteCfgDao.updateCfgValid(cfg); } //保存区域IP信息 if(entity.getAreaCfg()!=null && entity.getAreaCfg().size()>0){ AreaIpCfg cfg = new AreaIpCfg(); BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); cfg.setTableName(AreaIpCfg.getTablename()); websiteCfgDao.updateCfgValid(cfg); } // 处理定时任务 handelScheduleCfg(entity, entity.getIndexTable(), entity); } } public void auditPolicyCfg(CfgIndexInfo entity,Integer isAudit,Integer opAction) throws MaatConvertException{ //修改数据库审核状态信息 entity.setTableName(CfgIndexInfo.getTablename()); entity.setIsAudit(isAudit); entity.setAuditorId(UserUtils.getUser().getId()); entity.setAuditTime(new Date()); websiteCfgDao.auditCfg(entity); ToMaatBean maatBean = new ToMaatBean(); MaatCfg maatCfg = new MaatCfg(); List configCompileList = new ArrayList(); List groupRelationList = new ArrayList(); List ipRegionList = new ArrayList(); List strRegionList = new ArrayList(); List numRegionList = new ArrayList(); List digestRegionList = new ArrayList(); List areaIpRegionList = new ArrayList(); //查询子配置并修改审核状态 entity = this.getPolicyCfg(entity.getCfgId(),entity.getCompileId()); if(entity.getIpPortList()!=null && entity.getIpPortList().size()>0){ IpPortCfg cfg = new IpPortCfg(); BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); cfg.setTableName(IpPortCfg.getTablename()); websiteCfgDao.auditCfg(cfg); if(isAudit==1){ Map map = cfgConvert(ipRegionList,entity.getIpPortList(),1,entity,groupRelationList); groupRelationList=map.get("groupList"); ipRegionList=map.get("dstList"); if(map.get("numRegionList")!=null){ numRegionList.addAll(map.get("numRegionList")); } } } if(entity.getHttpUrlList()!=null && entity.getHttpUrlList().size()>0){ HttpUrlCfg cfg = new HttpUrlCfg(); BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); cfg.setTableName(HttpUrlCfg.getTablename()); websiteCfgDao.auditCfg(cfg); if(isAudit==1){ Map map = cfgConvert(strRegionList,entity.getHttpUrlList(),2,entity,groupRelationList); groupRelationList=map.get("groupList"); strRegionList=map.get("dstList"); } } if(entity.getHttpReqHdrList()!=null && entity.getHttpReqHdrList().size()>0){ HttpReqHeadCfg cfg = new HttpReqHeadCfg(); BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); cfg.setTableName(HttpReqHeadCfg.getTablename()); websiteCfgDao.auditCfg(cfg); if(isAudit==1){ Map map = cfgConvert(strRegionList,entity.getHttpReqHdrList(),2,entity,groupRelationList); groupRelationList=map.get("groupList"); strRegionList=map.get("dstList"); } } if(entity.getHttpResHdrList()!=null && entity.getHttpResHdrList().size()>0){ HttpResHeadCfg cfg = new HttpResHeadCfg(); BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); cfg.setTableName(HttpResHeadCfg.getTablename()); websiteCfgDao.auditCfg(cfg); if(isAudit==1){ Map map = cfgConvert(strRegionList,entity.getHttpResHdrList(),2,entity,groupRelationList); groupRelationList=map.get("groupList"); strRegionList=map.get("dstList"); } } if((entity.getHttpReqBodyList()!=null && entity.getHttpReqBodyList().size()>0) || (entity.getHttpResBodyList()!=null && entity.getHttpResBodyList().size()>0)){ HttpBodyCfg cfg = new HttpBodyCfg(); BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); cfg.setTableName(HttpBodyCfg.getTablename()); websiteCfgDao.auditCfg(cfg); if(isAudit==1){ if(entity.getHttpReqBodyList()!=null && entity.getHttpReqBodyList().size()>0){ Map map = cfgConvert(strRegionList,entity.getHttpReqBodyList(),2,entity,groupRelationList); groupRelationList=map.get("groupList"); strRegionList=map.get("dstList"); } if(entity.getHttpResBodyList()!=null && entity.getHttpResBodyList().size()>0){ Map map = cfgConvert(strRegionList,entity.getHttpResBodyList(),2,entity,groupRelationList); groupRelationList=map.get("groupList"); strRegionList=map.get("dstList"); } } } if(entity.getNtcSubscribeIdCfgList()!=null && entity.getNtcSubscribeIdCfgList().size()>0){ NtcSubscribeIdCfg cfg = new NtcSubscribeIdCfg(); BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); cfg.setTableName(NtcSubscribeIdCfg.getTablename()); websiteCfgDao.auditCfg(cfg); if(isAudit==1){ Map map = cfgConvert(strRegionList,entity.getNtcSubscribeIdCfgList(),2,entity,groupRelationList); groupRelationList=map.get("groupList"); strRegionList=map.get("dstList"); } } //保存区域IP信息 List areaIpCfgList=areaIpCfgDao.getByCompileId(entity.getCompileId()); if(!StringUtil.isEmpty(areaIpCfgList)){ AreaIpCfg cfg = new AreaIpCfg(); BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); cfg.setTableName(AreaIpCfg.getTablename()); websiteCfgDao.auditCfg(cfg); if(isAudit==1){ Map map = cfgConvert(areaIpRegionList,areaIpCfgList,1,entity,groupRelationList); groupRelationList=map.get("groupList"); areaIpRegionList=map.get("dstList"); } } if (isAudit != 1) { // 处理定时任务【如果有定时任务则删除旧的,新增新的】 handelScheduleCfg(entity, entity.getIndexTable(), entity); } //构造提交综合服务参数格式,一条配置提交一次综合服务 if(isAudit==1){ maatCfg.initDefaultValue(); BeanUtils.copyProperties(entity, maatCfg); maatCfg.setAction(entity.getAction()); maatCfg.setAuditTime(entity.getAuditTime()); maatCfg.setIpRegionList(ipRegionList); maatCfg.setStrRegionList(strRegionList); maatCfg.setNumRegionList(numRegionList); maatCfg.setDigestRegionList(digestRegionList); maatCfg.setGroupRelationList(groupRelationList); maatCfg.setGroupNum(groupRelationList.size()); maatCfg.setAreaIpRegionList(areaIpRegionList); maatCfg.setIsValid(entity.getIsValid()); // 自定义域参数 String userRegion = ""; ManipulatActionParam actionParam = new ManipulatActionParam(); /** * 除原自定义参数外 * user_region4 profile * user_region5 action(伪) **/ // Block if(Integer.valueOf(entity.getUserRegion5()).equals(16)){ actionParam.setMethod("block"); actionParam.setCode(Integer.valueOf(entity.getUserRegion1())); actionParam.setMessage(entity.getUserRegion2()); actionParam.setHtml_profile(Integer.valueOf(entity.getUserRegion4())); } // Redirect if(Integer.valueOf(entity.getUserRegion5()).equals(48)){ actionParam.setMethod("redirect"); actionParam.setCode(Integer.valueOf(entity.getUserRegion1())); actionParam.setTo(entity.getUserRegion2()); } // Replace if(Integer.valueOf(entity.getUserRegion5()).equals(80)){ List ReplaceCfgList = new ArrayList(); ReplaceCfg replaceCfg = new ReplaceCfg(); replaceCfg.setSearch_in(entity.getUserRegion1()); replaceCfg.setFind(entity.getUserRegion2()); replaceCfg.setReplace_with(entity.getUserRegion3()); ReplaceCfgList.add(replaceCfg); actionParam.setMethod("replace"); actionParam.setRules(ReplaceCfgList); } if(Integer.valueOf(entity.getUserRegion5()).equals(85)){ actionParam.setMethod("hijack"); actionParam.setHijack_profile(Integer.valueOf(entity.getUserRegion4())); } if(Integer.valueOf(entity.getUserRegion5()).equals(90)){ actionParam.setMethod("insert"); actionParam.setInsert_profile(Integer.valueOf(entity.getUserRegion4())); } userRegion = gsonToJson(actionParam); if(StringUtil.isEmpty(userRegion)){ userRegion = Constants.USER_REGION_PLACEHOLDER; } maatCfg.setUserRegion(userRegion); configCompileList.add(maatCfg); maatBean.setConfigCompileList(configCompileList); maatBean.setAuditTime(entity.getAuditTime()); maatBean.setCreatorName(entity.getCurrentUser().getName()); maatBean.setVersion(Constants.MAAT_VERSION); maatBean.setOpAction(opAction); //调用服务接口下发配置数据 String json=gsonToJson(maatBean); logger.info("操控策略配置下发配置参数:"+json); //调用服务接口下发配置 ToMaatResult result = ConfigServiceUtil.postMaatCfg(json); logger.info("操控策略配置下发响应信息:"+result.getMsg()); }else if(isAudit==3) { maatCfg.setCompileId(entity.getCompileId()); maatCfg.setServiceId(entity.getServiceId()); maatCfg.setIsValid(0);//无效 configCompileList.add(maatCfg); maatBean.setConfigCompileList(configCompileList); maatBean.setAuditTime(entity.getAuditTime()); maatBean.setCreatorName(entity.getCurrentUser().getName()); maatBean.setVersion(Constants.MAAT_VERSION); maatBean.setOpAction(Constants.UPDATE_ACTION); //调用服务接口取消配置 String json=gsonToJson(maatBean); logger.info("操控策略配置下发配置参数:"+json); //调用服务接口下发配置 ToMaatResult result = ConfigServiceUtil.put(json,1); logger.info("操控策略配置取消配置响应信息:"+result.getMsg()); } } /** * 查询可用的Profile信息 * @param source 16 Block / 85 Hijack / 90 Insert * @return List */ public List getProfileInfo(Integer source) { List resultList = new ArrayList(); if(source == 16) { ProxyFileStrategyCfg searchEntity = new ProxyFileStrategyCfg(); searchEntity.setIsAudit(1); List list = proxyFileDao.fingResPages(searchEntity); for (BaseCfg cfg : list) { resultList.add(cfg); } }else if(source == 85) { ProxyFileHijackCfg searchEntity = new ProxyFileHijackCfg(); searchEntity.setIsAudit(1); List list = proxyFileHijackDao.findPage(searchEntity); for (BaseCfg cfg : list) { resultList.add(cfg); } }else if(source == 90) { ProxyFileInsertScriptCfg searchEntity = new ProxyFileInsertScriptCfg(); searchEntity.setIsAudit(1); List list = proxyFileInsertDao.findPage(searchEntity); for (BaseCfg cfg : list) { resultList.add(cfg); } } return resultList; } }