use of cn.hutool.core.lang.Tuple in project Jpom by dromara.
the class NodeUpdateController method downloadRemote.
/**
* 远程下载
*
* @return json
* @see RemoteVersion
*/
@GetMapping(value = "download_remote.json", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.REMOTE_DOWNLOAD)
public String downloadRemote() throws IOException {
String saveDir = ServerConfigBean.getInstance().getAgentPath().getAbsolutePath();
Tuple download = RemoteVersion.download(saveDir, Type.Agent, false);
// 保存文件
this.saveAgentFile(download);
return JsonMessage.getString(200, "下载成功");
}
use of cn.hutool.core.lang.Tuple in project Jpom by dromara.
the class NodeUpdateHandler method updateNode.
/**
* 更新节点
*
* @param model 参数
*/
private void updateNode(WebSocketMessageModel model, WebSocketSession session) {
JSONObject params = (JSONObject) model.getParams();
JSONArray ids = params.getJSONArray("ids");
if (CollUtil.isEmpty(ids)) {
return;
}
String protocol = params.getString("protocol");
boolean http = StrUtil.equalsIgnoreCase(protocol, "http");
try {
AgentFileModel agentFileModel = systemParametersServer.getConfig(AgentFileModel.ID, AgentFileModel.class);
//
if (agentFileModel == null || !FileUtil.exist(agentFileModel.getSavePath())) {
this.onError(session, "Agent JAR包不存在");
return;
}
JsonMessage<Tuple> error = JpomManifest.checkJpomJar(agentFileModel.getSavePath(), Type.Agent, false);
if (error.getCode() != HttpStatus.HTTP_OK) {
this.onError(session, "Agent JAR 损坏请重新上传," + error.getMsg());
return;
}
for (int i = 0; i < ids.size(); i++) {
int finalI = i;
ThreadUtil.execute(() -> this.updateNodeItem(ids.getString(finalI), session, agentFileModel, http));
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("升级失败", e);
}
}
Aggregations