非maat配置取消
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.nis.web.controller.restful;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -10,6 +11,8 @@ 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;
|
||||
@@ -24,6 +27,7 @@ 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;
|
||||
@@ -41,8 +45,6 @@ import com.wordnik.swagger.annotations.Api;
|
||||
import com.wordnik.swagger.annotations.ApiOperation;
|
||||
import com.wordnik.swagger.annotations.ApiParam;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
/**
|
||||
* @ClassName: ConfigSourcesController
|
||||
* @Description: 配置存储服务
|
||||
@@ -88,7 +90,6 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
Map<Integer, List<Map<String, String>>> configMap = new HashMap<Integer, List<Map<String, String>>>();
|
||||
configMap.put(1, listMap);
|
||||
configRedisService.saveUnMaatConfig(configMap);
|
||||
|
||||
} else {
|
||||
Integer service = 100;
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
@@ -312,32 +313,14 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
checkOpAction(thread, System.currentTimeMillis() - start, opAction, 2);
|
||||
String msg = "";
|
||||
ConfigCompile compile = configSource.getConfigCompileList().get(0);
|
||||
// zdx 20180528改为调用rkg接口取消配置
|
||||
msg = configSourcesService.cancleConfigSources(thread, start, configSource.getConfigCompileList(),
|
||||
//zdx 20180528改为调用rkg接口取消配置
|
||||
msg = configSourcesService.updateConfigSources(thread, start, configSource.getConfigCompileList(),
|
||||
configSource.getOpTime(), sb);
|
||||
|
||||
if (msg.equals("error")) {
|
||||
String errorCode = "";
|
||||
Exception exception = ConfigSourcesService.getMsgList().get(0);
|
||||
String message = exception.getMessage();
|
||||
if (null != message && message.length() > 0) {
|
||||
int index = message.toUpperCase().indexOf("ORA-");
|
||||
if (index != -1) {
|
||||
errorCode = message.substring(index + 4, index + 9);
|
||||
|
||||
}
|
||||
}
|
||||
Map<Integer, String> throwExceptionInfo = OracleErrorCodeUtil.throwExceptionInfo(errorCode);
|
||||
for (int errorNum : throwExceptionInfo.keySet()) {
|
||||
if (errorNum == 998) {
|
||||
thread.setExceptionInfo(exception.toString());
|
||||
} else {
|
||||
thread.setExceptionInfo(throwExceptionInfo.get(errorNum));
|
||||
}
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
||||
throwExceptionInfo.get(errorNum), errorNum);
|
||||
|
||||
}
|
||||
"修改编译配置状态时出现异常"+exception.getMessage(), RestBusinessCode.unknow_error.getValue());
|
||||
}
|
||||
// configSourcesService.updateConfigSource(thread, start,
|
||||
// configSource.getConfigCompileList(),
|
||||
@@ -379,12 +362,11 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置id不能为空",
|
||||
RestBusinessCode.missing_args.getValue());
|
||||
}
|
||||
// if ((configCompile.getActiveSys() != null) ||
|
||||
// (configCompile.getEffectiveRange() != null
|
||||
// && !configCompile.getEffectiveRange().equals(""))) {
|
||||
// count++;
|
||||
// configSourcesService.setCompileInvalid(configCompile);
|
||||
// }
|
||||
// if ((configCompile.getActiveSys() != null) || (configCompile.getEffectiveRange() != null
|
||||
// && !configCompile.getEffectiveRange().equals(""))) {
|
||||
// count++;
|
||||
// configSourcesService.setCompileInvalid(configCompile);
|
||||
// }
|
||||
}
|
||||
if (count > 0) {
|
||||
Thread.sleep(14000);
|
||||
@@ -412,34 +394,33 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置id不能为空",
|
||||
RestBusinessCode.missing_args.getValue());
|
||||
}
|
||||
// if ((configCompile.getActiveSys() != null) ||
|
||||
// (configCompile.getEffectiveRange() != null
|
||||
// && !configCompile.getEffectiveRange().equals(""))) {
|
||||
// try {
|
||||
// configSourcesService.setCompileValid(configCompile);
|
||||
// } catch (Exception e1) {
|
||||
// String errorCode = "";
|
||||
// String message = e.getMessage();
|
||||
// if (null != message && message.length() > 0) {
|
||||
// int index = message.toUpperCase().indexOf("ORA-");
|
||||
// if (index != -1) {
|
||||
// errorCode = message.substring(index + 4, index + 9);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// Map<Integer, String> throwExceptionInfo = OracleErrorCodeUtil
|
||||
// .throwExceptionInfo(errorCode);
|
||||
// for (int errorNum : throwExceptionInfo.keySet()) {
|
||||
// if (errorNum == 998) {
|
||||
// thread.setExceptionInfo(e.toString());
|
||||
// } else {
|
||||
// thread.setExceptionInfo(throwExceptionInfo.get(errorNum));
|
||||
// }
|
||||
// throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
||||
// throwExceptionInfo.get(errorNum), errorNum);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if ((configCompile.getActiveSys() != null) || (configCompile.getEffectiveRange() != null
|
||||
// && !configCompile.getEffectiveRange().equals(""))) {
|
||||
// try {
|
||||
// configSourcesService.setCompileValid(configCompile);
|
||||
// } catch (Exception e1) {
|
||||
// String errorCode = "";
|
||||
// String message = e.getMessage();
|
||||
// if (null != message && message.length() > 0) {
|
||||
// int index = message.toUpperCase().indexOf("ORA-");
|
||||
// if (index != -1) {
|
||||
// errorCode = message.substring(index + 4, index + 9);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// Map<Integer, String> throwExceptionInfo = OracleErrorCodeUtil
|
||||
// .throwExceptionInfo(errorCode);
|
||||
// for (int errorNum : throwExceptionInfo.keySet()) {
|
||||
// if (errorNum == 998) {
|
||||
// thread.setExceptionInfo(e.toString());
|
||||
// } else {
|
||||
// thread.setExceptionInfo(throwExceptionInfo.get(errorNum));
|
||||
// }
|
||||
// throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
||||
// throwExceptionInfo.get(errorNum), errorNum);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -516,23 +497,23 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "配置数据插入成功",
|
||||
Constants.IS_DEBUG ? jsonString : null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/commonSources", method = RequestMethod.PUT, produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/commonSources", method = RequestMethod.PUT)
|
||||
@ApiOperation(value = "回调配置状态修改", httpMethod = "PUT", response = Map.class, notes = "回调配置状态修改服务")
|
||||
public Map updateCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
|
||||
@ApiParam(value = "回调配置状态修改", name = "updateStatConfigSource", required = true)
|
||||
public Map updateCommonConfigSource(@RequestBody UpdateStatConfigSource updateStatConfigSource, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
|
||||
long start = System.currentTimeMillis();
|
||||
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
||||
null);
|
||||
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,updateStatConfigSource);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
configSourcesService.updateCommonSources(thread, start, updateStatConfigSource.getUpdateStatCfgList(), new Date(),sb);
|
||||
|
||||
configSourcesService.saveCommonSources(thread, start, jsonString, sb);
|
||||
|
||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "配置数据插入成功",
|
||||
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)
|
||||
@ApiOperation(value = "样例文件上传服务", httpMethod = "POST", response = Map.class, notes = "样例文件上传服务")
|
||||
@ApiParam(value = "样例文件上传服务", name = "MultipartFile", required = true)
|
||||
@@ -540,42 +521,35 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
HttpServletResponse response) {
|
||||
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
|
||||
long start = System.currentTimeMillis();
|
||||
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
||||
null);
|
||||
String filePath = "";
|
||||
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 (null == file) {
|
||||
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),FileDesc.class);
|
||||
if(null==file){
|
||||
thread.setExceptionInfo("请选择上传文件到file参数");
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请选择上传文件到file参数",
|
||||
RestBusinessCode.missing_args.getValue());
|
||||
|
||||
|
||||
}
|
||||
if (!StringUtil.isEmpty(fileDesc.getChecksum())) {
|
||||
// 验证Md5
|
||||
//验证Md5
|
||||
String md5 = DigestUtils.md5Hex(file.getBytes());
|
||||
System.out.println("----------------------------MD5:'" + md5 + "'==='" + fileDesc.getChecksum() + "'");
|
||||
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);
|
||||
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);
|
||||
logger.info("-----------------调用接口上传文件---------------");
|
||||
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
|
||||
@@ -583,62 +557,57 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
}
|
||||
JSONObject jsonObj = new JSONObject();
|
||||
jsonObj.put("accessUrl", filePath.substring(filePath.indexOf("group")));
|
||||
// jsonObj.put("accessUrl", "filePath");
|
||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "文件上传成功", jsonObj);
|
||||
// jsonObj.put("accessUrl", "filePath");
|
||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
||||
"文件上传成功" ,jsonObj);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/fileDigestSources", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "文件摘要获取", httpMethod = "POST", response = Map.class, notes = "文件摘要获取")
|
||||
@ApiParam(value = "摘要文件", name = "MultipartFile", required = true)
|
||||
public Map fileDigestSources(MultipartFile file, HttpServletRequest request, HttpServletResponse response) {
|
||||
public Map fileDigestSources(MultipartFile file,HttpServletRequest request,
|
||||
HttpServletResponse response){
|
||||
long start = System.currentTimeMillis();
|
||||
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
||||
file, null);
|
||||
// JSONArray fileArray=new JSONArray();
|
||||
if (file == null) {
|
||||
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,file,null);
|
||||
//JSONArray fileArray=new JSONArray();
|
||||
if (file==null) {
|
||||
thread.setExceptionInfo("请上传获取摘要的文件到file");
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请上传获取摘要的文件到file参数",
|
||||
RestBusinessCode.missing_args.getValue());
|
||||
}
|
||||
JSONObject resultObject = new JSONObject();
|
||||
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),
|
||||
FileDesc.class);
|
||||
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),FileDesc.class);
|
||||
try {
|
||||
if (!StringUtil.isEmpty(fileDesc.getChecksum())) {
|
||||
// 验证Md5
|
||||
//验证Md5
|
||||
String md5 = DigestUtils.md5Hex(file.getBytes());
|
||||
System.out.println("----------------------------MD5:'" + md5 + "'==='" + fileDesc.getChecksum() + "'");
|
||||
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);
|
||||
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);
|
||||
logger.info("-----------------调用接口上传文件---------------");
|
||||
String filePath = FileManager.upload(fdsfile, null);
|
||||
resultObject.put("path", filePath.substring(filePath.indexOf("group")));
|
||||
} else {
|
||||
thread.setExceptionInfo("请求头信息中缺少checksum参数");
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请求头信息中缺少checksum参数",
|
||||
RestBusinessCode.missing_args.getValue());
|
||||
}
|
||||
|
||||
|
||||
CommonsMultipartFile filetemp = (CommonsMultipartFile) file;
|
||||
String tempFilePath = filetemp.getStorageDescription().toString();
|
||||
tempFilePath = tempFilePath.substring(tempFilePath.indexOf("[") + 1, tempFilePath.indexOf("]"));
|
||||
|
||||
String digestStr = configSourcesService.getDigestGen(request.getRealPath("/"), tempFilePath);
|
||||
String tempFilePath = filetemp.getStorageDescription().toString();
|
||||
tempFilePath = tempFilePath.substring(tempFilePath.indexOf("[")+1, tempFilePath.indexOf("]"));
|
||||
|
||||
String digestStr = configSourcesService.getDigestGen(request.getRealPath(File.separator),tempFilePath);
|
||||
resultObject.put("digest", digestStr);
|
||||
resultObject.put("rawLen", file.getSize());
|
||||
} catch (IOException e) {
|
||||
}catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
logger.error("文件上传过程中出现异常");
|
||||
thread.setExceptionInfo("文件上传过程中出现异常");
|
||||
@@ -652,9 +621,8 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "摘要获取过程中出现异常",
|
||||
RestBusinessCode.unknow_error.getValue());
|
||||
}
|
||||
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "摘要获取成功", resultObject);
|
||||
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "摘要获取成功",resultObject);
|
||||
}
|
||||
|
||||
private boolean isBlank(Date datetime) {
|
||||
if (null != datetime) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user