parent
6ac14e9371
commit
16acbbbcae
2
pom.xml
2
pom.xml
|
@ -17,7 +17,7 @@
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>com.dispose</groupId>
|
<groupId>com.dispose</groupId>
|
||||||
<artifactId>dispose_platform</artifactId>
|
<artifactId>dispose_platform</artifactId>
|
||||||
<version>2.0.8.6</version>
|
<version>2.0.8.7</version>
|
||||||
<name>dispose_platform</name>
|
<name>dispose_platform</name>
|
||||||
<description>Dispose Platform</description>
|
<description>Dispose Platform</description>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.dispose.ability.impl;
|
package com.dispose.ability.impl;
|
||||||
|
|
||||||
import com.dispose.ability.DisposeAbility;
|
import com.dispose.ability.DisposeAbility;
|
||||||
|
import com.dispose.common.CommonEnumHandler;
|
||||||
import com.dispose.common.DisposeCapacityType;
|
import com.dispose.common.DisposeCapacityType;
|
||||||
import com.dispose.common.DisposeConfigValue;
|
import com.dispose.common.DisposeConfigValue;
|
||||||
import com.dispose.common.DisposeObjectType;
|
import com.dispose.common.DisposeObjectType;
|
||||||
|
@ -28,19 +29,17 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Peng xin ability.
|
* The type Peng xin ability.
|
||||||
*
|
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class PengXinAbilityImpl implements DisposeAbility {
|
public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
/**
|
/**
|
||||||
* The Protect ip v 4.
|
* The Protect ip v 4.
|
||||||
*/
|
*/
|
||||||
private final List<String> protectIpV4 = new ArrayList<>();
|
//private final List<String> protectIpV4 = new ArrayList<>();
|
||||||
/**
|
/**
|
||||||
* The Protect ip v 6.
|
* The Protect ip v 6.
|
||||||
*/
|
*/
|
||||||
private final List<String> protectIpV6 = new ArrayList<>();
|
//private final List<String> protectIpV6 = new ArrayList<>();
|
||||||
/**
|
/**
|
||||||
* The Restful interface.
|
* The Restful interface.
|
||||||
*/
|
*/
|
||||||
|
@ -180,14 +179,18 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
|
|
||||||
ProtocolRespDTO<PengXinStartTaskRsp> rspInfo = restfulInterface.startDisposeTask(url, token, reqItems);
|
ProtocolRespDTO<PengXinStartTaskRsp> rspInfo = restfulInterface.startDisposeTask(url, token, reqItems);
|
||||||
|
|
||||||
// 判断是否token过期
|
ErrorCode err = verifyInterfaceResp(rspInfo);
|
||||||
if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getItems().get(0).getStatus())) {
|
|
||||||
rspInfo = restfulInterface.startDisposeTask(url, token, reqItems);
|
if (err != ErrorCode.ERR_OK) {
|
||||||
|
log.error("----Error PengXin start clean {} server return {}", disposeObject, err.getMsg());
|
||||||
|
return new MulReturnType<>(err, disposeObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rspInfo == null || rspInfo.getCode() != ErrorCode.ERR_OK.getHttpCode()) {
|
err = verifyRespStatus(rspInfo.getMsgContent().getItems().get(0).getStatus());
|
||||||
log.error("----Error PengXin start clean {} server return error", disposeObject);
|
|
||||||
return new MulReturnType<>(ErrorCode.ERR_PENGXIN_ERROR, null);
|
if (err != ErrorCode.ERR_OK) {
|
||||||
|
log.error("----Error PengXin start clean {} server return {}", disposeObject, err.getMsg());
|
||||||
|
return new MulReturnType<>(err, disposeObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rspInfo.getMsgContent().getItems().size() == 0) {
|
if (rspInfo.getMsgContent().getItems().size() == 0) {
|
||||||
|
@ -247,14 +250,18 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
ProtocolRespDTO<PengXinStopTaskRsp> rspInfo = restfulInterface.stopDisposeTask(url, token,
|
ProtocolRespDTO<PengXinStopTaskRsp> rspInfo = restfulInterface.stopDisposeTask(url, token,
|
||||||
new String[]{taskId});
|
new String[]{taskId});
|
||||||
|
|
||||||
// 判断是否token过期
|
ErrorCode err = verifyInterfaceResp(rspInfo);
|
||||||
if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getItems().get(0).getStatus())) {
|
|
||||||
rspInfo = restfulInterface.stopDisposeTask(url, token, new String[]{taskId});
|
if (err != ErrorCode.ERR_OK) {
|
||||||
|
log.error("----Error PengXin start clean {} server return {}", taskId, err.getMsg());
|
||||||
|
return new MulReturnType<>(err, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rspInfo == null || rspInfo.getCode() != ErrorCode.ERR_OK.getHttpCode()) {
|
err = verifyRespStatus(rspInfo.getMsgContent().getItems().get(0).getStatus());
|
||||||
log.error("----Error PengXin stop task{} server return error", taskId);
|
|
||||||
return new MulReturnType<>(ErrorCode.ERR_CALLDEVICE, null);
|
if (err != ErrorCode.ERR_OK) {
|
||||||
|
log.error("----Error PengXin start clean {} server return {}", taskId, err.getMsg());
|
||||||
|
return new MulReturnType<>(err, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rspInfo.getMsgContent().getItems().size() == 0) {
|
if (rspInfo.getMsgContent().getItems().size() == 0) {
|
||||||
|
@ -359,23 +366,28 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
@Override
|
@Override
|
||||||
public void getDisposeDeviceProtectObject() {
|
public void getDisposeDeviceProtectObject() {
|
||||||
// 集团一键处置线上环境,移除从设备获取能力信息相关接口调用
|
// 集团一键处置线上环境,移除从设备获取能力信息相关接口调用
|
||||||
|
|
||||||
// if (token == null || token.length() == 0) {
|
// if (token == null || token.length() == 0) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
// try {
|
|
||||||
// String url = urlRootPath + "dispose_device/information/capacity";
|
// String url = urlRootPath + "dispose_device/information/capacity";
|
||||||
//
|
//
|
||||||
|
// try {
|
||||||
// ProtocolRespDTO<PengXinDisposeAbilityRsp> rspInfo = restfulInterface.getDeviceDisposeAbility(url, token);
|
// ProtocolRespDTO<PengXinDisposeAbilityRsp> rspInfo = restfulInterface.getDeviceDisposeAbility(url, token);
|
||||||
//
|
//
|
||||||
// // 判断是否token过期
|
// ErrorCode err = verifyInterfaceResp(rspInfo);
|
||||||
// if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getStatus())) {
|
//
|
||||||
// rspInfo = restfulInterface.getDeviceDisposeAbility(url, token);
|
// if (err != ErrorCode.ERR_OK) {
|
||||||
|
// log.error("----Error PengXin get dispose device protect object server {} return {}", url, token);
|
||||||
|
// return;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if (rspInfo != null && rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode()
|
// err = verifyRespStatus(rspInfo.getMsgContent().getStatus());
|
||||||
// && rspInfo.getMsgContent().getStatus() == ErrorCode.ERR_OK.getCode()) {
|
//
|
||||||
|
// if (err != ErrorCode.ERR_OK) {
|
||||||
|
// log.error("---Error PengXin get dispose device protect object server {} return {}", url, err.getMsg());
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// rspInfo.getMsgContent().getCapacity().forEach(v -> {
|
// rspInfo.getMsgContent().getCapacity().forEach(v -> {
|
||||||
// if (v.getObjectType().equals(DisposeObjectType.DOMAIN.getValue())) {
|
// if (v.getObjectType().equals(DisposeObjectType.DOMAIN.getValue())) {
|
||||||
|
@ -403,9 +415,8 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
//
|
// } catch (Exception ex) {
|
||||||
// }
|
// log.error("server {}({}) exception: {}", url, token, ex);
|
||||||
// } catch (Exception ignored) {
|
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,22 +479,25 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
ProtocolRespDTO<PengXinTaskStatusRsp> rspInfo = restfulInterface.getDeviceTaskStatus(url, token,
|
ProtocolRespDTO<PengXinTaskStatusRsp> rspInfo = restfulInterface.getDeviceTaskStatus(url, token,
|
||||||
new String[]{taskId});
|
new String[]{taskId});
|
||||||
|
|
||||||
// 判断是否token过期
|
ErrorCode err = verifyInterfaceResp(rspInfo);
|
||||||
if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getItems().get(0).getStatus())) {
|
|
||||||
rspInfo = restfulInterface.getDeviceTaskStatus(url, token, new String[]{taskId});
|
if (err != ErrorCode.ERR_OK) {
|
||||||
|
log.error("----Error PengXin start clean {} server return {}", taskId, err.getMsg());
|
||||||
|
return new MulReturnType<>(err, -1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rspInfo != null) {
|
err = verifyRespStatus(rspInfo.getMsgContent().getItems().get(0).getStatus());
|
||||||
if (rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode()) {
|
|
||||||
int errCode = rspInfo.getMsgContent().getItems().get(0).getStatus();
|
if (err != ErrorCode.ERR_OK) {
|
||||||
if (rspInfo.getMsgContent().getItems().size() == 0 || errCode != ErrorCode.ERR_OK.getCode()) {
|
log.error("----Error PengXin start clean {} server return {}", taskId, err.getMsg());
|
||||||
|
return new MulReturnType<>(err, -1L);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rspInfo.getMsgContent().getItems().size() == 0) {
|
||||||
return new MulReturnType<>(ErrorCode.ERR_NOSUCHTASK, -1L);
|
return new MulReturnType<>(ErrorCode.ERR_NOSUCHTASK, -1L);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return new MulReturnType<>(ErrorCode.ERR_OK, rspInfo.getMsgContent().getItems().get(0).getTaskStatus());
|
return new MulReturnType<>(ErrorCode.ERR_OK, rspInfo.getMsgContent().getItems().get(0).getTaskStatus());
|
||||||
} else {
|
|
||||||
return new MulReturnType<>(ErrorCode.ERR_CALLDEVICE, -1L);
|
|
||||||
}
|
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
return new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, -1L);
|
return new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, -1L);
|
||||||
}
|
}
|
||||||
|
@ -505,27 +519,53 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reLogin.
|
* Verify interface resp error code.
|
||||||
|
*
|
||||||
|
* @param <T> the type parameter
|
||||||
|
* @param rspInfo the rsp info
|
||||||
|
* @return the error code
|
||||||
*/
|
*/
|
||||||
private <T> boolean reLogin(ProtocolRespDTO<T> rspInfo, int status) {
|
private <T> ErrorCode verifyInterfaceResp(ProtocolRespDTO<T> rspInfo) {
|
||||||
try {
|
if (rspInfo == null) {
|
||||||
// 判断是否token过期
|
return ErrorCode.ERR_PENGXIN_ERROR;
|
||||||
if (rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
|
} else if (rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
|
||||||
// 重新登录获取 token
|
|
||||||
upgradeToken();
|
upgradeToken();
|
||||||
return true;
|
return ErrorCode.ERR_TOKENTIMEOUT;
|
||||||
|
} else if (rspInfo.getCode() != HttpServletResponse.SC_OK) {
|
||||||
|
return ErrorCode.ERR_PENGXIN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rspInfo.getCode() == HttpServletResponse.SC_OK &&
|
if (rspInfo.getMsgContent() == null) {
|
||||||
(status == ErrorCode.ERR_LOGOUT.getCode() || status == ErrorCode.ERR_TOKENTIMEOUT.getCode() ||
|
return ErrorCode.ERR_PARAMS;
|
||||||
status == ErrorCode.ERR_TOKENNOTFOUND.getCode())) {
|
|
||||||
upgradeToken();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
return ErrorCode.ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify resp status error code.
|
||||||
|
*
|
||||||
|
* @param status the status
|
||||||
|
* @return the error code
|
||||||
|
*/
|
||||||
|
private ErrorCode verifyRespStatus(int status) {
|
||||||
|
if (status == ErrorCode.ERR_LOGOUT.getCode()
|
||||||
|
|| status == ErrorCode.ERR_TOKENTIMEOUT.getCode()
|
||||||
|
|| status == ErrorCode.ERR_TOKENNOTFOUND.getCode()) {
|
||||||
|
upgradeToken();
|
||||||
|
return ErrorCode.ERR_TOKENTIMEOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return CommonEnumHandler.codeOf(ErrorCode.class, status);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
return false;
|
if (status == ErrorCode.ERR_OK.getCode()) {
|
||||||
|
return ErrorCode.ERR_OK;
|
||||||
|
} else {
|
||||||
|
return ErrorCode.ERR_CALLDEVICE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,7 +578,7 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
|
|
||||||
// 集团一键处置线上环境,不再定时获取设备能力信息
|
// 集团一键处置线上环境,不再定时获取设备能力信息
|
||||||
// 更新防护对象
|
// 更新防护对象
|
||||||
//getDisposeDeviceProtectObject();
|
getDisposeDeviceProtectObject();
|
||||||
|
|
||||||
// 更新心跳状态
|
// 更新心跳状态
|
||||||
if (timerCnt++ % DisposeConfigValue.HEART_PERIOD_OF_SECOND == 0) {
|
if (timerCnt++ % DisposeConfigValue.HEART_PERIOD_OF_SECOND == 0) {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
public enum ErrorCode {
|
public enum ErrorCode implements BaseEnum {
|
||||||
/**
|
/**
|
||||||
* The Err ok.
|
* The Err ok.
|
||||||
*/
|
*/
|
||||||
|
@ -365,4 +365,25 @@ public enum ErrorCode {
|
||||||
public String getMsg() {
|
public String getMsg() {
|
||||||
return errMsg;
|
return errMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets value.
|
||||||
|
*
|
||||||
|
* @return the value
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Integer getValue() {
|
||||||
|
return this.errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets description.
|
||||||
|
*
|
||||||
|
* @return the description
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return this.errMsg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.pengxin.dispose.protocol;
|
package com.pengxin.dispose.protocol;
|
||||||
|
|
||||||
|
import com.dispose.common.CommonEnumHandler;
|
||||||
import com.dispose.common.ErrorCode;
|
import com.dispose.common.ErrorCode;
|
||||||
import com.dispose.pojo.dto.protocol.base.BaseProtocolDTO;
|
import com.dispose.pojo.dto.protocol.base.BaseProtocolDTO;
|
||||||
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||||
|
@ -86,19 +87,27 @@ public class PengXinInterface {
|
||||||
null,
|
null,
|
||||||
PengXinBaseResp.class,
|
PengXinBaseResp.class,
|
||||||
RequestMethod.GET);
|
RequestMethod.GET);
|
||||||
if (rspInfo != null && rspInfo.getMsgContent() != null) {
|
if (rspInfo != null) {
|
||||||
if (rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
|
if (rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
|
||||||
return ErrorCode.ERR_LOGOUT;
|
return ErrorCode.ERR_LOGOUT;
|
||||||
} else if (rspInfo.getCode() == HttpServletResponse.SC_OK) {
|
}
|
||||||
if(rspInfo.getMsgContent().getStatus() != ErrorCode.ERR_OK.getCode()){
|
|
||||||
return ErrorCode.ERR_LOGOUT;
|
if (rspInfo.getMsgContent() == null) {
|
||||||
} else {
|
return ErrorCode.ERR_PARAMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return CommonEnumHandler.codeOf(ErrorCode.class, rspInfo.getCode());
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
if (rspInfo.getCode() == ErrorCode.ERR_OK.getCode()) {
|
||||||
return ErrorCode.ERR_OK;
|
return ErrorCode.ERR_OK;
|
||||||
|
} else {
|
||||||
|
return ErrorCode.ERR_CALLDEVICE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ErrorCode.ERR_UNKNOWNCMD;
|
return ErrorCode.ERR_PARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue