parent
21c2c05f0a
commit
83d19736cf
|
@ -92,6 +92,8 @@ public enum IPAddrType {
|
||||||
*/
|
*/
|
||||||
public static boolean isIpAddress(String ipAddr) {
|
public static boolean isIpAddress(String ipAddr) {
|
||||||
|
|
||||||
|
final String ipv6PortChar = "[";
|
||||||
|
|
||||||
int counts = ipAddr.length() - ipAddr.replaceAll(GlobalVar.STRING_IPV6_FLAG, "").length();
|
int counts = ipAddr.length() - ipAddr.replaceAll(GlobalVar.STRING_IPV6_FLAG, "").length();
|
||||||
|
|
||||||
String ipv4Regex = "^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\."
|
String ipv4Regex = "^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\."
|
||||||
|
@ -106,14 +108,12 @@ public enum IPAddrType {
|
||||||
return ipAddr.matches(ipv4Regex);
|
return ipAddr.matches(ipv4Regex);
|
||||||
// v4 + port
|
// v4 + port
|
||||||
case 1:
|
case 1:
|
||||||
String ipv4 = ipAddr.substring(0, ipAddr.lastIndexOf(":"));
|
String ipv4 = ipAddr.substring(0, ipAddr.lastIndexOf(GlobalVar.STRING_IPV6_FLAG));
|
||||||
//String port = ipAddr.substring(ipAddr.lastIndexOf(":") + 1);
|
|
||||||
return ipv4.matches(ipv4Regex);
|
return ipv4.matches(ipv4Regex);
|
||||||
default:
|
default:
|
||||||
// Ip v6 + port
|
// Ip v6 + port
|
||||||
if (ipAddr.contains("[")) {
|
if (ipAddr.contains("[")) {
|
||||||
String ipv6 = ipAddr.substring(1, ipAddr.lastIndexOf("]"));
|
String ipv6 = ipAddr.substring(1, ipAddr.lastIndexOf(ipv6PortChar));
|
||||||
//String port = ipAddr.substring(ipAddr.lastIndexOf("]:") + 1);
|
|
||||||
return ipv6.matches(ipv6Regex);
|
return ipv6.matches(ipv6Regex);
|
||||||
} else {
|
} else {
|
||||||
return ipAddr.matches(ipv6Regex);
|
return ipAddr.matches(ipv6Regex);
|
||||||
|
|
|
@ -52,12 +52,7 @@ public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
|
||||||
log.error("User {} not logged in", username);
|
log.error("User {} not logged in", username);
|
||||||
return ErrorCode.ERR_LOGOUT;
|
return ErrorCode.ERR_LOGOUT;
|
||||||
}
|
}
|
||||||
// else if (ConstValue.SoapWrapperConst.USER_NAME.equals(username)) {
|
|
||||||
// // admin 用户具有操作权限
|
|
||||||
// return ErrorCode.ERR_OK;
|
|
||||||
// }
|
|
||||||
|
|
||||||
//log.error("User {} not enough permissions", username);
|
|
||||||
return ErrorCode.ERR_OK;
|
return ErrorCode.ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,37 +186,6 @@ public class TaskServiceImpl implements TaskService {
|
||||||
return ErrorCode.ERR_NOSUCHDEVICE;
|
return ErrorCode.ERR_NOSUCHDEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// // 对新建的任务执行启动操作
|
|
||||||
// if (task.getCurrentStatus() == DisposeTaskStatus.TASK_NEW.getCode()) {
|
|
||||||
// // 更新任务状态为进行中
|
|
||||||
// taskCacheManager.upgradeTaskStatus(taskId, DisposeTaskStatus.TASK_RUNNING.getCode());
|
|
||||||
//
|
|
||||||
// dev.forEach(k -> {
|
|
||||||
// DisposeEntryManager dp = DeviceRouter.getDeviceRouterFactory(k.getType(), k.getIpAddr());
|
|
||||||
//
|
|
||||||
// MulReturnType<ErrorCode, Long> ret = dp.runDispose(task.getDisposeIp(), DeviceCapacity.values()[task.getType()], planDuration);
|
|
||||||
//
|
|
||||||
// if (ret.getFirstParam() == ErrorCode.ERR_SYSTEMEXCEPTION) {
|
|
||||||
// log.error("Start task: taskId:{}, error:{}", taskId, ret.getFirstParam());
|
|
||||||
// // 增加设备执行清洗任务信息
|
|
||||||
// taskInfoMapper.addNewTaskInfo(taskId, k.getId(), null,
|
|
||||||
// (long) ErrorCode.ERR_SYSTEMEXCEPTION.getCode());
|
|
||||||
// } else {
|
|
||||||
// if (ret.getFirstParam() != ErrorCode.ERR_OK) {
|
|
||||||
// // 执行任务失败恢复缓存中的任务状态
|
|
||||||
// taskInfoMapper.addNewTaskInfo(taskId, k.getId(), null, (long) ret.getFirstParam().getCode());
|
|
||||||
// log.error("Start task: taskId:{}, disposeIp:{}, error:{}",
|
|
||||||
// taskId, task.getDisposeIp(), ret.getFirstParam());
|
|
||||||
// } else {
|
|
||||||
// // 执行任务成功
|
|
||||||
// taskInfoMapper.addNewTaskInfo(taskId, k.getId(), ret.getSecondParam(), (long) ret.getFirstParam().getCode());
|
|
||||||
// log.info("Start task finished: taskId:{}, disposeId:{}, type:{}",
|
|
||||||
// taskId, task.getDisposeIp(), task.getType());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 对新建的任务执行启动操作
|
// 对新建的任务执行启动操作
|
||||||
if (task.getCurrentStatus() == DisposeTaskStatus.TASK_NEW.getCode()) {
|
if (task.getCurrentStatus() == DisposeTaskStatus.TASK_NEW.getCode()) {
|
||||||
// 更新任务状态为进行中
|
// 更新任务状态为进行中
|
||||||
|
@ -281,36 +250,6 @@ public class TaskServiceImpl implements TaskService {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// dev.forEach(k -> {
|
|
||||||
// DisposeEntryManager dp = DeviceRouter.getDeviceRouterFactory(k.getType(), k.getIpAddr());
|
|
||||||
//
|
|
||||||
// TaskInfo taskInfo = taskInfoMapper.getTaskInfo(taskId, k.getId());
|
|
||||||
//
|
|
||||||
// MulReturnType<ErrorCode, Long> ret = dp.stopDispose(task.getDisposeIp(), DeviceCapacity.values()[task.getType()],
|
|
||||||
// (taskInfo == null || taskInfo.getExternId() == null) ? -1 : taskInfo.getExternId());
|
|
||||||
//
|
|
||||||
// if (ret.getFirstParam() == ErrorCode.ERR_SYSTEMEXCEPTION) {
|
|
||||||
// // 恢复缓存中任务状态到先前状态
|
|
||||||
// taskCacheManager.upgradeTaskStatus(taskId, prdStatus);
|
|
||||||
// log.error("Stop task: taskId:{}, error:{}", taskId, ret.getFirstParam());
|
|
||||||
// } else {
|
|
||||||
// if (ret.getFirstParam() != ErrorCode.ERR_OK) {
|
|
||||||
// // 恢复缓存中任务状态到先前状态
|
|
||||||
// taskCacheManager.upgradeTaskStatus(taskId, prdStatus);
|
|
||||||
// log.error("Stop task: taskId:{}, error:{}", taskId, ret.getFirstParam());
|
|
||||||
// } else {
|
|
||||||
// // 任务执行完成后更新数据库处置任务状态
|
|
||||||
// finishTask(taskId);
|
|
||||||
// log.info("Stop task finished: taskId:{}, disposeId:{}, type:{}",
|
|
||||||
// taskId, task.getDisposeIp(), task.getType());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// } else {
|
|
||||||
// log.error("No such task: taskId:{}", taskId);
|
|
||||||
// return ErrorCode.ERR_NOSUCHTASK;
|
|
||||||
// }
|
|
||||||
|
|
||||||
dev.forEach(k -> {
|
dev.forEach(k -> {
|
||||||
DisposeEntryManager dp = DeviceRouter.getDeviceRouterFactory(k.getType(), k.getIpAddr());
|
DisposeEntryManager dp = DeviceRouter.getDeviceRouterFactory(k.getType(), k.getIpAddr());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue