1、修改非maat配置取消接口请求参数;
2、添加maat配置 配置存储接口中service与action对应关系验证
This commit is contained in:
@@ -1,64 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package com.nis.domain.restful;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import com.wordnik.swagger.annotations.ApiModelProperty;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ClassName:CancleConfigSource
|
|
||||||
* @Description:TODO(这里用一句话描述这个类的作用)
|
|
||||||
* @author (zdx)
|
|
||||||
* @date 2018年6月1日 下午6:08:09
|
|
||||||
* @version V1.0
|
|
||||||
*/
|
|
||||||
public class UpdateStatConfig implements Serializable{
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 6346336602908201877L;
|
|
||||||
@ApiModelProperty(value = "配置ID", required = true)
|
|
||||||
private Long cfgId;
|
|
||||||
@ApiModelProperty(value = "业务ID", required = true)
|
|
||||||
private Integer service;
|
|
||||||
@ApiModelProperty(value = "是否有效", required = true)
|
|
||||||
private Integer isValid;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public UpdateStatConfig() {
|
|
||||||
super();
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param cfgId
|
|
||||||
* @param service
|
|
||||||
* @param isValid
|
|
||||||
*/
|
|
||||||
public UpdateStatConfig(Long cfgId, Integer service, Integer isValid) {
|
|
||||||
super();
|
|
||||||
this.cfgId = cfgId;
|
|
||||||
this.service = service;
|
|
||||||
this.isValid = isValid;
|
|
||||||
}
|
|
||||||
public Long getCfgId() {
|
|
||||||
return cfgId;
|
|
||||||
}
|
|
||||||
public void setCfgId(Long cfgId) {
|
|
||||||
this.cfgId = cfgId;
|
|
||||||
}
|
|
||||||
public Integer getService() {
|
|
||||||
return service;
|
|
||||||
}
|
|
||||||
public void setService(Integer service) {
|
|
||||||
this.service = service;
|
|
||||||
}
|
|
||||||
public Integer getIsValid() {
|
|
||||||
return isValid;
|
|
||||||
}
|
|
||||||
public void setIsValid(Integer isValid) {
|
|
||||||
this.isValid = isValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package com.nis.domain.restful;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ClassName:CancleConfigSource
|
|
||||||
* @Description:TODO(这里用一句话描述这个类的作用)
|
|
||||||
* @author (zdx)
|
|
||||||
* @date 2018年6月1日 下午6:08:09
|
|
||||||
* @version V1.0
|
|
||||||
*/
|
|
||||||
public class UpdateStatConfigSource implements Serializable{
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 277603807201929340L;
|
|
||||||
private List<UpdateStatConfig> UpdateStatCfgList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public UpdateStatConfigSource() {
|
|
||||||
super();
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param cancleConfigList
|
|
||||||
*/
|
|
||||||
public UpdateStatConfigSource(List<UpdateStatConfig> UpdateStatCfgList) {
|
|
||||||
super();
|
|
||||||
this.UpdateStatCfgList = UpdateStatCfgList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<UpdateStatConfig> getUpdateStatCfgList() {
|
|
||||||
return UpdateStatCfgList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUpdateStatCfgList(List<UpdateStatConfig> updateStatCfgList) {
|
|
||||||
UpdateStatCfgList = updateStatCfgList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -681,9 +681,11 @@ public class CompileVal {
|
|||||||
|
|
||||||
public static String serviceConfigCompileVal(ConfigCompile configCompile) {
|
public static String serviceConfigCompileVal(ConfigCompile configCompile) {
|
||||||
Long compileId = configCompile.getCompileId();
|
Long compileId = configCompile.getCompileId();
|
||||||
if (configCompile.getAction() != 1 && configCompile.getAction() != 2 && configCompile.getAction() != 5
|
Integer action = ServiceAndRDBIndexReal.getActionByService(configCompile.getService());
|
||||||
&& configCompile.getAction() != 6 && configCompile.getAction() != 7) {
|
if (StringUtil.isEmpty(action)){
|
||||||
return "编译配置id为" + compileId + "的配置中action的值只能是1(阻断),2(监测),5(封堵白名单),6(监测白名单),7(封堵监测都白名单)";
|
return "编译配置id为" + compileId + "的配置中service的值为"+configCompile.getService()+"时action不存在";
|
||||||
|
}else if(action.compareTo(configCompile.getAction())!=0) {
|
||||||
|
return "编译配置id为" + compileId + "的配置中service的值为"+configCompile.getService()+"时action只能为"+action;
|
||||||
}
|
}
|
||||||
if (configCompile.getDoBlacklist() != 1) {
|
if (configCompile.getDoBlacklist() != 1) {
|
||||||
return "编译配置id为" + compileId + "的配置中doBlacklist的值只能是1";
|
return "编译配置id为" + compileId + "的配置中doBlacklist的值只能是1";
|
||||||
|
|||||||
@@ -24,13 +24,18 @@ public class ServiceAndRDBIndexReal {
|
|||||||
* key是业务类型,value是业务类型对应的redisdbIndex
|
* key是业务类型,value是业务类型对应的redisdbIndex
|
||||||
*/
|
*/
|
||||||
private static Map<Integer, List<Integer>> serviceDBIndexmap = new HashMap<Integer, List<Integer>>();
|
private static Map<Integer, List<Integer>> serviceDBIndexmap = new HashMap<Integer, List<Integer>>();
|
||||||
|
/**
|
||||||
|
* key是业务类型,value是业务类型对应的动作(action)
|
||||||
|
*/
|
||||||
|
private static Map<Integer, Integer> serviceActionMap = new HashMap<Integer, Integer>();
|
||||||
static {
|
static {
|
||||||
String service = Configurations.getStringProperty("service", "");
|
String service = Configurations.getStringProperty("service", "");
|
||||||
if (service != null && !service.trim().equals("")) {
|
if (service != null && !service.trim().equals("")) {
|
||||||
String[] split = service.split(";");
|
String[] split = service.split(";");
|
||||||
for (String str : split) {
|
for (String str : split) {
|
||||||
String type = Configurations.getStringProperty(str, "");
|
String[] serviceAction = str.split(":");
|
||||||
|
serviceActionMap.put(Integer.valueOf(serviceAction[0]), Integer.valueOf(serviceAction[1]));
|
||||||
|
String type = Configurations.getStringProperty(serviceAction[0], "");
|
||||||
if (type != null && !type.trim().equals("")) {
|
if (type != null && !type.trim().equals("")) {
|
||||||
Map<Integer, String> typeMap = new HashMap<Integer, String>();
|
Map<Integer, String> typeMap = new HashMap<Integer, String>();
|
||||||
String[] typeArrs = type.split(";");
|
String[] typeArrs = type.split(";");
|
||||||
@@ -41,7 +46,7 @@ public class ServiceAndRDBIndexReal {
|
|||||||
typeMap.put(Integer.parseInt(typeArr[0]), tableName.toUpperCase());
|
typeMap.put(Integer.parseInt(typeArr[0]), tableName.toUpperCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sercieNameMap.put(Integer.parseInt(str), typeMap);
|
sercieNameMap.put(Integer.parseInt(serviceAction[0]), typeMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -88,7 +93,10 @@ public class ServiceAndRDBIndexReal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public static Integer getActionByService(Integer service) {
|
||||||
|
return serviceActionMap.get(service);
|
||||||
|
}
|
||||||
|
|
||||||
public static Map<Integer, Map<Integer, String>> getSercieNameMap() {
|
public static Map<Integer, Map<Integer, String>> getSercieNameMap() {
|
||||||
return sercieNameMap;
|
return sercieNameMap;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import com.nis.domain.restful.ConfigCompile;
|
|||||||
import com.nis.domain.restful.ConfigSource;
|
import com.nis.domain.restful.ConfigSource;
|
||||||
import com.nis.domain.restful.FileDesc;
|
import com.nis.domain.restful.FileDesc;
|
||||||
import com.nis.domain.restful.MaatConfig;
|
import com.nis.domain.restful.MaatConfig;
|
||||||
import com.nis.domain.restful.UpdateStatConfigSource;
|
|
||||||
import com.nis.restful.RestBusinessCode;
|
import com.nis.restful.RestBusinessCode;
|
||||||
import com.nis.restful.RestServiceException;
|
import com.nis.restful.RestServiceException;
|
||||||
import com.nis.util.Constants;
|
import com.nis.util.Constants;
|
||||||
@@ -503,19 +502,17 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
@RequestMapping(value = "/cfg/v1/commonSources", method = RequestMethod.PUT)
|
@RequestMapping(value = "/cfg/v1/commonSources", method = RequestMethod.PUT)
|
||||||
@ApiOperation(value = "回调配置状态修改", httpMethod = "PUT", response = Map.class, notes = "回调配置状态修改服务")
|
@ApiOperation(value = "回调配置状态修改", httpMethod = "PUT", response = Map.class, notes = "回调配置状态修改服务")
|
||||||
@ApiParam(value = "回调配置状态修改", name = "updateStatConfigSource", required = true)
|
@ApiParam(value = "回调配置状态修改", name = "updateStatConfigSource", required = true)
|
||||||
public Map updateCommonConfigSource(@RequestBody UpdateStatConfigSource updateStatConfigSource,
|
public Map updateCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
|
||||||
HttpServletRequest request, HttpServletResponse response) {
|
HttpServletResponse response) {
|
||||||
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
|
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
|
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,jsonString);
|
||||||
updateStatConfigSource);
|
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
|
|
||||||
|
configSourcesService.updateCommonSources(thread, start,jsonString, new Date(),sb);
|
||||||
|
|
||||||
configSourcesService.updateCommonSources(thread, start, updateStatConfigSource.getUpdateStatCfgList(),
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
||||||
new Date(), sb);
|
"配置状态修改成功" , Constants.IS_DEBUG ? jsonString : null);
|
||||||
|
|
||||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "配置状态修改成功",
|
|
||||||
Constants.IS_DEBUG ? updateStatConfigSource : null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/cfg/v1/fileUploadSources", method = RequestMethod.POST)
|
@RequestMapping(value = "/cfg/v1/fileUploadSources", method = RequestMethod.POST)
|
||||||
@@ -564,8 +561,8 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
JSONObject jsonObj = new JSONObject();
|
JSONObject jsonObj = new JSONObject();
|
||||||
jsonObj.put("accessUrl", filePath.substring(filePath.indexOf("group")));
|
// jsonObj.put("accessUrl", filePath.substring(filePath.indexOf("group")));
|
||||||
// jsonObj.put("accessUrl", "filePath");
|
jsonObj.put("accessUrl", "filePath");
|
||||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "文件上传成功", jsonObj);
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "文件上传成功", jsonObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -606,7 +603,8 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
// meta_list[4] = new NameValuePair("fileMd5", md5);
|
// meta_list[4] = new NameValuePair("fileMd5", md5);
|
||||||
logger.info("-----------------调用接口上传文件---------------");
|
logger.info("-----------------调用接口上传文件---------------");
|
||||||
String filePath = FileManager.upload(fdsfile, null);
|
String filePath = FileManager.upload(fdsfile, null);
|
||||||
resultObject.put("path", filePath.substring(filePath.indexOf("group")));
|
// resultObject.put("path", filePath.substring(filePath.indexOf("group")));
|
||||||
|
resultObject.put("path", filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonsMultipartFile filetemp = (CommonsMultipartFile) file;
|
CommonsMultipartFile filetemp = (CommonsMultipartFile) file;
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import java.util.concurrent.CountDownLatch;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
@@ -38,7 +40,6 @@ import com.nis.domain.restful.IpRegion;
|
|||||||
import com.nis.domain.restful.MaatConfig;
|
import com.nis.domain.restful.MaatConfig;
|
||||||
import com.nis.domain.restful.NumRegion;
|
import com.nis.domain.restful.NumRegion;
|
||||||
import com.nis.domain.restful.StrRegion;
|
import com.nis.domain.restful.StrRegion;
|
||||||
import com.nis.domain.restful.UpdateStatConfig;
|
|
||||||
import com.nis.restful.CompileJudgeCode;
|
import com.nis.restful.CompileJudgeCode;
|
||||||
import com.nis.restful.RestBusinessCode;
|
import com.nis.restful.RestBusinessCode;
|
||||||
import com.nis.restful.RestServiceException;
|
import com.nis.restful.RestServiceException;
|
||||||
@@ -61,8 +62,6 @@ import com.nis.web.service.BaseService;
|
|||||||
import com.nis.web.service.SaveRequestLogThread;
|
import com.nis.web.service.SaveRequestLogThread;
|
||||||
import com.nis.web.service.SpringContextHolder;
|
import com.nis.web.service.SpringContextHolder;
|
||||||
|
|
||||||
import net.sf.json.JSONObject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName: ControlService
|
* @ClassName: ControlService
|
||||||
* @Description: TODO(编译配置持久化)
|
* @Description: TODO(编译配置持久化)
|
||||||
@@ -2566,31 +2565,40 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
|
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
public String updateCommonSources(SaveRequestLogThread thread, long start, List<UpdateStatConfig> updateStatCfgList,
|
public String updateCommonSources(SaveRequestLogThread thread, long start,String jsonString,
|
||||||
Date opTime, StringBuffer sb) {
|
Date opTime, StringBuffer sb) {
|
||||||
Map<Integer, List<Long>> cfgMap = new HashMap<Integer, List<Long>>();
|
JsonArray jsonObjectList = null;
|
||||||
if (null != updateStatCfgList && updateStatCfgList.size() > 0) {
|
try {
|
||||||
for (UpdateStatConfig config : updateStatCfgList) {
|
jsonObjectList = new JsonParser().parse(jsonString).getAsJsonArray();
|
||||||
String msg = checkOptForUpdate(config);
|
} catch (Exception e) {
|
||||||
if (!msg.equals("ok")) {
|
// TODO: handle exception
|
||||||
thread.setExceptionInfo(msg + sb.toString());
|
logger1.error(e.getMessage());
|
||||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, msg + sb.toString(),
|
thread.setExceptionInfo(e.getMessage() + sb.toString());
|
||||||
RestBusinessCode.config_integrity_error.getValue());
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, e.getMessage() + sb.toString(),
|
||||||
}
|
RestBusinessCode.config_integrity_error.getValue());
|
||||||
if (cfgMap.containsKey(config.getService())) {
|
|
||||||
cfgMap.get(config.getService()).add(config.getCfgId());
|
|
||||||
} else {
|
|
||||||
List<Long> idList = new ArrayList<Long>();
|
|
||||||
idList.add(config.getCfgId());
|
|
||||||
cfgMap.put(config.getService(), idList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
thread.setExceptionInfo("配置列表不能为空" + sb.toString());
|
|
||||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "配置列表不能为空" + sb.toString(),
|
|
||||||
RestBusinessCode.config_integrity_error.getValue());
|
|
||||||
}
|
}
|
||||||
|
//<service,cfgIdList>
|
||||||
|
Map<Integer, List<Long>> cfgMap = new HashMap<Integer, List<Long>>();
|
||||||
|
for (int i = 0; i < jsonObjectList.size(); i++) {
|
||||||
|
JsonObject jsonObj=(JsonObject) jsonObjectList.get(i);
|
||||||
|
Map<String, Object> srcMap = JSONObject.fromObject(JSONObject.fromObject((jsonObj.toString())));
|
||||||
|
String msg = checkOptForUpdate(srcMap);
|
||||||
|
if (!msg.equals("ok")) {
|
||||||
|
thread.setExceptionInfo(msg + sb.toString());
|
||||||
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, msg + sb.toString(),
|
||||||
|
RestBusinessCode.config_integrity_error.getValue());
|
||||||
|
}
|
||||||
|
Integer service = Integer.valueOf(srcMap.get("service").toString());
|
||||||
|
Long cfgId = Long.valueOf(srcMap.get("cfgId").toString());
|
||||||
|
if (cfgMap.containsKey(service)) {
|
||||||
|
cfgMap.get(service).add(cfgId);
|
||||||
|
} else {
|
||||||
|
List<Long> idList = new ArrayList<Long>();
|
||||||
|
idList.add(cfgId);
|
||||||
|
cfgMap.put(service, idList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Map<Integer, Map<Integer, List<Long>>> restMap = new HashMap<Integer, Map<Integer, List<Long>>>();
|
Map<Integer, Map<Integer, List<Long>>> restMap = new HashMap<Integer, Map<Integer, List<Long>>>();
|
||||||
Iterator serviceIterator = cfgMap.keySet().iterator();
|
Iterator serviceIterator = cfgMap.keySet().iterator();
|
||||||
while (serviceIterator.hasNext()) {
|
while (serviceIterator.hasNext()) {
|
||||||
@@ -2610,22 +2618,31 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
|
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
private String checkOptForUpdate(UpdateStatConfig config) {
|
private String checkOptForUpdate(Map<String, Object> srcMap) {
|
||||||
if (StringUtil.isEmpty(config.getCfgId())) {
|
String cfgId = srcMap.get("cfgId").toString();
|
||||||
|
String service = srcMap.get("service").toString();
|
||||||
|
String isValid = srcMap.get("isValid").toString();
|
||||||
|
if (StringUtil.isEmpty(cfgId)) {
|
||||||
return "cfgId字段不能为空";
|
return "cfgId字段不能为空";
|
||||||
|
}else if(!StringUtil.isNumeric(cfgId)){
|
||||||
|
return "cfgId字段格式不正确";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtil.isEmpty(config.getService())) {
|
if (StringUtil.isEmpty(service)) {
|
||||||
return "service字段不能为空";
|
return "service字段不能为空";
|
||||||
|
}else if(!StringUtil.isNumeric(service)){
|
||||||
|
return "service字段格式不正确";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtil.isEmpty(config.getIsValid())) {
|
if (StringUtil.isEmpty(isValid)) {
|
||||||
return "配置id为" + config.getCfgId()+"的IsValid字段不能为空";
|
return "配置id为" + srcMap.get("cfgId")+"的isValid字段不能为空";
|
||||||
|
}else {
|
||||||
|
if(!StringUtil.isNumeric(service)){
|
||||||
|
return "isValid字段格式不正确";
|
||||||
|
}else if(!isValid.equals("0")){
|
||||||
|
return "isValid字段取值只能是0(失效)";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (config.getIsValid() != 0) {
|
|
||||||
return "配置id为" + config.getCfgId() + "的配置在修改时不能为有效";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
private boolean isIp(String ipStr){
|
private boolean isIp(String ipStr){
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
</p:expressions>
|
</p:expressions>
|
||||||
</p:maatType>
|
</p:maatType>
|
||||||
|
|
||||||
<p:maatType service="3;1;80;82;84;144;146;148">
|
<p:maatType service="17;1;80;82;84;144;146;148">
|
||||||
<p:expressions>
|
<p:expressions>
|
||||||
<p:keyExpression>EFFECTIVE_RULE;:;{compile_table_name};,;[compile_id]</p:keyExpression>
|
<p:keyExpression>EFFECTIVE_RULE;:;{compile_table_name};,;[compile_id]</p:keyExpression>
|
||||||
<p:valueExpression>[compile_id];\t;[service];\t;[action];\t;[do_blacklist];\t;[do_log];\t;[effective_range];\t;[user_region];\t;[is_valid];\t;[group_num];\t;[father_cfg_id];\t;[op_time]</p:valueExpression>
|
<p:valueExpression>[compile_id];\t;[service];\t;[action];\t;[do_blacklist];\t;[do_log];\t;[effective_range];\t;[user_region];\t;[is_valid];\t;[group_num];\t;[father_cfg_id];\t;[op_time]</p:valueExpression>
|
||||||
|
|||||||
@@ -5,11 +5,12 @@
|
|||||||
####3:例如:80=10:MM_COMPILE;11:MM_GROUP;12:AV_CONT_IP_PORT
|
####3:例如:80=10:MM_COMPILE;11:MM_GROUP;12:AV_CONT_IP_PORT
|
||||||
####4:type中10代表是编译配置,11代表是分组配置,12代表是ip类域配置,13代表是数值类配置,14代表是字符串类域配置,15代表是增强字符串类域配置,16代表是文件摘要类域配置,17代表是文本相似性域配置
|
####4:type中10代表是编译配置,11代表是分组配置,12代表是ip类域配置,13代表是数值类配置,14代表是字符串类域配置,15代表是增强字符串类域配置,16代表是文件摘要类域配置,17代表是文本相似性域配置
|
||||||
#################################################################################
|
#################################################################################
|
||||||
service=3;1;80;81;82;83;84;85;144;145;146;147;148;149
|
service=1:128;2:128;3:32;4:96;16:48;17:16;18:16;19:16;20:16;21:16;22:16;23:16;24:16;25:32;26:16;27:16;28:32;29:32;30:16;31:16;128:1;129:1;130:1;131:1;132:1;133:1;134:1;135:1;136:1;137:1;138:1;139:1;140:1;141:1;256:16;257:16;258:16;259:16;260:16;261:16;262:16;263:16;264:16;265:16;266:16;384:1;385:1;386:1;387:1;388:1;389:1;390:1;391:1;392:1;393:1;394:1;512:1;513:1;528:48;529:48;544:2;545:2;560:80;561:80;1024:16
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
3=10:NTC_COMPILE;11:NTC_GROUP;12:NTC_UNIVERSAL_IP
|
|
||||||
|
17=10:NTC_COMPILE;11:NTC_GROUP;12:NTC_UNIVERSAL_IP
|
||||||
1=10:WHITE_LIST_COMPILE;11:WHITE_LIST_GROUP;12:WHITE_LIST_IP
|
1=10:WHITE_LIST_COMPILE;11:WHITE_LIST_GROUP;12:WHITE_LIST_IP
|
||||||
80=10:MM_COMPILE;11:MM_GROUP;12:MM_AV_IP
|
80=10:MM_COMPILE;11:MM_GROUP;12:MM_AV_IP
|
||||||
81=10:MM_COMPILE;11:MM_GROUP;14:MM_AV_URL
|
81=10:MM_COMPILE;11:MM_GROUP;14:MM_AV_URL
|
||||||
|
|||||||
@@ -81,136 +81,153 @@ public class RestTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
//@Test
|
||||||
public void testGetPzId() {
|
public void testGetPzId() {
|
||||||
CloseableHttpResponse response = null;
|
CloseableHttpResponse response = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
HttpGet request = new HttpGet(
|
HttpGet request = new HttpGet(
|
||||||
"http://10.0.6.104:8080/galaxy/service/cfg/v1/configPzIdSources?sourceName=CONFIGCOMPILE");
|
"http://10.0.6.104:8080/galaxy/service/cfg/v1/configPzIdSources?sourceName=CONFIGCOMPILE");
|
||||||
//galaxy/service/cfg/v1/fileUploadSources
|
//galaxy/service/cfg/v1/fileUploadSources
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("sourceName", "CONFIGCOMPILE");
|
jsonObject.put("sourceName", "CONFIGCOMPILE");
|
||||||
jsonObject.put("createTime", "2018-05-21 21:00:00");
|
jsonObject.put("createTime", "2018-05-21 21:00:00");
|
||||||
jsonObject.put("key", "123456789");
|
jsonObject.put("key", "123456789");
|
||||||
jsonObject.put("fileName", "1.png");
|
jsonObject.put("fileName", "1.png");
|
||||||
jsonObject.put("checksum", "d99f9aa4f3748fa48aa6e350c628c67f");
|
jsonObject.put("checksum", "d99f9aa4f3748fa48aa6e350c628c67f");
|
||||||
|
|
||||||
// request.setHeader("File-Desc", jsonObject.toString());
|
// request.setHeader("File-Desc", jsonObject.toString());
|
||||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
|
|
||||||
response = httpClient.execute(request);
|
response = httpClient.execute(request);
|
||||||
//HttpEntity httpEntity = response.getEntity();
|
//HttpEntity httpEntity = response.getEntity();
|
||||||
String result = EntityUtils.toString(response.getEntity());
|
String result = EntityUtils.toString(response.getEntity());
|
||||||
Map<String, Object> resultMap = (Map<String, Object>)JsonMapper.fromJsonString(result, Map.class);
|
Map<String, Object> resultMap = (Map<String, Object>)JsonMapper.fromJsonString(result, Map.class);
|
||||||
Map<String, Object> dataMap = (Map<String, Object>)resultMap.get(RestConstants.REST_SERVICE_DATA);
|
Map<String, Object> dataMap = (Map<String, Object>)resultMap.get(RestConstants.REST_SERVICE_DATA);
|
||||||
List<?> idObject = (List<?>) dataMap.get("pzIdList");
|
List<?> idObject = (List<?>) dataMap.get("pzIdList");
|
||||||
for (Object object : idObject) {
|
for (Object object : idObject) {
|
||||||
if(object instanceof Integer){
|
if(object instanceof Integer){
|
||||||
System.out.println("Integer");
|
System.out.println("Integer");
|
||||||
}else if(object instanceof Long){
|
}else if(object instanceof Long){
|
||||||
System.out.println("Long");
|
System.out.println("Long");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("aa");
|
||||||
|
} catch (ClientProtocolException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
System.out.println("aa");
|
|
||||||
} catch (ClientProtocolException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
//@Test
|
||||||
}
|
public void test() {
|
||||||
//@Test
|
Date date = new Date();
|
||||||
public void test() {
|
System.out.println(date.getTime());
|
||||||
Date date = new Date();
|
|
||||||
System.out.println(date.getTime());
|
|
||||||
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
System.out.println(calendar.getTimeInMillis());
|
|
||||||
}
|
|
||||||
//@Test
|
|
||||||
public void testSdf() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
try {
|
|
||||||
SimpleDateFormat df1 = new SimpleDateFormat(
|
|
||||||
"yyyy-MM-dd HH:mm:ss");
|
|
||||||
// Date t = new Date();
|
|
||||||
Date t = df1.parse("2018-05-23 13:48:11");
|
|
||||||
Long time = t.getTime();
|
|
||||||
System.out.println(df1.format(t));
|
|
||||||
System.out.println(time);
|
|
||||||
Long time2 = (time/1000)*1000;
|
|
||||||
System.out.println(time2+" "+df1.format(time2));
|
|
||||||
|
|
||||||
System.out.println(df1.getTimeZone().getID()+"----------------"+df1.format(t));
|
|
||||||
|
|
||||||
df1.setTimeZone(TimeZone.getTimeZone("UTC"));
|
|
||||||
System.out.println(df1.format(t));
|
|
||||||
|
|
||||||
|
|
||||||
System.out.println("-------------------------------------------------------------------");
|
|
||||||
|
|
||||||
SimpleDateFormat df2 = new SimpleDateFormat(
|
|
||||||
"yyyy-MM-dd'T'HH:mm:ss.SSS");
|
|
||||||
Date t2 = new Date();
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTimeInMillis(time);
|
System.out.println(calendar.getTimeInMillis());
|
||||||
System.out.println(df2.getTimeZone().getID()+"----------------"+df2.format(calendar.getTime()));
|
}
|
||||||
|
//@Test
|
||||||
|
public void testSdf() {
|
||||||
df2.setTimeZone(TimeZone.getTimeZone("UTC"));
|
// TODO Auto-generated method stub
|
||||||
System.out.println(df2.getTimeZone().getID()+"----------------"+df2.format(calendar.getTime()));
|
try {
|
||||||
df2.setTimeZone(TimeZone.getTimeZone("UTC-8"));
|
SimpleDateFormat df1 = new SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss");
|
||||||
System.out.println(df2.getTimeZone().getID()+"----------------"+df2.format(calendar.getTime()));
|
// Date t = new Date();
|
||||||
df2.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
Date t = df1.parse("2018-05-23 13:48:11");
|
||||||
|
Long time = t.getTime();
|
||||||
System.out.println(df2.getTimeZone().getID()+"----------------"+df2.format(calendar.getTime()));
|
System.out.println(df1.format(t));
|
||||||
df2.setTimeZone(TimeZone.getTimeZone("GMT"));
|
System.out.println(time);
|
||||||
System.out.println(df2.getTimeZone().getID()+"----------------"+df2.format(calendar.getTime()));
|
Long time2 = (time/1000)*1000;
|
||||||
|
System.out.println(time2+" "+df1.format(time2));
|
||||||
|
|
||||||
System.out.println("-----------------------------------------");
|
System.out.println(df1.getTimeZone().getID()+"----------------"+df1.format(t));
|
||||||
|
|
||||||
df2.setTimeZone(TimeZone.getTimeZone("UTC"));
|
df1.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
Date date = df2.parse("2018-05-23T13:48:11.077");
|
System.out.println(df1.format(t));
|
||||||
|
|
||||||
System.out.println("2018-05-23 13:48:11"+"def:"+time+" "+date.getTime()+" 差:"+(time-date.getTime())/(60*60*1000));
|
|
||||||
|
System.out.println("-------------------------------------------------------------------");
|
||||||
|
|
||||||
|
SimpleDateFormat df2 = new SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd'T'HH:mm:ss.SSS");
|
||||||
|
Date t2 = new Date();
|
||||||
} catch (Exception e) {
|
Calendar calendar = Calendar.getInstance();
|
||||||
// TODO Auto-generated catch block
|
calendar.setTimeInMillis(time);
|
||||||
e.printStackTrace();
|
System.out.println(df2.getTimeZone().getID()+"----------------"+df2.format(calendar.getTime()));
|
||||||
|
|
||||||
|
|
||||||
|
df2.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
System.out.println(df2.getTimeZone().getID()+"----------------"+df2.format(calendar.getTime()));
|
||||||
|
df2.setTimeZone(TimeZone.getTimeZone("UTC-8"));
|
||||||
|
|
||||||
|
System.out.println(df2.getTimeZone().getID()+"----------------"+df2.format(calendar.getTime()));
|
||||||
|
df2.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
||||||
|
|
||||||
|
System.out.println(df2.getTimeZone().getID()+"----------------"+df2.format(calendar.getTime()));
|
||||||
|
df2.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
|
System.out.println(df2.getTimeZone().getID()+"----------------"+df2.format(calendar.getTime()));
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("-----------------------------------------");
|
||||||
|
|
||||||
|
df2.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
Date date = df2.parse("2018-05-23T13:48:11.077");
|
||||||
|
|
||||||
|
System.out.println("2018-05-23 13:48:11"+"def:"+time+" "+date.getTime()+" 差:"+(time-date.getTime())/(60*60*1000));
|
||||||
|
|
||||||
|
System.out.println(utileDate2TimeStamp(t));
|
||||||
|
System.out.println("=====--------------------------------------------------");
|
||||||
|
|
||||||
|
Calendar calendar2 = Calendar.getInstance();
|
||||||
|
calendar2.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
calendar2.setTimeInMillis(1527229532956l);
|
||||||
|
System.out.println(calendar2.getTime());
|
||||||
|
|
||||||
|
Calendar calendar3 = Calendar.getInstance();
|
||||||
|
calendar3.setTimeZone(TimeZone.getTimeZone("UTC+8"));
|
||||||
|
calendar3.setTimeInMillis(1527229532956l);
|
||||||
|
System.out.println(calendar3.getTime());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// String date = "2000-10-01T10:10:10.123Z";
|
||||||
|
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'");
|
||||||
|
// SimpleDateFormat df2 = new SimpleDateFormat(
|
||||||
|
// "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||||
|
// df2.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
||||||
|
// //创建被转换的对象calendar,有时区信息
|
||||||
|
// Calendar calendar = new GregorianCalendar();
|
||||||
|
// calendar.setTime(df2.parse(date));
|
||||||
|
// TimeZone timeZone = TimeZone.getTimeZone("GMT+8:00");
|
||||||
|
// calendar.setTimeZone(timeZone);
|
||||||
|
//
|
||||||
|
// User test = new User();
|
||||||
|
// test.setId("111");
|
||||||
|
// test.setDate(calendar.getTime());
|
||||||
|
// ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
// String json = objectMapper.writeValueAsString(test);
|
||||||
|
// System.out.println(json);
|
||||||
|
//
|
||||||
|
// User restore = objectMapper.readValue(json, User.class);
|
||||||
|
// //System.out.print(restore.getDate().getTimeZone().getDisplayName());
|
||||||
|
// }catch (Exception e) {
|
||||||
|
// e.printStackTrace(System.out);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
private java.sql.Timestamp utileDate2TimeStamp(java.util.Date udate) {
|
||||||
|
java.sql.Timestamp sqlDate = null;
|
||||||
|
long t = udate.getTime();
|
||||||
|
sqlDate = new java.sql.Timestamp(t);
|
||||||
|
return sqlDate;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// try {
|
|
||||||
// String date = "2000-10-01T10:10:10.123Z";
|
|
||||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'");
|
|
||||||
// SimpleDateFormat df2 = new SimpleDateFormat(
|
|
||||||
// "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
|
||||||
// df2.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
|
||||||
// //创建被转换的对象calendar,有时区信息
|
|
||||||
// Calendar calendar = new GregorianCalendar();
|
|
||||||
// calendar.setTime(df2.parse(date));
|
|
||||||
// TimeZone timeZone = TimeZone.getTimeZone("GMT+8:00");
|
|
||||||
// calendar.setTimeZone(timeZone);
|
|
||||||
//
|
|
||||||
// User test = new User();
|
|
||||||
// test.setId("111");
|
|
||||||
// test.setDate(calendar.getTime());
|
|
||||||
// ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
// String json = objectMapper.writeValueAsString(test);
|
|
||||||
// System.out.println(json);
|
|
||||||
//
|
|
||||||
// User restore = objectMapper.readValue(json, User.class);
|
|
||||||
// //System.out.print(restore.getDate().getTimeZone().getDisplayName());
|
|
||||||
// }catch (Exception e) {
|
|
||||||
// e.printStackTrace(System.out);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user