1、修改非maat配置取消接口请求参数;
2、添加maat配置 配置存储接口中service与action对应关系验证
This commit is contained in:
@@ -27,7 +27,6 @@ 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.domain.restful.UpdateStatConfigSource;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.util.Constants;
|
||||
@@ -503,19 +502,17 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
@RequestMapping(value = "/cfg/v1/commonSources", method = RequestMethod.PUT)
|
||||
@ApiOperation(value = "回调配置状态修改", httpMethod = "PUT", response = Map.class, notes = "回调配置状态修改服务")
|
||||
@ApiParam(value = "回调配置状态修改", name = "updateStatConfigSource", required = true)
|
||||
public Map updateCommonConfigSource(@RequestBody UpdateStatConfigSource updateStatConfigSource,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
public Map updateCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
|
||||
long start = System.currentTimeMillis();
|
||||
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
|
||||
updateStatConfigSource);
|
||||
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,jsonString);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
configSourcesService.updateCommonSources(thread, start,jsonString, new Date(),sb);
|
||||
|
||||
configSourcesService.updateCommonSources(thread, start, updateStatConfigSource.getUpdateStatCfgList(),
|
||||
new Date(), sb);
|
||||
|
||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "配置状态修改成功",
|
||||
Constants.IS_DEBUG ? updateStatConfigSource : null);
|
||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
||||
"配置状态修改成功" , Constants.IS_DEBUG ? jsonString : null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/fileUploadSources", method = RequestMethod.POST)
|
||||
@@ -564,8 +561,8 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
e.printStackTrace();
|
||||
}
|
||||
JSONObject jsonObj = new JSONObject();
|
||||
jsonObj.put("accessUrl", filePath.substring(filePath.indexOf("group")));
|
||||
// jsonObj.put("accessUrl", "filePath");
|
||||
// jsonObj.put("accessUrl", filePath.substring(filePath.indexOf("group")));
|
||||
jsonObj.put("accessUrl", "filePath");
|
||||
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);
|
||||
logger.info("-----------------调用接口上传文件---------------");
|
||||
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;
|
||||
|
||||
@@ -18,6 +18,8 @@ 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;
|
||||
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.NumRegion;
|
||||
import com.nis.domain.restful.StrRegion;
|
||||
import com.nis.domain.restful.UpdateStatConfig;
|
||||
import com.nis.restful.CompileJudgeCode;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
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.SpringContextHolder;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
/**
|
||||
* @ClassName: ControlService
|
||||
* @Description: TODO(编译配置持久化)
|
||||
@@ -2566,31 +2565,40 @@ public class ConfigSourcesService extends BaseService {
|
||||
|
||||
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) {
|
||||
Map<Integer, List<Long>> cfgMap = new HashMap<Integer, List<Long>>();
|
||||
if (null != updateStatCfgList && updateStatCfgList.size() > 0) {
|
||||
for (UpdateStatConfig config : updateStatCfgList) {
|
||||
String msg = checkOptForUpdate(config);
|
||||
if (!msg.equals("ok")) {
|
||||
thread.setExceptionInfo(msg + sb.toString());
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, msg + 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());
|
||||
JsonArray jsonObjectList = null;
|
||||
try {
|
||||
jsonObjectList = new JsonParser().parse(jsonString).getAsJsonArray();
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
logger1.error(e.getMessage());
|
||||
thread.setExceptionInfo(e.getMessage() + sb.toString());
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, e.getMessage() + 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>>>();
|
||||
Iterator serviceIterator = cfgMap.keySet().iterator();
|
||||
while (serviceIterator.hasNext()) {
|
||||
@@ -2610,22 +2618,31 @@ public class ConfigSourcesService extends BaseService {
|
||||
|
||||
return "ok";
|
||||
}
|
||||
private String checkOptForUpdate(UpdateStatConfig config) {
|
||||
if (StringUtil.isEmpty(config.getCfgId())) {
|
||||
private String checkOptForUpdate(Map<String, Object> srcMap) {
|
||||
String cfgId = srcMap.get("cfgId").toString();
|
||||
String service = srcMap.get("service").toString();
|
||||
String isValid = srcMap.get("isValid").toString();
|
||||
if (StringUtil.isEmpty(cfgId)) {
|
||||
return "cfgId字段不能为空";
|
||||
}else if(!StringUtil.isNumeric(cfgId)){
|
||||
return "cfgId字段格式不正确";
|
||||
}
|
||||
|
||||
if (StringUtil.isEmpty(config.getService())) {
|
||||
if (StringUtil.isEmpty(service)) {
|
||||
return "service字段不能为空";
|
||||
}else if(!StringUtil.isNumeric(service)){
|
||||
return "service字段格式不正确";
|
||||
}
|
||||
|
||||
if (StringUtil.isEmpty(config.getIsValid())) {
|
||||
return "配置id为" + config.getCfgId()+"的IsValid字段不能为空";
|
||||
if (StringUtil.isEmpty(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";
|
||||
}
|
||||
private boolean isIp(String ipStr){
|
||||
|
||||
Reference in New Issue
Block a user