use of io.jpom.system.AgentException in project Jpom by dromara.
the class PermissionInterceptor method addNode.
private void addNode(HttpServletRequest request) {
String nodeId = request.getParameter("nodeId");
if (!StrUtil.isBlankOrUndefined(nodeId)) {
// 节点信息
NodeModel nodeModel = nodeService.getByKey(nodeId);
if (nodeModel != null && !nodeModel.isOpenStatus()) {
throw new AgentException(nodeModel.getName() + "节点未启用");
}
request.setAttribute("node", nodeModel);
}
}
use of io.jpom.system.AgentException in project Jpom by dromara.
the class NodeForward method addUser.
/**
* 添加agent 授权信息header
*
* @param httpRequest request
* @param nodeModel 节点
* @param userModel 用户
*/
private static void addUser(HttpRequest httpRequest, NodeModel nodeModel, NodeUrl nodeUrl, UserModel userModel) {
// 判断开启状态
if (!nodeModel.isOpenStatus()) {
throw new AgentException(nodeModel.getName() + "节点未启用");
}
if (userModel != null) {
httpRequest.header(ConfigBean.JPOM_SERVER_USER_NAME, URLUtil.encode(userModel.getId()));
// httpRequest.header(ConfigBean.JPOM_SERVER_SYSTEM_USER_ROLE, userModel.getUserRole(nodeModel).name());
}
if (StrUtil.isEmpty(nodeModel.getLoginPwd())) {
NodeService nodeService = SpringUtil.getBean(NodeService.class);
NodeModel model = nodeService.getByKey(nodeModel.getId(), false);
nodeModel.setLoginPwd(model.getLoginPwd());
nodeModel.setLoginName(model.getLoginName());
}
httpRequest.header(ConfigBean.JPOM_AGENT_AUTHORIZE, nodeModel.toAuthorize());
httpRequest.header(Const.WORKSPACEID_REQ_HEADER, nodeModel.getWorkspaceId());
//
int timeOut = nodeModel.getTimeOut();
if (nodeUrl.getTimeOut() != -1 && timeOut > 0) {
//
timeOut = Math.max(timeOut, 2);
httpRequest.timeout(timeOut * 1000);
}
}
use of io.jpom.system.AgentException in project Jpom by dromara.
the class NodeForward method responseException.
/**
* 插件端 异常类型判断
*
* @param exception 异常
* @param nodeModel 插件端
*/
private static AgentException responseException(Exception exception, NodeModel nodeModel) {
String message = exception.getMessage();
Throwable cause = exception.getCause();
DefaultSystemLog.getLog().error("node [{}] connect failed...message: [{}]", nodeModel.getName(), message);
if (exception instanceof IORuntimeException) {
if (cause instanceof java.net.ConnectException || cause instanceof java.net.SocketTimeoutException) {
return new AgentException(nodeModel.getName() + "节点网络连接异常或超时,请优先检查插件端运行状态再检查 IP 地址、" + "端口号是否配置正确,防火墙规则," + "云服务器的安全组配置等网络相关问题排查定位。" + message);
}
} else if (exception instanceof cn.hutool.http.HttpException) {
if (cause instanceof java.net.SocketTimeoutException) {
return new AgentException(nodeModel.getName() + "节点网络连接超时,请优先检查插件端运行状态再检查节点超时时间配置是否合理,上传文件超时时间配置是否合理。" + message);
}
}
return new AgentException(nodeModel.getName() + "节点异常:" + message);
}
use of io.jpom.system.AgentException in project Jpom by dromara.
the class BaseNodeService method checkException.
protected String checkException(Exception e, String nodeModelName) {
if (e instanceof AgentException) {
AgentException agentException = (AgentException) e;
DefaultSystemLog.getLog().error("同步失败 {}", agentException.getMessage());
return "同步失败" + agentException.getMessage();
}
DefaultSystemLog.getLog().error("同步节点" + dataName + "失败:" + nodeModelName, e);
return "同步节点" + dataName + "失败" + e.getMessage();
}
Aggregations