|
|
|
@@ -5,6 +5,7 @@ import java.io.IOException;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
@@ -73,18 +74,21 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
|
|
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
|
|
|
configSource);
|
|
|
|
configSource);
|
|
|
|
|
|
|
|
// 分布式锁的标识,谁加锁,谁解锁,如果中间发生了异常则根据失效时间自动失效,默认五分钟失效
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
|
|
|
String requestId = UUID.randomUUID().toString();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (getLock(requestId)) {
|
|
|
|
if (null != configSource && null != configSource.getConfigCompileList()
|
|
|
|
if (null != configSource && null != configSource.getConfigCompileList()
|
|
|
|
&& configSource.getConfigCompileList().size() > 0) {
|
|
|
|
&& configSource.getConfigCompileList().size() > 0) {
|
|
|
|
checkOpAction(thread, System.currentTimeMillis() - start, configSource.getOpAction(), Constants.OPACTION_POST);
|
|
|
|
checkOpAction(thread, System.currentTimeMillis() - start, configSource.getOpAction(),
|
|
|
|
|
|
|
|
Constants.OPACTION_POST);
|
|
|
|
// 验证配置编译数据
|
|
|
|
// 验证配置编译数据
|
|
|
|
validateConfigSource(thread, start, configSource);
|
|
|
|
validateConfigSource(thread, start, configSource);
|
|
|
|
configSourcesService.saveMaatConfig(thread, start, configSource.getConfigCompileList(), sb);
|
|
|
|
configSourcesService.saveMaatConfig(thread, start, configSource.getConfigCompileList(), sb);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new RestServiceException("Maat规则不能为空",
|
|
|
|
throw new RestServiceException("Maat规则不能为空", RestBusinessCode.ConfigSourceIsNull.getValue());
|
|
|
|
RestBusinessCode.ConfigSourceIsNull.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
// TODO: handle exception
|
|
|
|
// TODO: handle exception
|
|
|
|
@@ -101,6 +105,8 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
"Maat 规则存储异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
|
|
|
"Maat 规则存储异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
deblocking(requestId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
|
|
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
|
|
|
@@ -116,7 +122,9 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
|
|
|
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
|
|
|
|
configSource);
|
|
|
|
configSource);
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
|
|
|
String requestId = UUID.randomUUID().toString();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (getLock(requestId)) {
|
|
|
|
if (null == configSource.getOpTime()) {
|
|
|
|
if (null == configSource.getOpTime()) {
|
|
|
|
configSource.setOpTime(new Date());
|
|
|
|
configSource.setOpTime(new Date());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -131,6 +139,7 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
throw new RestServiceException("Maat规则不能为空" + sb.toString(),
|
|
|
|
throw new RestServiceException("Maat规则不能为空" + sb.toString(),
|
|
|
|
RestBusinessCode.ConfigSourceIsNull.getValue());
|
|
|
|
RestBusinessCode.ConfigSourceIsNull.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
// TODO: handle exception
|
|
|
|
// TODO: handle exception
|
|
|
|
thread.setExceptionInfo("MAAT规则状态更新时出现异常:" + e.getMessage());
|
|
|
|
thread.setExceptionInfo("MAAT规则状态更新时出现异常:" + e.getMessage());
|
|
|
|
@@ -145,6 +154,8 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
"MAAT规则状态更新时出现异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
|
|
|
"MAAT规则状态更新时出现异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
deblocking(requestId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
|
|
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
|
|
|
@@ -183,30 +194,35 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
public Map createCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
|
|
|
|
public Map createCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
|
|
|
|
HttpServletResponse response) {
|
|
|
|
HttpServletResponse response) {
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
|
|
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request, null);
|
|
|
|
null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String requestId = UUID.randomUUID().toString();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (getLock(requestId)) {
|
|
|
|
configSourcesService.saveCommonSources(thread, start, jsonString);
|
|
|
|
configSourcesService.saveCommonSources(thread, start, jsonString);
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
// TODO: handle exception
|
|
|
|
// TODO: handle exception
|
|
|
|
thread.setExceptionInfo("回调规则存储异常:" + e.getMessage());
|
|
|
|
thread.setExceptionInfo("回调规则存储异常:" + e.getMessage());
|
|
|
|
logger.error("回调规则存储异常:" + e.getMessage());
|
|
|
|
logger.error("回调规则存储异常:" + e.getMessage());
|
|
|
|
if (e instanceof RestServiceException) {
|
|
|
|
if (e instanceof RestServiceException) {
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, "回调规则存储异常:" + e.getMessage(),
|
|
|
|
"回调规则存储异常:" + e.getMessage(), ((RestServiceException) e).getErrorCode());
|
|
|
|
((RestServiceException) e).getErrorCode());
|
|
|
|
} else if (e instanceof ServiceRuntimeException) {
|
|
|
|
} else if (e instanceof ServiceRuntimeException) {
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, "回调规则存储异常:" + e.getMessage(),
|
|
|
|
"回调规则存储异常:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode());
|
|
|
|
((ServiceRuntimeException) e).getErrorCode());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
"回调规则存储异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
|
|
|
"回调规则存储异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
deblocking(requestId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "回调规则下发成功",
|
|
|
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "回调规则下发成功",
|
|
|
|
Constants.IS_DEBUG ? jsonString : null);
|
|
|
|
Constants.IS_DEBUG ? jsonString : null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/cfg/v1/commonSources", method = RequestMethod.PATCH, produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@RequestMapping(value = "/cfg/v1/commonSources", method = RequestMethod.PATCH, produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@ApiOperation(value = "回调(通用)规则内容更新接口", httpMethod = "PATCH", response = Map.class, notes = "接收回调规则数据,格式为结构化行列式JSON,存储到流量处理平台配置线中")
|
|
|
|
@ApiOperation(value = "回调(通用)规则内容更新接口", httpMethod = "PATCH", response = Map.class, notes = "接收回调规则数据,格式为结构化行列式JSON,存储到流量处理平台配置线中")
|
|
|
|
public Map patchCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
|
|
|
|
public Map patchCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
|
|
|
|
@@ -214,8 +230,11 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PATCH, request,
|
|
|
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PATCH, request,
|
|
|
|
null);
|
|
|
|
null);
|
|
|
|
|
|
|
|
String requestId = UUID.randomUUID().toString();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (getLock(requestId)) {
|
|
|
|
configSourcesService.saveCommonSources(thread, start, jsonString);
|
|
|
|
configSourcesService.saveCommonSources(thread, start, jsonString);
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
// TODO: handle exception
|
|
|
|
// TODO: handle exception
|
|
|
|
thread.setExceptionInfo("回调规则内容更新异常:" + e.getMessage());
|
|
|
|
thread.setExceptionInfo("回调规则内容更新异常:" + e.getMessage());
|
|
|
|
@@ -230,11 +249,14 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
"回调规则内容更新异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
|
|
|
"回调规则内容更新异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
deblocking(requestId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "回调规则内容更新成功",
|
|
|
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "回调规则内容更新成功",
|
|
|
|
Constants.IS_DEBUG ? jsonString : null);
|
|
|
|
Constants.IS_DEBUG ? jsonString : null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@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 = "接收回调规则,对其状态置为失效")
|
|
|
|
public Map updateCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
|
|
|
|
public Map updateCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
|
|
|
|
@@ -243,8 +265,11 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
|
|
|
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
|
|
|
|
jsonString);
|
|
|
|
jsonString);
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
|
|
|
String requestId = UUID.randomUUID().toString();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (getLock(requestId)) {
|
|
|
|
configSourcesService.updateCommonSources(thread, start, jsonString, new Date(), sb);
|
|
|
|
configSourcesService.updateCommonSources(thread, start, jsonString, new Date(), sb);
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
// TODO: handle exception
|
|
|
|
// TODO: handle exception
|
|
|
|
thread.setExceptionInfo("回调规则状态更新异常:" + e.getMessage());
|
|
|
|
thread.setExceptionInfo("回调规则状态更新异常:" + e.getMessage());
|
|
|
|
@@ -259,6 +284,8 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
"回调规则状态更新异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
|
|
|
"回调规则状态更新异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
deblocking(requestId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "回调规则状态更新成功",
|
|
|
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "回调规则状态更新成功",
|
|
|
|
@@ -271,8 +298,7 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
public Map fileUploadSource(@RequestBody MultipartFile file, HttpServletRequest request,
|
|
|
|
public Map fileUploadSource(@RequestBody MultipartFile file, HttpServletRequest request,
|
|
|
|
HttpServletResponse response) {
|
|
|
|
HttpServletResponse response) {
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
|
|
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request, null);
|
|
|
|
null);
|
|
|
|
|
|
|
|
String filePath = "";
|
|
|
|
String filePath = "";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),
|
|
|
|
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),
|
|
|
|
@@ -292,7 +318,8 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
String ext = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
|
|
|
|
String ext = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
|
|
|
|
logger.info("-----------------调用接口上传文件---------------");
|
|
|
|
logger.info("-----------------调用接口上传文件---------------");
|
|
|
|
if (Constants.IS_USE_MINIO) {
|
|
|
|
if (Constants.IS_USE_MINIO) {
|
|
|
|
filePath = MinioUtil.uploadFile(file.getInputStream(), file.getOriginalFilename(), file.getContentType());
|
|
|
|
filePath = MinioUtil.uploadFile(file.getInputStream(), file.getOriginalFilename(),
|
|
|
|
|
|
|
|
file.getContentType());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(), file.getOriginalFilename(), ext);
|
|
|
|
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(), file.getOriginalFilename(), ext);
|
|
|
|
// NameValuePair[] meta_list = new NameValuePair[5];
|
|
|
|
// NameValuePair[] meta_list = new NameValuePair[5];
|
|
|
|
@@ -310,20 +337,21 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
logger.error(RestBusinessCode.FileUploadFailure.getErrorReason() + ":" + e.getMessage());
|
|
|
|
logger.error(RestBusinessCode.FileUploadFailure.getErrorReason() + ":" + e.getMessage());
|
|
|
|
thread.setExceptionInfo(RestBusinessCode.FileUploadFailure.getErrorReason() + ":" + e.getMessage());
|
|
|
|
thread.setExceptionInfo(RestBusinessCode.FileUploadFailure.getErrorReason() + ":" + e.getMessage());
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
RestBusinessCode.FileUploadFailure.getErrorReason()+":"+ e.getMessage(), RestBusinessCode.FileUploadFailure.getValue());
|
|
|
|
RestBusinessCode.FileUploadFailure.getErrorReason() + ":" + e.getMessage(),
|
|
|
|
|
|
|
|
RestBusinessCode.FileUploadFailure.getValue());
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
// TODO: handle exception
|
|
|
|
// TODO: handle exception
|
|
|
|
logger.error("文件上传异常:" + e.getMessage());
|
|
|
|
logger.error("文件上传异常:" + e.getMessage());
|
|
|
|
thread.setExceptionInfo("文件上传异常:" + e.getMessage());
|
|
|
|
thread.setExceptionInfo("文件上传异常:" + e.getMessage());
|
|
|
|
if (e instanceof RestServiceException) {
|
|
|
|
if (e instanceof RestServiceException) {
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, e.getMessage(),
|
|
|
|
e.getMessage(), ((RestServiceException) e).getErrorCode());
|
|
|
|
((RestServiceException) e).getErrorCode());
|
|
|
|
} else if (e instanceof ServiceRuntimeException) {
|
|
|
|
} else if (e instanceof ServiceRuntimeException) {
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start, e.getMessage(),
|
|
|
|
e.getMessage(), ((ServiceRuntimeException) e).getErrorCode());
|
|
|
|
((ServiceRuntimeException) e).getErrorCode());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start, e.getMessage(),
|
|
|
|
e.getMessage(), RestBusinessCode.FileUploadFailure.getValue());
|
|
|
|
RestBusinessCode.FileUploadFailure.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -339,8 +367,8 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
public Map fileDigestSources(@RequestBody MultipartFile file, HttpServletRequest request,
|
|
|
|
public Map fileDigestSources(@RequestBody MultipartFile file, HttpServletRequest request,
|
|
|
|
HttpServletResponse response) {
|
|
|
|
HttpServletResponse response) {
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
|
|
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request, file,
|
|
|
|
file, null);
|
|
|
|
null);
|
|
|
|
JSONObject resultObject = new JSONObject();
|
|
|
|
JSONObject resultObject = new JSONObject();
|
|
|
|
String filePath = "";
|
|
|
|
String filePath = "";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
@@ -355,13 +383,13 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
String md5 = DigestUtils.md5Hex(file.getInputStream());
|
|
|
|
String md5 = DigestUtils.md5Hex(file.getInputStream());
|
|
|
|
System.out.println("----------------------------MD5:'" + md5 + "'==='" + fileDesc.getChecksum() + "'");
|
|
|
|
System.out.println("----------------------------MD5:'" + md5 + "'==='" + fileDesc.getChecksum() + "'");
|
|
|
|
if (!md5.equals(fileDesc.getChecksum())) {
|
|
|
|
if (!md5.equals(fileDesc.getChecksum())) {
|
|
|
|
throw new RestServiceException("checksum与文件MD5值不一致",
|
|
|
|
throw new RestServiceException("checksum与文件MD5值不一致", RestBusinessCode.CheckSumIsWrong.getValue());
|
|
|
|
RestBusinessCode.CheckSumIsWrong.getValue());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String ext = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
|
|
|
|
String ext = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
|
|
|
|
logger.info("-----------------调用接口上传文件---------------");
|
|
|
|
logger.info("-----------------调用接口上传文件---------------");
|
|
|
|
if (Constants.IS_USE_MINIO) {
|
|
|
|
if (Constants.IS_USE_MINIO) {
|
|
|
|
filePath = MinioUtil.uploadFile(file.getInputStream(), file.getOriginalFilename(), file.getContentType());
|
|
|
|
filePath = MinioUtil.uploadFile(file.getInputStream(), file.getOriginalFilename(),
|
|
|
|
|
|
|
|
file.getContentType());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(), file.getOriginalFilename(), ext);
|
|
|
|
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(), file.getOriginalFilename(), ext);
|
|
|
|
// NameValuePair[] meta_list = new NameValuePair[5];
|
|
|
|
// NameValuePair[] meta_list = new NameValuePair[5];
|
|
|
|
@@ -380,20 +408,21 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
logger.error(RestBusinessCode.FileUploadFailure.getErrorReason() + ":" + e.getMessage());
|
|
|
|
logger.error(RestBusinessCode.FileUploadFailure.getErrorReason() + ":" + e.getMessage());
|
|
|
|
thread.setExceptionInfo(RestBusinessCode.FileUploadFailure.getErrorReason() + ":" + e.getMessage());
|
|
|
|
thread.setExceptionInfo(RestBusinessCode.FileUploadFailure.getErrorReason() + ":" + e.getMessage());
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
RestBusinessCode.FileUploadFailure.getErrorReason()+":"+ e.getMessage(), RestBusinessCode.FileUploadFailure.getValue());
|
|
|
|
RestBusinessCode.FileUploadFailure.getErrorReason() + ":" + e.getMessage(),
|
|
|
|
|
|
|
|
RestBusinessCode.FileUploadFailure.getValue());
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
// TODO: handle exception
|
|
|
|
// TODO: handle exception
|
|
|
|
logger.error(RestBusinessCode.FileUploadFailure.getErrorReason() + ":" + e.getMessage());
|
|
|
|
logger.error(RestBusinessCode.FileUploadFailure.getErrorReason() + ":" + e.getMessage());
|
|
|
|
thread.setExceptionInfo(RestBusinessCode.FileUploadFailure.getErrorReason() + ":" + e.getMessage());
|
|
|
|
thread.setExceptionInfo(RestBusinessCode.FileUploadFailure.getErrorReason() + ":" + e.getMessage());
|
|
|
|
if (e instanceof RestServiceException) {
|
|
|
|
if (e instanceof RestServiceException) {
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, e.getMessage(),
|
|
|
|
e.getMessage(), ((RestServiceException) e).getErrorCode());
|
|
|
|
((RestServiceException) e).getErrorCode());
|
|
|
|
} else if (e instanceof ServiceRuntimeException) {
|
|
|
|
} else if (e instanceof ServiceRuntimeException) {
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start, e.getMessage(),
|
|
|
|
e.getMessage(), ((ServiceRuntimeException) e).getErrorCode());
|
|
|
|
((ServiceRuntimeException) e).getErrorCode());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start, e.getMessage(),
|
|
|
|
e.getMessage(), RestBusinessCode.FileUploadFailure.getValue());
|
|
|
|
RestBusinessCode.FileUploadFailure.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
@@ -412,7 +441,8 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
logger.error(RestBusinessCode.GetFileDigestFailure.getValue() + ":" + e.getMessage() + ",请检查摘要获取工具是否安装成功");
|
|
|
|
logger.error(RestBusinessCode.GetFileDigestFailure.getValue() + ":" + e.getMessage() + ",请检查摘要获取工具是否安装成功");
|
|
|
|
thread.setExceptionInfo("摘要获取过程中出现异常:" + e.getMessage() + ",请检查摘要获取工具是否安装成功");
|
|
|
|
thread.setExceptionInfo("摘要获取过程中出现异常:" + e.getMessage() + ",请检查摘要获取工具是否安装成功");
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start, RestBusinessCode.GetFileDigestFailure.getErrorReason()+":"+e.getMessage()+",请检查摘要获取工具是否安装成功",
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
|
|
|
|
RestBusinessCode.GetFileDigestFailure.getErrorReason() + ":" + e.getMessage() + ",请检查摘要获取工具是否安装成功",
|
|
|
|
RestBusinessCode.GetFileDigestFailure.getValue());
|
|
|
|
RestBusinessCode.GetFileDigestFailure.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "摘要获取成功", resultObject);
|
|
|
|
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "摘要获取成功", resultObject);
|
|
|
|
@@ -429,16 +459,19 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
groupReuseSource);
|
|
|
|
groupReuseSource);
|
|
|
|
|
|
|
|
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
|
|
|
String requestId = UUID.randomUUID().toString();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (getLock(requestId)) {
|
|
|
|
if (null != groupReuseSource && null != groupReuseSource.getGroupReuseList()
|
|
|
|
if (null != groupReuseSource && null != groupReuseSource.getGroupReuseList()
|
|
|
|
&& groupReuseSource.getGroupReuseList().size() > 0) {
|
|
|
|
&& groupReuseSource.getGroupReuseList().size() > 0) {
|
|
|
|
checkOpAction(thread, System.currentTimeMillis() - start, groupReuseSource.getOpAction(), Constants.OPACTION_POST);
|
|
|
|
checkOpAction(thread, System.currentTimeMillis() - start, groupReuseSource.getOpAction(),
|
|
|
|
|
|
|
|
Constants.OPACTION_POST);
|
|
|
|
// 验证配置编译数据
|
|
|
|
// 验证配置编译数据
|
|
|
|
validateGroupReuseSource(thread, start, groupReuseSource);
|
|
|
|
validateGroupReuseSource(thread, start, groupReuseSource);
|
|
|
|
configSourcesService.addGroupReuseSources(thread, start, groupReuseSource.getGroupReuseList(), sb);
|
|
|
|
configSourcesService.addGroupReuseSources(thread, start, groupReuseSource.getGroupReuseList(), sb);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new RestServiceException("Maat规则不能为空",
|
|
|
|
throw new RestServiceException("Maat规则不能为空", RestBusinessCode.ConfigSourceIsNull.getValue());
|
|
|
|
RestBusinessCode.ConfigSourceIsNull.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
// TODO: handle exception
|
|
|
|
// TODO: handle exception
|
|
|
|
@@ -455,6 +488,8 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
"Maat 分组复用规则存储异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
|
|
|
"Maat 分组复用规则存储异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
deblocking(requestId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
|
|
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
|
|
|
@@ -470,7 +505,9 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
|
|
|
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
|
|
|
|
groupReuseSource);
|
|
|
|
groupReuseSource);
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
|
|
|
String requestId = UUID.randomUUID().toString();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (getLock(requestId)) {
|
|
|
|
if (null == groupReuseSource.getOpTime()) {
|
|
|
|
if (null == groupReuseSource.getOpTime()) {
|
|
|
|
groupReuseSource.setOpTime(new Date());
|
|
|
|
groupReuseSource.setOpTime(new Date());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -485,6 +522,7 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
throw new RestServiceException("分组复用信息不能为空" + sb.toString(),
|
|
|
|
throw new RestServiceException("分组复用信息不能为空" + sb.toString(),
|
|
|
|
RestBusinessCode.ConfigSourceIsNull.getValue());
|
|
|
|
RestBusinessCode.ConfigSourceIsNull.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
// TODO: handle exception
|
|
|
|
// TODO: handle exception
|
|
|
|
thread.setExceptionInfo("MAAT规则状态更新时出现异常:" + e.getMessage());
|
|
|
|
thread.setExceptionInfo("MAAT规则状态更新时出现异常:" + e.getMessage());
|
|
|
|
@@ -499,6 +537,8 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
|
|
|
"删除MAAT规则分组复用域配置时出现异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
|
|
|
"删除MAAT规则分组复用域配置时出现异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
deblocking(requestId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
|
|
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
|
|
|
@@ -531,6 +571,7 @@ public class ConfigSourcesController extends BaseRestController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isBlank(Date datetime) {
|
|
|
|
private boolean isBlank(Date datetime) {
|
|
|
|
if (null != datetime) {
|
|
|
|
if (null != datetime) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|