1、回调类中改为属于策略一部分无action;
2、添加分组复用域配置新增和删除接口;只有属于分组复用的业务类型在新增MAAT规则时才能只不填写域配置;
This commit is contained in:
@@ -2,7 +2,6 @@ package com.nis.web.controller.restful;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -10,7 +9,8 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.nis.web.service.AuditLogThread;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -22,16 +22,17 @@ 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.GroupReuse;
|
||||
import com.nis.domain.restful.GroupReuseSource;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.restful.ServiceRuntimeException;
|
||||
import com.nis.util.CompileVal;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.FileUtils;
|
||||
import com.nis.util.OracleErrorCodeUtil;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.web.controller.BaseRestController;
|
||||
import com.nis.web.service.AuditLogThread;
|
||||
import com.nis.web.service.ServicesRequestLogService;
|
||||
import com.nis.web.service.fdfs.FastDFSFile;
|
||||
import com.nis.web.service.fdfs.FileManager;
|
||||
@@ -41,8 +42,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: 配置存储服务
|
||||
@@ -177,7 +176,7 @@ 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 = "接收回调规则数据,格式为结构化行列式JSON,存储到流量处理平台配置线中")
|
||||
public Map createCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
|
||||
@@ -208,7 +207,6 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
Constants.IS_DEBUG ? jsonString : null);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/commonSources", method = RequestMethod.PUT)
|
||||
@ApiOperation(value = "回调(通用)规则状态更新接口", httpMethod = "PUT", response = Map.class, notes = "接收回调规则,对其状态置为失效")
|
||||
public Map updateCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
|
||||
@@ -376,6 +374,119 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "摘要获取成功", resultObject);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/groupReuseSources", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "分组复用域配置新增接口", httpMethod = "POST", response = Map.class, notes = "接收分组复用域配置,增加到对应的分组中")
|
||||
@ApiParam(value = "分组复用域配置对象", name = "configSource", required = true)
|
||||
public Map addGroupReuseSources(@RequestBody GroupReuseSource groupReuseSource, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
||||
groupReuseSource);
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
try {
|
||||
if (null != groupReuseSource && null != groupReuseSource.getGroupReuseList()
|
||||
&& groupReuseSource.getGroupReuseList().size() > 0) {
|
||||
checkOpAction(thread, System.currentTimeMillis() - start, groupReuseSource.getOpAction(), Constants.OPACTION_POST);
|
||||
// 验证配置编译数据
|
||||
validateGroupReuseSource(thread, start, groupReuseSource);
|
||||
configSourcesService.addGroupReuseSources(thread, start, groupReuseSource.getGroupReuseList(), sb);
|
||||
} else {
|
||||
throw new RestServiceException("Maat规则不能为空",
|
||||
RestBusinessCode.ConfigSourceIsNull.getValue());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
thread.setExceptionInfo("Maat 分组复用规则存储异常:" + e.getMessage());
|
||||
logger.error("Maat 分组复用规则存储异常:" + e.getMessage());
|
||||
if (e instanceof RestServiceException) {
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
||||
"Maat 分组复用规则存储异常:" + e.getMessage(), ((RestServiceException) e).getErrorCode());
|
||||
}else if(e instanceof ServiceRuntimeException) {
|
||||
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
||||
"Maat 分组复用规则存储异常:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode());
|
||||
}else{
|
||||
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
||||
"Maat 分组复用规则存储异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
||||
"Maat分组复用规则添加成功" + sb.toString(), Constants.IS_DEBUG ? groupReuseSource : null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/groupReuseSources", method = RequestMethod.PUT)
|
||||
@ApiOperation(value = "分组复用域配置删除接口", httpMethod = "PUT", response = Map.class, notes = "接收分组复用域配置,并从对应分组中删除")
|
||||
@ApiParam(value = "分组复用域配置对象", name = "configSource", required = true)
|
||||
public Map delGroupReuseSources(@RequestBody GroupReuseSource groupReuseSource, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
long start = System.currentTimeMillis();
|
||||
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
|
||||
groupReuseSource);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
try {
|
||||
if (null == groupReuseSource.getOpTime()) {
|
||||
groupReuseSource.setOpTime(new Date());
|
||||
}
|
||||
if (null != groupReuseSource && null != groupReuseSource.getGroupReuseList()
|
||||
&& groupReuseSource.getGroupReuseList().size() > 0) {
|
||||
int opAction = groupReuseSource.getOpAction();
|
||||
checkOpAction(thread, System.currentTimeMillis() - start, opAction, 2);
|
||||
configSourcesService.deleteGroupReuseSources(thread, start,groupReuseSource.getGroupReuseList(),
|
||||
groupReuseSource.getOpTime(), sb);
|
||||
|
||||
} else {
|
||||
throw new RestServiceException("分组复用信息不能为空" + sb.toString(),
|
||||
RestBusinessCode.ConfigSourceIsNull.getValue());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
thread.setExceptionInfo("MAAT规则状态更新时出现异常:" + e.getMessage());
|
||||
logger.error("删除MAAT规则分组复用域配置时出现异常:" + e.getMessage());
|
||||
if (e instanceof RestServiceException) {
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
||||
"删除MAAT规则分组复用域配置时出现异常:" + e.getMessage(), ((RestServiceException) e).getErrorCode());
|
||||
}else if(e instanceof ServiceRuntimeException) {
|
||||
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
||||
"删除MAAT规则分组复用域配置时出现异常:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode());
|
||||
}else{
|
||||
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
||||
"删除MAAT规则分组复用域配置时出现异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
||||
"MAAT规则分组复用域配置删除成功" + sb.toString(), Constants.IS_DEBUG ?groupReuseSource : null);
|
||||
}
|
||||
|
||||
private void validateGroupReuseSource(AuditLogThread thread, long start, GroupReuseSource groupReuseSource) {
|
||||
String errorInfo = "";
|
||||
|
||||
List<GroupReuse> groupReuseSourceList = groupReuseSource.getGroupReuseList();
|
||||
|
||||
if (StringUtils.isEmpty(groupReuseSource.getOperator())) {
|
||||
errorInfo = "get operator is Empty";
|
||||
}
|
||||
if (StringUtils.isEmpty(groupReuseSource.getVersion())) {
|
||||
errorInfo = "get version is Empty";
|
||||
}
|
||||
|
||||
if (!isBlank(groupReuseSource.getOpTime())) {
|
||||
errorInfo = "get OpTime is Empty";
|
||||
}
|
||||
|
||||
if (groupReuseSourceList.size() <= 0) {
|
||||
errorInfo = "分组复用的域配置列表不能为空";
|
||||
}
|
||||
if (!errorInfo.equals("")) {
|
||||
thread.setExceptionInfo(errorInfo);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorInfo,
|
||||
RestBusinessCode.missing_args.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
private boolean isBlank(Date datetime) {
|
||||
if (null != datetime) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user