Merge branch 'master' of git.komect.net:DDOSAQ/phoenix_ddos_handle
Conflicts: src/main/java/com/dispose/controller/DisposeTaskController.java
This commit is contained in:
commit
d9d4787112
|
@ -11,6 +11,8 @@ import tk.mybatis.spring.annotation.MapperScan;
|
|||
|
||||
/**
|
||||
* The type Phoenix boot application.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableAsync
|
||||
|
|
|
@ -2,11 +2,15 @@ package com.dispose.common;
|
|||
|
||||
/**
|
||||
* The type Const value.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public class ConstValue {
|
||||
|
||||
/**
|
||||
* The type Global configure.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public static class GlobalConfigure {
|
||||
/**
|
||||
|
@ -24,13 +28,15 @@ public class ConstValue {
|
|||
/**
|
||||
* The constant TOKEN_EXPIRED_TIME_MS.
|
||||
*/
|
||||
public static final long TOKEN_EXPIRED_TIME_MS = 1000 * 60 * 60;
|
||||
public static final long TOKEN_EXPIRED_TIME_MS = TOKEN_TIMEOUT_MS;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type Soap wrapper const.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public static class SOAPWrapperConst {
|
||||
public static class SoapWrapperConst {
|
||||
/**
|
||||
* The constant NAMESPACE_URI.
|
||||
*/
|
||||
|
@ -48,6 +54,8 @@ public class ConstValue {
|
|||
|
||||
/**
|
||||
* The type Protocol.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public static class Protocol {
|
||||
/**
|
||||
|
@ -67,11 +75,16 @@ public class ConstValue {
|
|||
*/
|
||||
public static final int CRYPTO_AES256 = 2;
|
||||
|
||||
/**
|
||||
* The constant REQUEST_TIMEOUT_MS.
|
||||
*/
|
||||
public static final int REQUEST_TIMEOUT_MS = 10 * 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type User account status.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public static class UserAccountStatus {
|
||||
/**
|
||||
|
|
|
@ -2,40 +2,35 @@ package com.dispose.common;
|
|||
|
||||
/**
|
||||
* The enum Device capacity.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public enum DeviceCapacity {
|
||||
/**
|
||||
* The Cleanup.
|
||||
* Cleanup device capacity.
|
||||
*/
|
||||
CLEANUP(0, "清洗能力"),
|
||||
/**
|
||||
* The Hidepend.
|
||||
* Hidepend device capacity.
|
||||
*/
|
||||
HIDEPEND(1, "高防能力"),
|
||||
/**
|
||||
* The Blackhool.
|
||||
* Blackhool device capacity.
|
||||
*/
|
||||
BLACKHOOL(2, "黑洞能力"),
|
||||
/**
|
||||
* The Detecive.
|
||||
* Detecive device capacity.
|
||||
*/
|
||||
DETECIVE(3, "检测能力");
|
||||
DETECIVE(3, "检测能力"),
|
||||
|
||||
/**
|
||||
* The Code.
|
||||
* Allcapacity device capacity.
|
||||
*/
|
||||
ALLCAPACITY(-1, "所有能力");
|
||||
|
||||
private final int code;
|
||||
/**
|
||||
* The Readme.
|
||||
*/
|
||||
private final String readme;
|
||||
|
||||
/**
|
||||
* Instantiates a new Device capacity.
|
||||
*
|
||||
* @param code the code
|
||||
* @param readme the readme
|
||||
*/
|
||||
DeviceCapacity(int code, String readme) {
|
||||
this.code = code;
|
||||
this.readme = readme;
|
||||
|
|
|
@ -2,37 +2,27 @@ package com.dispose.common;
|
|||
|
||||
/**
|
||||
* The enum Dispose device type.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public enum DisposeDeviceType {
|
||||
/**
|
||||
* The Dptech umc.
|
||||
* Dptech umc dispose device type.
|
||||
*/
|
||||
DPTECH_UMC(0, "迪普UMC管理平台"),
|
||||
/**
|
||||
* The Haohan platform.
|
||||
* Haohan platform dispose device type.
|
||||
*/
|
||||
HAOHAN_PLATFORM(1, "浩瀚处置设备"),
|
||||
|
||||
/**
|
||||
* The Virtual dispose.
|
||||
* Virtual dispose dispose device type.
|
||||
*/
|
||||
VIRTUAL_DISPOSE(999, "虚拟处置设备");
|
||||
|
||||
/**
|
||||
* The Code.
|
||||
*/
|
||||
private final int code;
|
||||
/**
|
||||
* The Readme.
|
||||
*/
|
||||
private final String readme;
|
||||
|
||||
/**
|
||||
* Instantiates a new Dispose device type.
|
||||
*
|
||||
* @param code the code
|
||||
* @param readme the readme
|
||||
*/
|
||||
DisposeDeviceType(int code, String readme) {
|
||||
this.code = code;
|
||||
this.readme = readme;
|
||||
|
|
|
@ -2,44 +2,34 @@ package com.dispose.common;
|
|||
|
||||
/**
|
||||
* The enum Dispose task status.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public enum DisposeTaskStatus {
|
||||
/**
|
||||
* The Task new.
|
||||
* Task new dispose task status.
|
||||
*/
|
||||
TASK_NEW(0, "新建"),
|
||||
/**
|
||||
* The Task running.
|
||||
* Task running dispose task status.
|
||||
*/
|
||||
TASK_RUNNING(1, "运行中"),
|
||||
/**
|
||||
* The Task stop.
|
||||
* Task stop dispose task status.
|
||||
*/
|
||||
TASK_STOP(2, "停止"),
|
||||
/**
|
||||
* The Task finish.
|
||||
* Task finish dispose task status.
|
||||
*/
|
||||
TASK_FINISH(3, "结束"),
|
||||
/**
|
||||
* The Task delete.
|
||||
* Task delete dispose task status.
|
||||
*/
|
||||
TASK_DELETE(4, "删除");
|
||||
|
||||
/**
|
||||
* The Code.
|
||||
*/
|
||||
private final int code;
|
||||
/**
|
||||
* The Readme.
|
||||
*/
|
||||
private final String readme;
|
||||
|
||||
/**
|
||||
* Instantiates a new Dispose task status.
|
||||
*
|
||||
* @param code the code
|
||||
* @param readme the readme
|
||||
*/
|
||||
DisposeTaskStatus(int code, String readme) {
|
||||
this.code = code;
|
||||
this.readme = readme;
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.dispose.common;
|
|||
|
||||
/**
|
||||
* The enum Dp tech attack type.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public enum DpTechAttackType {
|
||||
/**
|
||||
|
@ -53,21 +55,9 @@ public enum DpTechAttackType {
|
|||
*/
|
||||
HOST_TOTAL_TRAFFIC(31, "Host Total Traffic");
|
||||
|
||||
/**
|
||||
* The Code.
|
||||
*/
|
||||
private final int code;
|
||||
/**
|
||||
* The Readme.
|
||||
*/
|
||||
private final String readme;
|
||||
|
||||
/**
|
||||
* Instantiates a new Dp tech attack type.
|
||||
*
|
||||
* @param code the code
|
||||
* @param readme the readme
|
||||
*/
|
||||
DpTechAttackType(int code, String readme) {
|
||||
this.code = code;
|
||||
this.readme = readme;
|
||||
|
|
|
@ -2,126 +2,128 @@ package com.dispose.common;
|
|||
|
||||
/**
|
||||
* The enum Error code.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public enum ErrorCode {
|
||||
/**
|
||||
* The Err ok.
|
||||
* Err ok error code.
|
||||
*/
|
||||
ERR_OK(0, "成功"),
|
||||
/**
|
||||
* The Err password.
|
||||
* Err password error code.
|
||||
*/
|
||||
ERR_PASSWORD(1, "密码错误"),
|
||||
/**
|
||||
* The Err usernotfound.
|
||||
* Err usernotfound error code.
|
||||
*/
|
||||
ERR_USERNOTFOUND(2, "用户不存在"),
|
||||
/**
|
||||
* The Err passwordmore.
|
||||
* Err passwordmore error code.
|
||||
*/
|
||||
ERR_PASSWORDMORE(3, "连续密码错误达上限,再次输入错误将锁定用户"),
|
||||
/**
|
||||
* The Err userlock.
|
||||
* Err userlock error code.
|
||||
*/
|
||||
ERR_USERLOCK(4, "密码错误达上限,用户被锁定"),
|
||||
/**
|
||||
* The Err account.
|
||||
* Err account error code.
|
||||
*/
|
||||
ERR_ACCOUNT(5, "用户账户异常"),
|
||||
/**
|
||||
* The Err userexist.
|
||||
* Err userexist error code.
|
||||
*/
|
||||
ERR_USEREXIST(6, "该用户已经存在"),
|
||||
/**
|
||||
* The Err passwordsimple.
|
||||
* Err passwordsimple error code.
|
||||
*/
|
||||
ERR_PASSWORDSIMPLE(7, "用户密码强度不符合要求"),
|
||||
/**
|
||||
* The Err inputformat.
|
||||
* Err inputformat error code.
|
||||
*/
|
||||
ERR_INPUTFORMAT(8, "输入信息格式有误"),
|
||||
/**
|
||||
* The Err inputmiss.
|
||||
* Err inputmiss error code.
|
||||
*/
|
||||
ERR_INPUTMISS(9, "缺少必要输入信息"),
|
||||
/**
|
||||
* The Err permission.
|
||||
* Err permission error code.
|
||||
*/
|
||||
ERR_PERMISSION(10, "操作员权限不足"),
|
||||
/**
|
||||
* The Err reqtimeout.
|
||||
* Err reqtimeout error code.
|
||||
*/
|
||||
ERR_REQTIMEOUT(11, "请求超时"),
|
||||
/**
|
||||
* The Err params.
|
||||
* Err params error code.
|
||||
*/
|
||||
ERR_PARAMS(12, "参数错误"),
|
||||
/**
|
||||
* The Err systemexception.
|
||||
* Err systemexception error code.
|
||||
*/
|
||||
ERR_SYSTEMEXCEPTION(13, "系统异常"),
|
||||
/**
|
||||
* The Err unknowncmd.
|
||||
* Err unknowncmd error code.
|
||||
*/
|
||||
ERR_UNKNOWNCMD(14, "未知命令"),
|
||||
/**
|
||||
* The Err logout.
|
||||
* Err logout error code.
|
||||
*/
|
||||
ERR_LOGOUT(15, "用户未登录"),
|
||||
/**
|
||||
* The Err tokentimeout.
|
||||
* Err tokentimeout error code.
|
||||
*/
|
||||
ERR_TOKENTIMEOUT(16, "Token超时"),
|
||||
/**
|
||||
* The Err tokennotfound.
|
||||
* Err tokennotfound error code.
|
||||
*/
|
||||
ERR_TOKENNOTFOUND(17, "非法Token"),
|
||||
/**
|
||||
* The Err missauthhead.
|
||||
* Err missauthhead error code.
|
||||
*/
|
||||
ERR_MISSAUTHHEAD(18, "Http 请求缺少认证头部"),
|
||||
/**
|
||||
* The Err nosuchdevice.
|
||||
* Err nosuchdevice error code.
|
||||
*/
|
||||
ERR_NOSUCHDEVICE(19, "没有这个设备"),
|
||||
/**
|
||||
* The Err deviceexists.
|
||||
* Err deviceexists error code.
|
||||
*/
|
||||
ERR_DEVICEEXISTS(20, "设备已经存在"),
|
||||
/**
|
||||
* The Err paramexception.
|
||||
* Err paramexception error code.
|
||||
*/
|
||||
ERR_PARAMEXCEPTION(21, "参数异常"),
|
||||
/**
|
||||
* The Err version.
|
||||
* Err version error code.
|
||||
*/
|
||||
ERR_VERSION(23, "协议版本不兼容,请升级系统"),
|
||||
/**
|
||||
* The Err nosuchtype.
|
||||
* Err nosuchtype error code.
|
||||
*/
|
||||
ERR_NOSUCHTYPE(24, "没有这个类型的处置设备"),
|
||||
/**
|
||||
* The Err removemore.
|
||||
* Err removemore error code.
|
||||
*/
|
||||
ERR_REMOVEMORE(25, "禁止同时删除多个设备"),
|
||||
|
||||
/**
|
||||
* The Err taskrunning.
|
||||
* Err taskrunning error code.
|
||||
*/
|
||||
ERR_TASKRUNNING(26, "同类任务正在运行"),
|
||||
|
||||
/**
|
||||
* The Err unsupport.
|
||||
* Err unsupport error code.
|
||||
*/
|
||||
ERR_UNSUPPORT(27, "不支持的操作"),
|
||||
|
||||
/**
|
||||
* The Err interrupt.
|
||||
* Err interrupt error code.
|
||||
*/
|
||||
ERR_INTERRUPT(28, "操作中断"),
|
||||
|
||||
/**
|
||||
* The Err calldevice.
|
||||
* Err calldevice error code.
|
||||
*/
|
||||
ERR_CALLDEVICE(29, "调用设备失败"),
|
||||
|
||||
|
@ -141,21 +143,9 @@ public enum ErrorCode {
|
|||
ERR_REQUESTTIMEOUT(32, "请求超时"),
|
||||
;
|
||||
|
||||
/**
|
||||
* The Errno.
|
||||
*/
|
||||
private final int errno;
|
||||
/**
|
||||
* The Err msg.
|
||||
*/
|
||||
private final String errMsg;
|
||||
|
||||
/**
|
||||
* Instantiates a new Error code.
|
||||
*
|
||||
* @param err the err
|
||||
* @param msg the msg
|
||||
*/
|
||||
ErrorCode(int err, String msg) {
|
||||
this.errno = err;
|
||||
this.errMsg = msg;
|
||||
|
|
|
@ -2,36 +2,26 @@ package com.dispose.common;
|
|||
|
||||
/**
|
||||
* The enum Flow direction.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public enum FlowDirection {
|
||||
/**
|
||||
* The Direction input.
|
||||
* Direction input flow direction.
|
||||
*/
|
||||
DIRECTION_INPUT(0, "流入"),
|
||||
/**
|
||||
* The Direction output.
|
||||
* Direction output flow direction.
|
||||
*/
|
||||
DIRECTION_OUTPUT(1, "流出"),
|
||||
/**
|
||||
* The Direction twoway.
|
||||
* Direction twoway flow direction.
|
||||
*/
|
||||
DIRECTION_TWOWAY(2, "双向");
|
||||
|
||||
/**
|
||||
* The Code.
|
||||
*/
|
||||
private final int code;
|
||||
/**
|
||||
* The Readme.
|
||||
*/
|
||||
private final String readme;
|
||||
|
||||
/**
|
||||
* Instantiates a new Flow direction.
|
||||
*
|
||||
* @param code the code
|
||||
* @param readme the readme
|
||||
*/
|
||||
FlowDirection(int code, String readme) {
|
||||
this.code = code;
|
||||
this.readme = readme;
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.dispose.common;
|
|||
|
||||
/**
|
||||
* The type Global var.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public class GlobalVar {
|
||||
|
||||
|
@ -30,4 +32,29 @@ public class GlobalVar {
|
|||
* The constant IS_CHECK_REQUEST_TIMEOUT.
|
||||
*/
|
||||
public static volatile boolean IS_CHECK_REQUEST_TIMEOUT = false;
|
||||
|
||||
/**
|
||||
* The constant STRING_SPILT_CHAR.
|
||||
*/
|
||||
public static final String STRING_SPILT_CHAR = ",";
|
||||
|
||||
/**
|
||||
* The constant STRING_IPV4_FLAG.
|
||||
*/
|
||||
public static final String STRING_IPV4_FLAG = ".";
|
||||
|
||||
/**
|
||||
* The constant STRING_IPV6_FLAG.
|
||||
*/
|
||||
public static final String STRING_IPV6_FLAG = ":";
|
||||
|
||||
/**
|
||||
* The constant STRING_HTTP_AUTH_HEAD.
|
||||
*/
|
||||
public static final String STRING_HTTP_AUTH_HEAD = "Bearer ";
|
||||
|
||||
/**
|
||||
* The constant TASK_ERROR_MAX_RETRY.
|
||||
*/
|
||||
public static final int TASK_ERROR_MAX_RETRY = 3;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The type Helper.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public class Helper {
|
||||
/**
|
||||
|
@ -28,7 +30,7 @@ public class Helper {
|
|||
|
||||
String ret = strAttack.toString();
|
||||
|
||||
if (ret.endsWith(",")) {
|
||||
if (ret.endsWith(GlobalVar.STRING_SPILT_CHAR)) {
|
||||
ret = ret.substring(0, ret.length() - 1);
|
||||
}
|
||||
|
||||
|
@ -46,7 +48,7 @@ public class Helper {
|
|||
return new Integer[]{0};
|
||||
}
|
||||
|
||||
String[] spilt = str.split(",");
|
||||
String[] spilt = str.split(GlobalVar.STRING_SPILT_CHAR);
|
||||
List<Integer> intArray = new ArrayList<>();
|
||||
|
||||
for (String s : spilt) {
|
||||
|
@ -56,10 +58,23 @@ public class Helper {
|
|||
return intArray.toArray(new Integer[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets timestamp second.
|
||||
*
|
||||
* @param dateTime the date time
|
||||
* @return the timestamp second
|
||||
*/
|
||||
public static int getTimestampSecond(String dateTime) {
|
||||
return (int)(Timestamp.valueOf(dateTime).toInstant().toEpochMilli() / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets timestamp diff.
|
||||
*
|
||||
* @param begin the begin
|
||||
* @param end the end
|
||||
* @return the timestamp diff
|
||||
*/
|
||||
public static int getTimestampDiff(String begin, String end) {
|
||||
int starTime = getTimestampSecond(begin);
|
||||
int endTm = getTimestampSecond(end);
|
||||
|
@ -67,6 +82,12 @@ public class Helper {
|
|||
return endTm - starTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets timestamp diff now.
|
||||
*
|
||||
* @param begin the begin
|
||||
* @return the timestamp diff now
|
||||
*/
|
||||
public static int getTimestampDiffNow(String begin) {
|
||||
int starTime = getTimestampSecond(begin);
|
||||
int endTm = (int)(System.currentTimeMillis() / 1000);
|
||||
|
|
|
@ -7,6 +7,8 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* The type Http.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public class Http {
|
||||
|
||||
|
|
|
@ -7,14 +7,16 @@ import inet.ipaddr.IPAddressString;
|
|||
|
||||
/**
|
||||
* The enum Ip addr type.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public enum IPAddrType {
|
||||
/**
|
||||
* The Ipv 4 type.
|
||||
* Ipv 4 type ip addr type.
|
||||
*/
|
||||
IPV4_TYPE,
|
||||
/**
|
||||
* The Ipv 6 type.
|
||||
* Ipv 6 type ip addr type.
|
||||
*/
|
||||
IPV6_TYPE;
|
||||
|
||||
|
@ -25,7 +27,7 @@ public enum IPAddrType {
|
|||
* @return the ip addr type
|
||||
*/
|
||||
public static IPAddrType getIpAddrType(String ipAddr) {
|
||||
if (ipAddr.contains(":")) {
|
||||
if (ipAddr.contains(GlobalVar.STRING_IPV6_FLAG)) {
|
||||
return IPV6_TYPE;
|
||||
} else {
|
||||
return IPV4_TYPE;
|
||||
|
@ -60,9 +62,10 @@ public enum IPAddrType {
|
|||
* @throws AddressStringException the address string exception
|
||||
*/
|
||||
public static boolean ipInRange(String rangeIp, String ipAddr) throws AddressStringException {
|
||||
final int numIp = 2;
|
||||
String[] ipList = rangeIp.split("-");
|
||||
|
||||
if (ipList.length != 2) {
|
||||
if (ipList.length != numIp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -75,8 +78,14 @@ public enum IPAddrType {
|
|||
return range.contains(addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is ip address boolean.
|
||||
*
|
||||
* @param ipAddr the ip addr
|
||||
* @return the boolean
|
||||
*/
|
||||
public static boolean isIpAddress(String ipAddr) {
|
||||
if (!ipAddr.contains(".") && !ipAddr.contains(":")) {
|
||||
if (!ipAddr.contains(GlobalVar.STRING_IPV4_FLAG) && !ipAddr.contains(GlobalVar.STRING_IPV6_FLAG)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -7,22 +7,15 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
/**
|
||||
* The type Dispose configure.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "dispose")
|
||||
public class DisposeConfigure {
|
||||
/**
|
||||
* The Check protocol timeout.
|
||||
*/
|
||||
private String checkProtocolTimeout;
|
||||
/**
|
||||
* The Check request token.
|
||||
*/
|
||||
private String checkRequestToken;
|
||||
/**
|
||||
* The Check admin permission.
|
||||
*/
|
||||
private String checkAdminPermission;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import org.springframework.web.filter.CharacterEncodingFilter;
|
|||
|
||||
/**
|
||||
* The type Encoding filter config.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Configuration
|
||||
public class EncodingFilterConfig {
|
||||
|
|
|
@ -7,6 +7,8 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
/**
|
||||
* The type My config.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
|
@ -14,49 +16,16 @@ import org.springframework.stereotype.Component;
|
|||
@ConfigurationProperties(prefix = "phoenix")
|
||||
public class MyConfig {
|
||||
|
||||
/**
|
||||
* The System name.
|
||||
*/
|
||||
private String systemName;
|
||||
/**
|
||||
* The Swagger switch.
|
||||
*/
|
||||
private String swaggerSwitch;
|
||||
/**
|
||||
* The Redis server.
|
||||
*/
|
||||
private String redisServer;
|
||||
/**
|
||||
* The Request dec switch.
|
||||
*/
|
||||
private String requestDecSwitch;
|
||||
/**
|
||||
* The Response enc switch.
|
||||
*/
|
||||
private String responseEncSwitch;
|
||||
/**
|
||||
* The Aes key.
|
||||
*/
|
||||
private String aesKey;
|
||||
/**
|
||||
* The Redis redisson sentinel master name.
|
||||
*/
|
||||
private String redisRedissonSentinelMasterName;
|
||||
/**
|
||||
* The Redis redisson pwd.
|
||||
*/
|
||||
private String redisRedissonPwd;
|
||||
/**
|
||||
* The Threat info key.
|
||||
*/
|
||||
private String threatInfoKey;
|
||||
/**
|
||||
* The Threat info version url.
|
||||
*/
|
||||
private String threatInfoVersionUrl;
|
||||
/**
|
||||
* The Threat info download.
|
||||
*/
|
||||
private String threatInfoDownload;
|
||||
|
||||
}
|
||||
|
|
|
@ -11,25 +11,18 @@ import javax.annotation.Resource;
|
|||
|
||||
/**
|
||||
* The type Setup init.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SetupInit implements CommandLineRunner {
|
||||
/**
|
||||
* The Dispose configure.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeConfigure disposeConfigure;
|
||||
|
||||
/**
|
||||
* The Dispose node manager.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeNodeManager disposeNodeManager;
|
||||
|
||||
/**
|
||||
* The Task service.
|
||||
*/
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
|
||||
|
@ -42,7 +35,7 @@ public class SetupInit implements CommandLineRunner {
|
|||
public void run(String... args) {
|
||||
// 系统初始化入口
|
||||
GlobalVar.IS_CHECK_REQUEST_TIMEOUT = Boolean.parseBoolean(disposeConfigure.getCheckProtocolTimeout());
|
||||
disposeNodeManager.loadDisposeNodeFromDB();
|
||||
disposeNodeManager.loadDisposeNodeFromDatabase();
|
||||
taskService.loadTaskFromDatabase();
|
||||
}
|
||||
}
|
|
@ -8,6 +8,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|||
|
||||
/**
|
||||
* The type Token config.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Configuration
|
||||
public class TokenConfig implements WebMvcConfigurer {
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.dispose.common.ConstValue;
|
|||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.dto.ProtocolReqDTO;
|
||||
import com.dispose.pojo.dto.ProtocolRespDTO;
|
||||
import com.dispose.pojo.po.MReturnType;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.pojo.vo.auth.LoginReq;
|
||||
import com.dispose.pojo.vo.auth.LoginRsp;
|
||||
import com.dispose.pojo.vo.auth.LogoutRsp;
|
||||
|
@ -27,6 +27,8 @@ import java.security.NoSuchAlgorithmException;
|
|||
|
||||
/**
|
||||
* The type Auth controller.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "/auth")
|
||||
|
@ -34,9 +36,6 @@ import java.security.NoSuchAlgorithmException;
|
|||
@Api(value = "抗DDoS处置平台认证接口", tags = "抗DDoS处置平台认证接口")
|
||||
@Component
|
||||
public class AuthController {
|
||||
/**
|
||||
* The User account service.
|
||||
*/
|
||||
@Resource
|
||||
private UserAccountService userAccountService;
|
||||
|
||||
|
@ -62,7 +61,17 @@ public class AuthController {
|
|||
|
||||
LoginReq reqInfo = mr.getRequestObject(LoginReq.class);
|
||||
|
||||
MReturnType<ErrorCode, String> ret = userAccountService.loginService(reqInfo.getUserName(),
|
||||
if (reqInfo.getUserName() == null || reqInfo.getUserName().length() == 0) {
|
||||
log.error("Request username params error, error:{} --> {}", mr.getMsgContent(), reqInfo.getUserName());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
if (reqInfo.getPassword() == null || reqInfo.getPassword().length() == 0) {
|
||||
log.error("Request password params error, error:{} --> {}", mr.getMsgContent(), reqInfo.getPassword());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PASSWORD);
|
||||
}
|
||||
|
||||
MulReturnType<ErrorCode, String> ret = userAccountService.loginService(reqInfo.getUserName(),
|
||||
reqInfo.getPassword());
|
||||
|
||||
if (ret.getFirstParam() != ErrorCode.ERR_OK) {
|
||||
|
@ -107,6 +116,11 @@ public class AuthController {
|
|||
|
||||
LoginReq reqInfo = mr.getRequestObject(LoginReq.class);
|
||||
|
||||
if (reqInfo.getUserName() == null || reqInfo.getUserName().length() == 0) {
|
||||
log.error("Request username params error, error:{} --> {}", mr.getMsgContent(), reqInfo.getUserName());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
err = userAccountService.logoutService(reqInfo.getUserName(), mr.getAuthToken());
|
||||
|
||||
if (err != ErrorCode.ERR_OK) {
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package com.dispose.controller;
|
||||
|
||||
import com.dispose.common.ConstValue;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.common.Helper;
|
||||
import com.dispose.pojo.dto.ProtocolReqDTO;
|
||||
import com.dispose.pojo.dto.ProtocolRespDTO;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.vo.common.DisposeCapacity;
|
||||
import com.dispose.pojo.vo.common.IDArrayReq;
|
||||
import com.dispose.pojo.vo.common.TaskInfoData;
|
||||
import com.dispose.pojo.vo.common.TaskInfoDetail;
|
||||
|
@ -25,10 +23,10 @@ import com.dispose.pojo.vo.information.VersionRsp;
|
|||
import com.dispose.service.DisposeNodeManager;
|
||||
import com.dispose.service.TaskService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
@ -42,10 +40,13 @@ import javax.annotation.Resource;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The type Dispose node info controller.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "/information")
|
||||
|
@ -53,21 +54,12 @@ import java.util.stream.Collectors;
|
|||
@Api(value = "抗DDoS处置平台能力节点信息接口", tags = "抗DDoS处置平台能力节点信息接口")
|
||||
@Component
|
||||
public class DisposeNodeInfoController {
|
||||
/**
|
||||
* The Task service.
|
||||
*/
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
|
||||
/**
|
||||
* The Dispose node manager.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeNodeManager disposeNodeManager;
|
||||
|
||||
//@Resource
|
||||
//private DisposeDeviceMapper disposeDeviceMapper;
|
||||
|
||||
/**
|
||||
* Gets link status.
|
||||
*
|
||||
|
@ -90,43 +82,46 @@ public class DisposeNodeInfoController {
|
|||
}
|
||||
|
||||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
LinkStatusListRsp linkStatusListRsp = new LinkStatusListRsp();
|
||||
linkStatusListRsp.setItems(new ArrayList<>());
|
||||
|
||||
if (reqInfo.getId().length == 0) {
|
||||
List<DisposeDevice> devs = disposeNodeManager.getAllDisposeDevice();
|
||||
|
||||
if (devs != null && devs.size() > 0) {
|
||||
devs.forEach(v -> linkStatusListRsp.getItems().add(LinkStatusRsp.builder()
|
||||
.online(v.getLinkStatus())
|
||||
.id(v.getId().toString())
|
||||
.status(ErrorCode.ERR_OK.getCode())
|
||||
.message(ErrorCode.ERR_OK.getMsg())
|
||||
.build()));
|
||||
}
|
||||
} else {
|
||||
for (String v : reqInfo.getId()) {
|
||||
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
|
||||
if (dev != null && dev.getId().equals(Long.valueOf(v))) {
|
||||
linkStatusListRsp.getItems().add(LinkStatusRsp.builder()
|
||||
.online(dev.getLinkStatus())
|
||||
.id(dev.getId().toString())
|
||||
.status(ErrorCode.ERR_OK.getCode())
|
||||
.message(ErrorCode.ERR_OK.getMsg())
|
||||
.build());
|
||||
} else {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
linkStatusListRsp.getItems().add(LinkStatusRsp.builder()
|
||||
.online(0)
|
||||
.id(v)
|
||||
.status(ErrorCode.ERR_NOSUCHDEVICE.getCode())
|
||||
.message(ErrorCode.ERR_NOSUCHDEVICE.getMsg())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, linkStatusListRsp);
|
||||
LinkStatusListRsp rspInfo = new LinkStatusListRsp();
|
||||
rspInfo.setItems(new ArrayList<>());
|
||||
|
||||
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
|
||||
.stream()
|
||||
.filter(v -> reqInfo.getId().length == 0
|
||||
|| reqInfo.getId()[0].length() == 0
|
||||
|| Arrays.stream(reqInfo.getId()).anyMatch(s -> s.equals(v.getId().toString())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
valuableData.forEach(v -> rspInfo.getItems().add(LinkStatusRsp.builder()
|
||||
.online(v.getLinkStatus())
|
||||
.id(v.getId().toString())
|
||||
.status(ErrorCode.ERR_OK.getCode())
|
||||
.message(ErrorCode.ERR_OK.getMsg())
|
||||
.build()));
|
||||
|
||||
List<String> unExists = Arrays.stream(reqInfo.getId())
|
||||
.filter(v -> v.length() > 0)
|
||||
.filter(v -> !StringUtils.isNumeric(v)
|
||||
|| valuableData.stream().noneMatch(k -> k.getId() == Long.parseLong(v)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
unExists.forEach(v -> {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
rspInfo.getItems().add(LinkStatusRsp.builder()
|
||||
.online(0)
|
||||
.id(v)
|
||||
.status(ErrorCode.ERR_NOSUCHDEVICE.getCode())
|
||||
.message(ErrorCode.ERR_NOSUCHDEVICE.getMsg())
|
||||
.build());
|
||||
});
|
||||
|
||||
return ProtocolRespDTO.result(err, rspInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -151,41 +146,45 @@ public class DisposeNodeInfoController {
|
|||
}
|
||||
|
||||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
VersionListRsp versionListRsp = new VersionListRsp();
|
||||
versionListRsp.setItems(new ArrayList<>());
|
||||
|
||||
if (reqInfo.getId().length == 0) {
|
||||
List<DisposeDevice> devList = disposeNodeManager.getAllDisposeDevice();
|
||||
if (devList != null && devList.size() > 0) {
|
||||
devList.forEach(v -> versionListRsp.getItems().add(VersionRsp.builder()
|
||||
.id(v.getId().toString())
|
||||
.version(v.getVersion())
|
||||
.status(ErrorCode.ERR_OK.getCode())
|
||||
.message(ErrorCode.ERR_OK.getMsg())
|
||||
.build()));
|
||||
}
|
||||
} else {
|
||||
for (String v : reqInfo.getId()) {
|
||||
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
|
||||
if (dev != null && dev.getId().equals(Long.valueOf(v))) {
|
||||
versionListRsp.getItems().add(VersionRsp.builder()
|
||||
.id(dev.getId().toString())
|
||||
.version(dev.getVersion())
|
||||
.status(ErrorCode.ERR_OK.getCode())
|
||||
.message(ErrorCode.ERR_OK.getMsg())
|
||||
.build());
|
||||
} else {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
versionListRsp.getItems().add(VersionRsp.builder()
|
||||
.id(v)
|
||||
.status(ErrorCode.ERR_NOSUCHDEVICE.getCode())
|
||||
.message(ErrorCode.ERR_NOSUCHDEVICE.getMsg())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, versionListRsp);
|
||||
VersionListRsp rspInfo = new VersionListRsp();
|
||||
rspInfo.setItems(new ArrayList<>());
|
||||
|
||||
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
|
||||
.stream()
|
||||
.filter(v -> reqInfo.getId().length == 0
|
||||
|| reqInfo.getId()[0].length() == 0
|
||||
|| Arrays.stream(reqInfo.getId()).anyMatch(s -> s.equals(v.getId().toString())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
valuableData.forEach(v -> rspInfo.getItems().add(VersionRsp.builder()
|
||||
.id(v.getId().toString())
|
||||
.version(v.getVersion())
|
||||
.status(ErrorCode.ERR_OK.getCode())
|
||||
.message(ErrorCode.ERR_OK.getMsg())
|
||||
.build()));
|
||||
|
||||
List<String> unExists = Arrays.stream(reqInfo.getId())
|
||||
.filter(v -> v.length() > 0)
|
||||
.filter(v -> !StringUtils.isNumeric(v)
|
||||
|| valuableData.stream().noneMatch(k -> k.getId() == Long.parseLong(v)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
unExists.forEach(v -> {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
rspInfo.getItems().add(VersionRsp.builder()
|
||||
.id(v)
|
||||
.status(ErrorCode.ERR_NOSUCHDEVICE.getCode())
|
||||
.message(ErrorCode.ERR_NOSUCHDEVICE.getMsg())
|
||||
.build());
|
||||
});
|
||||
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -210,50 +209,46 @@ public class DisposeNodeInfoController {
|
|||
}
|
||||
|
||||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
DeviceInfoRsp rspInfo = new DeviceInfoRsp();
|
||||
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
DeviceInfoRsp rspInfo = new DeviceInfoRsp();
|
||||
rspInfo.setItems(new ArrayList<>());
|
||||
|
||||
if (reqInfo.getId().length == 0) {
|
||||
List<DisposeDevice> devList = disposeNodeManager.getAllDisposeDevice();
|
||||
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
|
||||
.stream()
|
||||
.filter(v -> reqInfo.getId().length == 0
|
||||
|| reqInfo.getId()[0].length() == 0
|
||||
|| Arrays.stream(reqInfo.getId()).anyMatch(s -> s.equals(v.getId().toString())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (devList != null && devList.size() > 0) {
|
||||
devList.forEach(v -> rspInfo.getItems().add(new DeviceInfoData(
|
||||
v.getId().toString(),
|
||||
v.getDevInfo().getVendor(),
|
||||
v.getDevInfo().getModel(),
|
||||
v.getDevInfo().getFirmware(),
|
||||
v.getDevInfo().getOs(),
|
||||
v.getDevInfo().getKernel(),
|
||||
v.getDevInfo().getArch(),
|
||||
v.getDevInfo().getMemory(),
|
||||
v.getDevInfo().getFreeMemory(),
|
||||
v.getDevInfo().getCpuUsed(),
|
||||
ErrorCode.ERR_OK
|
||||
)));
|
||||
}
|
||||
} else {
|
||||
for (String v : reqInfo.getId()) {
|
||||
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
|
||||
if (dev != null && dev.getId().equals(Long.valueOf(v)) && dev.getDevInfo() != null) {
|
||||
rspInfo.getItems().add(new DeviceInfoData(dev.getId().toString(),
|
||||
dev.getDevInfo().getVendor(),
|
||||
dev.getDevInfo().getModel(),
|
||||
dev.getDevInfo().getFirmware(),
|
||||
dev.getDevInfo().getOs(),
|
||||
dev.getDevInfo().getKernel(),
|
||||
dev.getDevInfo().getArch(),
|
||||
dev.getDevInfo().getMemory(),
|
||||
dev.getDevInfo().getFreeMemory(),
|
||||
dev.getDevInfo().getCpuUsed(),
|
||||
ErrorCode.ERR_OK
|
||||
));
|
||||
} else {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
rspInfo.getItems().add(new DeviceInfoData(v, ErrorCode.ERR_NOSUCHDEVICE));
|
||||
}
|
||||
}
|
||||
}
|
||||
valuableData.forEach(v -> rspInfo.getItems().add(new DeviceInfoData(
|
||||
v.getId().toString(),
|
||||
v.getDevInfo().getVendor(),
|
||||
v.getDevInfo().getModel(),
|
||||
v.getDevInfo().getFirmware(),
|
||||
v.getDevInfo().getOs(),
|
||||
v.getDevInfo().getKernel(),
|
||||
v.getDevInfo().getArch(),
|
||||
v.getDevInfo().getMemory(),
|
||||
v.getDevInfo().getFreeMemory(),
|
||||
v.getDevInfo().getCpuUsed(),
|
||||
ErrorCode.ERR_OK
|
||||
)));
|
||||
|
||||
List<String> unExists = Arrays.stream(reqInfo.getId())
|
||||
.filter(v -> v.length() > 0)
|
||||
.filter(v -> !StringUtils.isNumeric(v)
|
||||
|| valuableData.stream().noneMatch(k -> k.getId() == Long.parseLong(v)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
unExists.forEach(v -> {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
rspInfo.getItems().add(new DeviceInfoData(v, ErrorCode.ERR_NOSUCHDEVICE));
|
||||
});
|
||||
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||
}
|
||||
|
@ -269,7 +264,6 @@ public class DisposeNodeInfoController {
|
|||
@PostMapping("/capacity")
|
||||
@ResponseBody
|
||||
@ApiOperation("处置设备处置能力")
|
||||
//@JsonView(DisposeCapacity.CapacityView.class)
|
||||
public ProtocolRespDTO getCapacity(@RequestBody ProtocolReqDTO mr,
|
||||
@RequestHeader HttpHeaders headers)
|
||||
throws JsonProcessingException {
|
||||
|
@ -282,46 +276,47 @@ public class DisposeNodeInfoController {
|
|||
|
||||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
DeviceCapacityRsp rspInfo = new DeviceCapacityRsp();
|
||||
rspInfo.setItems(new ArrayList<>());
|
||||
|
||||
if (reqInfo.getId().length == 0) {
|
||||
List<DisposeDevice> devList = disposeNodeManager.getAllDisposeDevice();
|
||||
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
|
||||
.stream()
|
||||
.filter(v -> reqInfo.getId().length == 0
|
||||
|| reqInfo.getId()[0].length() == 0
|
||||
|| Arrays.stream(reqInfo.getId()).anyMatch(s -> s.equals(v.getId().toString())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (devList != null && devList.size() > 0) {
|
||||
devList.forEach(v -> {
|
||||
DeviceCapacityData cpData = new DeviceCapacityData(v.getDevCaps());
|
||||
cpData.setId(v.getId().toString());
|
||||
cpData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
cpData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
rspInfo.getItems().add(cpData);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
for (String v : reqInfo.getId()) {
|
||||
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
|
||||
if (dev != null && dev.getId().equals(Long.valueOf(v))) {
|
||||
DeviceCapacityData cpData = new DeviceCapacityData(dev.getDevCaps());
|
||||
cpData.setId(dev.getId().toString());
|
||||
cpData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
cpData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
rspInfo.getItems().add(cpData);
|
||||
} else {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
DeviceCapacityData cpData = new DeviceCapacityData();
|
||||
cpData.setId(v);
|
||||
cpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
||||
cpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
rspInfo.getItems().add(cpData);
|
||||
}
|
||||
}
|
||||
}
|
||||
valuableData.forEach(v -> {
|
||||
DeviceCapacityData cpData = new DeviceCapacityData(v.getDevCaps());
|
||||
cpData.setId(v.getId().toString());
|
||||
cpData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
cpData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
rspInfo.getItems().add(cpData);
|
||||
});
|
||||
|
||||
String rspMessage = new ObjectMapper()
|
||||
.writerWithView(DisposeCapacity.CapacityView.class)
|
||||
.writeValueAsString(rspInfo);
|
||||
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspMessage, ConstValue.Protocol.CRYPTO_NONE);
|
||||
List<String> unExists = Arrays.stream(reqInfo.getId())
|
||||
.filter(v -> v.length() > 0)
|
||||
.filter(v -> !StringUtils.isNumeric(v)
|
||||
|| valuableData.stream().noneMatch(k -> k.getId() == Long.parseLong(v)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
unExists.forEach(v -> {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
DeviceCapacityData cpData = new DeviceCapacityData();
|
||||
cpData.setId(v);
|
||||
cpData.setCapacity(null);
|
||||
cpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
||||
cpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
rspInfo.getItems().add(cpData);
|
||||
});
|
||||
|
||||
return ProtocolRespDTO.result(err, rspInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -335,7 +330,6 @@ public class DisposeNodeInfoController {
|
|||
@PostMapping("/protected_ip")
|
||||
@ResponseBody
|
||||
@ApiOperation("处置设备防护IP")
|
||||
//@JsonView(DisposeCapacity.CapacityView.class)
|
||||
public ProtocolRespDTO getProtectedIp(@RequestBody ProtocolReqDTO mr,
|
||||
@RequestHeader HttpHeaders headers)
|
||||
throws JsonProcessingException {
|
||||
|
@ -348,45 +342,46 @@ public class DisposeNodeInfoController {
|
|||
|
||||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
DeviceCapacityRsp rspInfo = new DeviceCapacityRsp();
|
||||
rspInfo.setItems(new ArrayList<>());
|
||||
|
||||
if (reqInfo.getId().length == 0) {
|
||||
List<DisposeDevice> devList = disposeNodeManager.getAllDisposeDevice();
|
||||
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
|
||||
.stream()
|
||||
.filter(v -> reqInfo.getId().length == 0
|
||||
|| reqInfo.getId()[0].length() == 0
|
||||
|| Arrays.stream(reqInfo.getId()).anyMatch(s -> s.equals(v.getId().toString())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (devList != null && devList.size() > 0) {
|
||||
devList.forEach(v -> {
|
||||
DeviceCapacityData cpData = new DeviceCapacityData(v.getDevCaps());
|
||||
cpData.setId(v.getId().toString());
|
||||
cpData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
cpData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
rspInfo.getItems().add(cpData);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
for (String v : reqInfo.getId()) {
|
||||
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
|
||||
if (dev != null && dev.getId().equals(Long.valueOf(v))) {
|
||||
DeviceCapacityData cpData = new DeviceCapacityData(dev.getDevCaps());
|
||||
cpData.setId(dev.getId().toString());
|
||||
cpData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
cpData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
rspInfo.getItems().add(cpData);
|
||||
} else {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
DeviceCapacityData cpData = new DeviceCapacityData();
|
||||
cpData.setId(v);
|
||||
cpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
||||
cpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
rspInfo.getItems().add(cpData);
|
||||
}
|
||||
}
|
||||
}
|
||||
valuableData.forEach(v -> {
|
||||
DeviceCapacityData cpData = new DeviceCapacityData(v.getDevCaps());
|
||||
cpData.setId(v.getId().toString());
|
||||
cpData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
cpData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
rspInfo.getItems().add(cpData);
|
||||
});
|
||||
|
||||
String rspMessage = new ObjectMapper().writerWithView(DisposeCapacity.DependIpView.class)
|
||||
.writeValueAsString(rspInfo);
|
||||
List<String> unExists = Arrays.stream(reqInfo.getId())
|
||||
.filter(v -> v.length() > 0)
|
||||
.filter(v -> !StringUtils.isNumeric(v)
|
||||
|| valuableData.stream().noneMatch(k -> k.getId() == Long.parseLong(v)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspMessage, ConstValue.Protocol.CRYPTO_NONE);
|
||||
unExists.forEach(v -> {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
DeviceCapacityData cpData = new DeviceCapacityData();
|
||||
cpData.setId(v);
|
||||
cpData.setCapacity(null);
|
||||
cpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
||||
cpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
rspInfo.getItems().add(cpData);
|
||||
});
|
||||
|
||||
return ProtocolRespDTO.result(err, rspInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -400,13 +395,9 @@ public class DisposeNodeInfoController {
|
|||
@PostMapping("/node_list")
|
||||
@ResponseBody
|
||||
@ApiOperation("处置设备列表")
|
||||
//@JsonView(DisposeCapacity.CapacityView.class)
|
||||
public ProtocolRespDTO getDisposeNodeList(@RequestBody ProtocolReqDTO mr,
|
||||
@RequestHeader HttpHeaders headers)
|
||||
throws JsonProcessingException {
|
||||
boolean isGetAllNode = false;
|
||||
IDArrayReq reqInfo = null;
|
||||
|
||||
ErrorCode err = mr.verifyRequest(headers);
|
||||
|
||||
if (err != ErrorCode.ERR_OK) {
|
||||
|
@ -414,60 +405,60 @@ public class DisposeNodeInfoController {
|
|||
return ProtocolRespDTO.result(err);
|
||||
}
|
||||
|
||||
if (mr.getMsgContent() == null || mr.getMsgContent()
|
||||
.length() == 0) {
|
||||
isGetAllNode = true;
|
||||
} else {
|
||||
reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
if (reqInfo == null || reqInfo.getId() == null || reqInfo.getId().length == 0) {
|
||||
isGetAllNode = true;
|
||||
}
|
||||
if (mr.getMsgContent() == null || mr.getMsgContent().length() == 0) {
|
||||
log.error("ProtocolReqDTO msgContent error");
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
DisposeNodeListRsp rspInfo = new DisposeNodeListRsp();
|
||||
rspInfo.setItems(new ArrayList<>());
|
||||
|
||||
if (isGetAllNode) {
|
||||
List<DisposeDevice> devList = disposeNodeManager.getAllDisposeDevice();
|
||||
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
|
||||
.stream()
|
||||
.filter(v -> reqInfo.getId().length == 0
|
||||
|| reqInfo.getId()[0].length() == 0
|
||||
|| Arrays.stream(reqInfo.getId()).anyMatch(s -> s.equals(v.getId().toString())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (devList != null && devList.size() > 0) {
|
||||
devList.forEach(v -> {
|
||||
DisposeNodeData dpData = DisposeNodeData.builder()
|
||||
.type(v.getType())
|
||||
.name(v.getName())
|
||||
.ip(v.getIpAddr())
|
||||
.build();
|
||||
valuableData.forEach(v -> {
|
||||
DisposeNodeData dpData = DisposeNodeData.builder()
|
||||
.type(v.getType())
|
||||
.name(v.getName())
|
||||
.ip(v.getIpAddr())
|
||||
.build();
|
||||
|
||||
dpData.setId(v.getId().toString());
|
||||
dpData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
dpData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
rspInfo.getItems().add(dpData);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
for (String v : reqInfo.getId()) {
|
||||
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
|
||||
if (dev != null && dev.getId().equals(Long.valueOf(v))) {
|
||||
DisposeNodeData dpData = DisposeNodeData.builder()
|
||||
.type(dev.getType())
|
||||
.name(dev.getName())
|
||||
.ip(dev.getIpAddr())
|
||||
.build();
|
||||
dpData.setId(dev.getId().toString());
|
||||
dpData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
dpData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
rspInfo.getItems().add(dpData);
|
||||
} else {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
DisposeNodeData dpData = new DisposeNodeData();
|
||||
dpData.setId(v);
|
||||
dpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
||||
dpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
rspInfo.getItems().add(dpData);
|
||||
}
|
||||
}
|
||||
dpData.setId(v.getId().toString());
|
||||
dpData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
dpData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
rspInfo.getItems().add(dpData);
|
||||
});
|
||||
|
||||
if (reqInfo.getId().length != 0) {
|
||||
List<String> unExists = Arrays.stream(reqInfo.getId())
|
||||
.filter(v -> v.length() > 0)
|
||||
.filter(v -> !StringUtils.isNumeric(v)
|
||||
|| valuableData.stream().noneMatch(k -> k.getId() == Long.parseLong(v)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
unExists.forEach(v -> {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
DisposeNodeData dpData = new DisposeNodeData();
|
||||
dpData.setId(v);
|
||||
dpData.setCapacity(null);
|
||||
dpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
||||
dpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
rspInfo.getItems().add(dpData);
|
||||
});
|
||||
}
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||
|
||||
return ProtocolRespDTO.result(err, rspInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -493,61 +484,50 @@ public class DisposeNodeInfoController {
|
|||
|
||||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
DisposeNodeListRsp rspInfo = new DisposeNodeListRsp();
|
||||
rspInfo.setItems(new ArrayList<>());
|
||||
|
||||
if (reqInfo.getId().length == 0) {
|
||||
List<DisposeDevice> devList = disposeNodeManager.getAllDisposeDevice();
|
||||
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
|
||||
.stream()
|
||||
.filter(v -> reqInfo.getId().length == 0
|
||||
|| reqInfo.getId()[0].length() == 0
|
||||
|| Arrays.stream(reqInfo.getId()).anyMatch(s -> s.equals(v.getId().toString())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (devList != null && devList.size() > 0) {
|
||||
devList.forEach(v -> {
|
||||
DisposeNodeData dpData = new DisposeNodeData(
|
||||
v.getType(),
|
||||
v.getName(),
|
||||
v.getIpAddr(),
|
||||
v.getAreaCode(),
|
||||
v.getManufacturer(),
|
||||
v.getModel(),
|
||||
v.getVersion(),
|
||||
v.getReadme(),
|
||||
v.getDevCaps()
|
||||
);
|
||||
dpData.setId(v.getId().toString());
|
||||
dpData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
dpData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
rspInfo.getItems().add(dpData);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
for (String v : reqInfo.getId()) {
|
||||
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
|
||||
if (dev != null && dev.getId().equals(Long.valueOf(v))) {
|
||||
DisposeNodeData dpData = new DisposeNodeData(
|
||||
dev.getType(),
|
||||
dev.getName(),
|
||||
dev.getIpAddr(),
|
||||
dev.getAreaCode(),
|
||||
dev.getManufacturer(),
|
||||
dev.getModel(),
|
||||
dev.getVersion(),
|
||||
dev.getReadme(),
|
||||
dev.getDevCaps()
|
||||
);
|
||||
dpData.setId(dev.getId().toString());
|
||||
dpData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
dpData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
rspInfo.getItems().add(dpData);
|
||||
} else {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
DisposeNodeData dpData = new DisposeNodeData();
|
||||
dpData.setId(v);
|
||||
dpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
||||
dpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
rspInfo.getItems().add(dpData);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||
valuableData.forEach(v -> {
|
||||
DisposeNodeData dpData = new DisposeNodeData(
|
||||
v.getType(), v.getName(), v.getIpAddr(),
|
||||
v.getAreaCode(), v.getManufacturer(), v.getModel(),
|
||||
v.getVersion(), v.getReadme(), v.getDevCaps());
|
||||
|
||||
dpData.setId(v.getId().toString());
|
||||
dpData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
dpData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
rspInfo.getItems().add(dpData);
|
||||
});
|
||||
|
||||
List<String> unExists = Arrays.stream(reqInfo.getId())
|
||||
.filter(v -> v.length() > 0)
|
||||
.filter(v -> !StringUtils.isNumeric(v)
|
||||
|| valuableData.stream().noneMatch(k -> k.getId() == Long.parseLong(v)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
unExists.forEach(v -> {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
DisposeNodeData dpData = new DisposeNodeData();
|
||||
dpData.setId(v);
|
||||
dpData.setCapacity(null);
|
||||
dpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
||||
dpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
rspInfo.getItems().add(dpData);
|
||||
});
|
||||
|
||||
return ProtocolRespDTO.result(err, rspInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -572,11 +552,18 @@ public class DisposeNodeInfoController {
|
|||
}
|
||||
|
||||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
NodeTaskRsp rspInfo = new NodeTaskRsp();
|
||||
|
||||
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
|
||||
.stream()
|
||||
.filter(v -> reqInfo.getId().length == 0
|
||||
|| reqInfo.getId()[0].length() == 0
|
||||
|| Arrays.stream(reqInfo.getId()).anyMatch(s -> s.equals(v.getId().toString())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
@ -584,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 {
|
||||
|
@ -608,24 +594,27 @@ public class DisposeNodeInfoController {
|
|||
.build();
|
||||
|
||||
taskData.getTaskArray().add(taskInfoData);
|
||||
taskData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (reqInfo.getId().length != 0) {
|
||||
List<String> unExists = Arrays.stream(reqInfo.getId())
|
||||
.filter(v -> valuableData.stream().noneMatch(k -> k.getId() == Long.parseLong(v)))
|
||||
.collect(Collectors.toList());
|
||||
List<String> unExists = Arrays.stream(reqInfo.getId())
|
||||
.filter(v -> v.length() > 0)
|
||||
.filter(v -> !StringUtils.isNumeric(v)
|
||||
|| valuableData.stream().noneMatch(k -> k.getId() == Long.parseLong(v)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
unExists.forEach(v -> {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
NodeTaskData taskData = new NodeTaskData();
|
||||
rspInfo.getItems().add(taskData);
|
||||
taskData.setId(v);
|
||||
taskData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
});
|
||||
}
|
||||
unExists.forEach(v -> {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
NodeTaskData taskData = new NodeTaskData();
|
||||
rspInfo.getItems().add(taskData);
|
||||
taskData.setId(v);
|
||||
taskData.setTaskArray(null);
|
||||
taskData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
});
|
||||
|
||||
return ProtocolRespDTO.result(err, rspInfo);
|
||||
}
|
||||
|
@ -652,11 +641,18 @@ public class DisposeNodeInfoController {
|
|||
}
|
||||
|
||||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
NodeTaskRsp rspInfo = new NodeTaskRsp();
|
||||
|
||||
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
|
||||
.stream()
|
||||
.filter(v -> reqInfo.getId().length == 0
|
||||
|| reqInfo.getId()[0].length() == 0
|
||||
|| Arrays.stream(reqInfo.getId()).anyMatch(s -> s.equals(v.getId().toString())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
@ -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,24 +684,27 @@ public class DisposeNodeInfoController {
|
|||
.build();
|
||||
|
||||
taskData.getTaskArray().add(taskInfoData);
|
||||
taskData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (reqInfo.getId().length != 0) {
|
||||
List<String> unExists = Arrays.stream(reqInfo.getId())
|
||||
.filter(v -> valuableData.stream().noneMatch(k -> k.getId() == Long.parseLong(v)))
|
||||
.collect(Collectors.toList());
|
||||
List<String> unExists = Arrays.stream(reqInfo.getId())
|
||||
.filter(v -> v.length() > 0)
|
||||
.filter(v -> !StringUtils.isNumeric(v)
|
||||
|| valuableData.stream().noneMatch(k -> k.getId() == Long.parseLong(v)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
unExists.forEach(v -> {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
NodeTaskData taskData = new NodeTaskData();
|
||||
rspInfo.getItems().add(taskData);
|
||||
taskData.setId(v);
|
||||
taskData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
});
|
||||
}
|
||||
unExists.forEach(v -> {
|
||||
log.error("device not exist, deviceId:{}", v);
|
||||
NodeTaskData taskData = new NodeTaskData();
|
||||
rspInfo.getItems().add(taskData);
|
||||
taskData.setId(v);
|
||||
taskData.setTaskArray(null);
|
||||
taskData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
});
|
||||
|
||||
return ProtocolRespDTO.result(err, rspInfo);
|
||||
}
|
||||
|
|
|
@ -5,13 +5,14 @@ import com.dispose.manager.UserAccountCacheManager;
|
|||
import com.dispose.pojo.dto.ProtocolReqDTO;
|
||||
import com.dispose.pojo.dto.ProtocolRespDTO;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.po.MReturnType;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.pojo.vo.common.IDArrayReq;
|
||||
import com.dispose.pojo.vo.common.IDReturnStatus;
|
||||
import com.dispose.pojo.vo.device.AddNodeReq;
|
||||
import com.dispose.pojo.vo.device.AddNodeRetData;
|
||||
import com.dispose.pojo.vo.device.AddNodeRsp;
|
||||
import com.dispose.service.DisposeNodeManager;
|
||||
import com.dispose.service.TaskService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
@ -28,10 +29,14 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* The type Dispose node manager controller.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "/manager")
|
||||
|
@ -39,18 +44,15 @@ import java.util.List;
|
|||
@Api(value = "抗DDoS处置平台能力节点管理接口", tags = "抗DDoS处置平台能力节点管理接口")
|
||||
@Component
|
||||
public class DisposeNodeManagerController {
|
||||
/**
|
||||
* The Dispose node manager.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeNodeManager disposeNodeManager;
|
||||
|
||||
/**
|
||||
* The User account cache manager.
|
||||
*/
|
||||
@Resource
|
||||
private UserAccountCacheManager userAccountCacheManager;
|
||||
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
|
||||
/**
|
||||
* Add dispose node protocol resp dto.
|
||||
*
|
||||
|
@ -93,12 +95,12 @@ public class DisposeNodeManagerController {
|
|||
.model(v.getModel())
|
||||
.version(v.getVersion())
|
||||
.build();
|
||||
MReturnType<ErrorCode, String> ret;
|
||||
MulReturnType<ErrorCode, String> ret;
|
||||
try {
|
||||
ret = disposeNodeManager.addNewDisposeDevice(dev);
|
||||
} catch (Exception ex) {
|
||||
log.error(ex.getMessage());
|
||||
ret = new MReturnType<>(ErrorCode.ERR_NOSUCHDEVICE, v.getIpAddr());
|
||||
ret = new MulReturnType<>(ErrorCode.ERR_NOSUCHDEVICE, v.getIpAddr());
|
||||
}
|
||||
|
||||
AddNodeRetData retStatus = new AddNodeRetData();
|
||||
|
@ -141,13 +143,20 @@ public class DisposeNodeManagerController {
|
|||
}
|
||||
|
||||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
List<IDReturnStatus> rspInfo = new ArrayList<>();
|
||||
|
||||
if (reqInfo == null || reqInfo.getId().length > 1) {
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
if (reqInfo.getId().length > 1
|
||||
|| Arrays.stream(reqInfo.getId()).anyMatch(v -> v.length() == 0)) {
|
||||
log.error("Prohibit deleting multiple devices at the same time");
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_REMOVEMORE);
|
||||
}
|
||||
|
||||
List<IDReturnStatus> rspInfo = new ArrayList<>();
|
||||
|
||||
IDReturnStatus retItem = new IDReturnStatus();
|
||||
retItem.setId(reqInfo.getId()[0]);
|
||||
|
||||
|
|
|
@ -4,11 +4,12 @@ import com.dispose.common.DeviceCapacity;
|
|||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.common.FlowDirection;
|
||||
import com.dispose.common.Helper;
|
||||
import com.dispose.common.IPAddrType;
|
||||
import com.dispose.manager.TaskCacheManager;
|
||||
import com.dispose.pojo.dto.ProtocolReqDTO;
|
||||
import com.dispose.pojo.dto.ProtocolRespDTO;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.po.MReturnType;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.pojo.vo.common.IDArrayReq;
|
||||
import com.dispose.pojo.vo.common.TaskInfoData;
|
||||
import com.dispose.pojo.vo.common.TaskInfoDetail;
|
||||
|
@ -38,13 +39,19 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The type Dispose task controller.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "/task")
|
||||
|
@ -52,30 +59,24 @@ import java.util.stream.Collectors;
|
|||
@Api(value = "抗DDoS处置平台处置任务接口", tags = "抗DDoS处置平台处置任务接口")
|
||||
@Component
|
||||
public class DisposeTaskController {
|
||||
/**
|
||||
* The Dispose node manager.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeNodeManager disposeNodeManager;
|
||||
|
||||
/**
|
||||
* The Task service.
|
||||
*/
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
|
||||
/**
|
||||
* The Task cache manager.
|
||||
*/
|
||||
@Resource
|
||||
private TaskCacheManager taskCacheManager;
|
||||
|
||||
/**
|
||||
* The User account service.
|
||||
*/
|
||||
@Resource
|
||||
private UserAccountService userAccountService;
|
||||
|
||||
private static Long convertTimeToLong(String time) {
|
||||
DateTimeFormatter ftf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
LocalDateTime parse = LocalDateTime.parse(time, ftf);
|
||||
return LocalDateTime.from(parse).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
}
|
||||
|
||||
/**
|
||||
* Task start protocol resp dto.
|
||||
*
|
||||
|
@ -89,7 +90,7 @@ public class DisposeTaskController {
|
|||
@ApiOperation("启动处置任务")
|
||||
public ProtocolRespDTO taskStart(@RequestBody @Valid ProtocolReqDTO mr,
|
||||
@RequestHeader HttpHeaders headers)
|
||||
throws JsonProcessingException {
|
||||
throws JsonProcessingException {
|
||||
ErrorCode err = mr.verifyRequest(headers);
|
||||
|
||||
if (err != ErrorCode.ERR_OK) {
|
||||
|
@ -99,27 +100,52 @@ public class DisposeTaskController {
|
|||
|
||||
StartTaskReq reqInfo = mr.getRequestObject(StartTaskReq.class);
|
||||
|
||||
if (reqInfo.getId() == null || reqInfo.getId().length() == 0) {
|
||||
log.error("Request id params error, error:{} --> {}", mr.getMsgContent(), reqInfo.getId());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
if (reqInfo.getType() == null
|
||||
|| reqInfo.getType() < DeviceCapacity.ALLCAPACITY.getCode()
|
||||
|| reqInfo.getType() > DeviceCapacity.DETECIVE.getCode()) {
|
||||
log.error("Request type params error, error:{} --> {}", mr.getMsgContent(), reqInfo.getType());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
if (reqInfo.getDisposeIp() == null || reqInfo.getDisposeIp().length() == 0
|
||||
|| !IPAddrType.isIpAddress(reqInfo.getDisposeIp())) {
|
||||
log.error("Request dispose ip params error, error:{} --> {}", mr.getMsgContent(), reqInfo.getDisposeIp());
|
||||
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();
|
||||
|
||||
TaskInfoDetail task = TaskInfoDetail.builder()
|
||||
.deviceId(Long.valueOf(reqInfo.getId()))
|
||||
.accountId(userAccountService.getUserByToken(mr.getAuthToken()).getId())
|
||||
.type(reqInfo.getType())
|
||||
.disposeIp(reqInfo.getDisposeIp())
|
||||
.planEndTime(String.valueOf(reqInfo.getDisposeTime() == null ? "" : reqInfo.getDisposeTime()))
|
||||
.flowDirection(reqInfo.getFlowDirection() != null ? reqInfo.getFlowDirection() : FlowDirection.DIRECTION_TWOWAY.getCode())
|
||||
.flowBandWidth(reqInfo.getFlowBandwidth() != null ? reqInfo.getFlowBandwidth() : 1024)
|
||||
.attackType(Helper.attackArrayToString(reqInfo.getAttackType()))
|
||||
.build();
|
||||
.deviceId(Long.valueOf(reqInfo.getId()))
|
||||
.accountId(userAccountService.getUserByToken(mr.getAuthToken()).getId())
|
||||
.type(reqInfo.getType())
|
||||
.disposeIp(reqInfo.getDisposeIp())
|
||||
.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()))
|
||||
.build();
|
||||
|
||||
MReturnType<ErrorCode, Long> ret = taskService.createTask(task);
|
||||
MulReturnType<ErrorCode, Long> ret = taskService.createTask(task);
|
||||
|
||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||
TaskInfoDetail tf = taskCacheManager.getTaskById(ret.getSecondParam());
|
||||
rspInfo.setId(String.valueOf(tf.getDeviceId()));
|
||||
rspInfo.setTaskId(String.valueOf(ret.getSecondParam()));
|
||||
rspInfo.setExpireTime(convertTimeToLong(tf.getPlanEndTime()));
|
||||
} else {
|
||||
log.error("Failed to create task, error:{}", ret.getFirstParam().getMsg());
|
||||
rspInfo.setId(String.valueOf(reqInfo.getId()));
|
||||
}
|
||||
|
||||
rspInfo.setStatus(ret.getFirstParam().getCode());
|
||||
|
@ -141,7 +167,7 @@ public class DisposeTaskController {
|
|||
@ApiOperation("停止处置任务")
|
||||
public ProtocolRespDTO taskStop(@RequestBody ProtocolReqDTO mr,
|
||||
@RequestHeader HttpHeaders headers)
|
||||
throws JsonProcessingException {
|
||||
throws JsonProcessingException {
|
||||
ErrorCode err = mr.verifyRequest(headers);
|
||||
|
||||
if (err != ErrorCode.ERR_OK) {
|
||||
|
@ -150,15 +176,24 @@ public class DisposeTaskController {
|
|||
}
|
||||
|
||||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
TaskInfoRsp rspInfo = new TaskInfoRsp();
|
||||
|
||||
Arrays.stream(reqInfo.getTaskId()).forEach(v -> {
|
||||
TaskInfoData taskData = TaskInfoData.builder().type(DeviceCapacity.CLEANUP.getCode()).build();
|
||||
|
||||
List<MReturnType<ErrorCode, TaskInfoDetail>> ret = taskService.stopTaskByTaskId(Long.parseLong(v));
|
||||
List<MulReturnType<ErrorCode, TaskInfoDetail>> ret = taskService.stopTaskByTaskId(Long.parseLong(v));
|
||||
|
||||
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);
|
||||
|
@ -171,8 +206,7 @@ public class DisposeTaskController {
|
|||
taskData.setTaskId(String.valueOf(taskInfo.getId()));
|
||||
taskData.setType(taskInfo.getType());
|
||||
taskData.setDisposeIp(taskInfo.getDisposeIp());
|
||||
taskData.setLeftTime(Math.abs(Helper.getTimestampDiffNow(taskInfo.getBeginTime())
|
||||
- Helper.getTimestampDiffNow(taskInfo.getPlanEndTime())) / 60);
|
||||
taskData.setLeftTime(Math.abs(Helper.getTimestampDiffNow(taskInfo.getPlanEndTime())) / 60);
|
||||
|
||||
taskData.setStatus(retError.getCode());
|
||||
taskData.setMessage(retError.getMsg());
|
||||
|
@ -180,6 +214,7 @@ public class DisposeTaskController {
|
|||
rspInfo.getItems().add(taskData);
|
||||
} else {
|
||||
log.error("Stop task: taskId:{}, error:{}", v, k.getFirstParam().getMsg());
|
||||
taskData.setTaskId(v);
|
||||
taskData.setStatus(k.getFirstParam().getCode());
|
||||
taskData.setMessage(k.getFirstParam().getMsg());
|
||||
}
|
||||
|
@ -203,7 +238,7 @@ public class DisposeTaskController {
|
|||
@ApiOperation("根据处置IP停止处置任务")
|
||||
public ProtocolRespDTO taskStopByIp(@RequestBody ProtocolReqDTO mr,
|
||||
@RequestHeader HttpHeaders headers)
|
||||
throws JsonProcessingException {
|
||||
throws JsonProcessingException {
|
||||
|
||||
ErrorCode err = mr.verifyRequest(headers);
|
||||
|
||||
|
@ -213,15 +248,37 @@ public class DisposeTaskController {
|
|||
}
|
||||
|
||||
StopTaskReq reqInfo = mr.getRequestObject(StopTaskReq.class);
|
||||
|
||||
if (reqInfo.getItems().stream().anyMatch(v -> v.getId() == null
|
||||
|| v.getId().length() == 0)) {
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
if (reqInfo.getItems().stream().anyMatch(v -> v.getType() == null
|
||||
|| v.getType() < DeviceCapacity.ALLCAPACITY.getCode()
|
||||
|| v.getType() > DeviceCapacity.DETECIVE.getCode())) {
|
||||
log.error("Request type params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
if (reqInfo.getItems().stream().anyMatch(v -> v.getDisposeIp() == null
|
||||
|| v.getDisposeIp().length() == 0
|
||||
|| !IPAddrType.isIpAddress(v.getDisposeIp()))) {
|
||||
log.error("Request ip params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
TaskInfoRsp rspInfo = new TaskInfoRsp();
|
||||
|
||||
reqInfo.getItems().forEach(v -> {
|
||||
TaskInfoData taskData = TaskInfoData.builder().type(v.getType()).build();
|
||||
|
||||
List<MReturnType<ErrorCode, TaskInfoDetail>> ret = taskService.stopTaskByDisposeIp(Long.parseLong(v.getId()), v.getType(), v.getDisposeIp());
|
||||
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);
|
||||
|
@ -234,14 +291,18 @@ public class DisposeTaskController {
|
|||
taskData.setTaskId(String.valueOf(taskInfo.getId()));
|
||||
taskData.setType(taskInfo.getType());
|
||||
taskData.setDisposeIp(taskInfo.getDisposeIp());
|
||||
taskData.setLeftTime((Math.abs(Helper.getTimestampDiffNow(taskInfo.getBeginTime())
|
||||
- Helper.getTimestampDiffNow(taskInfo.getPlanEndTime()))) / 60);
|
||||
taskData.setLeftTime(Math.abs(Helper.getTimestampDiffNow(taskInfo.getPlanEndTime())) / 60);
|
||||
|
||||
taskData.setStatus(retError.getCode());
|
||||
taskData.setMessage(retError.getMsg());
|
||||
} else {
|
||||
log.error("Stop task: taskId:{}, type:{}, disposeIp:{}, error:{}", v.getId(), v.getType(), v.getDisposeIp(),
|
||||
k.getFirstParam().getMsg());
|
||||
k.getFirstParam().getMsg());
|
||||
if (k.getFirstParam() == ErrorCode.ERR_NOSUCHTASK) {
|
||||
taskData.setDisposeIp(v.getDisposeIp());
|
||||
} else if (k.getFirstParam() == ErrorCode.ERR_NOSUCHDEVICE) {
|
||||
taskData.setId(v.getId());
|
||||
}
|
||||
taskData.setStatus(k.getFirstParam().getCode());
|
||||
taskData.setMessage(k.getFirstParam().getMsg());
|
||||
}
|
||||
|
@ -267,7 +328,7 @@ public class DisposeTaskController {
|
|||
@ApiOperation("停止处置节点处置任务")
|
||||
public ProtocolRespDTO taskStopAllOfDisposeNode(@RequestBody ProtocolReqDTO mr,
|
||||
@RequestHeader HttpHeaders headers)
|
||||
throws JsonProcessingException {
|
||||
throws JsonProcessingException {
|
||||
ErrorCode err = mr.verifyRequest(headers);
|
||||
|
||||
if (err != ErrorCode.ERR_OK) {
|
||||
|
@ -278,12 +339,26 @@ public class DisposeTaskController {
|
|||
StopTaskReq reqInfo = mr.getRequestObject(StopTaskReq.class);
|
||||
TaskInfoRsp rspInfo = new TaskInfoRsp();
|
||||
|
||||
if (reqInfo.getItems().stream().anyMatch(v -> v.getId() == null
|
||||
|| v.getId().length() == 0)) {
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
if (reqInfo.getItems().stream().anyMatch(v -> v.getType() == null
|
||||
|| v.getType() < DeviceCapacity.ALLCAPACITY.getCode()
|
||||
|| v.getType() > DeviceCapacity.DETECIVE.getCode())) {
|
||||
log.error("Request type params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
reqInfo.getItems().forEach(v -> {
|
||||
List<MReturnType<ErrorCode, TaskInfoDetail>> ret = taskService.stopTaskByDisposeNode(Long.parseLong(v.getId()), v.getType());
|
||||
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);
|
||||
|
@ -297,8 +372,7 @@ public class DisposeTaskController {
|
|||
taskData.setTaskId(String.valueOf(taskInfo.getId()));
|
||||
taskData.setType(taskInfo.getType());
|
||||
taskData.setDisposeIp(taskInfo.getDisposeIp());
|
||||
taskData.setLeftTime((Math.abs(Helper.getTimestampDiffNow(taskInfo.getBeginTime())
|
||||
- Helper.getTimestampDiffNow(taskInfo.getPlanEndTime()))) / 60);
|
||||
taskData.setLeftTime(Math.abs(Helper.getTimestampDiffNow(taskInfo.getPlanEndTime())) / 60);
|
||||
|
||||
taskData.setStatus(retError.getCode());
|
||||
taskData.setMessage(retError.getMsg());
|
||||
|
@ -306,8 +380,9 @@ public class DisposeTaskController {
|
|||
rspInfo.getItems().add(taskData);
|
||||
} else {
|
||||
log.error("Stop task: deviceId:{}, type:{}, error:{}", v.getId(),
|
||||
v.getType(), k.getFirstParam().getMsg());
|
||||
v.getType(), k.getFirstParam().getMsg());
|
||||
TaskInfoData taskData = TaskInfoData.builder().type(v.getType()).build();
|
||||
taskData.setId(v.getId());
|
||||
taskData.setStatus(k.getFirstParam().getCode());
|
||||
taskData.setMessage(k.getFirstParam().getMsg());
|
||||
}
|
||||
|
@ -331,7 +406,7 @@ public class DisposeTaskController {
|
|||
@ApiOperation("停止所有处置任务")
|
||||
public ProtocolRespDTO taskStopAll(@RequestBody ProtocolReqDTO mr,
|
||||
@RequestHeader HttpHeaders headers)
|
||||
throws JsonProcessingException {
|
||||
throws JsonProcessingException {
|
||||
|
||||
ErrorCode err = mr.verifyRequest(headers);
|
||||
|
||||
|
@ -341,9 +416,17 @@ public class DisposeTaskController {
|
|||
}
|
||||
|
||||
StopTaskData reqInfo = mr.getRequestObject(StopTaskData.class);
|
||||
|
||||
if (reqInfo.getType() == null
|
||||
|| reqInfo.getType() < DeviceCapacity.ALLCAPACITY.getCode()
|
||||
|| reqInfo.getType() > DeviceCapacity.DETECIVE.getCode()) {
|
||||
log.error("Request type params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
TaskInfoRsp rspInfo = new TaskInfoRsp();
|
||||
|
||||
List<MReturnType<ErrorCode, TaskInfoDetail>> ret = taskService.stopTaskByType(reqInfo.getType());
|
||||
List<MulReturnType<ErrorCode, TaskInfoDetail>> ret = taskService.stopTaskByType(reqInfo.getType());
|
||||
|
||||
if (ret.size() == 0) {
|
||||
log.error("No such dispose task");
|
||||
|
@ -361,8 +444,7 @@ public class DisposeTaskController {
|
|||
taskData.setTaskId(String.valueOf(taskInfo.getId()));
|
||||
taskData.setType(taskInfo.getType());
|
||||
taskData.setDisposeIp(taskInfo.getDisposeIp());
|
||||
taskData.setLeftTime((Math.abs(Helper.getTimestampDiffNow(taskInfo.getBeginTime())
|
||||
- Helper.getTimestampDiffNow(taskInfo.getPlanEndTime()))) / 60);
|
||||
taskData.setLeftTime(Math.abs(Helper.getTimestampDiffNow(taskInfo.getPlanEndTime())) / 60);
|
||||
|
||||
taskData.setStatus(retError.getCode());
|
||||
taskData.setMessage(retError.getMsg());
|
||||
|
@ -371,6 +453,7 @@ public class DisposeTaskController {
|
|||
} else {
|
||||
log.error("No task to stop: error:{}", k.getFirstParam().getMsg());
|
||||
TaskInfoData taskData = TaskInfoData.builder().type(reqInfo.getType()).build();
|
||||
taskData.setType(reqInfo.getType());
|
||||
taskData.setStatus(k.getFirstParam().getCode());
|
||||
taskData.setMessage(k.getFirstParam().getMsg());
|
||||
}
|
||||
|
@ -402,13 +485,27 @@ public class DisposeTaskController {
|
|||
}
|
||||
|
||||
GetTaskReq reqInfo = mr.getRequestObject(GetTaskReq.class);
|
||||
|
||||
if (reqInfo.getId() == null || Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request id params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
if (reqInfo.getType() == null
|
||||
|| reqInfo.getType() < DeviceCapacity.ALLCAPACITY.getCode()
|
||||
|| reqInfo.getType() > DeviceCapacity.DETECIVE.getCode()) {
|
||||
log.error("Request type params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
NodeTaskRsp rspInfo = new NodeTaskRsp();
|
||||
|
||||
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
|
||||
.stream()
|
||||
.filter(v -> reqInfo.getId().length == 0
|
||||
|| Arrays.stream(reqInfo.getId()).anyMatch(s -> s.equals(v.getId().toString())))
|
||||
.collect(Collectors.toList());
|
||||
.stream()
|
||||
.filter(v -> reqInfo.getId().length == 0
|
||||
|| reqInfo.getId()[0].length() == 0
|
||||
|| Arrays.stream(reqInfo.getId()).anyMatch(s -> s.equals(v.getId().toString())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
valuableData.forEach(v -> {
|
||||
NodeTaskData taskData = new NodeTaskData();
|
||||
|
@ -417,17 +514,18 @@ public class DisposeTaskController {
|
|||
|
||||
AtomicBoolean bHasData = new AtomicBoolean(false);
|
||||
taskService.getNodeAllRunningTask(v.getId()).forEach(k -> {
|
||||
if (v.getType().equals(reqInfo.getType()) || reqInfo.getType() == -1) {
|
||||
if (v.getType().equals(reqInfo.getType())
|
||||
|| reqInfo.getType() == DeviceCapacity.ALLCAPACITY.getCode()) {
|
||||
int diff = Helper.getTimestampDiff(k.getBeginTime(), k.getPlanEndTime());
|
||||
TaskInfoData taskInfoData = TaskInfoData.builder()
|
||||
.taskId(k.getId().toString())
|
||||
.type(k.getType())
|
||||
.startTime(Helper.getTimestampSecond(k.getBeginTime()))
|
||||
.disposeTime(diff)
|
||||
.disposeIp(k.getDisposeIp())
|
||||
.flowAttack(0)
|
||||
.flowClean(0)
|
||||
.build();
|
||||
.taskId(k.getId().toString())
|
||||
.type(k.getType())
|
||||
.startTime(Helper.getTimestampSecond(k.getBeginTime()))
|
||||
.disposeTime(diff)
|
||||
.disposeIp(k.getDisposeIp())
|
||||
.flowAttack(0)
|
||||
.flowClean(0)
|
||||
.build();
|
||||
|
||||
taskData.getTaskArray().add(taskInfoData);
|
||||
bHasData.compareAndSet(false, true);
|
||||
|
@ -438,26 +536,28 @@ public class DisposeTaskController {
|
|||
taskData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
} else {
|
||||
log.error("No such task, deviceId:{}", v);
|
||||
log.error("No such task, deviceId:{}", v.getId());
|
||||
taskData.setId(v.getId().toString());
|
||||
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
|
||||
taskData.setTaskArray(null);
|
||||
}
|
||||
});
|
||||
|
||||
if (reqInfo.getId().length != 0) {
|
||||
List<String> unExists = Arrays.stream(reqInfo.getId())
|
||||
List<String> unExists = Arrays.stream(reqInfo.getId())
|
||||
.filter(v -> v.length() > 0)
|
||||
.filter(v -> valuableData.stream().noneMatch(k -> k.getId() == Long.parseLong(v)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
unExists.forEach(v -> {
|
||||
log.error("No such task, deviceId:{}", v);
|
||||
NodeTaskData taskData = new NodeTaskData();
|
||||
rspInfo.getItems().add(taskData);
|
||||
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
|
||||
});
|
||||
}
|
||||
unExists.forEach(v -> {
|
||||
log.error("No such task, deviceId:{}", v);
|
||||
NodeTaskData taskData = new NodeTaskData();
|
||||
rspInfo.getItems().add(taskData);
|
||||
taskData.setId(v);
|
||||
taskData.setTaskArray(null);
|
||||
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
|
||||
});
|
||||
|
||||
return ProtocolRespDTO.result(err, rspInfo);
|
||||
}
|
||||
|
@ -475,7 +575,7 @@ public class DisposeTaskController {
|
|||
@ApiOperation("获取全部处置任务")
|
||||
public ProtocolRespDTO getAllTask(@RequestBody ProtocolReqDTO mr,
|
||||
@RequestHeader HttpHeaders headers)
|
||||
throws JsonProcessingException {
|
||||
throws JsonProcessingException {
|
||||
ErrorCode err = mr.verifyRequest(headers);
|
||||
|
||||
if (err != ErrorCode.ERR_OK) {
|
||||
|
@ -484,29 +584,36 @@ public class DisposeTaskController {
|
|||
}
|
||||
|
||||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
|
||||
if (reqInfo.getTaskId() == null || Arrays.stream(reqInfo.getTaskId()).anyMatch(Objects::isNull)) {
|
||||
log.error("Request taskId params error, error:{}", mr.getMsgContent());
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
|
||||
}
|
||||
|
||||
TaskInfoRsp rspInfo = new TaskInfoRsp();
|
||||
|
||||
List<TaskInfoDetail> valuableData = taskService.getAllTask()
|
||||
.stream()
|
||||
.filter(v -> reqInfo.getTaskId().length == 0
|
||||
|| Arrays.stream(reqInfo.getTaskId()).anyMatch(s -> s.equals(v.getId().toString())))
|
||||
.collect(Collectors.toList());
|
||||
.stream()
|
||||
.filter(v -> reqInfo.getTaskId().length == 0
|
||||
|| reqInfo.getTaskId()[0].length() == 0
|
||||
|| Arrays.stream(reqInfo.getTaskId()).anyMatch(s -> s.equals(v.getId().toString())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
valuableData.forEach(v -> {
|
||||
int diff = Helper.getTimestampDiff(v.getBeginTime(), v.getPlanEndTime());
|
||||
|
||||
TaskInfoData taskInfoData = TaskInfoData.builder()
|
||||
.taskId(v.getId().toString())
|
||||
.type(v.getType())
|
||||
.startTime(Helper.getTimestampSecond(v.getBeginTime()))
|
||||
.disposeTime(diff / 60)
|
||||
.disposeIp(v.getDisposeIp())
|
||||
.attackType(Helper.attackStringToArray(v.getAttackType()))
|
||||
.flowDirection(v.getFlowDirection())
|
||||
.flowBandWidth(v.getFlowBandWidth())
|
||||
.flowAttack(0)
|
||||
.flowClean(0)
|
||||
.build();
|
||||
.taskId(v.getId().toString())
|
||||
.type(v.getType())
|
||||
.startTime(Helper.getTimestampSecond(v.getBeginTime()))
|
||||
.disposeTime(diff / 60)
|
||||
.disposeIp(v.getDisposeIp())
|
||||
.attackType(Helper.attackStringToArray(v.getAttackType()))
|
||||
.flowDirection(v.getFlowDirection())
|
||||
.flowBandWidth(v.getFlowBandWidth())
|
||||
.flowAttack(0)
|
||||
.flowClean(0)
|
||||
.build();
|
||||
|
||||
rspInfo.getItems().add(taskInfoData);
|
||||
taskInfoData.setId(v.getDeviceId().toString());
|
||||
|
@ -514,19 +621,19 @@ public class DisposeTaskController {
|
|||
taskInfoData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
});
|
||||
|
||||
if (reqInfo.getTaskId().length != 0) {
|
||||
List<String> unExists = Arrays.stream(reqInfo.getTaskId())
|
||||
List<String> unExists = Arrays.stream(reqInfo.getTaskId())
|
||||
.filter(v -> v.length() > 0)
|
||||
.filter(v -> valuableData.stream().noneMatch(k -> k.getId() == Long.parseLong(v)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
unExists.forEach(v -> {
|
||||
log.error("No such task, taskId:{}", v);
|
||||
TaskInfoData taskData = new TaskInfoData();
|
||||
rspInfo.getItems().add(taskData);
|
||||
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
|
||||
});
|
||||
}
|
||||
unExists.forEach(v -> {
|
||||
log.error("No such task, taskId:{}", v);
|
||||
TaskInfoData taskData = new TaskInfoData();
|
||||
rspInfo.getItems().add(taskData);
|
||||
taskData.setTaskId(v);
|
||||
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
|
||||
});
|
||||
|
||||
return ProtocolRespDTO.result(err, rspInfo);
|
||||
}
|
||||
|
|
|
@ -3,28 +3,20 @@ package com.dispose.dispose;
|
|||
import com.dispose.common.DisposeDeviceType;
|
||||
import com.dispose.common.GlobalVar;
|
||||
import com.dispose.common.IPAddrType;
|
||||
import com.dispose.dispose.impl.DPTechImpl;
|
||||
import com.dispose.dispose.impl.DpTechImpl;
|
||||
import com.dispose.dispose.impl.VirtualDeviceImpl;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* The type Device router.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public class DeviceRouter {
|
||||
|
||||
/**
|
||||
* The constant deviceCacheMap.
|
||||
*/
|
||||
private static final ConcurrentHashMap<String, DisposeEntryManager> DEVICE_CACHE_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Gets map key.
|
||||
*
|
||||
* @param devType the dev type
|
||||
* @param ipAddr the ip addr
|
||||
* @return the map key
|
||||
*/
|
||||
private static String getMapKey(int devType, String ipAddr) {
|
||||
return devType + "_" + ipAddr;
|
||||
}
|
||||
|
@ -52,7 +44,7 @@ public class DeviceRouter {
|
|||
return dev;
|
||||
} else if (devType == DisposeDeviceType.DPTECH_UMC.getCode()) {
|
||||
// 迪普设备
|
||||
DisposeEntryManager dev = new DPTechImpl(ipAddr);
|
||||
DisposeEntryManager dev = new DpTechImpl(ipAddr);
|
||||
DEVICE_CACHE_MAP.put(mapKey, dev);
|
||||
return dev;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The interface Dispose entry manager.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface DisposeEntryManager {
|
||||
/**
|
||||
|
|
|
@ -33,16 +33,13 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* The type Dp tech.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Slf4j
|
||||
public class DPTechImpl implements DisposeEntryManager {
|
||||
/**
|
||||
* The Clean type port.
|
||||
*/
|
||||
private AbnormalFlowCleaningServicePortType cleanTypePort;
|
||||
/**
|
||||
* The Dispose configure.
|
||||
*/
|
||||
public class DpTechImpl implements DisposeEntryManager {
|
||||
private final AbnormalFlowCleaningServicePortType cleanTypePort;
|
||||
|
||||
@Resource
|
||||
private DisposeConfigure disposeConfigure;
|
||||
|
||||
|
@ -51,17 +48,17 @@ public class DPTechImpl implements DisposeEntryManager {
|
|||
*
|
||||
* @param ipAddr the ip addr
|
||||
*/
|
||||
public DPTechImpl(String ipAddr) {
|
||||
public DpTechImpl(String ipAddr) {
|
||||
JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
|
||||
jaxWsProxyFactoryBean.setServiceClass(AbnormalFlowCleaningServicePortType.class);
|
||||
jaxWsProxyFactoryBean.setAddress(String.format(ConstValue.SOAPWrapperConst.NAMESPACE_URI, ipAddr));
|
||||
jaxWsProxyFactoryBean.setAddress(String.format(ConstValue.SoapWrapperConst.NAMESPACE_URI, ipAddr));
|
||||
|
||||
//WS-Security Head
|
||||
Map<String, Object> outProps = new HashMap<>();
|
||||
outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
|
||||
|
||||
// 配置用户名,密码类型
|
||||
outProps.put(WSHandlerConstants.USER, ConstValue.SOAPWrapperConst.USER_NAME);
|
||||
outProps.put(WSHandlerConstants.USER, ConstValue.SoapWrapperConst.USER_NAME);
|
||||
outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
|
||||
// 注册密码处理回调函数
|
||||
outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, SoapPasswordCallbackHandler.class.getName());
|
||||
|
@ -75,8 +72,10 @@ public class DPTechImpl implements DisposeEntryManager {
|
|||
Client proxy = ClientProxy.getClient(this.cleanTypePort);
|
||||
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
|
||||
HTTPClientPolicy policy = new HTTPClientPolicy();
|
||||
policy.setConnectionTimeout(GlobalVar.SOAP_CONNECT_TIMEOUT); // 请求超时
|
||||
policy.setReceiveTimeout(GlobalVar.SOAP_RECEIVE_TIMEOUT); //读取超时
|
||||
// 请求超时
|
||||
policy.setConnectionTimeout(GlobalVar.SOAP_CONNECT_TIMEOUT);
|
||||
//读取超时
|
||||
policy.setReceiveTimeout(GlobalVar.SOAP_RECEIVE_TIMEOUT);
|
||||
conduit.setClient(policy);
|
||||
}
|
||||
|
||||
|
@ -86,7 +85,7 @@ public class DPTechImpl implements DisposeEntryManager {
|
|||
* @param ipAddr the ip addr
|
||||
* @param type the type
|
||||
*/
|
||||
public DPTechImpl(String ipAddr, IPAddrType type) {
|
||||
public DpTechImpl(String ipAddr, IPAddrType type) {
|
||||
this(ipAddr);
|
||||
}
|
||||
|
||||
|
@ -146,8 +145,8 @@ public class DPTechImpl implements DisposeEntryManager {
|
|||
devs = cleanTypePort.getAllProtectDevices();
|
||||
|
||||
if (devs != null && devs.length() > 0) {
|
||||
List<String> proIPv4 = new ArrayList<>();
|
||||
List<String> proIPv6 = new ArrayList<>();
|
||||
List<String> strIpV4 = new ArrayList<>();
|
||||
List<String> strIpV6 = new ArrayList<>();
|
||||
|
||||
// 读取清洗设备支持的清洗IP范围
|
||||
ArrayOfProtectionObjectDataForService objs = cleanTypePort.getAllProtectionObjectFromUMC();
|
||||
|
@ -155,18 +154,21 @@ public class DPTechImpl implements DisposeEntryManager {
|
|||
objs.getProtectionObjectDataForService().forEach(v -> {
|
||||
String ipSeg = v.getIpSegment().getValue();
|
||||
if (v.getIpType() == 0 && ipSeg.length() > 0) {
|
||||
proIPv4.addAll(Arrays.asList(ipSeg.replaceAll("\\d+_", "").split(",")));
|
||||
strIpV4.addAll(Arrays.asList(ipSeg.replaceAll("\\d+_", "").split(",")));
|
||||
} else if (v.getIpType() == 1 && ipSeg.length() > 0) {
|
||||
proIPv6.addAll(Arrays.asList(ipSeg.replaceAll("\\d+_", "").split(",")));
|
||||
strIpV6.addAll(Arrays.asList(ipSeg.replaceAll("\\d+_", "").split(",")));
|
||||
}
|
||||
});
|
||||
|
||||
// 保存清洗能力信息
|
||||
capList.add(DisposeDeviceCapacity.builder()
|
||||
.capacity(DeviceCapacity.CLEANUP.getCode()) // 清洗能力
|
||||
// 清洗能力
|
||||
.capacity(DeviceCapacity.CLEANUP.getCode())
|
||||
.tolFlowCapacity(0)
|
||||
.protectIpV4(proIPv4.toArray(new String[0])) // IPv4范围
|
||||
.protectIpV6(proIPv6.toArray(new String[0])) // IPv6范围
|
||||
// IPv4范围
|
||||
.protectIpV4(strIpV4.toArray(new String[0]))
|
||||
// IPv6范围
|
||||
.protectIpV6(strIpV6.toArray(new String[0]))
|
||||
.build());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
@ -212,7 +214,8 @@ public class DPTechImpl implements DisposeEntryManager {
|
|||
try {
|
||||
log.info("++++Begging DPTech Start Cleanup Task: {}", ip);
|
||||
// DPTech流量清洗需要对入口,出口方向,各种攻击类型分别调用接口下发清洗任务
|
||||
for (int d : new int[]{0, 1}) { // 遍历出口,入口两个方向
|
||||
// 遍历出口,入口两个方向
|
||||
for (int d : new int[]{0, 1}) {
|
||||
// 遍历所有清洗类型
|
||||
for (DpTechAttackType t : DpTechAttackType.values()) {
|
||||
NtcRequestResultInfo ret = cleanTypePort.startAbnormalTaskForUMC(ip, t.getCode(), d);
|
||||
|
@ -254,11 +257,6 @@ public class DPTechImpl implements DisposeEntryManager {
|
|||
// 遍历所有攻击类型的清洗任务
|
||||
for (DpTechAttackType t : DpTechAttackType.values()) {
|
||||
NtcRequestResultInfo ret = cleanTypePort.stopAbnormalTaskForUMC(ipAddr, t.getCode(), d);
|
||||
|
||||
// if (ret.getResultRetVal() != ErrorCode.ERR_OK.getCode()) {
|
||||
// log.error("Stop {} cleanup task error: {}", ipAddr, ret.getResultInfo());
|
||||
// return ErrorCode.ERR_CALLDEVICE;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,8 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The type Virtual device.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public class VirtualDeviceImpl implements DisposeEntryManager {
|
||||
/**
|
||||
|
|
|
@ -8,52 +8,24 @@ import java.io.Serializable;
|
|||
|
||||
/**
|
||||
* The type Device info.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
public class DeviceInfo implements Serializable {
|
||||
|
||||
/**
|
||||
* The constant serialVersionUID.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The Vendor.
|
||||
*/
|
||||
private String vendor;
|
||||
/**
|
||||
* The Model.
|
||||
*/
|
||||
private String model;
|
||||
/**
|
||||
* The Firmware.
|
||||
*/
|
||||
private String firmware;
|
||||
/**
|
||||
* The Os.
|
||||
*/
|
||||
private String os;
|
||||
/**
|
||||
* The Kernel.
|
||||
*/
|
||||
private String kernel;
|
||||
/**
|
||||
* The Arch.
|
||||
*/
|
||||
private String arch;
|
||||
/**
|
||||
* The Memory.
|
||||
*/
|
||||
private int memory;
|
||||
/**
|
||||
* The Free memory.
|
||||
*/
|
||||
private int freeMemory;
|
||||
/**
|
||||
* The Cpu used.
|
||||
*/
|
||||
private int cpuUsed;
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,6 +13,8 @@ import javax.servlet.http.HttpServletRequest;
|
|||
|
||||
/**
|
||||
* The type Global exception handler.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@ControllerAdvice
|
||||
@Slf4j
|
||||
|
|
|
@ -8,6 +8,8 @@ import javax.security.auth.callback.CallbackHandler;
|
|||
|
||||
/**
|
||||
* The type Soap password callback handler.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public class SoapPasswordCallbackHandler implements CallbackHandler {
|
||||
/**
|
||||
|
@ -19,6 +21,6 @@ public class SoapPasswordCallbackHandler implements CallbackHandler {
|
|||
public void handle(Callback[] callbacks) {
|
||||
// DPTech SOAP接口WSSecure头部密码填充
|
||||
WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
|
||||
pc.setPassword(ConstValue.SOAPWrapperConst.PASSWORD);
|
||||
pc.setPassword(ConstValue.SoapWrapperConst.PASSWORD);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.dispose.interceptor;
|
||||
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.common.GlobalVar;
|
||||
import com.dispose.pojo.dto.ProtocolRespDTO;
|
||||
import com.dispose.service.UserAccountService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
@ -14,12 +15,11 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
/**
|
||||
* The type Token interceptor.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Slf4j
|
||||
public class TokenInterceptor implements HandlerInterceptor {
|
||||
/**
|
||||
* The User account service.
|
||||
*/
|
||||
@Resource
|
||||
private UserAccountService userAccountService;
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class TokenInterceptor implements HandlerInterceptor {
|
|||
String token = request.getHeader("Authorization");
|
||||
|
||||
if (token != null && token.length() > 0) {
|
||||
token = token.replaceFirst("Bearer ", "");
|
||||
token = token.replaceFirst(GlobalVar.STRING_HTTP_AUTH_HEAD, "");
|
||||
ErrorCode err = userAccountService.authTokenCheck(token);
|
||||
// 判断token是否合法
|
||||
if (err != ErrorCode.ERR_OK) {
|
||||
|
|
|
@ -7,6 +7,8 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The interface Task cache manager.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface TaskCacheManager {
|
||||
/**
|
||||
|
@ -30,10 +32,10 @@ public interface TaskCacheManager {
|
|||
*
|
||||
* @return the all task
|
||||
*/
|
||||
List<TaskInfoDetail> getAllTask();
|
||||
List<TaskInfoDetail> getAllRunningTask();
|
||||
|
||||
/**
|
||||
* Remove task error code.
|
||||
* Remove task.
|
||||
*
|
||||
* @param id the id
|
||||
*/
|
||||
|
@ -47,8 +49,4 @@ public interface TaskCacheManager {
|
|||
* @return the error code
|
||||
*/
|
||||
ErrorCode upgradeTaskStatus(Long id, int status);
|
||||
|
||||
// void increaseRetryTimes();
|
||||
//
|
||||
// void cleanRetryTimes();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import java.security.NoSuchAlgorithmException;
|
|||
|
||||
/**
|
||||
* The interface User account cache manager.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface UserAccountCacheManager {
|
||||
/**
|
||||
|
|
|
@ -12,13 +12,12 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
/**
|
||||
* The type Task cache manager.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class TaskCacheManagerImpl implements TaskCacheManager {
|
||||
/**
|
||||
* The Task cache map.
|
||||
*/
|
||||
private final ConcurrentHashMap<Long, TaskInfoDetail> taskCacheMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
|
@ -27,7 +26,7 @@ public class TaskCacheManagerImpl implements TaskCacheManager {
|
|||
* @return the all task
|
||||
*/
|
||||
@Override
|
||||
public List<TaskInfoDetail> getAllTask() {
|
||||
public List<TaskInfoDetail> getAllRunningTask() {
|
||||
return new ArrayList<>(taskCacheMap.values());
|
||||
}
|
||||
|
||||
|
@ -75,13 +74,14 @@ public class TaskCacheManagerImpl implements TaskCacheManager {
|
|||
}
|
||||
|
||||
// 添加到Map缓存中
|
||||
taskData.setRetryTimes(0); // 保留字段
|
||||
// 保留字段
|
||||
taskData.setRetryTimes(0);
|
||||
taskCacheMap.put(taskData.getId(), taskData);
|
||||
return ErrorCode.ERR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove task error code.
|
||||
* Remove task.
|
||||
*
|
||||
* @param id the id
|
||||
*/
|
||||
|
|
|
@ -21,26 +21,16 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
/**
|
||||
* The type User account cache manager.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
|
||||
/**
|
||||
* The constant RANDOM_GEN.
|
||||
*/
|
||||
private static final Random RANDOM_GEN = new Random(System.currentTimeMillis());
|
||||
/**
|
||||
* The User account cache.
|
||||
*/
|
||||
private final ConcurrentHashMap<String, UserAccountCache> userAccountCache = new ConcurrentHashMap<>();
|
||||
/**
|
||||
* The Dispose configure.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeConfigure disposeConfigure;
|
||||
/**
|
||||
* The Object mapper.
|
||||
*/
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
|
@ -52,7 +42,7 @@ public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
|
|||
*/
|
||||
@Override
|
||||
public ErrorCode verifyPermission(String token) {
|
||||
if ("false".equals(disposeConfigure.getCheckAdminPermission())) {
|
||||
if (String.valueOf(false).equals(disposeConfigure.getCheckAdminPermission())) {
|
||||
return ErrorCode.ERR_OK;
|
||||
}
|
||||
|
||||
|
@ -61,7 +51,7 @@ public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
|
|||
if (username == null || username.length() == 0) {
|
||||
log.error("User {} not logged in", username);
|
||||
return ErrorCode.ERR_LOGOUT;
|
||||
} else if ("admin".equals(username)) {
|
||||
} else if (ConstValue.SoapWrapperConst.USER_NAME.equals(username)) {
|
||||
// admin 用户具有操作权限
|
||||
return ErrorCode.ERR_OK;
|
||||
}
|
||||
|
@ -257,16 +247,20 @@ public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
|
|||
|
||||
// token过期获取以前没有token,创建一个新token
|
||||
if ((System.currentTimeMillis() - uc.getLastAccess())
|
||||
>= ConstValue.GlobalConfigure.TOKEN_TIMEOUT_MS
|
||||
|| uc.getToken().length() == 0) {
|
||||
>= ConstValue.GlobalConfigure.TOKEN_TIMEOUT_MS
|
||||
|| uc.getToken().length() == 0) {
|
||||
// 移除过期的项
|
||||
userAccountCache.remove(uc.getToken());
|
||||
// 更新token,访问时间
|
||||
uc.setToken(createUserToken(username));
|
||||
// 重新添加到缓存中
|
||||
userAccountCache.put(uc.getToken(), uc);
|
||||
log.info("Refresh {} Token:{}", username, uc.getToken());
|
||||
} else {
|
||||
log.info("Get {} Token:{}", username, uc.getToken());
|
||||
}
|
||||
|
||||
uc.setLastAccess(System.currentTimeMillis());
|
||||
|
||||
} else {
|
||||
// 用户不存在说明没有登陆过,创建一个新的用户缓存
|
||||
uc = UserAccountCache.builder()
|
||||
|
@ -284,13 +278,6 @@ public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
|
|||
return uc.getToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create user token string.
|
||||
*
|
||||
* @param username the username
|
||||
* @return the string
|
||||
* @throws NoSuchAlgorithmException the no such algorithm exception
|
||||
*/
|
||||
private String createUserToken(String username) throws NoSuchAlgorithmException {
|
||||
// 获取指定摘要算法的messageDigest对象
|
||||
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
|
||||
|
|
|
@ -6,6 +6,8 @@ import tk.mybatis.mapper.common.MySqlMapper;
|
|||
|
||||
/**
|
||||
* The interface Dispose device mapper.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface DisposeDeviceMapper extends Mapper<DisposeDevice>, MySqlMapper<DisposeDevice> {
|
||||
/**
|
||||
|
|
|
@ -10,6 +10,8 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The interface Dispose task mapper.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface DisposeTaskMapper extends Mapper<TaskInfoDetail>,
|
||||
IdsMapper<TaskInfoDetail>, MySqlMapper<TaskInfoDetail> {
|
||||
|
|
|
@ -8,6 +8,8 @@ import tk.mybatis.mapper.common.MySqlMapper;
|
|||
|
||||
/**
|
||||
* The interface User account mapper.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface UserAccountMapper extends Mapper<UserAccount>,
|
||||
IdsMapper<UserAccount>, MySqlMapper<UserAccount> {
|
||||
|
|
|
@ -9,22 +9,18 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* The type Protocol dto.
|
||||
* The type Base protocol dto.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@ApiModel("通信协议实体")
|
||||
@JsonPropertyOrder({"ver", "cryptoType", "timeStamp", "msgContent"})
|
||||
public abstract class ProtocolDTO {
|
||||
/**
|
||||
* The Ver.
|
||||
*/
|
||||
public abstract class BaseProtocolDTO {
|
||||
@ApiModelProperty(value = "协议版本号", required = true, example = "1")
|
||||
private Integer ver;
|
||||
|
||||
/**
|
||||
* The Crypto type.
|
||||
*/
|
||||
@ApiModelProperty(value = "msgContent字段内容编码格式:\n" +
|
||||
"0:无编码格式,普通字符串\n" +
|
||||
"1:base64编码格式\n" +
|
||||
|
@ -33,15 +29,9 @@ public abstract class ProtocolDTO {
|
|||
example = "0")
|
||||
private Integer cryptoType;
|
||||
|
||||
/**
|
||||
* The Time stamp.
|
||||
*/
|
||||
@ApiModelProperty(value = "当前UTC时间戳", required = true, example = "1526625689000")
|
||||
private Long timeStamp;
|
||||
|
||||
/**
|
||||
* The Msg content.
|
||||
*/
|
||||
@ApiModelProperty(value = "协议详细内容,Json字符串格式。\n" +
|
||||
"保存该cmdId命令相关的详细内容,\n" +
|
||||
"具体每个cmdId命令的详细内容参看对应的命令协议定义",
|
|
@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
|||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
|
@ -14,18 +15,15 @@ import java.util.Objects;
|
|||
|
||||
/**
|
||||
* The type Protocol req dto.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
@Slf4j
|
||||
public class ProtocolReqDTO extends ProtocolDTO {
|
||||
/**
|
||||
* The constant OBJECT_MAPPER.
|
||||
*/
|
||||
public class ProtocolReqDTO extends BaseProtocolDTO {
|
||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
|
||||
/**
|
||||
* The constant token.
|
||||
*/
|
||||
private static String token = "";
|
||||
|
||||
/**
|
||||
|
@ -75,12 +73,12 @@ public class ProtocolReqDTO extends ProtocolDTO {
|
|||
try {
|
||||
String authString = Objects.requireNonNull(headers.get("Authorization")).get(0);
|
||||
|
||||
if (authString.length() == 0 || !authString.startsWith("Bearer ")) {
|
||||
if (authString.length() == 0 || !authString.startsWith(GlobalVar.STRING_HTTP_AUTH_HEAD)) {
|
||||
log.error("Input Authorization header error: [{}]", authString);
|
||||
return ErrorCode.ERR_PARAMEXCEPTION;
|
||||
}
|
||||
// 保持当前请求token内容
|
||||
ProtocolReqDTO.token = authString.replaceFirst("Bearer ", "");
|
||||
ProtocolReqDTO.token = authString.replaceFirst(GlobalVar.STRING_HTTP_AUTH_HEAD, "");
|
||||
} catch (Exception ex) {
|
||||
log.error(ex.getMessage());
|
||||
return ErrorCode.ERR_MISSAUTHHEAD;
|
||||
|
|
|
@ -14,28 +14,20 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
/**
|
||||
* The type Protocol resp dto.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"ver", "cryptoType", "timeStamp", "code", "msgContent"})
|
||||
public class ProtocolRespDTO extends ProtocolDTO {
|
||||
public class ProtocolRespDTO extends BaseProtocolDTO {
|
||||
|
||||
/**
|
||||
* The Code.
|
||||
*/
|
||||
@ApiModelProperty(value = "服务器返回状态码",
|
||||
example = "200")
|
||||
private int code;
|
||||
private Integer code;
|
||||
|
||||
/**
|
||||
* Gets object json.
|
||||
*
|
||||
* @param obj the obj
|
||||
* @return the object json
|
||||
* @throws JsonProcessingException the json processing exception
|
||||
*/
|
||||
private static String getObjectJson(Object obj) throws JsonProcessingException {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The type Dispose device.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
|
@ -32,78 +34,36 @@ import java.util.List;
|
|||
@Table(name = "dispose_device")
|
||||
@NameStyle(Style.normal)
|
||||
public class DisposeDevice implements Serializable {
|
||||
/**
|
||||
* The constant serialVersionUID.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The Id.
|
||||
*/
|
||||
@Id
|
||||
@KeySql(useGeneratedKeys = true)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* The Ip addr.
|
||||
*/
|
||||
private String ipAddr;
|
||||
|
||||
/**
|
||||
* The Type.
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* The Area code.
|
||||
*/
|
||||
private Integer areaCode;
|
||||
|
||||
/**
|
||||
* The Name.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The Manufacturer.
|
||||
*/
|
||||
private String manufacturer;
|
||||
|
||||
/**
|
||||
* The Model.
|
||||
*/
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* The Version.
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* The Readme.
|
||||
*/
|
||||
private String readme;
|
||||
|
||||
/**
|
||||
* The Status.
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* The Link status.
|
||||
*/
|
||||
@Transient
|
||||
private Integer linkStatus;
|
||||
|
||||
/**
|
||||
* The Dev caps.
|
||||
*/
|
||||
@Transient
|
||||
private List<DisposeDeviceCapacity> devCaps;
|
||||
|
||||
/**
|
||||
* The Dev info.
|
||||
*/
|
||||
@Transient
|
||||
private DeviceInfo devInfo;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ import java.io.Serializable;
|
|||
|
||||
/**
|
||||
* The type User account.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
|
@ -27,41 +29,20 @@ import java.io.Serializable;
|
|||
@NameStyle(Style.normal)
|
||||
public class UserAccount implements Serializable {
|
||||
|
||||
/**
|
||||
* The constant serialVersionUID.
|
||||
*/
|
||||
private static final long serialVersionUID = -1L;
|
||||
|
||||
/**
|
||||
* The Id.
|
||||
*/
|
||||
@Id
|
||||
@KeySql(useGeneratedKeys = true)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* The Username.
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* The Password.
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* The Last login time.
|
||||
*/
|
||||
private String lastLoginTime;
|
||||
|
||||
|
||||
/**
|
||||
* The Lock time.
|
||||
*/
|
||||
private String lockTime;
|
||||
|
||||
/**
|
||||
* The Status.
|
||||
*/
|
||||
private Integer status;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import java.io.Serializable;
|
|||
|
||||
/**
|
||||
* The type Dispose device capacity.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
|
@ -20,28 +22,13 @@ import java.io.Serializable;
|
|||
@Builder
|
||||
public class DisposeDeviceCapacity implements Serializable {
|
||||
|
||||
/**
|
||||
* The constant serialVersionUID.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The Capacity.
|
||||
*/
|
||||
private Integer capacity;
|
||||
|
||||
/**
|
||||
* The Tol flow capacity.
|
||||
*/
|
||||
private Integer tolFlowCapacity;
|
||||
|
||||
/**
|
||||
* The Protect ip v 4.
|
||||
*/
|
||||
private String[] protectIpV4;
|
||||
|
||||
/**
|
||||
* The Protect ip v 6.
|
||||
*/
|
||||
private String[] protectIpV6;
|
||||
}
|
||||
|
|
|
@ -8,17 +8,12 @@ import lombok.Getter;
|
|||
*
|
||||
* @param <A> the type parameter
|
||||
* @param <B> the type parameter
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Getter
|
||||
@Builder
|
||||
public class MReturnType<A, B> {
|
||||
/**
|
||||
* The First param.
|
||||
*/
|
||||
public class MulReturnType<A, B> {
|
||||
private final A firstParam;
|
||||
/**
|
||||
* The Second param.
|
||||
*/
|
||||
private final B secondParam;
|
||||
|
||||
/**
|
||||
|
@ -27,7 +22,7 @@ public class MReturnType<A, B> {
|
|||
* @param a the a
|
||||
* @param b the b
|
||||
*/
|
||||
public MReturnType(A a, B b) {
|
||||
public MulReturnType(A a, B b) {
|
||||
this.firstParam = a;
|
||||
this.secondParam = b;
|
||||
}
|
|
@ -8,6 +8,8 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
/**
|
||||
* The type New node info.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
|
@ -15,40 +17,13 @@ import lombok.NoArgsConstructor;
|
|||
@AllArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class NewNodeInfo {
|
||||
/**
|
||||
* The Id.
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* The Type.
|
||||
*/
|
||||
private int type;
|
||||
/**
|
||||
* The Ip addr.
|
||||
*/
|
||||
private Integer type;
|
||||
private String ipAddr;
|
||||
/**
|
||||
* The Area code.
|
||||
*/
|
||||
private int areaCode;
|
||||
/**
|
||||
* The Name.
|
||||
*/
|
||||
private Integer areaCode;
|
||||
private String name;
|
||||
/**
|
||||
* The Manufacturer.
|
||||
*/
|
||||
private String manufacturer;
|
||||
/**
|
||||
* The Model.
|
||||
*/
|
||||
private String model;
|
||||
/**
|
||||
* The Version.
|
||||
*/
|
||||
private String version;
|
||||
/**
|
||||
* The Readme.
|
||||
*/
|
||||
private String readme;
|
||||
}
|
||||
|
|
|
@ -6,18 +6,14 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
/**
|
||||
* The type Return status.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ReturnStatus {
|
||||
/**
|
||||
* The Status.
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* The Message.
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,24 +5,14 @@ import lombok.Data;
|
|||
|
||||
/**
|
||||
* The type User account cache.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class UserAccountCache {
|
||||
/**
|
||||
* The Username.
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* The Token.
|
||||
*/
|
||||
private String token;
|
||||
/**
|
||||
* The Last access.
|
||||
*/
|
||||
private Long lastAccess;
|
||||
/**
|
||||
* The Pwd err times.
|
||||
*/
|
||||
private Integer pwdErrTimes;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
/**
|
||||
* The type Login req.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
|
@ -16,12 +18,6 @@ import lombok.NoArgsConstructor;
|
|||
@AllArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class LoginReq {
|
||||
/**
|
||||
* The User name.
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* The Password.
|
||||
*/
|
||||
private String password;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
/**
|
||||
* The type Login rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -20,20 +22,8 @@ import lombok.NoArgsConstructor;
|
|||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({"userName", "token", "logTime", "expireTime", "status", "message"})
|
||||
public class LoginRsp extends ReturnStatus {
|
||||
/**
|
||||
* The User name.
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* The Token.
|
||||
*/
|
||||
private String token;
|
||||
/**
|
||||
* The Log time.
|
||||
*/
|
||||
private Long logTime;
|
||||
/**
|
||||
* The Expire time.
|
||||
*/
|
||||
private Long expireTime;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
/**
|
||||
* The type Logout rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -18,8 +20,5 @@ import lombok.NoArgsConstructor;
|
|||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"userName", "token", "logTime", "expireTime", "status", "message"})
|
||||
public class LogoutRsp extends ReturnStatus {
|
||||
/**
|
||||
* The User name.
|
||||
*/
|
||||
private String userName;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import lombok.Setter;
|
|||
|
||||
/**
|
||||
* The type Dispose capacity.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
|
@ -18,41 +20,35 @@ import lombok.Setter;
|
|||
@AllArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class DisposeCapacity {
|
||||
/**
|
||||
* The Type.
|
||||
*/
|
||||
@JsonView(BaseView.class)
|
||||
private Integer type;
|
||||
/**
|
||||
* The Dispose ip.
|
||||
*/
|
||||
@JsonView(DependIpView.class)
|
||||
private String disposeIp;
|
||||
/**
|
||||
* The Tol capacity.
|
||||
*/
|
||||
@JsonView(CapacityView.class)
|
||||
private Integer tolCapacity;
|
||||
/**
|
||||
* The Used capacity.
|
||||
*/
|
||||
@JsonView(CapacityView.class)
|
||||
private Integer usedCapacity;
|
||||
|
||||
/**
|
||||
* The interface Base view.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface BaseView {
|
||||
}
|
||||
|
||||
/**
|
||||
* The interface Capacity view.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface CapacityView extends BaseView {
|
||||
}
|
||||
|
||||
/**
|
||||
* The interface Depend ip view.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface DependIpView extends BaseView {
|
||||
}
|
||||
|
|
|
@ -3,24 +3,59 @@ package com.dispose.pojo.vo.common;
|
|||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The type Id array req.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Getter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class IDArrayReq {
|
||||
/**
|
||||
* The Id.
|
||||
*/
|
||||
private String[] id;
|
||||
/**
|
||||
* The Task id.
|
||||
*/
|
||||
private String[] taskId;
|
||||
|
||||
public void setId(String[] id) {
|
||||
List<String> idList = Arrays.asList(id);
|
||||
|
||||
if (idList.contains(null)) {
|
||||
this.id = null;
|
||||
} else if (idList.contains("")) {
|
||||
this.id = new String[]{""};
|
||||
} else {
|
||||
Map<String, Long> ret = idList.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
|
||||
System.out.println(ret);
|
||||
|
||||
List<String> keyList = new ArrayList<>(ret.keySet());
|
||||
this.id = keyList.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTaskId(String[] taskId) {
|
||||
List<String> idList = Arrays.asList(taskId);
|
||||
|
||||
if (idList.contains(null)) {
|
||||
this.taskId = null;
|
||||
} else if (idList.contains("")) {
|
||||
this.taskId = new String[]{""};
|
||||
} else {
|
||||
Map<String, Long> ret = idList.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
|
||||
System.out.println(ret);
|
||||
|
||||
List<String> keyList = new ArrayList<>(ret.keySet());
|
||||
this.taskId = keyList.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
/**
|
||||
* The type Id return status.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -18,12 +20,6 @@ import lombok.NoArgsConstructor;
|
|||
@JsonPropertyOrder({"id", "devId", "status", "message"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class IDReturnStatus extends ReturnStatus {
|
||||
/**
|
||||
* The Id.
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* The Dev id.
|
||||
*/
|
||||
private String devId;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
/**
|
||||
* The type Task info data.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -20,55 +22,19 @@ import lombok.NoArgsConstructor;
|
|||
"flowDirection", "attackType", "flowBandWidth", "flowAttack", "flowClean", "leftTime", "status", "message"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class TaskInfoData extends IDReturnStatus {
|
||||
/**
|
||||
* The Task id.
|
||||
*/
|
||||
private String taskId;
|
||||
/**
|
||||
* The Type.
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* The Dispose ip.
|
||||
*/
|
||||
private String disposeIp;
|
||||
/**
|
||||
* The Left time.
|
||||
*/
|
||||
private Integer leftTime;
|
||||
/**
|
||||
* The Start time.
|
||||
*/
|
||||
private Integer startTime;
|
||||
/**
|
||||
* The Dispose time.
|
||||
*/
|
||||
private Integer disposeTime;
|
||||
/**
|
||||
* The Flow direction.
|
||||
*/
|
||||
private Integer flowDirection;
|
||||
/**
|
||||
* The Attack type.
|
||||
*/
|
||||
private Integer[] attackType;
|
||||
/**
|
||||
* The Flow band width.
|
||||
*/
|
||||
private Integer flowBandWidth;
|
||||
|
||||
/**
|
||||
* The Flow attack.
|
||||
*/
|
||||
private Integer flowAttack;
|
||||
|
||||
/**
|
||||
* The Flow clean.
|
||||
*/
|
||||
private Integer flowClean;
|
||||
|
||||
/**
|
||||
* The Current status.
|
||||
*/
|
||||
private Integer currentStatus;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ import java.io.Serializable;
|
|||
|
||||
/**
|
||||
* The type Task info detail.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
|
@ -21,63 +23,21 @@ import java.io.Serializable;
|
|||
@Table(name = "dispose_task")
|
||||
@NameStyle(Style.normal)
|
||||
public class TaskInfoDetail implements Serializable {
|
||||
/**
|
||||
* The constant serialVersionUID.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The Id.
|
||||
*/
|
||||
@Id
|
||||
private Long id;
|
||||
/**
|
||||
* The Device id.
|
||||
*/
|
||||
private Long deviceId;
|
||||
/**
|
||||
* The Account id.
|
||||
*/
|
||||
private Long accountId;
|
||||
/**
|
||||
* The Type.
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* The Dispose ip.
|
||||
*/
|
||||
private String disposeIp;
|
||||
/**
|
||||
* The Begin time.
|
||||
*/
|
||||
private String beginTime;
|
||||
/**
|
||||
* The Plan end time.
|
||||
*/
|
||||
private String planEndTime;
|
||||
/**
|
||||
* The End time.
|
||||
*/
|
||||
private String endTime;
|
||||
/**
|
||||
* The Flow direction.
|
||||
*/
|
||||
private Integer flowDirection;
|
||||
/**
|
||||
* The Attack type.
|
||||
*/
|
||||
private String attackType;
|
||||
/**
|
||||
* The Flow band width.
|
||||
*/
|
||||
private Integer flowBandWidth;
|
||||
/**
|
||||
* The Current status.
|
||||
*/
|
||||
private Integer currentStatus;
|
||||
|
||||
/**
|
||||
* The Retry times.
|
||||
*/
|
||||
private int retryTimes;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The type Add node req.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
|
@ -18,8 +20,5 @@ import java.util.List;
|
|||
@AllArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class AddNodeReq {
|
||||
/**
|
||||
* The Items.
|
||||
*/
|
||||
private List<NewNodeInfo> items;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
/**
|
||||
* The type Add node ret data.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -16,8 +18,5 @@ import lombok.NoArgsConstructor;
|
|||
@JsonPropertyOrder({"id", "ipAddr", "devId", "status", "message"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class AddNodeRetData extends IDReturnStatus {
|
||||
/**
|
||||
* The Ip addr.
|
||||
*/
|
||||
private String ipAddr;
|
||||
}
|
||||
|
|
|
@ -9,12 +9,14 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The type Add node rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class AddNodeRsp {
|
||||
/**
|
||||
* The Result.
|
||||
* The Items.
|
||||
*/
|
||||
List<AddNodeRetData> items;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.dispose.pojo.vo.information;
|
||||
|
||||
import com.dispose.common.GlobalVar;
|
||||
import com.dispose.pojo.po.DisposeDeviceCapacity;
|
||||
import com.dispose.pojo.vo.common.DisposeCapacity;
|
||||
import com.dispose.pojo.vo.common.IDReturnStatus;
|
||||
|
@ -15,6 +16,8 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The type Device capacity data.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -46,7 +49,7 @@ public class DeviceCapacityData extends IDReturnStatus {
|
|||
Arrays.asList(v.getProtectIpV6() != null ? v.getProtectIpV6() : new String[]{})
|
||||
);
|
||||
|
||||
if (ipAddrs.endsWith(",")) {
|
||||
if (ipAddrs.endsWith(GlobalVar.STRING_SPILT_CHAR)) {
|
||||
ipAddrs = ipAddrs.substring(0, ipAddrs.length() - 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,14 +9,13 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The type Device capacity rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@JsonPropertyOrder({"id", "capacity", "status", "message"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class DeviceCapacityRsp {
|
||||
/**
|
||||
* The Items.
|
||||
*/
|
||||
private List<DeviceCapacityData> items;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
/**
|
||||
* The type Device info data.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -17,17 +19,8 @@ import lombok.NoArgsConstructor;
|
|||
@JsonPropertyOrder({"id"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class DeviceInfoData extends DeviceInfo {
|
||||
/**
|
||||
* The Id.
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* The Status.
|
||||
*/
|
||||
private int status;
|
||||
/**
|
||||
* The Message.
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,8 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The type Device info rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
public class DeviceInfoRsp {
|
||||
|
|
|
@ -13,6 +13,8 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The type Dispose node data.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -23,37 +25,13 @@ import java.util.List;
|
|||
@JsonPropertyOrder({"id", "type", "name", "ip", "areaCode", "manufacturer", "model", "version", "readme", "status",
|
||||
"message"})
|
||||
public class DisposeNodeData extends DeviceCapacityData {
|
||||
/**
|
||||
* The Type.
|
||||
*/
|
||||
private int type;
|
||||
/**
|
||||
* The Name.
|
||||
*/
|
||||
private Integer type;
|
||||
private String name;
|
||||
/**
|
||||
* The Ip.
|
||||
*/
|
||||
private String ip;
|
||||
/**
|
||||
* The Area code.
|
||||
*/
|
||||
private Integer areaCode;
|
||||
/**
|
||||
* The Manufacturer.
|
||||
*/
|
||||
private String manufacturer;
|
||||
/**
|
||||
* The Model.
|
||||
*/
|
||||
private String model;
|
||||
/**
|
||||
* The Version.
|
||||
*/
|
||||
private String version;
|
||||
/**
|
||||
* The Readme.
|
||||
*/
|
||||
private String readme;
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,12 +7,11 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The type Dispose node list rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class DisposeNodeListRsp {
|
||||
/**
|
||||
* The Items.
|
||||
*/
|
||||
private List<DisposeNodeData> items;
|
||||
}
|
||||
|
|
|
@ -20,12 +20,11 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The type Link status list rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class LinkStatusListRsp {
|
||||
/**
|
||||
* The Items.
|
||||
*/
|
||||
private List<LinkStatusRsp> items;
|
||||
}
|
|
@ -10,6 +10,8 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
/**
|
||||
* The type Link status rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -18,20 +20,8 @@ import lombok.NoArgsConstructor;
|
|||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"id", "devId", "online", "status", "message"})
|
||||
public class LinkStatusRsp extends IDReturnStatus {
|
||||
/**
|
||||
* The Online.
|
||||
*/
|
||||
private int online;
|
||||
/**
|
||||
* the id
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* the status
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* the message
|
||||
*/
|
||||
private String message;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The type Node task data.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -22,9 +24,6 @@ import java.util.List;
|
|||
@JsonPropertyOrder({"id", "taskArray", "status", "message"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class NodeTaskData extends IDReturnStatus {
|
||||
/**
|
||||
* The Task array.
|
||||
*/
|
||||
private List<TaskInfoData> taskArray;
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,14 +9,13 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The type Node task rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
public class NodeTaskRsp {
|
||||
/**
|
||||
* The Items.
|
||||
*/
|
||||
private List<NodeTaskData> items;
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,13 +20,12 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The type Version list rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class VersionListRsp {
|
||||
/**
|
||||
* The Items.
|
||||
*/
|
||||
private List<VersionRsp> items;
|
||||
|
||||
}
|
|
@ -10,6 +10,8 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
/**
|
||||
* The type Version rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -18,24 +20,9 @@ import lombok.NoArgsConstructor;
|
|||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"id", "devId", "version", "status", "message"})
|
||||
public class VersionRsp extends IDReturnStatus {
|
||||
/**
|
||||
* The Version.
|
||||
*/
|
||||
private String version;
|
||||
/**
|
||||
* the id
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* the devId
|
||||
*/
|
||||
private String devId;
|
||||
/**
|
||||
* the status
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* the message
|
||||
*/
|
||||
private String message;
|
||||
}
|
||||
|
|
|
@ -1,25 +1,20 @@
|
|||
package com.dispose.pojo.vo.task;
|
||||
|
||||
import com.dispose.pojo.vo.common.IDArrayReq;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* The type Get task req.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class GetTaskReq {
|
||||
/**
|
||||
* The Id.
|
||||
*/
|
||||
private String[] id;
|
||||
|
||||
/**
|
||||
* The Type.
|
||||
*/
|
||||
public class GetTaskReq extends IDArrayReq {
|
||||
private Integer type;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
/**
|
||||
* The type Start task req.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
|
@ -15,32 +17,11 @@ import lombok.NoArgsConstructor;
|
|||
@AllArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class StartTaskReq {
|
||||
/**
|
||||
* The Id.
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* The Type.
|
||||
*/
|
||||
private String id;
|
||||
private Integer type;
|
||||
/**
|
||||
* The Dispose ip.
|
||||
*/
|
||||
private String disposeIp;
|
||||
/**
|
||||
* The Dispose time.
|
||||
*/
|
||||
private Integer disposeTime;
|
||||
/**
|
||||
* The Flow direction.
|
||||
*/
|
||||
private Integer flowDirection;
|
||||
/**
|
||||
* The Attack type.
|
||||
*/
|
||||
private Integer[] attackType;
|
||||
/**
|
||||
* The Flow band width.
|
||||
*/
|
||||
private Integer flowBandwidth;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
/**
|
||||
* The type Start task rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -18,12 +20,6 @@ import lombok.NoArgsConstructor;
|
|||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"id", "taskId", "expireTime", "status", "message"})
|
||||
public class StartTaskRsp extends IDReturnStatus {
|
||||
/**
|
||||
* The Task id.
|
||||
*/
|
||||
private String taskId;
|
||||
/**
|
||||
* The Expire time.
|
||||
*/
|
||||
private int expireTime;
|
||||
private Long expireTime;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
/**
|
||||
* The type Stop task data.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
|
@ -17,16 +19,7 @@ import lombok.NoArgsConstructor;
|
|||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({"id", "type", "disposeIp"})
|
||||
public class StopTaskData {
|
||||
/**
|
||||
* The Id.
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* The Type.
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* The Dispose ip.
|
||||
*/
|
||||
private String disposeIp;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The type Stop task req.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
|
|
|
@ -10,6 +10,8 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The type Task info rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
|
|
|
@ -3,12 +3,14 @@ package com.dispose.service;
|
|||
import com.dispose.common.DeviceCapacity;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.po.MReturnType;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The interface Dispose node manager.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface DisposeNodeManager {
|
||||
/**
|
||||
|
@ -17,7 +19,7 @@ public interface DisposeNodeManager {
|
|||
* @param dev the dev
|
||||
* @return the m return type
|
||||
*/
|
||||
MReturnType<ErrorCode, String> addNewDisposeDevice(DisposeDevice dev);
|
||||
MulReturnType<ErrorCode, String> addNewDisposeDevice(DisposeDevice dev);
|
||||
|
||||
/**
|
||||
* Del dispose device by ip error code.
|
||||
|
@ -59,9 +61,9 @@ public interface DisposeNodeManager {
|
|||
DisposeDevice getDisposeDeviceById(Long id);
|
||||
|
||||
/**
|
||||
* Load dispose node from db.
|
||||
* Load dispose node from database.
|
||||
*/
|
||||
void loadDisposeNodeFromDB();
|
||||
void loadDisposeNodeFromDatabase();
|
||||
|
||||
/**
|
||||
* Cleanup dispose node cache.
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package com.dispose.service;
|
||||
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.po.MReturnType;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.pojo.vo.common.TaskInfoDetail;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The interface Task service.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface TaskService {
|
||||
/**
|
||||
|
@ -21,7 +23,7 @@ public interface TaskService {
|
|||
* @param task the task
|
||||
* @return the m return type
|
||||
*/
|
||||
MReturnType<ErrorCode, Long> createTask(TaskInfoDetail task);
|
||||
MulReturnType<ErrorCode, Long> createTask(TaskInfoDetail task);
|
||||
|
||||
/**
|
||||
* Start task error code.
|
||||
|
@ -40,14 +42,14 @@ public interface TaskService {
|
|||
ErrorCode stopTask(Long taskId);
|
||||
|
||||
/**
|
||||
* Stop task by dispose ip error code.
|
||||
* Stop task by dispose ip list.
|
||||
*
|
||||
* @param devId the dev id
|
||||
* @param type the type
|
||||
* @param ipAddr the ip addr
|
||||
* @return the error code
|
||||
* @return the list
|
||||
*/
|
||||
List<MReturnType<ErrorCode, TaskInfoDetail>> stopTaskByDisposeIp(Long devId, int type, String ipAddr);
|
||||
List<MulReturnType<ErrorCode, TaskInfoDetail>> stopTaskByDisposeIp(Long devId, int type, String ipAddr);
|
||||
|
||||
/**
|
||||
* Stop task by task id list.
|
||||
|
@ -55,7 +57,7 @@ public interface TaskService {
|
|||
* @param taskId the task id
|
||||
* @return the list
|
||||
*/
|
||||
List<MReturnType<ErrorCode, TaskInfoDetail>> stopTaskByTaskId(Long taskId);
|
||||
List<MulReturnType<ErrorCode, TaskInfoDetail>> stopTaskByTaskId(Long taskId);
|
||||
|
||||
/**
|
||||
* Stop task by type list.
|
||||
|
@ -63,7 +65,7 @@ public interface TaskService {
|
|||
* @param type the type
|
||||
* @return the list
|
||||
*/
|
||||
List<MReturnType<ErrorCode, TaskInfoDetail>> stopTaskByType(int type);
|
||||
List<MulReturnType<ErrorCode, TaskInfoDetail>> stopTaskByType(int type);
|
||||
|
||||
/**
|
||||
* Stop task by dispose node list.
|
||||
|
@ -72,7 +74,7 @@ public interface TaskService {
|
|||
* @param type the type
|
||||
* @return the list
|
||||
*/
|
||||
List<MReturnType<ErrorCode, TaskInfoDetail>> stopTaskByDisposeNode(Long devId, int type);
|
||||
List<MulReturnType<ErrorCode, TaskInfoDetail>> stopTaskByDisposeNode(Long devId, int type);
|
||||
|
||||
/**
|
||||
* Finish task error code.
|
||||
|
@ -83,7 +85,7 @@ public interface TaskService {
|
|||
ErrorCode finishTask(Long taskId);
|
||||
|
||||
/**
|
||||
* Task is running xx boolean.
|
||||
* Task is running boolean.
|
||||
*
|
||||
* @param task the task
|
||||
* @return the boolean
|
||||
|
@ -131,4 +133,11 @@ public interface TaskService {
|
|||
* @return the all task
|
||||
*/
|
||||
List<TaskInfoDetail> getAllTask();
|
||||
|
||||
/**
|
||||
* Gets active task.
|
||||
*
|
||||
* @return the active task
|
||||
*/
|
||||
List<TaskInfoDetail> getActiveTask();
|
||||
}
|
||||
|
|
|
@ -2,12 +2,14 @@ package com.dispose.service;
|
|||
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.entity.UserAccount;
|
||||
import com.dispose.pojo.po.MReturnType;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* The interface User account service.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface UserAccountService {
|
||||
/**
|
||||
|
@ -18,7 +20,7 @@ public interface UserAccountService {
|
|||
* @return the m return type
|
||||
* @throws NoSuchAlgorithmException the no such algorithm exception
|
||||
*/
|
||||
MReturnType<ErrorCode, String> loginService(String username, String password) throws NoSuchAlgorithmException;
|
||||
MulReturnType<ErrorCode, String> loginService(String username, String password) throws NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* Logout service error code.
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.dispose.dispose.DisposeEntryManager;
|
|||
import com.dispose.mapper.DisposeDeviceMapper;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.po.DisposeDeviceCapacity;
|
||||
import com.dispose.pojo.po.MReturnType;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.service.DisposeNodeManager;
|
||||
import com.dispose.service.UserAccountService;
|
||||
import inet.ipaddr.AddressStringException;
|
||||
|
@ -24,35 +24,31 @@ import java.util.stream.Collectors;
|
|||
|
||||
/**
|
||||
* The type Dispose node manager.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DisposeNodeManagerImpl implements DisposeNodeManager {
|
||||
/**
|
||||
* The Dispose dev map.
|
||||
*/
|
||||
private final ConcurrentHashMap<String, DisposeDevice> disposeDevMap = new ConcurrentHashMap<>();
|
||||
/**
|
||||
* The Dispose device mapper.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeDeviceMapper disposeDeviceMapper;
|
||||
/**
|
||||
* The User account service.
|
||||
*/
|
||||
@Resource
|
||||
private UserAccountService userAccountService;
|
||||
|
||||
/**
|
||||
* Cleanup dispose node cache.
|
||||
*/
|
||||
@Override
|
||||
public void cleanupDisposeNodeCache() {
|
||||
disposeDevMap.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load dispose node from db.
|
||||
* Load dispose node from database.
|
||||
*/
|
||||
@Override
|
||||
public void loadDisposeNodeFromDB() {
|
||||
public void loadDisposeNodeFromDatabase() {
|
||||
// 清理缓存中的所有内容
|
||||
disposeDevMap.clear();
|
||||
|
||||
|
@ -137,12 +133,14 @@ public class DisposeNodeManagerImpl implements DisposeNodeManager {
|
|||
* @return the m return type
|
||||
*/
|
||||
@Override
|
||||
public MReturnType<ErrorCode, String> addNewDisposeDevice(DisposeDevice dev) {
|
||||
public MulReturnType<ErrorCode, String> addNewDisposeDevice(DisposeDevice dev) {
|
||||
DisposeEntryManager dp;
|
||||
|
||||
if (dev.getType() == null || dev.getIpAddr() == null || !IPAddrType.isIpAddress(dev.getIpAddr())) {
|
||||
if (dev.getType() == null || dev.getIpAddr() == null
|
||||
|| dev.getIpAddr().length() == 0
|
||||
|| !IPAddrType.isIpAddress(dev.getIpAddr())) {
|
||||
log.error("Add device error: type {}, ip {}", dev.getType(), dev.getIpAddr());
|
||||
return new MReturnType<>(ErrorCode.ERR_PARAMEXCEPTION, String.valueOf(-1));
|
||||
return new MulReturnType<>(ErrorCode.ERR_PARAMS, String.valueOf(-1));
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -154,11 +152,11 @@ public class DisposeNodeManagerImpl implements DisposeNodeManager {
|
|||
if (!dp.getDeviceLinkStatus()) {
|
||||
log.error("The device heartbeat is abnormal and offline: deviceId:{}, type:{}, ip:{}",
|
||||
dev.getId(), dev.getType(), dev.getIpAddr());
|
||||
return new MReturnType<>(ErrorCode.ERR_NOSUCHDEVICE, String.valueOf(-1));
|
||||
return new MulReturnType<>(ErrorCode.ERR_NOSUCHDEVICE, String.valueOf(-1));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.error("No such dispose device: deviceId:{}, type:{}, ip:{}", dev.getId(), dev.getType(), dev.getIpAddr());
|
||||
return new MReturnType<>(ErrorCode.ERR_NOSUCHDEVICE, String.valueOf(-1));
|
||||
return new MulReturnType<>(ErrorCode.ERR_NOSUCHDEVICE, String.valueOf(-1));
|
||||
}
|
||||
|
||||
// 从缓存中获取设备信息
|
||||
|
@ -167,7 +165,7 @@ public class DisposeNodeManagerImpl implements DisposeNodeManager {
|
|||
// 设备已经存在
|
||||
if (dbDev != null) {
|
||||
log.error("The dispose device already exists: deviceId:{}, type:{}, ip:{}", dev.getId(), dev.getType(), dev.getIpAddr());
|
||||
return new MReturnType<>(ErrorCode.ERR_DEVICEEXISTS, String.valueOf(dbDev.getId()));
|
||||
return new MulReturnType<>(ErrorCode.ERR_DEVICEEXISTS, String.valueOf(dbDev.getId()));
|
||||
}
|
||||
|
||||
// 获取设备能力
|
||||
|
@ -186,7 +184,7 @@ public class DisposeNodeManagerImpl implements DisposeNodeManager {
|
|||
|
||||
// 保存设备信息到缓存中
|
||||
disposeDevMap.put(dev.getIpAddr(), dev);
|
||||
return new MReturnType<>(ErrorCode.ERR_OK, dev.getId().toString());
|
||||
return new MulReturnType<>(ErrorCode.ERR_OK, dev.getId().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -225,13 +223,6 @@ public class DisposeNodeManagerImpl implements DisposeNodeManager {
|
|||
return findRet.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is ip in range boolean.
|
||||
*
|
||||
* @param cap the cap
|
||||
* @param ipAddr the ip addr
|
||||
* @return the boolean
|
||||
*/
|
||||
private boolean isIpInRange(DisposeDeviceCapacity cap, String ipAddr) {
|
||||
try {
|
||||
if (IPAddrType.getIpAddrType(ipAddr) == IPAddrType.IPV4_TYPE) {
|
||||
|
|
|
@ -3,13 +3,12 @@ package com.dispose.service.impl;
|
|||
import com.dispose.common.DeviceCapacity;
|
||||
import com.dispose.common.DisposeTaskStatus;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.common.IPAddrType;
|
||||
import com.dispose.dispose.DeviceRouter;
|
||||
import com.dispose.dispose.DisposeEntryManager;
|
||||
import com.dispose.manager.TaskCacheManager;
|
||||
import com.dispose.mapper.DisposeTaskMapper;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.po.MReturnType;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.pojo.vo.common.TaskInfoDetail;
|
||||
import com.dispose.service.DisposeNodeManager;
|
||||
import com.dispose.service.TaskService;
|
||||
|
@ -29,42 +28,25 @@ import java.util.stream.Collectors;
|
|||
|
||||
/**
|
||||
* The type Task service.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class TaskServiceImpl implements TaskService {
|
||||
|
||||
/**
|
||||
* The Object mapper.
|
||||
*/
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
/**
|
||||
* The Task cache manager.
|
||||
*/
|
||||
@Resource
|
||||
private TaskCacheManager taskCacheManager;
|
||||
|
||||
/**
|
||||
* The Dispose task mapper.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeTaskMapper disposeTaskMapper;
|
||||
|
||||
/**
|
||||
* The Dispose node manager.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeNodeManager disposeNodeManager;
|
||||
|
||||
/**
|
||||
* Gets dispose device handle.
|
||||
*
|
||||
* @param disposeIp the dispose ip
|
||||
* @param devCapType the dev cap type
|
||||
* @return the dispose device handle
|
||||
*/
|
||||
private DisposeEntryManager getDisposeDeviceHandle(String disposeIp, int devCapType) {
|
||||
|
||||
DisposeDevice dev = getDisposeNode(disposeIp, devCapType);
|
||||
|
@ -77,13 +59,6 @@ public class TaskServiceImpl implements TaskService {
|
|||
return DeviceRouter.deviceRouterFactory(dev.getType(), dev.getIpAddr());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets dispose node.
|
||||
*
|
||||
* @param disposeIp the dispose ip
|
||||
* @param devCapType the dev cap type
|
||||
* @return the dispose node
|
||||
*/
|
||||
private DisposeDevice getDisposeNode(String disposeIp, int devCapType) {
|
||||
DeviceCapacity cap;
|
||||
|
||||
|
@ -105,14 +80,13 @@ public class TaskServiceImpl implements TaskService {
|
|||
*/
|
||||
@Override
|
||||
public void loadTaskFromDatabase() {
|
||||
// 从数据库中取出所有新建和正在运行的任务
|
||||
List<TaskInfoDetail> taskList = disposeTaskMapper.selectAll()
|
||||
.stream()
|
||||
.filter(v -> v.getType().equals(DisposeTaskStatus.TASK_NEW.getCode())
|
||||
|| v.getType().equals(DisposeTaskStatus.TASK_RUNNING.getCode()))
|
||||
// 从数据库中取出所有任务
|
||||
List<TaskInfoDetail> taskList = disposeTaskMapper.selectAll().stream()
|
||||
.filter(this::taskIsRunning)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
taskList.forEach(v -> {
|
||||
v.setRetryTimes(0);
|
||||
if (taskCacheManager.addTask(v) != ErrorCode.ERR_OK) {
|
||||
try {
|
||||
log.error("load error:\n" + objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(v));
|
||||
|
@ -130,23 +104,13 @@ public class TaskServiceImpl implements TaskService {
|
|||
* @return the m return type
|
||||
*/
|
||||
@Override
|
||||
public MReturnType<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 MReturnType.<ErrorCode, Long>builder()
|
||||
.firstParam(ErrorCode.ERR_PARAMEXCEPTION)
|
||||
.secondParam(-1L)
|
||||
.build();
|
||||
}
|
||||
|
||||
public MulReturnType<ErrorCode, Long> createTask(TaskInfoDetail task) {
|
||||
DisposeDevice disposeDevice;
|
||||
Long taskId = task.getDeviceId();
|
||||
|
||||
// 首先查找有没有能处置这个ip的能力节点
|
||||
if (taskId == null || taskId < 0) { // 没有指定处置能力节点的情况
|
||||
// 没有指定处置能力节点的情况
|
||||
if (taskId == null || taskId < 0) {
|
||||
disposeDevice = getDisposeNode(task.getDisposeIp(), task.getType());
|
||||
} else { // 指定了处置能力节点的情况
|
||||
disposeDevice = disposeNodeManager.getDisposeDeviceById(taskId);
|
||||
|
@ -155,7 +119,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
if (disposeDevice == null) {
|
||||
log.error("No such device to dispose this task: devId:{}, disposeIp:{}, type:{}",
|
||||
task.getDeviceId(), task.getDisposeIp(), task.getType());
|
||||
return MReturnType.<ErrorCode, Long>builder()
|
||||
return MulReturnType.<ErrorCode, Long>builder()
|
||||
.firstParam(ErrorCode.ERR_NOSUCHDEVICE)
|
||||
.secondParam(-1L)
|
||||
.build();
|
||||
|
@ -164,7 +128,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
}
|
||||
|
||||
// 查询当前是否有相同能力节点,相同用户,相同处置IP的且正在执行的处置任务,如果存在则忽略该次任务(依照产品需求)
|
||||
List<TaskInfoDetail> taskList = taskCacheManager.getAllTask()
|
||||
List<TaskInfoDetail> taskList = taskCacheManager.getAllRunningTask()
|
||||
.stream()
|
||||
.filter(v -> ((taskId == null || taskId == -1L) || Objects.equals(v.getDeviceId(), task.getDeviceId()))
|
||||
&& Objects.equals(v.getAccountId(), task.getAccountId())
|
||||
|
@ -176,7 +140,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
if (taskList.size() > 0) {
|
||||
log.error("Same dispose task is running: devId:{}, disposeIp:{}, type:{}",
|
||||
task.getDeviceId(), task.getDisposeIp(), task.getType());
|
||||
return MReturnType.<ErrorCode, Long>builder()
|
||||
return MulReturnType.<ErrorCode, Long>builder()
|
||||
.firstParam(ErrorCode.ERR_TASKRUNNING)
|
||||
.secondParam(taskList.get(0).getId())
|
||||
.build();
|
||||
|
@ -194,7 +158,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
log.info("Create new dispose task is running: devId:{}, disposeIp:{}, type:{}, result:{}",
|
||||
task.getDeviceId(), task.getDisposeIp(), task.getType(), err.getMsg());
|
||||
|
||||
return MReturnType.<ErrorCode, Long>builder().firstParam(err).secondParam(task.getId()).build();
|
||||
return MulReturnType.<ErrorCode, Long>builder().firstParam(err).secondParam(task.getId()).build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -331,7 +295,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
}
|
||||
|
||||
/**
|
||||
* Task is running xx boolean.
|
||||
* Task is running boolean.
|
||||
*
|
||||
* @param task the task
|
||||
* @return the boolean
|
||||
|
@ -364,7 +328,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
@Override
|
||||
public List<TaskInfoDetail> getNodeAllRunningTask(Long devId) {
|
||||
List<TaskInfoDetail> taskList = taskCacheManager
|
||||
.getAllTask()
|
||||
.getAllRunningTask()
|
||||
.stream()
|
||||
.filter(v -> v.getCurrentStatus() == DisposeTaskStatus.TASK_RUNNING.getCode()
|
||||
&& v.getDeviceId().equals(devId))
|
||||
|
@ -386,17 +350,14 @@ public class TaskServiceImpl implements TaskService {
|
|||
*/
|
||||
@Override
|
||||
public List<TaskInfoDetail> getNodeAllTask(Long devId) {
|
||||
List<TaskInfoDetail> taskList = taskCacheManager
|
||||
.getAllTask()
|
||||
.stream()
|
||||
.filter(v -> v.getDeviceId().equals(devId))
|
||||
.collect(Collectors.toList());
|
||||
List<TaskInfoDetail> taskList = disposeTaskMapper.getAllTaskByNodeDevId(devId);
|
||||
|
||||
if (taskList.size() > 0) {
|
||||
log.info("The device has tasks: devId:{}, tasksNumber:{}", devId, taskList.size());
|
||||
return taskList;
|
||||
}
|
||||
|
||||
log.info("The device has nothing tasks: devId:{}", devId);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
|
@ -407,15 +368,41 @@ public class TaskServiceImpl implements TaskService {
|
|||
*/
|
||||
@Override
|
||||
public List<TaskInfoDetail> getAllTask() {
|
||||
return taskCacheManager.getAllTask();
|
||||
List<TaskInfoDetail> taskList = disposeTaskMapper.selectAll();
|
||||
|
||||
if (taskList.size() > 0) {
|
||||
return taskList;
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets active task.
|
||||
*
|
||||
* @return the active task
|
||||
*/
|
||||
@Override
|
||||
public List<MReturnType<ErrorCode, TaskInfoDetail>> stopTaskByTaskId(Long taskId) {
|
||||
List<MReturnType<ErrorCode, TaskInfoDetail>> retList = new ArrayList<>();
|
||||
public List<TaskInfoDetail> getActiveTask() {
|
||||
List<TaskInfoDetail> taskList = taskCacheManager.getAllRunningTask();
|
||||
|
||||
if (taskList.size() > 0) {
|
||||
return taskList;
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop task by task id list.
|
||||
*
|
||||
* @param taskId the task id
|
||||
* @return the list
|
||||
*/
|
||||
@Override
|
||||
public List<MulReturnType<ErrorCode, TaskInfoDetail>> stopTaskByTaskId(Long taskId) {
|
||||
List<MulReturnType<ErrorCode, TaskInfoDetail>> retList = new ArrayList<>();
|
||||
|
||||
// 根据处置IP,拿出所有正在处置的任务
|
||||
List<TaskInfoDetail> taskList = taskCacheManager.getAllTask().stream()
|
||||
List<TaskInfoDetail> taskList = taskCacheManager.getAllRunningTask().stream()
|
||||
.filter(v -> (Objects.equals(v.getId(), taskId))
|
||||
&& taskIsRunning(v))
|
||||
.collect(Collectors.toList());
|
||||
|
@ -423,7 +410,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
// 对符合条件的任务调用停止命令
|
||||
taskList.forEach(v -> {
|
||||
ErrorCode err = stopTask(v.getId());
|
||||
retList.add(new MReturnType<>(err, v));
|
||||
retList.add(new MulReturnType<>(err, v));
|
||||
});
|
||||
|
||||
return retList;
|
||||
|
@ -440,27 +427,29 @@ public class TaskServiceImpl implements TaskService {
|
|||
*/
|
||||
@Override
|
||||
public boolean taskIsExists(Long devId, Long userId, String disposeIp, int disposeType) {
|
||||
return taskCacheManager.getAllTask().stream()
|
||||
return taskCacheManager.getAllRunningTask().stream()
|
||||
.anyMatch(v -> Objects.equals(v.getAccountId(), userId)
|
||||
&& Objects.equals(v.getDeviceId(), devId)
|
||||
&& Objects.equals(v.getDisposeIp(), disposeIp)
|
||||
&& Objects.equals(v.getType(), disposeType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop task by dispose ip list.
|
||||
*
|
||||
* @param devId the dev id
|
||||
* @param type the type
|
||||
* @param ipAddr the ip addr
|
||||
* @return the list
|
||||
*/
|
||||
@Override
|
||||
public List<MReturnType<ErrorCode, TaskInfoDetail>> stopTaskByDisposeIp(Long devId, int type, String ipAddr) {
|
||||
List<MReturnType<ErrorCode, TaskInfoDetail>> retList = new ArrayList<>();
|
||||
|
||||
if (devId == null || devId == -1L || ipAddr == null || ipAddr.length() == 0 || !IPAddrType.isIpAddress(ipAddr)) {
|
||||
retList.add(new MReturnType<>(ErrorCode.ERR_PARAMEXCEPTION, null));
|
||||
log.error("Input params error: devId:{}, disposeIp:{}, type:{}", devId, ipAddr, type);
|
||||
return retList;
|
||||
}
|
||||
public List<MulReturnType<ErrorCode, TaskInfoDetail>> stopTaskByDisposeIp(Long devId, int type, String ipAddr) {
|
||||
List<MulReturnType<ErrorCode, TaskInfoDetail>> retList = new ArrayList<>();
|
||||
|
||||
// 根据处置IP,拿出所有正在处置的任务
|
||||
List<TaskInfoDetail> taskList = taskCacheManager.getAllTask().stream()
|
||||
List<TaskInfoDetail> taskList = taskCacheManager.getAllRunningTask().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());
|
||||
|
@ -468,46 +457,59 @@ public class TaskServiceImpl implements TaskService {
|
|||
// 对符合条件的任务调用停止命令
|
||||
taskList.forEach(v -> {
|
||||
ErrorCode err = stopTask(v.getId());
|
||||
retList.add(new MReturnType<>(err, v));
|
||||
retList.add(new MulReturnType<>(err, v));
|
||||
});
|
||||
|
||||
return retList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop task by dispose node list.
|
||||
*
|
||||
* @param devId the dev id
|
||||
* @param type the type
|
||||
* @return the list
|
||||
*/
|
||||
@Override
|
||||
public List<MReturnType<ErrorCode, TaskInfoDetail>> stopTaskByDisposeNode(Long devId, int type) {
|
||||
List<MReturnType<ErrorCode, TaskInfoDetail>> retList = new ArrayList<>();
|
||||
public List<MulReturnType<ErrorCode, TaskInfoDetail>> stopTaskByDisposeNode(Long devId, int type) {
|
||||
List<MulReturnType<ErrorCode, TaskInfoDetail>> retList = new ArrayList<>();
|
||||
|
||||
// 根据处置IP,拿出所有正在处置的任务
|
||||
List<TaskInfoDetail> taskList = taskCacheManager.getAllTask().stream()
|
||||
List<TaskInfoDetail> taskList = taskCacheManager.getAllRunningTask().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());
|
||||
|
||||
// 对符合条件的任务调用停止命令
|
||||
taskList.forEach(v -> {
|
||||
ErrorCode err = stopTask(v.getId());
|
||||
retList.add(new MReturnType<>(err, v));
|
||||
retList.add(new MulReturnType<>(err, v));
|
||||
});
|
||||
|
||||
return retList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop task by type list.
|
||||
*
|
||||
* @param type the type
|
||||
* @return the list
|
||||
*/
|
||||
@Override
|
||||
public List<MReturnType<ErrorCode, TaskInfoDetail>> stopTaskByType(int type) {
|
||||
List<MReturnType<ErrorCode, TaskInfoDetail>> retList = new ArrayList<>();
|
||||
public List<MulReturnType<ErrorCode, TaskInfoDetail>> stopTaskByType(int type) {
|
||||
List<MulReturnType<ErrorCode, TaskInfoDetail>> retList = new ArrayList<>();
|
||||
|
||||
// 根据处置IP,拿出所有正在处置的任务
|
||||
List<TaskInfoDetail> taskList = taskCacheManager.getAllTask().stream()
|
||||
.filter(v -> (Objects.equals(v.getType(), type) || type == -1)
|
||||
List<TaskInfoDetail> taskList = taskCacheManager.getAllRunningTask().stream()
|
||||
.filter(v -> (Objects.equals(v.getType(), type) || type == DeviceCapacity.ALLCAPACITY.getCode())
|
||||
&& taskIsRunning(v))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 对符合条件的任务调用停止命令
|
||||
taskList.forEach(v -> {
|
||||
ErrorCode err = stopTask(v.getId());
|
||||
retList.add(new MReturnType<>(err, v));
|
||||
retList.add(new MulReturnType<>(err, v));
|
||||
});
|
||||
|
||||
return retList;
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.dispose.config.DisposeConfigure;
|
|||
import com.dispose.manager.UserAccountCacheManager;
|
||||
import com.dispose.mapper.UserAccountMapper;
|
||||
import com.dispose.pojo.entity.UserAccount;
|
||||
import com.dispose.pojo.po.MReturnType;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.service.UserAccountService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -16,26 +16,19 @@ import java.security.NoSuchAlgorithmException;
|
|||
|
||||
/**
|
||||
* The type User account service.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class UserAccountServiceImpl implements UserAccountService {
|
||||
|
||||
/**
|
||||
* The User account cache manager.
|
||||
*/
|
||||
@Resource
|
||||
private UserAccountCacheManager userAccountCacheManager;
|
||||
|
||||
/**
|
||||
* The User account mapper.
|
||||
*/
|
||||
@Resource
|
||||
private UserAccountMapper userAccountMapper;
|
||||
|
||||
/**
|
||||
* The Dispose configure.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeConfigure disposeConfigure;
|
||||
|
||||
|
@ -48,7 +41,7 @@ public class UserAccountServiceImpl implements UserAccountService {
|
|||
@Override
|
||||
public ErrorCode authTokenCheck(String token) {
|
||||
// 判断当前配置是否需要校验 token
|
||||
if ("false".equals(disposeConfigure.getCheckRequestToken())) {
|
||||
if (String.valueOf(false).equals(disposeConfigure.getCheckRequestToken())) {
|
||||
return ErrorCode.ERR_OK;
|
||||
}
|
||||
|
||||
|
@ -64,20 +57,20 @@ public class UserAccountServiceImpl implements UserAccountService {
|
|||
* @throws NoSuchAlgorithmException the no such algorithm exception
|
||||
*/
|
||||
@Override
|
||||
public MReturnType<ErrorCode, String> loginService(String username, String password) throws NoSuchAlgorithmException {
|
||||
public MulReturnType<ErrorCode, String> loginService(String username, String password) throws NoSuchAlgorithmException {
|
||||
userAccountMapper.refreshLoginTime(username);
|
||||
UserAccount loginUser = userAccountMapper.getUserByName(username);
|
||||
|
||||
// 该用户是否存在
|
||||
if (loginUser == null) {
|
||||
log.error("User {} not exists", username);
|
||||
return MReturnType.<ErrorCode, String>builder().firstParam(ErrorCode.ERR_USERNOTFOUND).build();
|
||||
return MulReturnType.<ErrorCode, String>builder().firstParam(ErrorCode.ERR_USERNOTFOUND).build();
|
||||
}
|
||||
|
||||
// 用户是否被锁定
|
||||
if (loginUser.getStatus() == ConstValue.UserAccountStatus.LOCKED) {
|
||||
log.error("User {} is locked", username);
|
||||
return MReturnType.<ErrorCode, String>builder().firstParam(ErrorCode.ERR_USERLOCK).build();
|
||||
return MulReturnType.<ErrorCode, String>builder().firstParam(ErrorCode.ERR_USERLOCK).build();
|
||||
}
|
||||
|
||||
// 用户密码错误
|
||||
|
@ -92,19 +85,19 @@ public class UserAccountServiceImpl implements UserAccountService {
|
|||
if (errTimes == ConstValue.GlobalConfigure.ALLOW_PWD_ERR_TIMES - 1) {
|
||||
// 提示用户即将锁定账户
|
||||
log.error("User {} password [{}] error reach the upper limit", username, password);
|
||||
return MReturnType.<ErrorCode, String>builder().firstParam(ErrorCode.ERR_PASSWORDMORE).build();
|
||||
return MulReturnType.<ErrorCode, String>builder().firstParam(ErrorCode.ERR_PASSWORDMORE).build();
|
||||
} else if (errTimes >= ConstValue.GlobalConfigure.ALLOW_PWD_ERR_TIMES) {
|
||||
// 锁定账户
|
||||
userAccountMapper.lockUserAccount(username);
|
||||
log.error("User {} is locked", username);
|
||||
return MReturnType.<ErrorCode, String>builder().firstParam(ErrorCode.ERR_USERLOCK).build();
|
||||
return MulReturnType.<ErrorCode, String>builder().firstParam(ErrorCode.ERR_USERLOCK).build();
|
||||
} else {
|
||||
log.error("User {} password [{}] error", username, password);
|
||||
return MReturnType.<ErrorCode, String>builder().firstParam(ErrorCode.ERR_PASSWORD).build();
|
||||
return MulReturnType.<ErrorCode, String>builder().firstParam(ErrorCode.ERR_PASSWORD).build();
|
||||
}
|
||||
}
|
||||
|
||||
return MReturnType.<ErrorCode, String>builder()
|
||||
return MulReturnType.<ErrorCode, String>builder()
|
||||
.firstParam(ErrorCode.ERR_OK)
|
||||
.secondParam(userAccountCacheManager.getUserToken(username)).build();
|
||||
}
|
||||
|
|
|
@ -17,14 +17,13 @@ import java.util.Collections;
|
|||
|
||||
/**
|
||||
* The type Swagger 2 config.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class Swagger2Config {
|
||||
|
||||
/**
|
||||
* The My config.
|
||||
*/
|
||||
@Resource
|
||||
private MyConfig myConfig;
|
||||
|
||||
|
@ -37,16 +36,13 @@ public class Swagger2Config {
|
|||
public Docket api() {
|
||||
return new Docket(DocumentationType.SWAGGER_2).enable(Boolean.parseBoolean(myConfig.getSwaggerSwitch()))
|
||||
.select().apis(RequestHandlerSelectors.any()).paths(PathSelectors.any())
|
||||
.paths(Predicates.not(PathSelectors.regex("/error.*")))// 错误路径不监控
|
||||
.paths(PathSelectors.regex("/.*")) // 对根下所有路径进行监控
|
||||
// 错误路径不监控
|
||||
.paths(Predicates.not(PathSelectors.regex("/error.*")))
|
||||
// 对根下所有路径进行监控
|
||||
.paths(PathSelectors.regex("/.*"))
|
||||
.build().apiInfo(apiInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* Api info api info.
|
||||
*
|
||||
* @return the api info
|
||||
*/
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfo(
|
||||
"phoenix脚手架工程API示例", "展示所有API信息,方便测试", "API V1.0", "xxx", new Contact("phoenix",
|
||||
|
|
|
@ -14,12 +14,11 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* The type Device manager task.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Component
|
||||
public class DeviceManagerTask {
|
||||
/**
|
||||
* The Dispose node manager.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeNodeManager disposeNodeManager;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.dispose.task;
|
|||
|
||||
import com.dispose.common.DisposeTaskStatus;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.manager.TaskCacheManager;
|
||||
import com.dispose.common.GlobalVar;
|
||||
import com.dispose.pojo.vo.common.TaskInfoDetail;
|
||||
import com.dispose.service.TaskService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -15,19 +15,12 @@ import java.util.Iterator;
|
|||
|
||||
/**
|
||||
* The type Task manager task.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class TaskManagerTask {
|
||||
/**
|
||||
* The Task cache manager.
|
||||
*/
|
||||
@Resource
|
||||
private TaskCacheManager taskCacheManager;
|
||||
|
||||
/**
|
||||
* The Task service.
|
||||
*/
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
|
||||
|
@ -37,7 +30,7 @@ public class TaskManagerTask {
|
|||
@Async("bizExecutor")
|
||||
@Scheduled(fixedDelay = 1000)
|
||||
public void taskRuntimeManager() {
|
||||
Iterator<TaskInfoDetail> it = taskCacheManager.getAllTask().iterator();
|
||||
Iterator<TaskInfoDetail> it = taskService.getActiveTask().iterator();
|
||||
|
||||
// 由于可能删除列表中的项目,所以使用迭代器
|
||||
while (it.hasNext()) {
|
||||
|
@ -52,11 +45,17 @@ public class TaskManagerTask {
|
|||
continue;
|
||||
}
|
||||
|
||||
// 如果重试次数过多,停止处理该任务
|
||||
if(taskData.getRetryTimes() > GlobalVar.TASK_ERROR_MAX_RETRY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 判断是否有新建任务,如果有的话启动新建的处置任务
|
||||
if (taskData.getCurrentStatus() == DisposeTaskStatus.TASK_NEW.getCode()) {
|
||||
log.info("Start task {}:{} of {}",
|
||||
taskData.getId(), taskData.getDisposeIp(), taskData.getBeginTime());
|
||||
if (taskService.startTask(taskData.getId()) != ErrorCode.ERR_OK) {
|
||||
taskData.setRetryTimes(taskData.getRetryTimes() + 1);
|
||||
log.error("startTask Task {}:{} error\n", taskData.getId(), taskData.getDisposeIp());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ import java.util.concurrent.Executor;
|
|||
|
||||
/**
|
||||
* The type Thread pool config.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Configuration
|
||||
public class ThreadPoolConfig {
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.dispose.common.ConstValue;
|
|||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.common.GlobalVar;
|
||||
import com.dispose.pojo.dto.ProtocolRespDTO;
|
||||
import com.dispose.pojo.po.MReturnType;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.service.UserAccountService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.Getter;
|
||||
|
@ -66,7 +66,7 @@ public class InitTestEnvironment {
|
|||
*/
|
||||
@Before
|
||||
public void userLogin() throws Exception {
|
||||
MReturnType<ErrorCode, String> ret = userAccountService.loginService(getUSER_NAME(), getPASSWORD());
|
||||
MulReturnType<ErrorCode, String> ret = userAccountService.loginService(getUSER_NAME(), getPASSWORD());
|
||||
|
||||
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
||||
logToken = ret.getSecondParam();
|
||||
|
@ -155,12 +155,6 @@ public class InitTestEnvironment {
|
|||
}
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
if ((jsonObject.getString("code").length() == 0) ||
|
||||
Long.parseLong(jsonObject.getString("code")) != 200) {
|
||||
err = ErrorCode.ERR_UNKNOWNCMD;
|
||||
}
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
return jsonObject.getString("msgContent");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.dispose.test.controller;
|
||||
|
||||
import com.dispose.common.GlobalVar;
|
||||
import com.dispose.test.Global.InitTestEnvironment;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.po.ReturnStatus;
|
||||
|
@ -178,7 +179,7 @@ public class AuthControllerQATest extends InitTestEnvironment {
|
|||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_USERNOTFOUND.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
@ -188,7 +189,7 @@ public class AuthControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_USERNOTFOUND.getCode()));
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -207,7 +208,7 @@ public class AuthControllerQATest extends InitTestEnvironment {
|
|||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_USERNOTFOUND.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
@ -217,7 +218,7 @@ public class AuthControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_USERNOTFOUND.getCode()));
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -291,7 +292,7 @@ public class AuthControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/logout")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -322,7 +323,7 @@ public class AuthControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/logout")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -351,10 +352,10 @@ public class AuthControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/logout")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_USERNOTFOUND.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
@ -364,7 +365,7 @@ public class AuthControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_USERNOTFOUND.getCode()));
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -380,10 +381,10 @@ public class AuthControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/logout")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_USERNOTFOUND.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
@ -393,6 +394,6 @@ public class AuthControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_USERNOTFOUND.getCode()));
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.dispose.test.controller;
|
|||
|
||||
import com.dispose.common.ConstValue;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.common.GlobalVar;
|
||||
import com.dispose.pojo.dto.ProtocolReqDTO;
|
||||
import com.dispose.pojo.dto.ProtocolRespDTO;
|
||||
import com.dispose.pojo.vo.auth.LoginReq;
|
||||
|
@ -151,7 +152,7 @@ public class AuthControllerTest extends InitTestEnvironment {
|
|||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/logout")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
|
@ -180,7 +181,7 @@ public class AuthControllerTest extends InitTestEnvironment {
|
|||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/logout")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(502))
|
||||
|
@ -204,7 +205,7 @@ public class AuthControllerTest extends InitTestEnvironment {
|
|||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/logout")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_VERSION.getHttpCode()))
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
*/
|
||||
package com.dispose.test.controller;
|
||||
|
||||
import com.dispose.common.GlobalVar;
|
||||
import com.dispose.test.Global.InitTestEnvironment;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
|
@ -85,7 +86,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ver = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/version")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
|
@ -126,7 +127,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ver = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/version")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
|
@ -167,7 +168,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ver = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/version")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
|
@ -200,7 +201,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ver = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/version")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -227,7 +228,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ver = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/version")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -254,7 +255,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ver = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/version")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -282,20 +283,27 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ver = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/version")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
String msgContent = verifyResp(ver);
|
||||
VersionRsp versionRsp = objectMapper.readValue(msgContent, new TypeReference<VersionRsp>() {
|
||||
VersionListRsp versionListRsp = objectMapper.readValue(msgContent, new TypeReference<VersionListRsp>() {
|
||||
});
|
||||
|
||||
Assert.assertEquals(String.valueOf(versionRsp.getStatus()),
|
||||
String.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(versionRsp.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
|
||||
List<VersionRsp> verList = versionListRsp.getItems();
|
||||
|
||||
Assert.assertEquals(verList.size(), 1);
|
||||
for (VersionRsp versionRsp : verList
|
||||
) {
|
||||
Assert.assertNotNull(versionRsp.getId());
|
||||
Assert.assertEquals(String.valueOf(versionRsp.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
Assert.assertEquals(versionRsp.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -310,7 +318,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String deviceInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/deviceinfo")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
|
@ -348,7 +356,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String deviceInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/deviceinfo")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
|
@ -386,7 +394,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String deviceInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/deviceinfo")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
|
@ -418,7 +426,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String deviceInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/deviceinfo")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -446,7 +454,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String deviceInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/deviceinfo")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -473,7 +481,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String deviceInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/deviceinfo")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -501,20 +509,27 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String deviceInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/deviceinfo")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus rspInfo = objectMapper.readValue(verifyResp(deviceInfo), ReturnStatus.class);
|
||||
String msgContent = verifyResp(deviceInfo);
|
||||
DeviceInfoRsp deviceInfoRsp = objectMapper.readValue(msgContent, new TypeReference<DeviceInfoRsp>() {
|
||||
});
|
||||
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
|
||||
List<DeviceInfoData> verList = deviceInfoRsp.getItems();
|
||||
|
||||
Assert.assertEquals(verList.size(), 1);
|
||||
for (DeviceInfoData deviceInfoData : verList
|
||||
) {
|
||||
Assert.assertNotNull(deviceInfoData.getId());
|
||||
Assert.assertEquals(String.valueOf(deviceInfoData.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
Assert.assertEquals(deviceInfoData.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -529,7 +544,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String linkstatus = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/linkstatus")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
|
@ -573,7 +588,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String linkstatus = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/linkstatus")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
|
@ -616,7 +631,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String linkstatus = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/linkstatus")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
|
@ -652,7 +667,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String linkstatus = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/linkstatus")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -679,7 +694,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String linkstatus = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/linkstatus")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -706,7 +721,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String linkstatus = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/linkstatus")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -734,20 +749,27 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String linkstatus = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/linkstatus")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus rspInfo = objectMapper.readValue(verifyResp(linkstatus), ReturnStatus.class);
|
||||
String msgContent = verifyResp(linkstatus);
|
||||
LinkStatusListRsp linkStatusListRsp = objectMapper.readValue(msgContent, new TypeReference<LinkStatusListRsp>() {
|
||||
});
|
||||
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
|
||||
List<LinkStatusRsp> linkStatusRspList = linkStatusListRsp.getItems();
|
||||
|
||||
Assert.assertEquals(linkStatusRspList.size(), 1);
|
||||
for (LinkStatusRsp linkStatusRsp : linkStatusRspList
|
||||
) {
|
||||
Assert.assertNotNull(linkStatusRsp.getId());
|
||||
Assert.assertEquals(String.valueOf(linkStatusRsp.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
Assert.assertEquals(linkStatusRsp.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -761,7 +783,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
|
@ -799,7 +821,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
|
@ -837,7 +859,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
|
@ -877,7 +899,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
|
@ -905,7 +927,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
|
@ -933,7 +955,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
|
@ -961,19 +983,27 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(capacity), ReturnStatus.class);
|
||||
String msgContent = verifyResp(capacity);
|
||||
DeviceCapacityRsp deviceCapacityRsp = objectMapper.readValue(msgContent, new TypeReference<DeviceCapacityRsp>() {
|
||||
});
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
List<DeviceCapacityData> deviceCapacityDataList = deviceCapacityRsp.getItems();
|
||||
|
||||
Assert.assertEquals(deviceCapacityDataList.size(), 1);
|
||||
for (DeviceCapacityData deviceCapacityData : deviceCapacityDataList
|
||||
) {
|
||||
Assert.assertNotNull(deviceCapacityData.getId());
|
||||
Assert.assertEquals(String.valueOf(deviceCapacityData.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
Assert.assertEquals(deviceCapacityData.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -990,7 +1020,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
|
@ -1016,7 +1046,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String protectedIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/protected_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
|
@ -1056,7 +1086,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String protectedIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/protected_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
|
@ -1097,7 +1127,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String protectedIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/protected_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
|
@ -1139,7 +1169,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/protected_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
|
@ -1168,7 +1198,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/protected_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
|
@ -1196,7 +1226,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/protected_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
|
@ -1224,7 +1254,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/protected_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
|
@ -1253,7 +1283,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/protected_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
|
@ -1281,7 +1311,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/run_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -1336,7 +1366,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/run_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -1391,7 +1421,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/run_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -1420,7 +1450,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/run_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -1448,7 +1478,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/run_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -1477,7 +1507,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/run_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -1516,7 +1546,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/all_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -1571,7 +1601,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/all_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -1608,7 +1638,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/all_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -1637,7 +1667,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/all_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -1665,7 +1695,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/all_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -1694,7 +1724,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/all_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -1732,7 +1762,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_list")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -1772,7 +1802,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_list")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -1817,7 +1847,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_list")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -1861,35 +1891,19 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_list")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(ret), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(rspInfo);
|
||||
if (rspInfo.getItems().size() > 0) {
|
||||
for (DisposeNodeData disposeNodeData : rspInfo.getItems()
|
||||
) {
|
||||
Assert.assertNotNull(disposeNodeData);
|
||||
Assert.assertNotNull(disposeNodeData.getStatus());
|
||||
Assert.assertNotNull(disposeNodeData.getMessage());
|
||||
|
||||
if (disposeNodeData.getStatus() == 0) {
|
||||
Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertNotNull(disposeNodeData.getId());
|
||||
Assert.assertNotNull(String.valueOf(disposeNodeData.getType()));
|
||||
Assert.assertNotNull(disposeNodeData.getName());
|
||||
Assert.assertNotNull(disposeNodeData.getIp());
|
||||
} else {
|
||||
Assert.assertNotEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1906,38 +1920,23 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_list")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(ret), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(rspInfo);
|
||||
if (rspInfo.getItems().size() > 0) {
|
||||
for (DisposeNodeData disposeNodeData : rspInfo.getItems()
|
||||
) {
|
||||
Assert.assertNotNull(disposeNodeData);
|
||||
if (disposeNodeData.getStatus() == 0) {
|
||||
Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertNotNull(disposeNodeData.getId());
|
||||
Assert.assertNotNull(String.valueOf(disposeNodeData.getType()));
|
||||
Assert.assertNotNull(disposeNodeData.getName());
|
||||
Assert.assertNotNull(disposeNodeData.getIp());
|
||||
} else {
|
||||
Assert.assertNotEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
}
|
||||
Assert.assertNotNull(disposeNodeData.getStatus());
|
||||
Assert.assertNotNull(disposeNodeData.getMessage());
|
||||
}
|
||||
}
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* H 6 id null 目前默认这种情况是允许的,获取所有节点列表信息
|
||||
* H 6 id null 不允许
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
|
@ -1949,50 +1948,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_list")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
|
||||
|
||||
Assert.assertNotNull(rspInfo);
|
||||
if (rspInfo.getItems().size() > 0) {
|
||||
for (DisposeNodeData disposeNodeData : rspInfo.getItems()
|
||||
) {
|
||||
Assert.assertNotNull(disposeNodeData);
|
||||
if (disposeNodeData.getStatus() == 0) {
|
||||
Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertNotNull(disposeNodeData.getId());
|
||||
Assert.assertNotNull(String.valueOf(disposeNodeData.getType()));
|
||||
Assert.assertNotNull(disposeNodeData.getName());
|
||||
Assert.assertNotNull(disposeNodeData.getIp());
|
||||
} else {
|
||||
Assert.assertNotEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
}
|
||||
Assert.assertNotNull(disposeNodeData.getStatus());
|
||||
Assert.assertNotNull(disposeNodeData.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* H 7 id "abd"
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void h7_getNodeListErrorIdExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
|
||||
"\"msgContent\":\"{\\\"id\\\":[\\\"abd\\\"]}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_list")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -2007,6 +1963,39 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* H 7 id "abd"
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void h7_getNodeListErrorIdExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
|
||||
"\"msgContent\":\"{\\\"id\\\":[\\\"abd\\\"]}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_list")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
|
||||
List<DisposeNodeData> disposeNodeDataList = rspInfo.getItems();
|
||||
|
||||
Assert.assertEquals(disposeNodeDataList.size(), 1);
|
||||
for (DisposeNodeData disposeNodeData : disposeNodeDataList
|
||||
) {
|
||||
Assert.assertNotNull(disposeNodeData.getId());
|
||||
Assert.assertEquals(String.valueOf(disposeNodeData.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
Assert.assertEquals(disposeNodeData.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* I 1 get multiple Node Details Normal Test.
|
||||
*
|
||||
|
@ -2020,7 +2009,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_details")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -2035,7 +2024,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
for (DisposeNodeData disposeNodeData : rspInfo.getItems()
|
||||
) {
|
||||
Assert.assertNotNull(disposeNodeData);
|
||||
if(disposeNodeData.getStatus() == 0){
|
||||
if (disposeNodeData.getStatus() == 0) {
|
||||
Assert.assertNotNull(disposeNodeData.getId());
|
||||
Assert.assertNotNull(String.valueOf(disposeNodeData.getType()));
|
||||
Assert.assertNotNull(disposeNodeData.getIp());
|
||||
|
@ -2044,12 +2033,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
|
||||
Assert.assertNotNull(disposeNodeData.getCapacity());
|
||||
for (DisposeCapacity disposeCapacity:disposeNodeData.getCapacity()
|
||||
) {
|
||||
for (DisposeCapacity disposeCapacity : disposeNodeData.getCapacity()
|
||||
) {
|
||||
Assert.assertNotNull(disposeCapacity.getType());
|
||||
Assert.assertNotNull(disposeCapacity.getDisposeIp());
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
Assert.assertNotNull(disposeNodeData.getStatus());
|
||||
Assert.assertNotNull(disposeNodeData.getMessage());
|
||||
Assert.assertNotEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
|
@ -2071,7 +2060,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_details")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -2086,7 +2075,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
for (DisposeNodeData disposeNodeData : rspInfo.getItems()
|
||||
) {
|
||||
Assert.assertNotNull(disposeNodeData);
|
||||
if(disposeNodeData.getStatus() == 0){
|
||||
if (disposeNodeData.getStatus() == 0) {
|
||||
Assert.assertNotNull(disposeNodeData.getId());
|
||||
Assert.assertNotNull(String.valueOf(disposeNodeData.getType()));
|
||||
Assert.assertNotNull(disposeNodeData.getIp());
|
||||
|
@ -2095,12 +2084,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
|
||||
Assert.assertNotNull(disposeNodeData.getCapacity());
|
||||
for (DisposeCapacity disposeCapacity:disposeNodeData.getCapacity()
|
||||
for (DisposeCapacity disposeCapacity : disposeNodeData.getCapacity()
|
||||
) {
|
||||
Assert.assertNotNull(disposeCapacity.getType());
|
||||
Assert.assertNotNull(disposeCapacity.getDisposeIp());
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
Assert.assertNotNull(disposeNodeData.getStatus());
|
||||
Assert.assertNotNull(disposeNodeData.getMessage());
|
||||
Assert.assertNotEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
|
@ -2122,7 +2111,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_details")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -2151,7 +2140,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_details")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -2181,20 +2170,24 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_details")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus rspInfo = objectMapper.readValue(verifyResp(ret), ReturnStatus.class);
|
||||
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
|
||||
List<DisposeNodeData> disposeNodeDataList = rspInfo.getItems();
|
||||
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
|
||||
Assert.assertEquals(disposeNodeDataList.size(), 1);
|
||||
for (DisposeNodeData disposeNodeData : disposeNodeDataList
|
||||
) {
|
||||
Assert.assertNotNull(disposeNodeData.getId());
|
||||
Assert.assertEquals(String.valueOf(disposeNodeData.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
Assert.assertEquals(disposeNodeData.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.dispose.test.controller;
|
||||
|
||||
import com.dispose.common.GlobalVar;
|
||||
import com.dispose.test.Global.InitTestEnvironment;
|
||||
import com.dispose.common.DisposeTaskStatus;
|
||||
import com.dispose.common.ErrorCode;
|
||||
|
@ -80,7 +81,7 @@ public class DeviceNodeInfoControllerSmokeTest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/all_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -131,7 +132,7 @@ public class DeviceNodeInfoControllerSmokeTest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/all_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -160,7 +161,7 @@ public class DeviceNodeInfoControllerSmokeTest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/run_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -212,7 +213,7 @@ public class DeviceNodeInfoControllerSmokeTest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_details")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -255,7 +256,7 @@ public class DeviceNodeInfoControllerSmokeTest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_details")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.dispose.test.controller;
|
||||
|
||||
import com.dispose.common.GlobalVar;
|
||||
import com.dispose.test.Global.InitTestEnvironment;
|
||||
import com.dispose.common.ConstValue;
|
||||
import com.dispose.common.ErrorCode;
|
||||
|
@ -143,7 +144,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String ver = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/version")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -191,7 +192,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String verAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/version")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -239,7 +240,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String deviceInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/deviceinfo")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -288,7 +289,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String deviceInfoAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/deviceinfo")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -337,7 +338,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -392,7 +393,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String capacityAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -446,7 +447,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String protectedIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/protected_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -506,7 +507,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String protectedIpAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/protected_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -567,7 +568,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String nodeList = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_list")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -620,7 +621,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String nodeListAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_list")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -673,7 +674,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String disposeNodeDetails = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_details")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -731,7 +732,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String disposeNodeDetailsAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/node_details")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -784,7 +785,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String linkstatus = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/linkstatus")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -831,7 +832,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String linkStatusAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/linkstatus")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -877,7 +878,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String runTask = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/run_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -936,7 +937,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String runTaskAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/run_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -995,7 +996,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String taskAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/all_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -1052,7 +1053,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String allTaskAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/all_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.dispose.test.controller;
|
||||
|
||||
import com.dispose.common.GlobalVar;
|
||||
import com.dispose.pojo.vo.device.AddNodeRsp;
|
||||
import com.dispose.test.Global.InitTestEnvironment;
|
||||
import com.dispose.common.ErrorCode;
|
||||
|
@ -68,7 +69,7 @@ public class DeviceNodeManagerControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -95,7 +96,7 @@ public class DeviceNodeManagerControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -126,7 +127,7 @@ public class DeviceNodeManagerControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -157,7 +158,7 @@ public class DeviceNodeManagerControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -181,14 +182,13 @@ public class DeviceNodeManagerControllerQATest extends InitTestEnvironment {
|
|||
public void a6_addDeviceNodeTypeNullExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587628826908," +
|
||||
"\"msgContent\":\"{\\\"items\\\":[{\\\"areaCode\\\":0,\\\"ipAddr\\\":\\\"10.88.77.15\\\"," +
|
||||
"\\\"manufacturer\\\":\\\"DPTech\\\",\\\"model\\\":\\\"UMC\\\"," +
|
||||
"\\\"name\\\":\\\"中移杭研实验室清洗设备\\\",\\\"readme\\\":\\\"实验室测试设备\\\"," +
|
||||
"\\\"type\\\":\\\"null\\\",\\\"version\\\":\\\"5.7.13\\\"}]}\"}";
|
||||
"\\\"manufacturer\\\":\\\"DPTech\\\",\\\"model\\\":\\\"UMC\\\",\\\"name\\\":\\\"中移杭研实验室清洗设备\\\"," +
|
||||
"\\\"readme\\\":\\\"实验室测试设备\\\",\\\"type\\\":null,\\\"version\\\":\\\"5.7.13\\\"}]}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -206,11 +206,7 @@ public class DeviceNodeManagerControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertNotNull(v.getMessage());
|
||||
Assert.assertNotNull(v.getStatus());
|
||||
|
||||
if (v.getStatus() == 0) {
|
||||
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
} else if (v.getStatus() == 20) {
|
||||
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_DEVICEEXISTS.getCode()));
|
||||
}
|
||||
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,7 +225,7 @@ public class DeviceNodeManagerControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -259,7 +255,7 @@ public class DeviceNodeManagerControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -274,7 +270,7 @@ public class DeviceNodeManagerControllerQATest extends InitTestEnvironment {
|
|||
) {
|
||||
Assert.assertNotNull(addNodeRetData.getMessage());
|
||||
Assert.assertNotNull(addNodeRetData.getStatus());
|
||||
Assert.assertEquals(Long.valueOf(addNodeRetData.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(Long.valueOf(addNodeRetData.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -292,7 +288,7 @@ public class DeviceNodeManagerControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -319,7 +315,7 @@ public class DeviceNodeManagerControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -346,7 +342,7 @@ public class DeviceNodeManagerControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -373,7 +369,7 @@ public class DeviceNodeManagerControllerQATest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package com.dispose.test.controller;
|
||||
|
||||
import com.dispose.common.GlobalVar;
|
||||
import com.dispose.test.Global.InitTestEnvironment;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.po.MReturnType;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.pojo.vo.common.IDReturnStatus;
|
||||
import com.dispose.pojo.vo.device.AddNodeRetData;
|
||||
import com.dispose.pojo.vo.device.AddNodeRsp;
|
||||
|
@ -63,30 +64,30 @@ public class DeviceNodeManagerControllerSmokeTest extends InitTestEnvironment {
|
|||
/**
|
||||
* test Determine whether the ipAddr exists.
|
||||
*/
|
||||
public MReturnType<Boolean, String> verifyIpAddr(String ipAddr) {
|
||||
MReturnType<Boolean, String> ret;
|
||||
public MulReturnType<Boolean, String> verifyIpAddr(String ipAddr) {
|
||||
MulReturnType<Boolean, String> ret;
|
||||
boolean result = false;
|
||||
DisposeDevice disposeDevice = disposeNodeManager.getDisposeDeviceByIp(ipAddr);
|
||||
if (disposeDevice != null) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = new MReturnType<>(result, ipAddr);
|
||||
ret = new MulReturnType<>(result, ipAddr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* test Determine whether the Id exists.
|
||||
*/
|
||||
public MReturnType<Boolean, String> verifyId(String id) {
|
||||
MReturnType<Boolean, String> ret;
|
||||
public MulReturnType<Boolean, String> verifyId(String id) {
|
||||
MulReturnType<Boolean, String> ret;
|
||||
boolean result = false;
|
||||
DisposeDevice disposeDevice = disposeNodeManager.getDisposeDeviceById(Long.valueOf(id));
|
||||
if (disposeDevice != null) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = new MReturnType<>(result, id);
|
||||
ret = new MulReturnType<>(result, id);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -106,7 +107,7 @@ public class DeviceNodeManagerControllerSmokeTest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -146,7 +147,7 @@ public class DeviceNodeManagerControllerSmokeTest extends InitTestEnvironment {
|
|||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.delete("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package com.dispose.test.controller;
|
||||
|
||||
import com.dispose.common.GlobalVar;
|
||||
import com.dispose.test.Global.InitTestEnvironment;
|
||||
import com.dispose.common.ConstValue;
|
||||
import com.dispose.common.DisposeDeviceType;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.dto.ProtocolReqDTO;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.po.MReturnType;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.pojo.po.NewNodeInfo;
|
||||
import com.dispose.pojo.vo.common.IDArrayReq;
|
||||
import com.dispose.pojo.vo.common.IDReturnStatus;
|
||||
|
@ -73,30 +74,30 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment {
|
|||
/**
|
||||
* test Determine whether the ipAddr exists.
|
||||
*/
|
||||
public MReturnType<Boolean, String> verifyIpAddr(String ipAddr) {
|
||||
MReturnType<Boolean, String> ret;
|
||||
public MulReturnType<Boolean, String> verifyIpAddr(String ipAddr) {
|
||||
MulReturnType<Boolean, String> ret;
|
||||
boolean result = false;
|
||||
DisposeDevice disposeDevice = disposeNodeManager.getDisposeDeviceByIp(ipAddr);
|
||||
if (disposeDevice != null) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = new MReturnType<>(result, ipAddr);
|
||||
ret = new MulReturnType<>(result, ipAddr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* test Determine whether the Id exists.
|
||||
*/
|
||||
public MReturnType<Boolean, String> verifyId(String id) {
|
||||
MReturnType<Boolean, String> ret;
|
||||
public MulReturnType<Boolean, String> verifyId(String id) {
|
||||
MulReturnType<Boolean, String> ret;
|
||||
boolean result = false;
|
||||
DisposeDevice disposeDevice = disposeNodeManager.getDisposeDeviceById(Long.valueOf(id));
|
||||
if (disposeDevice != null) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = new MReturnType<>(result, id);
|
||||
ret = new MulReturnType<>(result, id);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -134,7 +135,7 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment {
|
|||
String deviceAdd = mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -207,7 +208,7 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment {
|
|||
String deviceDel = mockMvc.perform(MockMvcRequestBuilders
|
||||
.delete("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -277,7 +278,7 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment {
|
|||
String delAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.delete("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(525))
|
||||
|
@ -317,7 +318,7 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment {
|
|||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_VERSION.getHttpCode()))
|
||||
|
@ -355,7 +356,7 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment {
|
|||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken() + "dsasdfa")
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken() + "dsasdfa")
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().is4xxClientError())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_LOGOUT.getHttpCode()))
|
||||
|
@ -382,7 +383,7 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment {
|
|||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.delete("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken() + "1234")
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken() + "1234")
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().is4xxClientError())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_LOGOUT.getHttpCode()))
|
||||
|
@ -409,7 +410,7 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment {
|
|||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.delete("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_VERSION.getHttpCode()))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.dispose.test.controller;
|
||||
|
||||
import com.dispose.common.GlobalVar;
|
||||
import com.dispose.test.Global.InitTestEnvironment;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.po.ReturnStatus;
|
||||
|
@ -62,7 +63,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStart = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/start")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -99,21 +100,19 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStart = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/start")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqDataNoIp))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(startTaskRsp);
|
||||
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
|
||||
Assert.assertNotNull(startTaskRsp.getStatus());
|
||||
Assert.assertNotNull(startTaskRsp.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,21 +129,19 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStart = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/start")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqDataNullIp))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(startTaskRsp);
|
||||
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
|
||||
Assert.assertNotNull(startTaskRsp.getStatus());
|
||||
Assert.assertNotNull(startTaskRsp.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,21 +157,19 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStart = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/start")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqDataIntegerIp))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(startTaskRsp);
|
||||
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
|
||||
Assert.assertNotNull(startTaskRsp.getStatus());
|
||||
Assert.assertNotNull(startTaskRsp.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,10 +185,10 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStart = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/start")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqDataNullId))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
@ -202,7 +197,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -218,7 +213,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStart = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/start")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqDataNoType))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -246,21 +241,19 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStart = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/start")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqDataNullType))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(startTaskRsp);
|
||||
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
|
||||
Assert.assertNotNull(startTaskRsp.getStatus());
|
||||
Assert.assertNotNull(startTaskRsp.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -277,7 +270,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStart = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/start")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqDataNoDisposeTime))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -306,10 +299,10 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStart = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/start")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqDataNullDisposeTime))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
@ -320,7 +313,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
|
||||
Assert.assertNotNull(startTaskRsp.getStatus());
|
||||
Assert.assertNotNull(startTaskRsp.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -337,21 +330,19 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStart = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/start")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqDataStringDisposeTime))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(startTaskRsp);
|
||||
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
|
||||
Assert.assertNotNull(startTaskRsp.getStatus());
|
||||
Assert.assertNotNull(startTaskRsp.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -367,10 +358,10 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStop = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
@ -379,7 +370,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -395,7 +386,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStop = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -423,10 +414,10 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopByIpNullId = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
@ -435,7 +426,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -451,10 +442,10 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopByIpNollId = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
@ -463,7 +454,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -479,21 +470,19 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopByIpNoDisposeIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
TaskInfoRsp rspStatus = objectMapper.readValue(verifyResp(taskStopByIpNoDisposeIp), TaskInfoRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStopByIpNoDisposeIp), ReturnStatus.class);
|
||||
|
||||
rspStatus.getItems().forEach(v -> {
|
||||
Assert.assertNotNull(v.getStatus());
|
||||
Assert.assertNotNull(v.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
});
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -509,21 +498,19 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopByIpNullDisposeIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
TaskInfoRsp rspStatus = objectMapper.readValue(verifyResp(taskStopByIpNullDisposeIp), TaskInfoRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStopByIpNullDisposeIp), ReturnStatus.class);
|
||||
|
||||
rspStatus.getItems().forEach(v -> {
|
||||
Assert.assertNotNull(v.getStatus());
|
||||
Assert.assertNotNull(v.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
});
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -539,21 +526,19 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopByIpErrorDisposeIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
TaskInfoRsp rspStatus = objectMapper.readValue(verifyResp(taskStopByIpErrorDisposeIp), TaskInfoRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStopByIpErrorDisposeIp), ReturnStatus.class);
|
||||
|
||||
rspStatus.getItems().forEach(v -> {
|
||||
Assert.assertNotNull(v.getStatus());
|
||||
Assert.assertNotNull(v.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
});
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -569,21 +554,19 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopByIpIntegerDisposeIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
TaskInfoRsp rspStatus = objectMapper.readValue(verifyResp(taskStopByIpIntegerDisposeIp), TaskInfoRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStopByIpIntegerDisposeIp), ReturnStatus.class);
|
||||
|
||||
rspStatus.getItems().forEach(v -> {
|
||||
Assert.assertNotNull(v.getStatus());
|
||||
Assert.assertNotNull(v.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
});
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -599,7 +582,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopByIpNoType = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -627,10 +610,10 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopByIpNullType = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
@ -639,7 +622,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -653,7 +636,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopByNode = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_node")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -690,7 +673,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopByNode = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_node")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -729,10 +712,10 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopByNode = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_node")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
@ -741,7 +724,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -757,10 +740,10 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopByNode = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_node")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
@ -769,7 +752,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -785,7 +768,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopByNode = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_node")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -813,10 +796,10 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopByNode = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_node")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
@ -825,7 +808,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -838,7 +821,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_all")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -874,7 +857,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_all")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -911,7 +894,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_all")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -949,7 +932,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_all")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -976,10 +959,10 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_all")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
@ -988,7 +971,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1003,7 +986,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String taskStopAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_all")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -1040,7 +1023,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String getNodeTaskInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/get_node")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -1090,7 +1073,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String getNodeTaskInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/get_node")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -1138,41 +1121,19 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String getNodeTaskInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/get_node")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
NodeTaskRsp nodeTaskRsp = objectMapper.readValue(verifyResp(getNodeTaskInfo), NodeTaskRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(getNodeTaskInfo), ReturnStatus.class);
|
||||
|
||||
List<NodeTaskData> taskInfoList = nodeTaskRsp.getItems();
|
||||
for (NodeTaskData task : taskInfoList
|
||||
) {
|
||||
Assert.assertNotNull(task.getStatus());
|
||||
Assert.assertNotNull(task.getMessage());
|
||||
if (task.getStatus() == 0) {
|
||||
Assert.assertNotNull(task.getId());
|
||||
Assert.assertNotNull(task.getTaskArray());
|
||||
|
||||
for (TaskInfoData taskInfoData : task.getTaskArray()
|
||||
) {
|
||||
Assert.assertNotNull(taskInfoData.getTaskId());
|
||||
Assert.assertNotNull(taskInfoData.getType());
|
||||
Assert.assertNotNull(taskInfoData.getStartTime());
|
||||
Assert.assertNotNull(taskInfoData.getDisposeTime());
|
||||
Assert.assertNotNull(taskInfoData.getDisposeIp());
|
||||
}
|
||||
|
||||
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
} else if (task.getStatus() == 19) {
|
||||
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
} else if (task.getStatus() == 30) {
|
||||
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHTASK.getCode()));
|
||||
}
|
||||
}
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1186,7 +1147,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String NodeTaskInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/get_node")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
@ -1212,7 +1173,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String getNodeDetailedInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/get")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -1246,7 +1207,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
String NodeTaskInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/get")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.dispose.test.controller;
|
||||
|
||||
import com.dispose.common.GlobalVar;
|
||||
import com.dispose.test.Global.InitTestEnvironment;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.vo.common.TaskInfoData;
|
||||
|
@ -60,7 +61,7 @@ public class TaskControllerSmokeTest extends InitTestEnvironment {
|
|||
String taskStart = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/start")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -93,7 +94,7 @@ public class TaskControllerSmokeTest extends InitTestEnvironment {
|
|||
String taskStop = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -127,7 +128,7 @@ public class TaskControllerSmokeTest extends InitTestEnvironment {
|
|||
String taskStopByIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -160,7 +161,7 @@ public class TaskControllerSmokeTest extends InitTestEnvironment {
|
|||
String getNodeDetailedInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/get")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.dispose.test.controller;
|
|||
|
||||
import com.dispose.common.DisposeTaskStatus;
|
||||
import com.dispose.common.FlowDirection;
|
||||
import com.dispose.common.GlobalVar;
|
||||
import com.dispose.service.TaskService;
|
||||
import com.dispose.test.Global.InitTestEnvironment;
|
||||
import com.dispose.common.ConstValue;
|
||||
|
@ -86,7 +87,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
private Long getExistsTaskId() {
|
||||
List<TaskInfoDetail> lt = taskCacheManager.getAllTask();
|
||||
List<TaskInfoDetail> lt = taskCacheManager.getAllRunningTask();
|
||||
|
||||
if (lt != null && lt.size() > 0) {
|
||||
return lt.get(0).getId();
|
||||
|
@ -123,7 +124,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
@Test
|
||||
public void t1_startTask() throws Exception {
|
||||
StartTaskReq reqData = StartTaskReq.builder()
|
||||
.id(-1)
|
||||
.id("-1")
|
||||
.type(DeviceCapacity.CLEANUP.getCode())
|
||||
.disposeIp("192.168.3.4")
|
||||
.disposeTime(60)
|
||||
|
@ -141,7 +142,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
String taskStart = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/start")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -191,7 +192,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
String taskStop = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -242,7 +243,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
String taskStop = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -304,7 +305,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
String taskStopByIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -362,7 +363,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
String taskStopByIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -423,7 +424,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
String taskStopByIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -491,7 +492,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
String taskStopByIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -553,7 +554,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
String taskStopByNode = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_node")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -611,7 +612,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
String taskStopByNode = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_node")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -665,7 +666,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
String taskStopAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_all")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -717,7 +718,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
String taskStopAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_all")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -755,10 +756,9 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
*/
|
||||
@Test
|
||||
public void t6_getNodeAllTask() throws Exception {
|
||||
GetTaskReq reqData = GetTaskReq.builder()
|
||||
.id(new String[]{String.valueOf(getExistsDeviceId()), "123"})
|
||||
.type(0)
|
||||
.build();
|
||||
GetTaskReq reqData = new GetTaskReq();
|
||||
reqData.setId(new String[]{String.valueOf(getExistsDeviceId()), "123"});
|
||||
reqData.setType(0);
|
||||
|
||||
Long reqTimeStamp = System.currentTimeMillis();
|
||||
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||
|
@ -772,7 +772,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
String getTask = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/get_node")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -807,6 +807,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
Assert.assertTrue(task.getDisposeIp().matches(regex));
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(Long.valueOf(taskNode.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
} else {
|
||||
Assert.assertNotEquals(Long.valueOf(taskNode.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
|
@ -821,10 +822,9 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
*/
|
||||
@Test
|
||||
public void t6_getNodeAllTaskAll() throws Exception {
|
||||
GetTaskReq reqData = GetTaskReq.builder()
|
||||
.id(new String[]{})
|
||||
.type(0)
|
||||
.build();
|
||||
GetTaskReq reqData = new GetTaskReq();
|
||||
reqData.setId(new String[]{});
|
||||
reqData.setType(0);
|
||||
|
||||
Long reqTimeStamp = System.currentTimeMillis();
|
||||
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||
|
@ -836,7 +836,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
String getTask = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/get_node")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -899,7 +899,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/get")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
@ -928,7 +928,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
|||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/get")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.dispose.test.debug;
|
||||
|
||||
import com.dispose.pojo.vo.common.IDArrayReq;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@Slf4j
|
||||
public class demo {
|
||||
@Test
|
||||
public void a1_IDIDArrayReqTest() throws JsonProcessingException {
|
||||
String json = "{\"id\":[\"1\", \"123\", \"1234\", \"1234\"]}";
|
||||
String json2 = "{\"id\":[\"1\", \"123\", \"1234\"]}";
|
||||
String json3 = "{\"id\":[\"\", \"1\", \"123\", \"1234\"]}";
|
||||
String json4 = "{\"id\":[\"1\", \"123\", \"1234\", null]}";
|
||||
|
||||
|
||||
IDArrayReq id = new ObjectMapper().readValue(json3, IDArrayReq.class);
|
||||
Assert.assertEquals(id.getId().length, 1);
|
||||
|
||||
id = new ObjectMapper().readValue(json2, IDArrayReq.class);
|
||||
Assert.assertEquals(id.getId().length, 3);
|
||||
|
||||
id = new ObjectMapper().readValue(json, IDArrayReq.class);
|
||||
Assert.assertEquals(id.getId().length, 3);
|
||||
|
||||
id = new ObjectMapper().readValue(json4, IDArrayReq.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.dispose.test.huawei;
|
||||
|
||||
import com.dispose.common.Http;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Assert;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@Slf4j
|
||||
@SpringBootTest
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
public class ATICInterfaceTestCase {
|
||||
@Test
|
||||
public void a1_authRequestTest() {
|
||||
String jsonRequest = "{\"username\":\"test\",\"password\":\"BeiJing01@Lab3\"}";
|
||||
String svrReturn = Http.postJson("https://106.38.75.154:43443/rest/openapi/ddos/auth",
|
||||
null,
|
||||
jsonRequest);
|
||||
|
||||
log.info("Server Return: [{}]", svrReturn);
|
||||
Assert.assertNotNull(svrReturn);
|
||||
Assert.assertNotEquals(svrReturn.length(), 0);
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ package com.dispose.test.manager;
|
|||
import com.dispose.test.Global.InitTestEnvironment;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.manager.UserAccountCacheManager;
|
||||
import com.dispose.pojo.po.MReturnType;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.service.UserAccountService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -49,7 +49,7 @@ public class UserAccountManagerTest extends InitTestEnvironment {
|
|||
*/
|
||||
@Before
|
||||
public void userLogin() throws NoSuchAlgorithmException {
|
||||
MReturnType<ErrorCode, String> ret = userAccountService.loginService(getUSER_NAME(), getPASSWORD());
|
||||
MulReturnType<ErrorCode, String> ret = userAccountService.loginService(getUSER_NAME(), getPASSWORD());
|
||||
|
||||
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
||||
userToken = ret.getSecondParam();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue