1、删除无用类和方法;

2、修改异常处理方式,一直往上抛在controller里记录日志并返回给客户端;
3、回调类配置新增时isValid只能为1
This commit is contained in:
zhangdongxu
2018-08-10 15:14:12 +08:00
parent 329b79607e
commit eb49689c55
83 changed files with 627 additions and 14591 deletions

View File

@@ -63,43 +63,43 @@ public class ConfigSourcesController extends BaseRestController {
@Autowired
ConfigRedisService configRedisService;
@RequestMapping(value = "/cfg/v1/configSources", method = RequestMethod.POST)
@ApiOperation(value = "MAAT规则存储接口", httpMethod = "POST", response = Map.class, notes = "接收MAAT规则数据存储到流量处理平台配置线中")
@ApiParam(value = "MAAT规则对象", name = "configSource", required = true)
public Map createMaatConfigSource(@RequestBody ConfigSource configSource, HttpServletRequest request,
HttpServletResponse response) {
CompileVal.setBusinessCode(null);
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
long start = System.currentTimeMillis();
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
configSource);
StringBuffer sb = new StringBuffer();
if (null != configSource && null != configSource.getConfigCompileList()
&& configSource.getConfigCompileList().size() > 0) {
checkOpAction(thread, System.currentTimeMillis() - start, configSource.getOpAction(), Constants.OPACTION_POST);
// 验证配置编译数据
validateConfigSource(thread, start, configSource);
String msg = configSourcesService.saveMaatConfig(thread, start, configSource.getConfigCompileList(), sb);
if ("error".equals(msg)) {
Exception exception = ConfigSourcesService.getMsgList().get(0);
if (exception instanceof RestServiceException) {
throw new RestServiceException(thread, System.currentTimeMillis() - start,
"Maat 规则存储异常:" + exception.getMessage(), CompileVal.getBusinessCode());
}else{
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
"Maat 规则存储异常:" + exception.getMessage(), CompileVal.getBusinessCode());
}
try {
if (null != configSource && null != configSource.getConfigCompileList()
&& configSource.getConfigCompileList().size() > 0) {
checkOpAction(thread, System.currentTimeMillis() - start, configSource.getOpAction(), Constants.OPACTION_POST);
// 验证配置编译数据
validateConfigSource(thread, start, configSource);
configSourcesService.saveMaatConfig(thread, start, configSource.getConfigCompileList(), sb);
} else {
throw new RestServiceException("Maat规则不能为空",
RestBusinessCode.ConfigSourceIsNull.getValue());
}
} else {
thread.setExceptionInfo("Maat规则不能为空");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "Maat规则不能为空",
RestBusinessCode.missing_args.getValue());
} catch (Exception e) {
// TODO: handle exception
thread.setExceptionInfo("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,
@@ -111,171 +111,44 @@ public class ConfigSourcesController extends BaseRestController {
@ApiParam(value = "MAAT规则对象", name = "configSource", required = true)
public Map updateConfigSource(@RequestBody ConfigSource configSource, HttpServletRequest request,
HttpServletResponse response) {
CompileVal.setBusinessCode(null);
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
long start = System.currentTimeMillis();
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
configSource);
StringBuffer sb = new StringBuffer();
if (null == configSource.getOpTime()) {
configSource.setOpTime(new Date());
}
if (null != configSource && null != configSource.getConfigCompileList()
&& configSource.getConfigCompileList().size() > 0) {
int opAction = configSource.getOpAction();
checkOpAction(thread, System.currentTimeMillis() - start, opAction, 2);
String msg = "";
ConfigCompile compile = configSource.getConfigCompileList().get(0);
// zdx 20180528改为调用rkg接口取消配置
msg = configSourcesService.updateConfigSources(thread, start, configSource.getConfigCompileList(),
configSource.getOpTime(), sb);
if (msg.equals("error")) {
Exception exception = ConfigSourcesService.getMsgList().get(0);
if (exception instanceof RestServiceException) {
throw new RestServiceException(thread, System.currentTimeMillis() - start,
"MAAT规则状态更新时出现异常:" + exception.getMessage(),CompileVal.getBusinessCode());
}else {
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
"MAAT规则状态更新时出现异常:" + exception.getMessage(),CompileVal.getBusinessCode());
}
try {
if (null == configSource.getOpTime()) {
configSource.setOpTime(new Date());
}
if (null != configSource && null != configSource.getConfigCompileList()
&& configSource.getConfigCompileList().size() > 0) {
int opAction = configSource.getOpAction();
checkOpAction(thread, System.currentTimeMillis() - start, opAction, 2);
configSourcesService.updateConfigSources(thread, start, configSource.getConfigCompileList(),
configSource.getOpTime(), sb);
} else {
throw new RestServiceException("Maat规则不能为空" + sb.toString(),
RestBusinessCode.ConfigSourceIsNull.getValue());
}
} catch (Exception e) {
// TODO: handle exception
thread.setExceptionInfo("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());
}
// configSourcesService.updateConfigSource(thread, start,
// configSource.getConfigCompileList(),
// configSource.getOpTime(), sb);
} else {
thread.setExceptionInfo("Maat规则不能为空");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "Maat规则不能为空" + sb.toString(),
RestBusinessCode.missing_args.getValue());
}
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
"Maat规则状态更新成功" + sb.toString(), Constants.IS_DEBUG ? configSource : null);
}
@RequestMapping(value = "/cfg/v1/configModifySources", method = RequestMethod.PUT)
@ApiOperation(value = "MAAT规则修改接口", httpMethod = "PUT", response = Map.class, notes = "接收Maat规则,对其规则内容进行修改")
@ApiParam(value = "MAAT规则对象", name = "configSource", required = true)
public Map configModifySources(@RequestBody ConfigSource configSource, HttpServletRequest request,
HttpServletResponse response) {
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
long start = System.currentTimeMillis();
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
configSource);
StringBuffer sb = new StringBuffer();
if (null != configSource && null != configSource.getConfigCompileList()
&& configSource.getConfigCompileList().size() > 0) {
int opAction = configSource.getOpAction();
checkOpAction(thread, System.currentTimeMillis() - start, opAction, 2);
// 验证配置编译数据
validateConfigSource(thread, start, configSource);
try {
List<ConfigCompile> configCompileList = configSource.getConfigCompileList();
if (null != configCompileList && configCompileList.size() > 0) {
int count = 0;
for (ConfigCompile configCompile : configCompileList) {
Long compileId = configCompile.getCompileId();
if (null == compileId) {
thread.setExceptionInfo("编译配置id不能为空");
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 (count > 0) {
Thread.sleep(14000);
}
String str = configSourcesService.configModifySources(configCompileList);
if (str.equals("idIsNull")) {
thread.setExceptionInfo("编译配置id不能为空");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置id不能为空",
RestBusinessCode.missing_args.getValue());
}
} else {
thread.setExceptionInfo("编译配置数据不能为空");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置数据不能为空",
RestBusinessCode.missing_args.getValue());
}
} catch (Exception e) {
List<ConfigCompile> configCompileList = configSource.getConfigCompileList();
if (null != configCompileList && configCompileList.size() > 0) {
for (ConfigCompile configCompile : configCompileList) {
Long compileId = configCompile.getCompileId();
if (null == compileId) {
thread.setExceptionInfo("编译配置id不能为空");
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);
// }
// }
// }
}
}
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 ServiceRuntimeException(thread, System.currentTimeMillis() - start,
throwExceptionInfo.get(errorNum), errorNum);
}
}
} else {
thread.setExceptionInfo("编译配置数据不能为空");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置数据不能为空",
RestBusinessCode.missing_args.getValue());
}
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
"修改编译配置数据成功" + sb.toString(), Constants.IS_DEBUG ? configSource : null);
}
private void validateConfigSource(AuditLogThread thread, long start, ConfigSource configSource) {
String errorInfo = "";
@@ -294,7 +167,7 @@ public class ConfigSourcesController extends BaseRestController {
if (configCompileList.size() <= 0) {
errorInfo = "Maat规则不能为空";
}
}
if (!errorInfo.equals("")) {
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorInfo,
@@ -307,24 +180,27 @@ public class ConfigSourcesController extends BaseRestController {
@ApiOperation(value = "回调(通用)规则存储接口", httpMethod = "POST", response = Map.class, notes = "接收回调规则数据,格式为结构化行列式JSON,存储到流量处理平台配置线中")
public Map createCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
HttpServletResponse response) {
CompileVal.setBusinessCode(null);
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
long start = System.currentTimeMillis();
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
null);
String msg = configSourcesService.saveCommonSources(thread, start, jsonString);
if (msg.equals("error")) {
Exception exception = ConfigSourcesService.getMsgList().get(0);
if (exception instanceof RestServiceException) {
try {
configSourcesService.saveCommonSources(thread, start, jsonString);
} catch (Exception e) {
// TODO: handle exception
thread.setExceptionInfo("回调规则存储异常:" + e.getMessage());
if (e instanceof RestServiceException) {
throw new RestServiceException(thread, System.currentTimeMillis() - start,
"回调规则存储异常:" + exception.getMessage(), CompileVal.getBusinessCode());
"回调规则存储异常:" + e.getMessage(), ((RestServiceException) e).getErrorCode());
}else if (e instanceof ServiceRuntimeException) {
throw new RestServiceException(thread, System.currentTimeMillis() - start,
"回调规则存储异常:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode());
}else {
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
"回调规则存储异常:" + exception.getMessage(), CompileVal.getBusinessCode());
"回调规则存储异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
}
}
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "回调规则下发成功",
Constants.IS_DEBUG ? jsonString : null);
}
@@ -334,23 +210,27 @@ public class ConfigSourcesController extends BaseRestController {
@ApiOperation(value = "回调(通用)规则状态更新接口", httpMethod = "PUT", response = Map.class, notes = "接收回调规则,对其状态置为失效")
public Map updateCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
HttpServletResponse response) {
CompileVal.setBusinessCode(null);
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
long start = System.currentTimeMillis();
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
jsonString);
StringBuffer sb = new StringBuffer();
String msg = configSourcesService.updateCommonSources(thread, start, jsonString, new Date(), sb);
if (msg.equals("error")) {
Exception exception = ConfigSourcesService.getMsgList().get(0);
if (exception instanceof RestServiceException) {
try {
configSourcesService.updateCommonSources(thread, start, jsonString, new Date(), sb);
} catch (Exception e) {
// TODO: handle exception
thread.setExceptionInfo("回调规则状态更新异常:" + e.getMessage());
if (e instanceof RestServiceException) {
throw new RestServiceException(thread, System.currentTimeMillis() - start,
"回调规则状态更新异常:" + exception.getMessage(), CompileVal.getBusinessCode());
"回调规则状态更新异常:" + e.getMessage(), ((RestServiceException) e).getErrorCode());
}else if (e instanceof ServiceRuntimeException) {
throw new RestServiceException(thread, System.currentTimeMillis() - start,
"回调规则状态更新异常:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode());
}else {
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
"回调规则状态更新异常:" + exception.getMessage(), CompileVal.getBusinessCode());
"回调规则状态更新异常:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
}
}
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "回调规则状态更新成功",
Constants.IS_DEBUG ? jsonString : null);
}
@@ -360,7 +240,6 @@ public class ConfigSourcesController extends BaseRestController {
@ApiParam(value = "样例文件上传服务", name = "MultipartFile", required = true)
public Map fileUploadSource(@RequestBody MultipartFile file, HttpServletRequest request,
HttpServletResponse response) {
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
long start = System.currentTimeMillis();
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
null);
@@ -369,9 +248,7 @@ public class ConfigSourcesController extends BaseRestController {
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.FileIsNull.getValue());
throw new RestServiceException("请选择上传文件到file参数", RestBusinessCode.FileIsNull.getValue());
}
if (!StringUtil.isEmpty(fileDesc.getChecksum())) {
@@ -380,9 +257,7 @@ public class ConfigSourcesController extends BaseRestController {
// 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.CheckSumIsWrong.getValue());
throw new RestServiceException("checksum与文件MD5值不一致", RestBusinessCode.CheckSumIsWrong.getValue());
}
String ext = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(), file.getOriginalFilename(), ext);
@@ -399,11 +274,13 @@ public class ConfigSourcesController extends BaseRestController {
}catch (IOException e) {
// TODO Auto-generated catch block
logger.error(RestBusinessCode.FileUploadFailure.getErrorReason()+":"+e.getMessage());
thread.setExceptionInfo(RestBusinessCode.FileUploadFailure.getErrorReason()+":"+e.getMessage());
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
RestBusinessCode.FileUploadFailure.getErrorReason()+":"+ e.getMessage(), RestBusinessCode.FileUploadFailure.getValue());
}catch (Exception e) {
// TODO: handle exception
logger.error(e.getMessage());
logger.error("文件上传异常:" +e.getMessage());
thread.setExceptionInfo("文件上传异常:" + e.getMessage());
if (e instanceof RestServiceException) {
throw new RestServiceException(thread, System.currentTimeMillis() - start,
e.getMessage(), ((RestServiceException) e).getErrorCode());
@@ -430,47 +307,38 @@ public class ConfigSourcesController extends BaseRestController {
long start = System.currentTimeMillis();
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
file, null);
if (file == null) {
thread.setExceptionInfo("请上传获取摘要的文件到file");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请上传获取摘要的文件到file参数",
RestBusinessCode.FileIsNull.getValue());
}
JSONObject resultObject = new JSONObject();
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),
FileDesc.class);
try {
if (file == null) {
throw new RestServiceException("请上传获取摘要的文件到file参数", RestBusinessCode.FileIsNull.getValue());
}
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),
FileDesc.class);
if (!StringUtil.isEmpty(fileDesc.getChecksum())) {
// 验证Md5
String md5 = DigestUtils.md5Hex(file.getInputStream());
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值不一致",
throw new RestServiceException("checksum与文件MD5值不一致",
RestBusinessCode.CheckSumIsWrong.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);
logger.info("-----------------调用接口上传文件---------------");
String filePath = FileManager.upload(fdsfile, null);
// resultObject.put("path", filePath.substring(filePath.indexOf("group")));
resultObject.put("accessUrl", filePath);
}
}catch (IOException e) {
// TODO Auto-generated catch block
logger.error(RestBusinessCode.FileUploadFailure.getErrorReason()+":"+e.getMessage());
thread.setExceptionInfo(RestBusinessCode.FileUploadFailure.getErrorReason()+":"+ e.getMessage());
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
RestBusinessCode.FileUploadFailure.getErrorReason()+":"+ e.getMessage(), RestBusinessCode.FileUploadFailure.getValue());
}catch (Exception e) {
// TODO: handle exception
logger.error(e.getMessage());
logger.error(RestBusinessCode.FileUploadFailure.getErrorReason()+":"+e.getMessage());
thread.setExceptionInfo(RestBusinessCode.FileUploadFailure.getErrorReason()+":"+ e.getMessage());
if (e instanceof RestServiceException) {
throw new RestServiceException(thread, System.currentTimeMillis() - start,
e.getMessage(), ((RestServiceException) e).getErrorCode());
@@ -481,16 +349,15 @@ public class ConfigSourcesController extends BaseRestController {
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
e.getMessage(), RestBusinessCode.FileUploadFailure.getValue());
}
}
try {
String tempFilePath = request.getRealPath(File.separator) + "upload" + File.separator
+ (new Date()).getTime() + file.getOriginalFilename();
file.transferTo(new File(tempFilePath));
//System.out.println("------------" + tempFilePath);
System.out.println("摘要获取开始:---------------");
logger.info("摘要获取开始:---------------");
String digestStr = configSourcesService.getDigestGen(request.getRealPath(File.separator), tempFilePath);
System.out.println("摘要获取结束:---------------:"+digestStr);
logger.info("摘要获取结束:---------------:"+digestStr);
resultObject.put("digest", digestStr);
resultObject.put("rawLen", file.getSize());
FileUtils.deleteFile(tempFilePath);
@@ -498,7 +365,7 @@ public class ConfigSourcesController extends BaseRestController {
// TODO Auto-generated catch block
e.printStackTrace();
logger.error(RestBusinessCode.GetFileDigestFailure.getValue()+":"+e.getMessage()+",请检查摘要获取工具是否安装成功");
// thread.setExceptionInfo("摘要获取过程中出现异常");
thread.setExceptionInfo("摘要获取过程中出现异常:"+e.getMessage()+",请检查摘要获取工具是否安装成功");
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start, RestBusinessCode.GetFileDigestFailure.getValue()+":"+e.getMessage()+",请检查摘要获取工具是否安装成功",
RestBusinessCode.GetFileDigestFailure.getValue());
}

View File

@@ -1,223 +0,0 @@
/**
*@Title: DmbCkController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.nis.web.service.AuditLogThread;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
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 com.nis.domain.restful.DmbCk;
import com.nis.domain.restful.DmbCkSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DmbCkService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: DmbCkController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
//@RequestMapping("${servicePath}/cfg/v1")
public class DmbCkController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected DmbCkService dmbCkService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
// @Autowired
// protected CommonConfigService commonConfigService;
// @Autowired
// protected RedisDao redisDao;
/**
* saveDmbCkBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param DmbCkSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbCkSources", method = RequestMethod.POST)
@ApiOperation(value = "保存运营商信息", httpMethod = "POST", notes = "save provider info")
public Map saveDmbCkBatch(@RequestBody DmbCkSource dmbCkSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, dmbCkSource);
super.checkOpAction(thread,System.currentTimeMillis()-start, dmbCkSource.getOpAction(), Constants.OPACTION_POST);
try{
this.chekckData(dmbCkSource);
dmbCkService.saveDmbCkBatch(dmbCkSource.getDmbCkList());
// commonConfigService.saveOrUpdateConfigState("DMB_CK", dmbCkSource.getOpTime());
// redisDao.saveMaps(dmbCkSource.getDmbCkList(), "DMB_CK", DmbCk.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存运营商信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存运营商信息成功",dmbCkSource.getDmbCkList());
}
/**
*
* updateDmbCkBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param DmbCkSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbCkSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新运营商信息", httpMethod = "PUT", notes = "update provider info")
public Map updateDmbCkBatch(@RequestBody DmbCkSource dmbCkSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, dmbCkSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dmbCkSource.getOpAction(), Constants.OPACTION_PUT);
try{
this.chekckData(dmbCkSource);
dmbCkService.updateDmbCkBatch(dmbCkSource.getDmbCkList());
// commonConfigService.saveOrUpdateConfigState("DMB_CK", dmbCkSource.getOpTime());
// redisDao.updateMaps(dmbCkSource.getDmbCkList(), "DMB_CK", DmbCk.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新运营商信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新运营商信息成功",dmbCkSource.getDmbCkList());
}
/**
*
* deleteDmbCk(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbCkSources/{id}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除运营商信息", httpMethod = "DELETE", notes = "delete provider info")
public Map deleteDmbCk(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
dmbCkService.removeDmbCk(id);
// commonConfigService.saveOrUpdateConfigState("DMB_CK", new Date());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除运营商信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteDmbCk(多条删除)
* (这里描述这个方法适用条件 可选)
* @param DmbCkSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbCkSources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除运营商信息", httpMethod = "DELETE", notes = "delete provider info")
public Map deleteDmbCk(@RequestBody DmbCkSource dmbCkSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, dmbCkSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dmbCkSource.getOpAction(), Constants.OPACTION_DELETE);
try{
dmbCkService.removeDmbCkBatch(dmbCkSource.getDmbCkList());
// commonConfigService.saveOrUpdateConfigState("DMB_CK", dmbCkSource.getOpTime());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除运营商信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",dmbCkSource.getDmbCkList());
}
/**
*
* chekckData(操作验证时间)
* (这里描述这个方法适用条件 可选)
* @param entity
* @return
*boolean
* @exception
* @since 1.0.0
*/
private void chekckData(DmbCkSource entity){
Date now=new Date();
for(DmbCk dmbCk :entity.getDmbCkList()){
dmbCk.setLastUpdate(now);
if(dmbCk.getOpTime()==null)
dmbCk.setOpTime(entity.getOpTime());
}
}
}

