OCT
REM: 1. 修改打印日志和返回信息 2. 增加启动处置任务接口处置时长字段判断 3. 过滤停止处置任务中入参数组中存在空字符串的情况,停止处置任务不能用id字段为空字符串表示停止所有处置任务 4. 去除多余的入参字段判断
This commit is contained in:
parent
939645d73e
commit
8ab11aa2ff
|
@ -84,7 +84,7 @@ public class DisposeNodeInfoController {
|
|||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request params error, error:{}", mr.getMsgContent());
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,6 @@ public class DisposeNodeInfoController {
|
|||
|
||||
unExists.forEach(v -> {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
|
||||
rspInfo.getItems().add(LinkStatusRsp.builder()
|
||||
.online(0)
|
||||
.id(v)
|
||||
|
@ -149,7 +148,7 @@ public class DisposeNodeInfoController {
|
|||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request params error, error:{}", mr.getMsgContent());
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
|
@ -212,7 +211,7 @@ public class DisposeNodeInfoController {
|
|||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request params error, error:{}", mr.getMsgContent());
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
|
@ -278,7 +277,7 @@ public class DisposeNodeInfoController {
|
|||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request params error, error:{}", mr.getMsgContent());
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
|
@ -309,7 +308,6 @@ public class DisposeNodeInfoController {
|
|||
|
||||
unExists.forEach(v -> {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
|
||||
DeviceCapacityData cpData = new DeviceCapacityData();
|
||||
cpData.setId(v);
|
||||
cpData.setCapacity(null);
|
||||
|
@ -345,7 +343,7 @@ public class DisposeNodeInfoController {
|
|||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request params error, error:{}", mr.getMsgContent());
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
|
@ -375,7 +373,6 @@ public class DisposeNodeInfoController {
|
|||
|
||||
unExists.forEach(v -> {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
|
||||
DeviceCapacityData cpData = new DeviceCapacityData();
|
||||
cpData.setId(v);
|
||||
cpData.setCapacity(null);
|
||||
|
@ -416,7 +413,7 @@ public class DisposeNodeInfoController {
|
|||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request params error, error:{}", mr.getMsgContent());
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
|
@ -452,7 +449,6 @@ public class DisposeNodeInfoController {
|
|||
|
||||
unExists.forEach(v -> {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
|
||||
DisposeNodeData dpData = new DisposeNodeData();
|
||||
dpData.setId(v);
|
||||
dpData.setCapacity(null);
|
||||
|
@ -489,7 +485,7 @@ public class DisposeNodeInfoController {
|
|||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request params error, error:{}", mr.getMsgContent());
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
|
@ -523,7 +519,6 @@ public class DisposeNodeInfoController {
|
|||
|
||||
unExists.forEach(v -> {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
|
||||
DisposeNodeData dpData = new DisposeNodeData();
|
||||
dpData.setId(v);
|
||||
dpData.setCapacity(null);
|
||||
|
@ -559,7 +554,7 @@ public class DisposeNodeInfoController {
|
|||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request params error, error:{}", mr.getMsgContent());
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
|
@ -576,13 +571,12 @@ public class DisposeNodeInfoController {
|
|||
NodeTaskData taskData = new NodeTaskData();
|
||||
rspInfo.getItems().add(taskData);
|
||||
taskData.setId(v.getId().toString());
|
||||
taskData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
|
||||
List<TaskInfoDetail> runTasks = taskService.getNodeAllRunningTask(v.getId());
|
||||
|
||||
if (runTasks == null || runTasks.size() == 0) {
|
||||
log.error("No tasks in progress");
|
||||
taskData.setTaskArray(null);
|
||||
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
|
||||
} else {
|
||||
|
@ -600,6 +594,8 @@ public class DisposeNodeInfoController {
|
|||
.build();
|
||||
|
||||
taskData.getTaskArray().add(taskInfoData);
|
||||
taskData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -647,7 +643,7 @@ public class DisposeNodeInfoController {
|
|||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request params error, error:{}", mr.getMsgContent());
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
|
@ -664,13 +660,12 @@ public class DisposeNodeInfoController {
|
|||
NodeTaskData taskData = new NodeTaskData();
|
||||
rspInfo.getItems().add(taskData);
|
||||
taskData.setId(v.getId().toString());
|
||||
taskData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
|
||||
List<TaskInfoDetail> runTasks = taskService.getNodeAllTask(v.getId());
|
||||
|
||||
if (runTasks == null || runTasks.size() == 0) {
|
||||
log.error("No such tasks");
|
||||
taskData.setTaskArray(null);
|
||||
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
|
||||
} else {
|
||||
|
@ -689,6 +684,8 @@ public class DisposeNodeInfoController {
|
|||
.build();
|
||||
|
||||
taskData.getTaskArray().add(taskInfoData);
|
||||
taskData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -118,6 +118,10 @@ public class DisposeTaskController {
|
|||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
if (reqInfo.getDisposeTime() == null) {
|
||||
log.error("Request dispose time params error, error:{} --> {}", mr.getMsgContent(), reqInfo.getDisposeTime());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
StartTaskRsp rspInfo = new StartTaskRsp();
|
||||
|
||||
|
@ -126,7 +130,7 @@ public class DisposeTaskController {
|
|||
.accountId(userAccountService.getUserByToken(mr.getAuthToken()).getId())
|
||||
.type(reqInfo.getType())
|
||||
.disposeIp(reqInfo.getDisposeIp())
|
||||
.planEndTime(String.valueOf(reqInfo.getDisposeTime() == null ? "" : reqInfo.getDisposeTime()))
|
||||
.planEndTime(String.valueOf(reqInfo.getDisposeTime()))
|
||||
.flowDirection(reqInfo.getFlowDirection() != null ? reqInfo.getFlowDirection() : FlowDirection.DIRECTION_TWOWAY.getCode())
|
||||
.flowBandWidth(reqInfo.getFlowBandwidth() != null ? reqInfo.getFlowBandwidth() : 1024)
|
||||
.attackType(Helper.attackArrayToString(reqInfo.getAttackType()))
|
||||
|
@ -173,8 +177,10 @@ public class DisposeTaskController {
|
|||
|
||||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getTaskId() == null || Arrays.stream(reqInfo.getTaskId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request params error, error:{}", mr.getMsgContent());
|
||||
if (reqInfo.getTaskId() == null
|
||||
|| Arrays.stream(reqInfo.getTaskId()).anyMatch(v -> v.length() == 0)
|
||||
|| Arrays.stream(reqInfo.getTaskId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request taskId params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
|
@ -187,6 +193,7 @@ public class DisposeTaskController {
|
|||
|
||||
if (ret.size() == 0) {
|
||||
log.error("No such dispose task, taskId:{}", v);
|
||||
taskData.setTaskId(v);
|
||||
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
|
||||
rspInfo.getItems().add(taskData);
|
||||
|
@ -270,7 +277,8 @@ public class DisposeTaskController {
|
|||
List<MulReturnType<ErrorCode, TaskInfoDetail>> ret = taskService.stopTaskByDisposeIp(Long.parseLong(v.getId()), v.getType(), v.getDisposeIp());
|
||||
|
||||
if (ret.size() == 0) {
|
||||
log.error("No such dispose task, taskId:{}", v);
|
||||
log.error("No such dispose task, deviceId:{}", v.getId());
|
||||
taskData.setId(v.getId());
|
||||
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
|
||||
rspInfo.getItems().add(taskData);
|
||||
|
@ -348,8 +356,9 @@ public class DisposeTaskController {
|
|||
List<MulReturnType<ErrorCode, TaskInfoDetail>> ret = taskService.stopTaskByDisposeNode(Long.parseLong(v.getId()), v.getType());
|
||||
|
||||
if (ret.size() == 0) {
|
||||
log.error("No such dispose task, taskId:{}", v);
|
||||
log.error("No such dispose task, deviceId:{}", v.getId());
|
||||
TaskInfoData taskData = TaskInfoData.builder().type(v.getType()).build();
|
||||
taskData.setId(v.getId());
|
||||
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
|
||||
rspInfo.getItems().add(taskData);
|
||||
|
@ -577,7 +586,7 @@ public class DisposeTaskController {
|
|||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getTaskId() == null || Arrays.stream(reqInfo.getTaskId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request params error, error:{}", mr.getMsgContent());
|
||||
log.error("Request taskId params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
|
|
|
@ -103,17 +103,6 @@ public class TaskServiceImpl implements TaskService {
|
|||
*/
|
||||
@Override
|
||||
public MulReturnType<ErrorCode, Long> createTask(TaskInfoDetail task) {
|
||||
if (task.getDisposeIp() == null || task.getDisposeIp().length() == 0
|
||||
|| task.getPlanEndTime() == null || task.getPlanEndTime().length() == 0
|
||||
|| task.getType() == null || !IPAddrType.isIpAddress(task.getDisposeIp())) {
|
||||
log.error("Input params error: devId:{}, disposeIp:{}, type:{}, planEndTime:{}",
|
||||
task.getDeviceId(), task.getDisposeIp(), task.getType(), task.getPlanEndTime());
|
||||
return MulReturnType.<ErrorCode, Long>builder()
|
||||
.firstParam(ErrorCode.ERR_PARAMEXCEPTION)
|
||||
.secondParam(-1L)
|
||||
.build();
|
||||
}
|
||||
|
||||
DisposeDevice disposeDevice;
|
||||
Long taskId = task.getDeviceId();
|
||||
|
||||
|
@ -438,16 +427,10 @@ public class TaskServiceImpl implements TaskService {
|
|||
public List<MulReturnType<ErrorCode, TaskInfoDetail>> stopTaskByDisposeIp(Long devId, int type, String ipAddr) {
|
||||
List<MulReturnType<ErrorCode, TaskInfoDetail>> retList = new ArrayList<>();
|
||||
|
||||
if (devId == null || devId == -1L || ipAddr == null || ipAddr.length() == 0 || !IPAddrType.isIpAddress(ipAddr)) {
|
||||
retList.add(new MulReturnType<>(ErrorCode.ERR_PARAMEXCEPTION, null));
|
||||
log.error("Input params error: devId:{}, disposeIp:{}, type:{}", devId, ipAddr, type);
|
||||
return retList;
|
||||
}
|
||||
|
||||
// 根据处置IP,拿出所有正在处置的任务
|
||||
List<TaskInfoDetail> taskList = taskCacheManager.getAllTask().stream()
|
||||
.filter(v -> (Objects.equals(v.getDeviceId(), devId))
|
||||
&& (Objects.equals(v.getType(), type) || type == -1)
|
||||
&& (Objects.equals(v.getType(), type) || type == DeviceCapacity.ALLCAPACITY.getCode())
|
||||
&& Objects.equals(v.getDisposeIp(), ipAddr)
|
||||
&& taskIsRunning(v))
|
||||
.collect(Collectors.toList());
|
||||
|
@ -475,7 +458,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
// 根据处置IP,拿出所有正在处置的任务
|
||||
List<TaskInfoDetail> taskList = taskCacheManager.getAllTask().stream()
|
||||
.filter(v -> ((devId == -1L) || Objects.equals(v.getDeviceId(), devId))
|
||||
&& (Objects.equals(v.getType(), type) || type == -1)
|
||||
&& (Objects.equals(v.getType(), type) || type == DeviceCapacity.ALLCAPACITY.getCode())
|
||||
&& taskIsRunning(v))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
@ -500,7 +483,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
|
||||
// 根据处置IP,拿出所有正在处置的任务
|
||||
List<TaskInfoDetail> taskList = taskCacheManager.getAllTask().stream()
|
||||
.filter(v -> (Objects.equals(v.getType(), type) || type == -1)
|
||||
.filter(v -> (Objects.equals(v.getType(), type) || type == DeviceCapacity.ALLCAPACITY.getCode())
|
||||
&& taskIsRunning(v))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
|
Loading…
Reference in New Issue