diff --git a/pom.xml b/pom.xml
index 89a2b00..11aa66b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -618,7 +618,12 @@
httpclient
4.4
-
+
+ org.apache.httpcomponents
+ httpmime
+ 4.4
+
+
org.springframework.data
diff --git a/src/main/java/com/nis/domain/restful/CommonSourceFieldCfg.java b/src/main/java/com/nis/domain/restful/CommonSourceFieldCfg.java
new file mode 100644
index 0000000..fa8b9f0
--- /dev/null
+++ b/src/main/java/com/nis/domain/restful/CommonSourceFieldCfg.java
@@ -0,0 +1,105 @@
+/**
+ *
+ */
+package com.nis.domain.restful;
+
+/**
+ * @ClassName:CommonSourceCfg
+ * @Description:TODO(这里用一句话描述这个类的作用)
+ * @author (zdx)
+ * @date 2018年5月19日 下午8:00:45
+ * @version V1.0
+ */
+public class CommonSourceFieldCfg {
+
+ private String fieldType;
+ private String srcName;
+ private String dstName;
+ private String range;
+ private Boolean isRequired=false;
+ private String defaultVal;
+ private String regexp;
+
+ public CommonSourceFieldCfg() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param fieldType
+ * @param srcName
+ * @param dstName
+ * @param range
+ * @param isRequired
+ * @param defauleVal
+ * @param regexp
+ */
+ public CommonSourceFieldCfg(String fieldType, String srcName,
+ String dstName, String range, Boolean isRequired,
+ String defaultVal, String regexp) {
+ super();
+ this.fieldType = fieldType;
+ this.srcName = srcName;
+ this.dstName = dstName;
+ this.range = range;
+ this.isRequired = isRequired;
+ this.defaultVal = defaultVal;
+ this.regexp = regexp;
+ }
+
+ public String getSrcName() {
+ return srcName;
+ }
+
+ public void setSrcName(String srcName) {
+ this.srcName = srcName;
+ }
+
+ public String getDstName() {
+ return dstName;
+ }
+
+ public void setDstName(String dstName) {
+ this.dstName = dstName;
+ }
+
+ public Boolean getIsRequired() {
+ return isRequired;
+ }
+
+ public void setIsRequired(Boolean isRequired) {
+ this.isRequired = isRequired;
+ }
+
+ public String getDefaultVal() {
+ return defaultVal;
+ }
+
+ public void setDefaultVal(String defaultVal) {
+ this.defaultVal = defaultVal;
+ }
+
+ public String getFieldType() {
+ return fieldType;
+ }
+
+ public void setFieldType(String fieldType) {
+ this.fieldType = fieldType;
+ }
+
+ public String getRange() {
+ return range;
+ }
+
+ public void setRange(String range) {
+ this.range = range;
+ }
+
+ public String getRegexp() {
+ return regexp;
+ }
+
+ public void setRegexp(String regexp) {
+ this.regexp = regexp;
+ }
+}
diff --git a/src/main/java/com/nis/domain/restful/FileDesc.java b/src/main/java/com/nis/domain/restful/FileDesc.java
new file mode 100644
index 0000000..cc22ab4
--- /dev/null
+++ b/src/main/java/com/nis/domain/restful/FileDesc.java
@@ -0,0 +1,77 @@
+/**
+ *
+ */
+package com.nis.domain.restful;
+
+import java.util.Date;
+
+/**
+ * @ClassName:FileDesc
+ * @Description:TODO(这里用一句话描述这个类的作用)
+ * @author (zdx)
+ * @date 2018年5月21日 下午8:09:06
+ * @version V1.0
+ */
+public class FileDesc {
+
+ private String filetype;
+ private Date createTime;
+ private String key;
+ private String fileName;
+ private String checksum;
+ /**
+ *
+ */
+ public FileDesc() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param filetype
+ * @param createTime
+ * @param key
+ * @param fileName
+ * @param checksum
+ */
+ public FileDesc(String filetype, Date createTime, String key,
+ String fileName, String checksum) {
+ super();
+ this.filetype = filetype;
+ this.createTime = createTime;
+ this.key = key;
+ this.fileName = fileName;
+ this.checksum = checksum;
+ }
+
+ public String getFiletype() {
+ return filetype;
+ }
+ public void setFiletype(String filetype) {
+ this.filetype = filetype;
+ }
+ public Date getCreateTime() {
+ return createTime;
+ }
+ public void setCreateTime(Date createTime) {
+ this.createTime = createTime;
+ }
+ public String getKey() {
+ return key;
+ }
+ public void setKey(String key) {
+ this.key = key;
+ }
+ public String getFileName() {
+ return fileName;
+ }
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+ public String getChecksum() {
+ return checksum;
+ }
+ public void setChecksum(String checksum) {
+ this.checksum = checksum;
+ }
+}
diff --git a/src/main/java/com/nis/util/ReadCommSourceXmlUtil.java b/src/main/java/com/nis/util/ReadCommSourceXmlUtil.java
new file mode 100644
index 0000000..97dc41b
--- /dev/null
+++ b/src/main/java/com/nis/util/ReadCommSourceXmlUtil.java
@@ -0,0 +1,110 @@
+/**
+ *
+ */
+package com.nis.util;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.io.SAXReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.nis.domain.restful.CommonSourceFieldCfg;
+
+/**
+ * @ClassName:ReadCommSourceXmlUtil
+ * @Description:TODO(这里用一句话描述这个类的作用)
+ * @author (zdx)
+ * @date 2018年5月19日 下午7:57:52
+ * @version V1.0
+ */
+public class ReadCommSourceXmlUtil {
+ private static Logger logger = LoggerFactory.getLogger(ReadCommSourceXmlUtil.class);
+ private static String XMLPATH = "/commonSources/commonSources.xml";
+ public static Map> commonSourceCfgMap = new HashMap>();
+
+ static {
+ readCfgXml();
+ }
+
+
+ public static void main(String[] args) {
+ try {
+ readCfgXml();
+ Set keySet = commonSourceCfgMap.keySet();
+ for (String key : keySet) {
+ List fieldCfgList = commonSourceCfgMap.get(key);
+ for (CommonSourceFieldCfg commonSourceFieldCfg : fieldCfgList) {
+ System.out.println("srcName:"+commonSourceFieldCfg.getSrcName()+",dstName:"+commonSourceFieldCfg.getDstName()+",val:"+commonSourceFieldCfg.getRegexp());
+ }
+ }
+
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public static List getCommonSourceCfgByService(String service) {
+ return commonSourceCfgMap.get(service);
+ }
+
+
+ private static void readCfgXml() {
+ try {
+
+ InputStream resourceAsStream = ReadCommSourceXmlUtil.class.getResourceAsStream(XMLPATH);
+ SAXReader reader = new SAXReader();
+ Document read = reader.read(resourceAsStream);
+ Element rootElement = read.getRootElement();
+ if (rootElement != null && rootElement.elements().size() > 0) {
+ List elements = rootElement.elements();
+ for (Element element : elements) {
+ String serviceIdsStr = element.attribute("serviceIds").getValue();
+ if (serviceIdsStr != null && !serviceIdsStr.trim().equals("")) {
+ String[] serviceIds = serviceIdsStr.split(",");
+ for (String serviceId : serviceIds) {
+ if (!StringUtil.isEmpty(serviceId.trim())) {
+ List cfgList = new ArrayList();
+ List fieldElmt = element.elements("field");
+ for (Element field : fieldElmt) {
+ CommonSourceFieldCfg fieldCfg = new CommonSourceFieldCfg();
+ fieldCfg.setFieldType(field.attribute("fieldType").getValue());
+ fieldCfg.setSrcName(field.attribute("srcName").getValue());
+ fieldCfg.setDstName(field.attribute("dstName").getValue());
+ if (!StringUtil.isEmpty(field.attribute("range"))) {
+ fieldCfg.setRange(field.attribute("range").getValue());
+ }
+ if (!StringUtil.isEmpty(field.attribute("isRequired"))) {
+ fieldCfg.setIsRequired(Boolean.valueOf(field.attribute("isRequired").getValue()));
+ }
+ if (!StringUtil.isEmpty(field.attribute("defaultVal"))) {
+ fieldCfg.setDefaultVal(field.attribute("defaultVal").getValue());
+ }
+ if (!StringUtil.isEmpty(field.attribute("regexp"))) {
+ fieldCfg.setRegexp(field.attribute("regexp").getValue());
+ }
+ cfgList.add(fieldCfg);
+ }
+ commonSourceCfgMap.put(serviceId.trim(), cfgList);
+ }
+
+ }
+
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ logger.error("加载commonSources.xml失败", e);
+ }
+ }
+
+}
diff --git a/src/main/java/com/nis/web/controller/BaseRestController.java b/src/main/java/com/nis/web/controller/BaseRestController.java
index 93a6f55..a3c2822 100644
--- a/src/main/java/com/nis/web/controller/BaseRestController.java
+++ b/src/main/java/com/nis/web/controller/BaseRestController.java
@@ -43,7 +43,7 @@ import com.nis.web.service.ServicesRequestLogService;
*/
public class BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
- private SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHssSSS");
+ private SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
/**
*
* @Title: serviceResponse
diff --git a/src/main/java/com/nis/web/controller/restful/ConfigSourcesController.java b/src/main/java/com/nis/web/controller/restful/ConfigSourcesController.java
index e47c6cd..f6657b0 100644
--- a/src/main/java/com/nis/web/controller/restful/ConfigSourcesController.java
+++ b/src/main/java/com/nis/web/controller/restful/ConfigSourcesController.java
@@ -1,5 +1,6 @@
package com.nis.web.controller.restful;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@@ -9,15 +10,20 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import net.sf.json.JSONObject;
+
+import org.apache.commons.codec.digest.DigestUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
import com.nis.domain.restful.ConfigCompile;
import com.nis.domain.restful.ConfigSource;
+import com.nis.domain.restful.FileDesc;
import com.nis.domain.restful.MaatConfig;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
@@ -28,8 +34,9 @@ import com.nis.util.StringUtils;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
+import com.nis.web.service.fdfs.FastDFSFile;
+import com.nis.web.service.fdfs.FileManager;
import com.nis.web.service.restful.ConfigRedisService;
-import com.nis.web.service.restful.ConfigRedisServiceimpl;
import com.nis.web.service.restful.ConfigSourcesService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
@@ -433,7 +440,66 @@ public class ConfigSourcesController extends BaseRestController {
}
}
+ @RequestMapping(value = "/cfg/v1/commonSources", method = RequestMethod.POST, produces=org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
+ @ApiOperation(value = "回调配置存储", httpMethod = "POST", response = Map.class, notes = "回调配置存储服务")
+ //@ApiParam(value = "回调配置数据源", name = "JSONObject", requirerue)
+ public Map createCommonConfigSource(@RequestBody String jsonString , HttpServletRequest request,
+ HttpServletResponse response) {
+ ConfigSourcesService.setMsgList(new ArrayList());// 清除上次记录的日志信息
+ long start = System.currentTimeMillis();
+ SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,null);
+ StringBuffer sb = new StringBuffer();
+
+ configSourcesService.savaCommonSources(thread, start, jsonString, sb);
+ return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
+ "配置数据插入成功" , Constants.IS_DEBUG ? jsonString : null);
+ }
+
+ @RequestMapping(value = "/cfg/v1/fileUploadSources", method = RequestMethod.POST)
+ @ApiOperation(value = "样例文件上传服务", httpMethod = "POST", response = Map.class, notes = "样例文件上传服务")
+ @ApiParam(value = "样例文件上传服务", name = "MultipartFile", required = true)
+ public Map fileUploadSource(@RequestBody MultipartFile file, HttpServletRequest request,
+ HttpServletResponse response) {
+ ConfigSourcesService.setMsgList(new ArrayList());// 清除上次记录的日志信息
+ long start = System.currentTimeMillis();
+ SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,null);
+ String filePath ="";
+ try {
+ FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),FileDesc.class);
+ if (!StringUtil.isEmpty(fileDesc.getChecksum())) {
+ //验证Md5
+ String md5 = DigestUtils.md5Hex(file.getBytes());
+ System.out.println("----------------------------MD5:'"+md5+"'==='"+fileDesc.getChecksum()+"'");
+ if (!md5.equals(fileDesc.getChecksum())) {
+ thread.setExceptionInfo("checksum与文件MD5值不一致");
+ throw new RestServiceException(thread, System.currentTimeMillis() - start, "checksum与文件MD5值不一致",
+ RestBusinessCode.config_integrity_error.getValue());
+ }
+ String ext = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
+ FastDFSFile fdsfile = new FastDFSFile(file.getBytes(),file.getOriginalFilename(), ext);
+// NameValuePair[] meta_list = new NameValuePair[5];
+// meta_list[0] = new NameValuePair("fileName", file.getOriginalFilename());
+// meta_list[1] = new NameValuePair("fileLength", String.valueOf(file.getSize()));
+// meta_list[2] = new NameValuePair("fileExt", ext);
+// meta_list[3] = new NameValuePair("fileAuthor", "rkg");
+// meta_list[4] = new NameValuePair("fileMd5", md5);
+ filePath = FileManager.upload(fdsfile, null);
+ }else{
+ thread.setExceptionInfo("请求头信息中缺少checksum参数");
+ throw new RestServiceException(thread, System.currentTimeMillis() - start, "请求头信息中缺少checksum参数",
+ RestBusinessCode.missing_args.getValue());
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ JSONObject jsonObj = new JSONObject();
+ jsonObj.put("accessUrl", filePath.substring(filePath.indexOf("group")));
+ return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
+ "文件上传成功" ,jsonObj);
+ }
+
private boolean isBlank(Date datetime) {
if (null != datetime) {
return true;
diff --git a/src/main/java/com/nis/web/service/restful/ConfigPzIdService.java b/src/main/java/com/nis/web/service/restful/ConfigPzIdService.java
index 8be0358..807edf7 100644
--- a/src/main/java/com/nis/web/service/restful/ConfigPzIdService.java
+++ b/src/main/java/com/nis/web/service/restful/ConfigPzIdService.java
@@ -4,15 +4,19 @@
package com.nis.web.service.restful;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nis.domain.restful.ConfigPzIdSource;
+import com.nis.util.StringUtil;
import com.nis.web.dao.ConfigPzIdDao;
import com.nis.web.service.BaseLogService;
+import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIConversion.Static;
/**
* @ClassName:ConfigPzIdService
@@ -31,11 +35,23 @@ public class ConfigPzIdService extends BaseLogService {
@Autowired
protected ConfigPzIdDao dao;
+ @Autowired
+ ConfigRedisService configRedisService;
+
+ private static Map sourceNameMap = new HashMap();
+ static {
+ sourceNameMap.put("CONFIG_COMPILE", "SEQ_COMPILEID");
+ sourceNameMap.put("CONFIG_GROUP", "SEQ_GROUPID");
+ sourceNameMap.put("CONFIG_REGION", "SEQ_REGIONID");
+ }
+
public ConfigPzIdSource getConfigPzIdList(ConfigPzIdSource entity){
List pzIdList = new ArrayList();
entity.setSourceName(entity.getSourceName().toUpperCase());
+ String seqName= StringUtil.isEmpty(sourceNameMap.get(entity.getSourceName()))?"SEQ_COMPILEID":sourceNameMap.get(entity.getSourceName());
for (int i = 0; i < entity.getNum(); i++) {
- pzIdList.add(dao.getConfigPzIdList(entity));
+ //pzIdList.add(dao.getConfigPzIdList(entity)); //直接从数据库序列号获取
+ pzIdList.add(configRedisService.getIncrId(seqName));
}
entity.setPzIdList(pzIdList);
return entity;
diff --git a/src/main/java/com/nis/web/service/restful/ConfigSourcesService.java b/src/main/java/com/nis/web/service/restful/ConfigSourcesService.java
index 5202b07..d929dff 100644
--- a/src/main/java/com/nis/web/service/restful/ConfigSourcesService.java
+++ b/src/main/java/com/nis/web/service/restful/ConfigSourcesService.java
@@ -2,12 +2,20 @@ package com.nis.web.service.restful;
import java.sql.Connection;
import java.sql.SQLException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.TimeZone;
import java.util.concurrent.CountDownLatch;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sf.json.JSONObject;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
@@ -16,7 +24,11 @@ import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
import com.nis.domain.Page;
+import com.nis.domain.restful.CommonSourceFieldCfg;
import com.nis.domain.restful.ConfigCompile;
import com.nis.domain.restful.ConfigCompileTest;
import com.nis.domain.restful.ConfigGroupRelation;
@@ -27,9 +39,11 @@ import com.nis.domain.restful.StrRegion;
import com.nis.restful.CompileJudgeCode;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
+import com.nis.util.BasicProvingUtil;
import com.nis.util.CompileVal;
import com.nis.util.Configurations;
import com.nis.util.OracleErrorCodeUtil;
+import com.nis.util.ReadCommSourceXmlUtil;
import com.nis.util.StringUtil;
import com.nis.util.StringUtils;
import com.nis.web.dao.ConfigCompileDao;
@@ -78,6 +92,11 @@ public class ConfigSourcesService extends BaseService {
@Autowired
private StrRegionDao strRegionDao;
+ private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
+
+ @Autowired
+ ConfigRedisService configRedisService;
+
public static Map> getTableRelation() {
Map> tableMap = new HashMap>();
Map typeMap = new HashMap();
@@ -2076,7 +2095,136 @@ public class ConfigSourcesService extends BaseService {
}
return "ok";
}
-
+
+ public String savaCommonSources(SaveRequestLogThread thread, long start,String jsonString,
+ StringBuffer sb) {
+ JsonArray jsonObjectList = new JsonParser().parse(jsonString).getAsJsonArray();
+ Map>> dstMaps = new HashMap>>();
+ for (int i = 0; i < jsonObjectList.size(); i++) {
+ JsonObject jsonObj=(JsonObject) jsonObjectList.get(i);
+ Map srcMap = JSONObject.fromObject(JSONObject.fromObject((jsonObj.toString())));
+ if(srcMap.containsKey("service")){
+ Map dstMap = new HashMap();
+ List commonSourceFieldCfgList = ReadCommSourceXmlUtil.getCommonSourceCfgByService(srcMap.get("service").toString().trim());
+ if (StringUtil.isEmpty(commonSourceFieldCfgList)) {
+ logger.error("service请检查service配置是否正确");
+ thread.setExceptionInfo("请检查service配置是否正确");
+ throw new RestServiceException(thread, System.currentTimeMillis() - start,"请检查service配置是否正确",
+ RestBusinessCode.wrong_range.getValue());
+ }
+ for (CommonSourceFieldCfg commonSourceFieldCfg : commonSourceFieldCfgList) {
+ //是否必填
+ if(commonSourceFieldCfg.getIsRequired()&&!srcMap.containsKey(commonSourceFieldCfg.getSrcName())){
+ logger.error(commonSourceFieldCfg.getSrcName()+"参数不能为空");
+ thread.setExceptionInfo(commonSourceFieldCfg.getSrcName()+"参数不能为空");
+ throw new RestServiceException(thread, System.currentTimeMillis() - start,commonSourceFieldCfg.getSrcName()+"参数不能为空",
+ RestBusinessCode.missing_args.getValue());
+ }
+ //字段类型 String Number Date Ip Port
+ String dstStr = StringUtil.isEmpty(srcMap.get(commonSourceFieldCfg.getSrcName()))?commonSourceFieldCfg.getDefaultVal():srcMap.get(commonSourceFieldCfg.getSrcName()).toString();
+ if (!StringUtil.isEmpty(dstStr)&&dstStr.startsWith("[")&&dstStr.endsWith("]")) {
+ dstStr = srcMap.get(dstStr.substring(1, dstStr.length()-1)).toString();
+ }
+ switch (commonSourceFieldCfg.getFieldType()) {
+ case "Number":
+ if(!StringUtil.isNumeric(dstStr)){
+ logger.error(commonSourceFieldCfg.getSrcName()+"参数不能格式不正确,必需是数值型");
+ thread.setExceptionInfo(commonSourceFieldCfg.getSrcName()+"参数不能格式不正确,必需是数值型");
+ throw new RestServiceException(thread, System.currentTimeMillis() - start,commonSourceFieldCfg.getSrcName()+"参数不能格式不正确",
+ RestBusinessCode.missing_args.getValue());
+ }
+ break;
+ case "Date":
+ try {
+ sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
+ Date date = sdf.parse(dstStr);
+ dstStr = date.getTime()+"000";
+ } catch (ParseException e) {
+ // TODO Auto-generated catch block
+ logger.error(commonSourceFieldCfg.getSrcName()+"参数格式不正确,必须是日期型");
+ thread.setExceptionInfo(commonSourceFieldCfg.getSrcName()+"参数格式不正确,必须是日期型");
+ throw new RestServiceException(thread, System.currentTimeMillis() - start,commonSourceFieldCfg.getSrcName()+"参数不能格式不正确,必须是日期型",
+ RestBusinessCode.missing_args.getValue());
+ }
+ break;
+ case "Ip":
+ if (!isIp(dstStr)) {
+ logger.error(commonSourceFieldCfg.getSrcName()+"参数格式不正确,不是合法的IP地址");
+ thread.setExceptionInfo(commonSourceFieldCfg.getSrcName()+"参数格式不正确,不是合法的IP地址");
+ throw new RestServiceException(thread, System.currentTimeMillis() - start,commonSourceFieldCfg.getSrcName()+"参数不能格式不正确,不是合法的IP地址",
+ RestBusinessCode.missing_args.getValue());
+ }
+ break;
+ case "Port":
+ if (!BasicProvingUtil.isPortOrPortMask(dstStr)) {
+ logger.error(commonSourceFieldCfg.getSrcName()+"参数格式不正确,不是合法的Port");
+ thread.setExceptionInfo(commonSourceFieldCfg.getSrcName()+"参数格式不正确,不是合法的Port");
+ throw new RestServiceException(thread, System.currentTimeMillis() - start,commonSourceFieldCfg.getSrcName()+"参数不能格式不正确,不是合法的Port",
+ RestBusinessCode.missing_args.getValue());
+ }
+ break;
+
+ }
+ //range取值范围验证
+ if(!StringUtil.isEmpty(commonSourceFieldCfg.getRange())){
+ String [] range= commonSourceFieldCfg.getRange().split("-");
+ if(!(Long.valueOf(range[0]).compareTo(Long.valueOf(dstStr))<=0&&Long.valueOf(range[1]).compareTo(Long.valueOf(dstStr))>=0)){
+ logger.error(commonSourceFieldCfg.getSrcName()+"参数不在有效范围");
+ thread.setExceptionInfo(commonSourceFieldCfg.getSrcName()+"参数不在有效范围");
+ throw new RestServiceException(thread, System.currentTimeMillis() - start, commonSourceFieldCfg.getSrcName()+"参数不在有效范围",
+ RestBusinessCode.wrong_range.getValue());
+
+ }
+ }
+ //regexp 特殊格式正则验证
+ Boolean valFlag = true;
+ if(!StringUtil.isEmpty(commonSourceFieldCfg.getRegexp())){
+ Pattern pattern = Pattern.compile(commonSourceFieldCfg.getRegexp());
+ Matcher matcher = pattern.matcher(dstStr);
+ valFlag = valFlag&matcher.matches();
+ }
+ if (valFlag) {
+ dstMap.put(commonSourceFieldCfg.getDstName(),dstStr);
+ }else{
+ logger.error(commonSourceFieldCfg.getSrcName()+"参数格式与正则不匹配");
+ thread.setExceptionInfo(commonSourceFieldCfg.getSrcName()+"参数格式与正则不匹配");
+ throw new RestServiceException(thread, System.currentTimeMillis() - start, commonSourceFieldCfg.getSrcName()+"参数格式不正确或数据不在有效范围",
+ RestBusinessCode.param_formate_error.getValue());
+ }
+ }
+ if (StringUtil.isEmpty(dstMaps.get(Integer.valueOf(srcMap.get("service").toString())))) {
+ List