use of io.jpom.permission.Feature 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.permission.Feature in project Jpom by dromara.
the class LogManageController method logData.
/**
* 删除 需要验证是否最后修改时间
*
* @param nodeId 节点
* @param path 路径
* @return json
*/
@RequestMapping(value = "log_del.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.DEL)
public String logData(String nodeId, @ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "path错误") String path) {
if (StrUtil.isNotEmpty(nodeId)) {
return NodeForward.request(getNode(), getRequest(), NodeUrl.DelSystemLog).toString();
}
WebAopLog webAopLog = SpringUtil.getBean(WebAopLog.class);
File file = FileUtil.file(webAopLog.getPropertyValue(), path);
// 判断修改时间
long modified = file.lastModified();
if (System.currentTimeMillis() - modified < TimeUnit.DAYS.toMillis(1)) {
return JsonMessage.getString(405, "不能删除当天的日志");
}
if (FileUtil.del(file)) {
// 离线上一个日志
ServiceFileTailWatcher.offlineFile(file);
return JsonMessage.getString(200, "删除成功");
}
return JsonMessage.getString(500, "删除失败");
}
use of io.jpom.permission.Feature in project Jpom by dromara.
the class LogManageController method logDownload.
@RequestMapping(value = "log_download", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.DOWNLOAD)
public void logDownload(String nodeId, @ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "path错误") String path) {
if (StrUtil.isNotEmpty(nodeId)) {
NodeForward.requestDownload(getNode(), getRequest(), getResponse(), NodeUrl.DownloadSystemLog);
return;
}
WebAopLog webAopLog = SpringUtil.getBean(WebAopLog.class);
File file = FileUtil.file(webAopLog.getPropertyValue(), path);
if (file.isFile()) {
ServletUtil.write(getResponse(), file);
}
}
use of io.jpom.permission.Feature 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.permission.Feature 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);
}
Aggregations