View File

@@ -1,223 +0,0 @@
/**
*@Title: DmbPortController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
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 com.nis.domain.restful.DmbPort;
import com.nis.domain.restful.DmbPortSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.AuditLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DmbPortService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: DmbPortController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
//@RequestMapping("${servicePath}/cfg/v1")
public class DmbPortController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected DmbPortService dmbPortService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
// @Autowired
// protected CommonConfigService commonConfigService;
// @Autowired
// protected RedisDao redisDao;
/**
* saveDmbPortBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param DmbPortSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbPortSources", method = RequestMethod.POST)
@ApiOperation(value = "保存运营商端口信息", httpMethod = "POST", notes = "save provider port info")
public Map saveDmbPortBatch(@RequestBody DmbPortSource dmbPortSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, dmbPortSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dmbPortSource.getOpAction(), Constants.OPACTION_POST);
try{
this.chekckData(dmbPortSource);
dmbPortService.saveDmbPortBatch(dmbPortSource.getDmbPortList());
// commonConfigService.saveOrUpdateConfigState("DMB_PORT", dmbPortSource.getOpTime());
// redisDao.saveMaps(dmbPortSource.getDmbPortList(), "DMB_PORT", DmbPort.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存运营商端口信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存运营商端口信息成功",dmbPortSource.getDmbPortList());
}
/**
*
* updateDmbPortBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param DmbPortSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbPortSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新运营商端口信息", httpMethod = "PUT", notes = "update provider port info")
public Map updateDmbPortBatch(@RequestBody DmbPortSource dmbPortSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, dmbPortSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dmbPortSource.getOpAction(), Constants.OPACTION_PUT);
try{
this.chekckData(dmbPortSource);
dmbPortService.updateDmbPortBatch(dmbPortSource.getDmbPortList());
// commonConfigService.saveOrUpdateConfigState("DMB_PORT", dmbPortSource.getOpTime());
// redisDao.updateMaps(dmbPortSource.getDmbPortList(), "DMB_PORT", DmbPort.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新运营商端口信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新运营商端口信息成功",dmbPortSource.getDmbPortList());
}
/**
*
* deleteDmbPort(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbPortSources/{id}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除运营商端口信息", httpMethod = "DELETE", notes = "delete provider port info")
public Map deleteDmbPort(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
dmbPortService.removeDmbPort(id);
// commonConfigService.saveOrUpdateConfigState("DMB_PORT", new Date());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除运营商端口信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteDmbPort(多条删除)
* (这里描述这个方法适用条件 可选)
* @param DmbPortSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbPortSources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除运营商端口信息", httpMethod = "DELETE", notes = "delete provider port info")
public Map deleteDmbPort(@RequestBody DmbPortSource dmbPortSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, dmbPortSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dmbPortSource.getOpAction(), Constants.OPACTION_DELETE);
try{
dmbPortService.removeDmbPortBatch(dmbPortSource.getDmbPortList());
// commonConfigService.saveOrUpdateConfigState("DMB_PORT", dmbPortSource.getOpTime());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除运营商端口信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",dmbPortSource.getDmbPortList());
}
/**
*
* chekckData(操作验证时间)
* (这里描述这个方法适用条件 可选)
* @param entity
* @return
*boolean
* @exception
* @since 1.0.0
*/
private void chekckData(DmbPortSource entity){
Date now=new Date();
for(DmbPort dmbPort :entity.getDmbPortList()){
dmbPort.setLastUpdate(now);
if(dmbPort.getOpTime()==null)
dmbPort.setOpTime(entity.getOpTime());
}
}
}

