use of io.jpom.model.data.NodeModel in project Jpom by dromara.
the class NodeEditController method nodeStatus.
@RequestMapping(value = "node_status", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.LIST)
public String nodeStatus() {
long timeMillis = System.currentTimeMillis();
NodeModel node = getNode();
JSONObject jsonObject = NodeForward.requestData(node, NodeUrl.Status, getRequest(), JSONObject.class);
Assert.notNull(jsonObject, "获取信息失败");
JSONArray jsonArray = new JSONArray();
jsonObject.put("timeOut", System.currentTimeMillis() - timeMillis);
jsonObject.put("nodeId", node.getId());
jsonArray.add(jsonObject);
return JsonMessage.getString(200, "", jsonArray);
}
use of io.jpom.model.data.NodeModel in project Jpom by dromara.
the class SystemUpdateController method checkVersion.
/**
* 检查是否存在新版本
*
* @return json
* @see RemoteVersion
*/
@PostMapping(value = "check_version.json", produces = MediaType.APPLICATION_JSON_VALUE)
public String checkVersion() {
NodeModel nodeModel = tryGetNode();
if (nodeModel != null) {
return NodeForward.request(getNode(), getRequest(), NodeUrl.CHECK_VERSION).toString();
}
RemoteVersion remoteVersion = RemoteVersion.loadRemoteInfo();
return JsonMessage.getString(200, "", remoteVersion);
}
use of io.jpom.model.data.NodeModel in project Jpom by dromara.
the class SystemUpdateController method uploadJar.
@PostMapping(value = "uploadJar.json", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.EXECUTE)
public String uploadJar() throws IOException {
NodeModel nodeModel = tryGetNode();
if (nodeModel != null) {
return NodeForward.requestMultipart(getNode(), getMultiRequest(), NodeUrl.SystemUploadJar).toString();
}
//
Objects.requireNonNull(JpomManifest.getScriptFile());
MultipartFileBuilder multipartFileBuilder = createMultipart();
String absolutePath = ServerConfigBean.getInstance().getUserTempPath().getAbsolutePath();
multipartFileBuilder.setFileExt("jar", "zip").addFieldName("file").setUseOriginalFilename(true).setSavePath(absolutePath);
String path = multipartFileBuilder.save();
// 解析压缩包
File file = JpomManifest.zipFileFind(path, Type.Server, absolutePath);
path = FileUtil.getAbsolutePath(file);
// 基础检查
JsonMessage<Tuple> error = JpomManifest.checkJpomJar(path, Type.Server);
if (error.getCode() != HttpStatus.HTTP_OK) {
return error.toString();
}
Tuple data = error.getData();
String version = data.get(0);
JpomManifest.releaseJar(path, version);
//
backupInfoService.autoBackup();
//
JpomApplication.restart();
return JsonMessage.getString(200, Const.UPGRADE_MSG);
}
use of io.jpom.model.data.NodeModel in project Jpom by dromara.
the class SystemUpdateController method upgrade.
/**
* 远程下载升级
*
* @return json
* @see RemoteVersion
*/
@GetMapping(value = "remote_upgrade.json", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.DOWNLOAD)
public String upgrade() throws IOException {
NodeModel nodeModel = tryGetNode();
if (nodeModel != null) {
return NodeForward.request(getNode(), getRequest(), NodeUrl.REMOTE_UPGRADE).toString();
}
RemoteVersion.upgrade(ConfigBean.getInstance().getTempPath().getAbsolutePath(), objects -> backupInfoService.autoBackup());
return JsonMessage.getString(200, Const.UPGRADE_MSG);
}
use of io.jpom.model.data.NodeModel in project Jpom by dromara.
the class SystemUpdateController method info.
@PostMapping(value = "info", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.LIST)
public String info() {
NodeModel nodeModel = tryGetNode();
if (nodeModel != null) {
return NodeForward.request(getNode(), getRequest(), NodeUrl.Info).toString();
}
JpomManifest instance = JpomManifest.getInstance();
RemoteVersion remoteVersion = RemoteVersion.cacheInfo();
//
JSONObject jsonObject = new JSONObject();
jsonObject.put("manifest", instance);
jsonObject.put("remoteVersion", remoteVersion);
return JsonMessage.getString(200, "", jsonObject);
}
Aggregations