View File

@@ -1,250 +0,0 @@
/**
*@Title: DnsFakeInfoController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.nis.web.service.AuditLogThread;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
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 com.nis.domain.restful.DnsFakeInfo;
import com.nis.domain.restful.DnsFakeInfoSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DnsFakeInfoService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: DnsFakeInfoController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
//@RequestMapping("${servicePath}/cfg/v1")
public class DnsFakeInfoController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected DnsFakeInfoService dnsFakeInfoService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
// @Autowired
// protected CommonConfigService commonConfigService;
// @Autowired
// protected RedisDao redisDao;
/**
* saveDnsFakeInfoBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param DnsFakeInfoSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsFakeInfoSources", method = RequestMethod.POST)
@ApiOperation(value = "保存DNS欺骗信息", httpMethod = "POST", notes = "save dns fake info")
public Map saveDnsFakeInfoBatch(@RequestBody DnsFakeInfoSource dnsFakeInfoSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, dnsFakeInfoSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsFakeInfoSource.getOpAction(), Constants.OPACTION_POST);
try{
if(chekckData(dnsFakeInfoSource,false)){
dnsFakeInfoService.saveDnsFakeInfoBatch(dnsFakeInfoSource.getDnsFakeInfoList());
// commonConfigService.saveOrUpdateConfigState("DNS_FAKE_INFO", dnsFakeInfoSource.getOpTime());
// redisDao.saveMaps(dnsFakeInfoSource.getDnsFakeInfoList(), "DNS_FAKE_INFO", DnsFakeInfo.class, "id");
}else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存DNS欺骗信息失败,组号不能小于0且2-100组号不可使用",RestBusinessCode.unknow_error.getValue());
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存DNS欺骗信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存DNS欺骗信息成功",dnsFakeInfoSource.getDnsFakeInfoList());
}
/**
*
* updateDnsFakeInfoBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param DnsFakeInfoSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsFakeInfoSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新DNS欺骗信息", httpMethod = "PUT", notes = "update dns fake info")
public Map updateDnsFakeInfoBatch(@RequestBody DnsFakeInfoSource dnsFakeInfoSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, dnsFakeInfoSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsFakeInfoSource.getOpAction(), Constants.OPACTION_PUT);
try{
if(chekckData(dnsFakeInfoSource,true)){
dnsFakeInfoService.updateDnsFakeInfoBatch(dnsFakeInfoSource.getDnsFakeInfoList());
// commonConfigService.saveOrUpdateConfigState("DNS_FAKE_INFO", dnsFakeInfoSource.getOpTime());
// redisDao.updateMaps(dnsFakeInfoSource.getDnsFakeInfoList(), "DNS_FAKE_INFO", DnsFakeInfo.class, "id");
}else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新DNS欺骗信息失败,组号不能小于0且2-100组号不可使用",RestBusinessCode.unknow_error.getValue());
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新DNS欺骗信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新DNS欺骗信息成功",dnsFakeInfoSource.getDnsFakeInfoList());
}
/**
*
* deleteDnsFakeInfo(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsFakeInfoSources/{id}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除DNS欺骗信息", httpMethod = "DELETE", notes = "delete dns fake info")
public Map deleteDnsFakeInfo(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
boolean isValid=dnsFakeInfoService.isValid(id);
if(!isValid){
dnsFakeInfoService.removeDnsFakeInfo(id);
// commonConfigService.saveOrUpdateConfigState("DNS_FAKE_INFO", new Date());
}else{
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS欺骗信息失败,不能删除有效的DNS欺骗信息",RestBusinessCode.unknow_error.getValue());
}
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS欺骗信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteDnsFakeInfo(多条删除)
* (这里描述这个方法适用条件 可选)
* @param DnsFakeInfoSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsFakeInfoSources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除DNS欺骗信息", httpMethod = "DELETE", notes = "delete dns fake info")
public Map deleteDnsFakeInfo(@RequestBody DnsFakeInfoSource dnsFakeInfoSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, dnsFakeInfoSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsFakeInfoSource.getOpAction(), Constants.OPACTION_DELETE);
try{
boolean isValid=dnsFakeInfoService.isValid(dnsFakeInfoSource.getDnsFakeInfoList());
if(isValid){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS欺骗信息失败,包含有效的DNS欺骗信息",RestBusinessCode.unknow_error.getValue());
}else{
dnsFakeInfoService.removeDnsFakeInfoBatch(dnsFakeInfoSource.getDnsFakeInfoList());
// commonConfigService.saveOrUpdateConfigState("DNS_FAKE_INFO", dnsFakeInfoSource.getOpTime());
}
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS欺骗信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",dnsFakeInfoSource.getDnsFakeInfoList());
}
/**
*
* chekckData(0-1组号以及100以外的组号可以使用)
* (这里描述这个方法适用条件 可选)
* @param entityList
* @param update 是否是更新请求
* @return
*boolean
* @exception
* @since 1.0.0
*/
private boolean chekckData(DnsFakeInfoSource entity,boolean update){
int ok=1;
Date now=new Date();
for(DnsFakeInfo dnsFakeInfo :entity.getDnsFakeInfoList()){
dnsFakeInfo.setLastUpdate(now);
if(dnsFakeInfo.getOpTime()==null)
dnsFakeInfo.setOpTime(entity.getOpTime());
// if(update&&dnsFakeInfo.getGroupId()==null)continue;
// if(dnsFakeInfo.getGroupId().intValue()<0||(2<dnsFakeInfo.getGroupId().intValue()&&dnsFakeInfo.getGroupId().intValue()<=100)){
// ok=0;
// break;
// }
}
return ok==1;
}
}

View File

@@ -1,249 +0,0 @@
/**
*@Title: DnsFakeIpController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
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 com.nis.domain.restful.DnsFakeIp;
import com.nis.domain.restful.DnsFakeIpSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.AuditLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DnsFakeIpService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: DnsFakeIpController.java
* @Description: TODO
* @author (dell)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
//@RequestMapping("${servicePath}/cfg/v1")
public class DnsFakeIpController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected DnsFakeIpService dnsFakeIpService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
// @Autowired
// protected RedisDao redisDao;
/**
* saveDnsFakeIpBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param DnsFakeIpSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsFakeIpSources", method = RequestMethod.POST)
@ApiOperation(value = "保存DNS欺骗IP地址", httpMethod = "POST", notes = "save dns fake ip")
public Map saveDnsFakeIpBatch(@RequestBody DnsFakeIpSource dnsFakeIpSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, dnsFakeIpSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsFakeIpSource.getOpAction(), Constants.OPACTION_POST);
try{
if(chekckData(dnsFakeIpSource,false)){
dnsFakeIpService.saveDnsFakeIpBatch(dnsFakeIpSource.getDnsFakeIpList());
}else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存DNS欺骗IP地址失败,组号不能小于0且2-100组号不可使用",RestBusinessCode.unknow_error.getValue());
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存DNS欺骗IP地址失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存DNS欺骗IP地址成功",dnsFakeIpSource.getDnsFakeIpList());
}
/**
*
* updateDnsFakeIpBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param DnsFakeIpSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsFakeIpSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新DNS欺骗IP地址", httpMethod = "PUT", notes = "update dns fake ip")
public Map updateDnsFakeIpBatch(@RequestBody DnsFakeIpSource dnsFakeIpSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, dnsFakeIpSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsFakeIpSource.getOpAction(), Constants.OPACTION_PUT);
try{
if(chekckData(dnsFakeIpSource,true)){
dnsFakeIpService.updateDnsFakeIpBatch(dnsFakeIpSource.getDnsFakeIpList());
// redisDao.updateMaps(dnsFakeIpSource.getDnsFakeIpList(), "DNS_FAKE_IP", DnsFakeIp.class, "id");
}else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新DNS欺骗IP地址失败,组号不能小于0且2-100组号不可使用",RestBusinessCode.unknow_error.getValue());
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新DNS欺骗IP地址失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新DNS欺骗IP地址成功",dnsFakeIpSource.getDnsFakeIpList());
}
/**
*
* deleteDnsFakeIp(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsFakeIpSources/{id}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除DNS欺骗IP地址", httpMethod = "DELETE", notes = "delete dns fake ip")
public Map deleteDnsFakeIp(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
boolean isValid=dnsFakeIpService.isValid(id);
if(!isValid){
dnsFakeIpService.removeDnsFakeIp(id);
// commonConfigService.saveOrUpdateConfigState("DNS_FAKE_IP", new Date());
}else{
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS欺骗IP地址失败,不能删除有效的DNS欺骗IP地址",RestBusinessCode.unknow_error.getValue());
}
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS欺骗IP地址失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteDnsFakeIp(多条删除)
* (这里描述这个方法适用条件 可选)
* @param DnsFakeIpSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsFakeIpSources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除DNS欺骗IP地址", httpMethod = "DELETE", notes = "delete dns fake ip")
public Map deleteDnsFakeIp(@RequestBody DnsFakeIpSource dnsFakeIpSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, dnsFakeIpSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsFakeIpSource.getOpAction(), Constants.OPACTION_DELETE);
try{
boolean isValid=dnsFakeIpService.isValid(dnsFakeIpSource.getDnsFakeIpList());
if(isValid){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS欺骗IP地址失败,包含有效的DNS欺骗IP地址",RestBusinessCode.unknow_error.getValue());
}else{
dnsFakeIpService.removeDnsFakeIpBatch(dnsFakeIpSource.getDnsFakeIpList());
// commonConfigService.saveOrUpdateConfigState("DNS_FAKE_IP", dnsFakeIpSource.getOpTime());
}
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS欺骗IP地址失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",dnsFakeIpSource.getDnsFakeIpList());
}
/**
*
* chekckData(0-1组号以及100以外的组号可以使用)
* (这里描述这个方法适用条件 可选)
* @param entityList
* @param update 是否是更新请求
* @return
*boolean
* @exception
* @since 1.0.0
*/
private boolean chekckData(DnsFakeIpSource entity,boolean update){
int ok=1;
Date now=new Date();
for(DnsFakeIp dnsFakeIp :entity.getDnsFakeIpList()){
dnsFakeIp.setLastUpdate(now);
if(dnsFakeIp.getOpTime()==null)
dnsFakeIp.setOpTime(entity.getOpTime());
if(!update){//insert需要判断默认值保存完毕返回完整对象
if(dnsFakeIp.getProtocol()==null)dnsFakeIp.setProtocol(0);
if(dnsFakeIp.getDirection()==null)dnsFakeIp.setDirection(0);
}
if(update&&dnsFakeIp.getGroupId()==null)continue;
if(dnsFakeIp.getGroupId().intValue()<0||(2<dnsFakeIp.getGroupId().intValue()&&dnsFakeIp.getGroupId().intValue()<=100)){
ok=0;
break;
}
}
return ok==1;
}
}

View File

@@ -1,249 +0,0 @@
/**
*@Title: DnsGroupTypeController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author dell
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.nis.web.service.AuditLogThread;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
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 com.nis.domain.restful.DnsGroupType;
import com.nis.domain.restful.DnsGroupTypeSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DnsGroupTypeService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: DnsGroupTypeController.java
* @Description: TODO
* @author (dell)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
//@RequestMapping("${servicePath}/cfg/v1")
public class DnsGroupTypeController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected DnsGroupTypeService dnsGroupTypeService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
// @Autowired
// protected CommonConfigService commonConfigService;
// @Autowired
// protected RedisDao redisDao;
/**
*
* saveDnsGroupTypeBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param DnsGroupTypeSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsGroupTypeSources", method = RequestMethod.POST)
@ApiOperation(value = "保存DNS分组类型", httpMethod = "POST", notes = "save dns group type")
public Map saveDnsGroupTypeBatch(@RequestBody DnsGroupTypeSource dnsGroupTypeSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, dnsGroupTypeSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsGroupTypeSource.getOpAction(), Constants.OPACTION_POST);
try{
// if(chekckData(dnsGroupTypeSource/*,false*/))
chekckData(thread,start,dnsGroupTypeSource,Constants.OPACTION_POST);
dnsGroupTypeService.saveDnsGroupTypeBatch(thread,start,dnsGroupTypeSource.getDnsGroupTypeList());
// commonConfigService.saveOrUpdateConfigState("DNS_GROUP_TYPE", dnsGroupTypeSource.getOpTime());
// redisDao.saveMaps(dnsGroupTypeSource.getDnsGroupTypeList(), "DNS_GROUP_TYPE", DnsGroupType.class, "id");
// else
// throw new RestServiceException("保存DNS分组类型失败,组号不能小于0且2-100组号不可使用",RestBusinessCode.unknow_error.getValue());
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存DNS分组类型失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存DNS分组类型成功",dnsGroupTypeSource.getDnsGroupTypeList());
}
/**
*
* updateDnsGroupTypeBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param DnsGroupTypeSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsGroupTypeSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新DNS分组类型", httpMethod = "PUT", notes = "update dns group type")
public Map updateDnsGroupTypeBatch(@RequestBody DnsGroupTypeSource dnsGroupTypeSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, dnsGroupTypeSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsGroupTypeSource.getOpAction(), Constants.OPACTION_PUT);
try{
// if(chekckData(dnsGroupTypeSource/*,true*/))
chekckData(thread,start,dnsGroupTypeSource,Constants.OPACTION_PUT);
dnsGroupTypeService.updateDnsGroupTypeBatch(thread,start,dnsGroupTypeSource.getDnsGroupTypeList());
// commonConfigService.saveOrUpdateConfigState("DNS_GROUP_TYPE", dnsGroupTypeSource.getOpTime());
// redisDao.updateMaps(dnsGroupTypeSource.getDnsGroupTypeList(), "DNS_GROUP_TYPE", DnsGroupType.class, "id");
// else
// throw new RestServiceException("更新DNS分组类型失败,组号不能小于0且2-100组号不可使用",RestBusinessCode.unknow_error.getValue());
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新DNS分组类型失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新DNS分组类型成功",dnsGroupTypeSource.getDnsGroupTypeList());
}
/**
*
* deleteDnsGroupType(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsGroupTypeSources/{id}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除DNS分组类型", httpMethod = "DELETE", notes = "delete dns group type")
public Map deleteDnsGroupType(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
boolean isValid=dnsGroupTypeService.isValid(id);
if(!isValid){
dnsGroupTypeService.removeDnsGroupType(id);
// commonConfigService.saveOrUpdateConfigState("DNS_GROUP_TYPE", new Date());
}else{
throw new RestServiceException(thread,System.currentTimeMillis()-start,"不能删除有效的DNS分组类型");
}
}catch(RestServiceException e){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS分组类型失败,"+e.getMessage(), RestBusinessCode.unknow_error.getValue());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS分组类型失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteDnsGroupType(多条删除)
* (这里描述这个方法适用条件 可选)
* @param DnsGroupTypeSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsGroupTypeSources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除DNS分组类型", httpMethod = "DELETE", notes = "delete dns group type")
public Map deleteDnsGroupType(@RequestBody DnsGroupTypeSource dnsGroupTypeSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, dnsGroupTypeSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsGroupTypeSource.getOpAction(), Constants.OPACTION_DELETE);
try{
boolean isValid=dnsGroupTypeService.isValid(dnsGroupTypeSource.getDnsGroupTypeList());
if(isValid){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"包含有效的DNS分组类型");
}else{
dnsGroupTypeService.removeDnsGroupTypeBatch(dnsGroupTypeSource.getDnsGroupTypeList());
// commonConfigService.saveOrUpdateConfigState("DNS_GROUP_TYPE", dnsGroupTypeSource.getOpTime());
}
}catch(RestServiceException e){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS分组类型失败,"+e.getMessage(), RestBusinessCode.unknow_error.getValue());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS分组类型失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",dnsGroupTypeSource.getDnsGroupTypeList());
}
/**
*
* chekckData(0-1组号以及100以外的组号可以使用)
* (这里描述这个方法适用条件 可选)
* @param entityList
* @param update 是否是更新请求
* @return
*boolean
* @exception
* @since 1.0.0
*/
private void chekckData(AuditLogThread thread, long start, DnsGroupTypeSource entity, int opAction){
for(DnsGroupType dnsGroupType :entity.getDnsGroupTypeList()){
if(dnsGroupType.getOpTime()==null)
dnsGroupType.setOpTime(entity.getOpTime());
if(opAction==Constants.OPACTION_PUT&&dnsGroupType.getGroupId()==null)continue;
else if(dnsGroupType.getGroupId()==null){
throw new RestServiceException(thread, System.currentTimeMillis(), "组号为空", RestBusinessCode.missing_args.getValue());
}else if(dnsGroupType.getGroupId().intValue()<=100){
throw new RestServiceException(thread, System.currentTimeMillis(), "组号小于等于100", RestBusinessCode.wrong_range.getValue());
}
}
}
}

View File

@@ -1,262 +0,0 @@
/**
*@Title: DnsResponseStrategy.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author dell
*@date 2016年9月5日 下午4:12:27
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
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 com.nis.domain.restful.DnsResponseStrategy;
import com.nis.domain.restful.DnsResponseStrategySource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.AuditLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DnsResponseStrategyService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: DnsResponseStrategyController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月5日 下午4:12:27
* @version V1.0
*/
@RestController
//@RequestMapping("${servicePath}/cfg/v1")
public class DnsResponseStrategyController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected DnsResponseStrategyService dnsResponseStrategyService;
// @Autowired
// protected RedisDao redisDao;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
/**
*
* saveDnsResponseStrategyBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param dnsResponseStrategySource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsResponseStrategySources", method = RequestMethod.POST)
@ApiOperation(value = "保存DNS响应策略", httpMethod = "POST", notes = "save dns response strategy")
public Map saveDnsResponseStrategyBatch(@RequestBody DnsResponseStrategySource dnsResponseStrategySource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, dnsResponseStrategySource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsResponseStrategySource.getOpAction(), Constants.OPACTION_POST);
try{
chekckData(thread,start,dnsResponseStrategySource,Constants.OPACTION_POST);
dnsResponseStrategyService.saveDnsResponseStrategyBatch(thread,start,dnsResponseStrategySource.getDnsResponseStrategyList());
// redisDao.saveMaps(dnsResponseStrategySource.getDnsResponseStrategyList(), "DNS_RESPONSE_STRATEGY", DnsResponseStrategy.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException){
throw e;
}
e.printStackTrace();
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存DNS响应策略失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存DNS响应策略成功",dnsResponseStrategySource.getDnsResponseStrategyList());
}
/**
*
* updateDnsResponseStrategyBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param dnsResponseStrategySource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsResponseStrategySources", method = RequestMethod.PUT)
@ApiOperation(value = "更新DNS响应策略", httpMethod = "PUT", notes = "update dns response strategy")
public Map updateDnsResponseStrategyBatch(@RequestBody DnsResponseStrategySource dnsResponseStrategySource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, dnsResponseStrategySource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsResponseStrategySource.getOpAction(), Constants.OPACTION_PUT);
try{
chekckData(thread,start,dnsResponseStrategySource,Constants.OPACTION_PUT);
dnsResponseStrategyService.updateDnsResponseStrategyBatch(thread,start,dnsResponseStrategySource.getDnsResponseStrategyList());
// commonConfigService.saveOrUpdateConfigState("DNS_RESPONSE_STRATEGY", dnsResponseStrategySource.getOpTime());
// redisDao.updateMaps(dnsResponseStrategySource.getDnsResponseStrategyList(), "DNS_RESPONSE_STRATEGY", DnsResponseStrategy.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException){
throw e;
}
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新DNS响应策略失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新DNS响应策略成功",dnsResponseStrategySource.getDnsResponseStrategyList());
}
/**
*
* deleteDnsResponseStrategy(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsResponseStrategySources/{id}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除DNS响应策略", httpMethod = "DELETE", notes = "delete dns response strategy")
public Map deleteDnsResponseStrategy(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
boolean isValid=dnsResponseStrategyService.isValid(id);
if(!isValid){
dnsResponseStrategyService.removeDnsResponseStrategy(id);
// commonConfigService.saveOrUpdateConfigState("DNS_RESPONSE_STRATEGY", new Date());
}else{
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS响应策略失败,不能删除有效的DNS响应策略", RestBusinessCode.unknow_error.getValue());
}
}catch(RestServiceException e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS响应策略失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteDnsResponseStrategy(多条删除)
* (这里描述这个方法适用条件 可选)
* @param dnsResponseStrategySource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsResponseStrategySources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除DNS响应策略", httpMethod = "DELETE", notes = "delete dns response strategy")
public Map deleteDnsResponseStrategy(@RequestBody DnsResponseStrategySource dnsResponseStrategySource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, dnsResponseStrategySource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsResponseStrategySource.getOpAction(), Constants.OPACTION_DELETE);
try{
boolean isValid=dnsResponseStrategyService.isValid(dnsResponseStrategySource.getDnsResponseStrategyList());
if(isValid){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS响应策略失败,包含有效的DNS响应策略",RestBusinessCode.unknow_error.getValue());
}else
dnsResponseStrategyService.removeDnsResponseStrategyBatch(dnsResponseStrategySource.getDnsResponseStrategyList());
}catch(RestServiceException e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS响应策略失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",dnsResponseStrategySource.getDnsResponseStrategyList());
}
/**
*
* chekckData(验证数据,减少遍历次数,尽量在此方法内验证数据)
* (这里描述这个方法适用条件 可选)
* @param entity
*void
* @exception
* @since 1.0.0
*/
private void chekckData(AuditLogThread thread, long start, DnsResponseStrategySource entity, int opAction){
Date now =new Date();
for(DnsResponseStrategy dnsResponseStrategy :entity.getDnsResponseStrategyList()){
checkReqStrateId(thread,start,dnsResponseStrategy,opAction);
dnsResponseStrategy.setLastUpdate(now);
if(dnsResponseStrategy.getOpTime()==null)
dnsResponseStrategy.setOpTime(entity.getOpTime());
if(opAction==Constants.OPACTION_POST){//新增数据时设置默认值
if(dnsResponseStrategy.getResGroupOneId()==null)dnsResponseStrategy.setResGroupOneId(0);
if(dnsResponseStrategy.getResGroupOneNum()==null)dnsResponseStrategy.setResGroupOneNum(0);
if(dnsResponseStrategy.getResGroupTwoId()==null)dnsResponseStrategy.setResGroupTwoId(0);
if(dnsResponseStrategy.getResGroupTwoNum()==null)dnsResponseStrategy.setResGroupTwoNum(0);
if(dnsResponseStrategy.getResGroupThreeId()==null)dnsResponseStrategy.setResGroupThreeId(0);
if(dnsResponseStrategy.getResGroupThreeNum()==null)dnsResponseStrategy.setResGroupThreeNum(0);
if(dnsResponseStrategy.getResGroupFourId()==null)dnsResponseStrategy.setResGroupFourId(0);
if(dnsResponseStrategy.getResGroupFourNum()==null)dnsResponseStrategy.setResGroupFourNum(0);
if(dnsResponseStrategy.getResGroupFiveId()==null)dnsResponseStrategy.setResGroupFiveId(0);
if(dnsResponseStrategy.getResGroupFiveNum()==null)dnsResponseStrategy.setResGroupFiveNum(0);
if(dnsResponseStrategy.getAddGroup()==null)dnsResponseStrategy.setAddGroup(0);
if(dnsResponseStrategy.getAuthGroup()==null)dnsResponseStrategy.setAuthGroup(0);
}
}
}
private void checkReqStrateId(AuditLogThread thread, long start, DnsResponseStrategy dnsResponseStrategy, int opAction){
//update时可以为空
if(opAction==Constants.OPACTION_PUT&&dnsResponseStrategy.getReqStrateId()==null)return;
if(dnsResponseStrategy.getReqStrateId()==null){
throw new RestServiceException(thread, System.currentTimeMillis(), "请求策略号为空", RestBusinessCode.missing_args.getValue());
}else if(dnsResponseStrategy.getReqStrateId()<=100){
throw new RestServiceException(thread, System.currentTimeMillis(), "请求策略号小于等于100", RestBusinessCode.wrong_range.getValue());
}
}
}

View File

@@ -1,223 +0,0 @@
/**
*@Title: EncryptProtoRandomController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.nis.web.service.AuditLogThread;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
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 com.nis.domain.restful.EncryptProtoRandom;
import com.nis.domain.restful.EncryptProtoRandomSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.EncryptProtoRandomService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: EncryptProtoRandomController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
//@RequestMapping("${servicePath}/cfg/v1")
public class EncryptProtoRandomController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected EncryptProtoRandomService encryptProtoRandomService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
// @Autowired
// protected CommonConfigService commonConfigService;
// @Autowired
// protected RedisDao redisDao;
/**
* saveEncryptProtoRandomBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param EncryptProtoRandomSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/encryptProtoRandomSources", method = RequestMethod.POST)
@ApiOperation(value = "保存加密类协议随机封堵配置", httpMethod = "POST", notes = "save encrypt_proto_random")
public Map saveEncryptProtoRandomBatch(@RequestBody EncryptProtoRandomSource encryptProtoRandomSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, encryptProtoRandomSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,encryptProtoRandomSource.getOpAction(), Constants.OPACTION_POST);
try{
this.chekckData(encryptProtoRandomSource);
encryptProtoRandomService.saveEncryptProtoRandomBatch(encryptProtoRandomSource.getEncryptProtoRandomList());
// commonConfigService.saveOrUpdateConfigState("DMB_CK", encryptProtoRandomSource.getOpTime());
// redisDao.saveMaps(encryptProtoRandomSource.getEncryptProtoRandomList(), "DMB_CK", EncryptProtoRandom.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存加密类协议随机封堵配置失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存加密类协议随机封堵配置成功",encryptProtoRandomSource.getEncryptProtoRandomList());
}
/**
*
* updateEncryptProtoRandomBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param EncryptProtoRandomSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/encryptProtoRandomSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新加密类协议随机封堵配置", httpMethod = "PUT", notes = "update encrypt_proto_random")
public Map updateEncryptProtoRandomBatch(@RequestBody EncryptProtoRandomSource encryptProtoRandomSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, encryptProtoRandomSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,encryptProtoRandomSource.getOpAction(), Constants.OPACTION_PUT);
try{
this.chekckData(encryptProtoRandomSource);
encryptProtoRandomService.updateEncryptProtoRandomBatch(encryptProtoRandomSource.getEncryptProtoRandomList());
// commonConfigService.saveOrUpdateConfigState("DMB_CK", encryptProtoRandomSource.getOpTime());
// redisDao.updateMaps(encryptProtoRandomSource.getEncryptProtoRandomList(), "DMB_CK", EncryptProtoRandom.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新加密类协议随机封堵配置失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新加密类协议随机封堵配置成功",encryptProtoRandomSource.getEncryptProtoRandomList());
}
/**
*
* deleteEncryptProtoRandom(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/encryptProtoRandomSources/{id}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除加密类协议随机封堵配置", httpMethod = "DELETE", notes = "delete encrypt_proto_random")
public Map deleteEncryptProtoRandom(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
encryptProtoRandomService.removeEncryptProtoRandom(id);
// commonConfigService.saveOrUpdateConfigState("DMB_CK", new Date());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除加密类协议随机封堵配置失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteEncryptProtoRandom(多条删除)
* (这里描述这个方法适用条件 可选)
* @param EncryptProtoRandomSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/encryptProtoRandomSources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除加密类协议随机封堵配置", httpMethod = "DELETE", notes = "delete encrypt_proto_random")
public Map deleteEncryptProtoRandom(@RequestBody EncryptProtoRandomSource encryptProtoRandomSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, encryptProtoRandomSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,encryptProtoRandomSource.getOpAction(), Constants.OPACTION_DELETE);
try{
encryptProtoRandomService.removeEncryptProtoRandomBatch(encryptProtoRandomSource.getEncryptProtoRandomList());
// commonConfigService.saveOrUpdateConfigState("DMB_CK", encryptProtoRandomSource.getOpTime());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除加密类协议随机封堵配置失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",encryptProtoRandomSource.getEncryptProtoRandomList());
}
/**
*
* chekckData(操作验证时间)
* (这里描述这个方法适用条件 可选)
* @param entity
* @return
*boolean
* @exception
* @since 1.0.0
*/
private void chekckData(EncryptProtoRandomSource entity){
Date now=new Date();
for(EncryptProtoRandom encryptProtoRandom :entity.getEncryptProtoRandomList()){
encryptProtoRandom.setLastUpdate(now);
if(encryptProtoRandom.getOpTime()==null)
encryptProtoRandom.setOpTime(entity.getOpTime());
}
}
}

View File

@@ -1,223 +0,0 @@
/**
*@Title: FwqInfoController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
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 com.nis.domain.restful.FwqInfo;
import com.nis.domain.restful.FwqInfoSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.AuditLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.FwqInfoService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: FwqInfoController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
//@RequestMapping("${servicePath}/cfg/v1")
public class FwqInfoController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected FwqInfoService fwqInfoService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
// @Autowired
// protected CommonConfigService commonConfigService;
// @Autowired
// protected RedisDao redisDao;
/**
* saveFwqInfoBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param FwqInfoSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/fwqInfoSources", method = RequestMethod.POST)
@ApiOperation(value = "保存服务器信息", httpMethod = "POST", notes = "save server info")
public Map saveFwqInfoBatch(@RequestBody FwqInfoSource fwqInfoSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, fwqInfoSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,fwqInfoSource.getOpAction(), Constants.OPACTION_POST);
try{
chekckData(fwqInfoSource);
fwqInfoService.saveFwqInfoBatch(fwqInfoSource.getFwqInfoList());
// commonConfigService.saveOrUpdateConfigState("FWQ_INFO", fwqInfoSource.getOpTime());
// redisDao.saveMaps(fwqInfoSource.getFwqInfoList(), "FWQ_INFO", FwqInfo.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存服务器信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存服务器信息成功",fwqInfoSource.getFwqInfoList());
}
/**
*
* updateFwqInfoBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param FwqInfoSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/fwqInfoSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新服务器信息", httpMethod = "PUT", notes = "update server info")
public Map updateFwqInfoBatch(@RequestBody FwqInfoSource fwqInfoSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, fwqInfoSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,fwqInfoSource.getOpAction(), Constants.OPACTION_PUT);
try{
chekckData(fwqInfoSource);
fwqInfoService.updateFwqInfoBatch(fwqInfoSource.getFwqInfoList());
// commonConfigService.saveOrUpdateConfigState("FWQ_INFO", fwqInfoSource.getOpTime());
// redisDao.updateMaps(fwqInfoSource.getFwqInfoList(), "FWQ_INFO", FwqInfo.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新服务器信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新服务器信息成功",fwqInfoSource.getFwqInfoList());
}
/**
*
* deleteFwqInfo(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/fwqInfoSources/{id}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除服务器信息", httpMethod = "DELETE", notes = "delete server info")
public Map deleteFwqInfo(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
fwqInfoService.removeFwqInfo(id);
// commonConfigService.saveOrUpdateConfigState("FWQ_INFO", new Date());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除服务器信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteFwqInfo(多条删除)
* (这里描述这个方法适用条件 可选)
* @param FwqInfoSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/fwqInfoSources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除服务器信息", httpMethod = "DELETE", notes = "delete server info")
public Map deleteFwqInfo(@RequestBody FwqInfoSource fwqInfoSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
AuditLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, fwqInfoSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,fwqInfoSource.getOpAction(), Constants.OPACTION_DELETE);
try{
fwqInfoService.removeFwqInfoBatch(fwqInfoSource.getFwqInfoList());
// commonConfigService.saveOrUpdateConfigState("FWQ_INFO", fwqInfoSource.getOpTime());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除服务器信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",fwqInfoSource.getFwqInfoList());
}
/**
*
* chekckData(操作验证时间)
* (这里描述这个方法适用条件 可选)
* @param entity
* @return
*boolean
* @exception
* @since 1.0.0
*/
private void chekckData(FwqInfoSource entity){
Date now =new Date();
for(FwqInfo fwqInfo :entity.getFwqInfoList()){
fwqInfo.setLastUpdate(now);
if(fwqInfo.getOpTime()==null)
fwqInfo.setOpTime(entity.getOpTime());
}
}
}

View File

@@ -11,6 +11,7 @@ import java.util.UUID;
import com.nis.domain.restful.*;
import com.nis.web.service.AuditLogThread;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -379,32 +380,39 @@ public class MaatTestController {
public String testSaveMaatMore(@RequestParam(required = true) Integer service,
@RequestParam(required = true) Integer saveCount, Integer forCount) {
List<String> list = new ArrayList<String>();
for (int a = 0; a < forCount; a++) {
long start = System.currentTimeMillis();
AuditLogThread thread = new AuditLogThread();
StringBuffer sb = new StringBuffer();
List<ConfigCompile> configCompileList = new ArrayList<ConfigCompile>();
for (int i = 0; i < saveCount; i++) {
configCompileList.add(getConfigCompile(service));
try {
for (int a = 0; a < forCount; a++) {
long start = System.currentTimeMillis();
AuditLogThread thread = new AuditLogThread();
StringBuffer sb = new StringBuffer();
List<ConfigCompile> configCompileList = new ArrayList<ConfigCompile>();
for (int i = 0; i < saveCount; i++) {
configCompileList.add(getConfigCompile(service));
}
// 保存测试配置
configSourcesService.saveMaatConfig(thread, start, configCompileList, sb);
List<Long> compileIdList = new ArrayList<Long>();
for (ConfigCompile configCompile : configCompileList) {
compileIdList.add(configCompile.getCompileId());
}
FileUtils.addStrToFile(
sdf.format(new Date()) + "\t" + "业务类型" + service + "添加" + saveCount + "条数据成功,配置id是" + compileIdList
+ "\n" + sdf.format(new Date()) + "\t开始验证添加的数据各字段是否正确\n",
Configurations.getStringProperty("maatTestLogPath", ""), true);
// 验证数据是否在正确
maatTestServiceimpl.getKeys(configCompileList);
list.add(testDelMaat(compileIdList.toString().replace("[", "").replace("]", ""), service));
}
// 保存测试配置
configSourcesService.saveMaatConfig(thread, start, configCompileList, sb);
List<Long> compileIdList = new ArrayList<Long>();
for (ConfigCompile configCompile : configCompileList) {
compileIdList.add(configCompile.getCompileId());
}
FileUtils.addStrToFile(
sdf.format(new Date()) + "\t" + "业务类型" + service + "添加" + saveCount + "条数据成功,配置id是" + compileIdList
+ "\n" + sdf.format(new Date()) + "\t开始验证添加的数据各字段是否正确\n",
Configurations.getStringProperty("maatTestLogPath", ""), true);
// 验证数据是否在正确
maatTestServiceimpl.getKeys(configCompileList);
list.add(testDelMaat(compileIdList.toString().replace("[", "").replace("]", ""), service));
// return "http://127.0.0.1:8080/galaxy/service/cfg/v1/testDelMaat?serviceType="
// + service + "&configId="
// + compileIdList.toString().replace("[", "").replace("]", "");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return list.toString();
// return "http://127.0.0.1:8080/galaxy/service/cfg/v1/testDelMaat?serviceType="
// + service + "&configId="
// + compileIdList.toString().replace("[", "").replace("]", "");
}
@RequestMapping(value = "/cfg/v1/testSaveMaat", method = RequestMethod.GET)
@@ -415,22 +423,30 @@ public class MaatTestController {
long start = System.currentTimeMillis();
AuditLogThread thread = new AuditLogThread();
StringBuffer sb = new StringBuffer();
List<ConfigCompile> configCompileList = new ArrayList<ConfigCompile>();
for (int i = 0; i < saveCount; i++) {
configCompileList.add(getConfigCompile(service));
}
// 保存测试配置
configSourcesService.saveMaatConfig(thread, start, configCompileList, sb);
List<Long> compileIdList = new ArrayList<Long>();
for (ConfigCompile configCompile : configCompileList) {
compileIdList.add(configCompile.getCompileId());
try {
List<ConfigCompile> configCompileList = new ArrayList<ConfigCompile>();
for (int i = 0; i < saveCount; i++) {
configCompileList.add(getConfigCompile(service));
}
// 保存测试配置
configSourcesService.saveMaatConfig(thread, start, configCompileList, sb);
for (ConfigCompile configCompile : configCompileList) {
compileIdList.add(configCompile.getCompileId());
}
FileUtils.addStrToFile(
sdf.format(new Date()) + "\t" + "业务类型" + service + "添加" + saveCount + "条数据成功,配置id是" + compileIdList
+ "\n" + sdf.format(new Date()) + "\t开始验证添加的数据各字段是否正确\n",
Configurations.getStringProperty("maatTestLogPath", ""), true);
// 验证数据是否在正确
maatTestServiceimpl.getKeys(configCompileList);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
FileUtils.addStrToFile(
sdf.format(new Date()) + "\t" + "业务类型" + service + "添加" + saveCount + "条数据成功,配置id是" + compileIdList
+ "\n" + sdf.format(new Date()) + "\t开始验证添加的数据各字段是否正确\n",
Configurations.getStringProperty("maatTestLogPath", ""), true);
// 验证数据是否在正确
maatTestServiceimpl.getKeys(configCompileList);
return "http://127.0.0.1:8080/galaxy/service/cfg/v1/testDelMaat?serviceType=" + service + "&configId="
+ compileIdList.toString().replace("[", "").replace("]", "");
}