use of io.jpom.permission.Feature in project Jpom by dromara.
the class OutGivingProjectEditController method delete.
/**
* 删除分发项目
*
* @param id 项目id
* @return json
*/
@RequestMapping(value = "delete_project", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.DEL)
public String delete(String id) {
HttpServletRequest request = getRequest();
OutGivingModel outGivingModel = outGivingServer.getByKey(id, request);
Assert.notNull(outGivingModel, "没有对应的分发项目");
// 判断构建
boolean releaseMethod = buildService.checkReleaseMethod(id, request, BuildReleaseMethod.Outgiving);
Assert.state(!releaseMethod, "当前分发存在构建项,不能删除");
//
Assert.state(outGivingModel.outGivingProject(), "该项目不是节点分发项目,不能在此次删除");
UserModel userModel = getUser();
List<OutGivingNodeProject> deleteNodeProject = outGivingModel.outGivingNodeProjectList();
if (deleteNodeProject != null) {
// 删除实际的项目
for (OutGivingNodeProject outGivingNodeProject1 : deleteNodeProject) {
NodeModel nodeModel = nodeService.getByKey(outGivingNodeProject1.getNodeId());
JsonMessage<String> jsonMessage = this.deleteNodeProject(nodeModel, userModel, outGivingNodeProject1.getProjectId());
if (jsonMessage.getCode() != HttpStatus.HTTP_OK) {
return JsonMessage.getString(406, nodeModel.getName() + "节点失败:" + jsonMessage.getMsg());
}
}
}
outGivingServer.delByKey(id, request);
return JsonMessage.getString(200, "删除成功");
}
use of io.jpom.permission.Feature in project Jpom by dromara.
the class ScriptLogController method delLog.
/**
* 删除日志
*
* @param id id
* @param executeId 执行ID
* @return json
*/
@RequestMapping(value = "del_log", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.DEL)
public String delLog(@ValidatorItem() String id, @ValidatorItem() String executeId) {
ScriptModel item = scriptServer.getByKey(id, getRequest());
Assert.notNull(item, "没有对应数据");
File logFile = item.logFile(executeId);
boolean fastDel = CommandUtil.systemFastDel(logFile);
Assert.state(!fastDel, "删除日志文件失败");
scriptExecuteLogServer.delByKey(executeId);
return JsonMessage.getString(200, "删除成功");
}
use of io.jpom.permission.Feature in project Jpom by dromara.
the class CommandLogController method batchList.
/**
* 命令执行记录
*
* @param commandId 命令ID
* @param batchId 批次ID
* @return result
*
* @api {GET} node/ssh_command_log/batch_list 命令执行记录
* @apiGroup node/ssh_command_log
* @apiUse defResultJson
* @apiParam {String} commandId 命令ID
* @apiParam {String} batchId 批次ID
* @apiSuccess {Object} commandExecLogModels 命令执行记录
* @apiSuccess {String} commandExecLogModels.commandId 命令ID
* @apiSuccess {String} commandExecLogModels.batchId 批次ID
* @apiSuccess {String} commandExecLogModels.sshId ssh Id
* @apiSuccess {Number} commandExecLogModels.status Status
* @apiSuccess {String} commandExecLogModels.commandName 命令名称
* @apiSuccess {String} commandExecLogModels.sshName ssh 名称
* @apiSuccess {String} commandExecLogModels.params 参数
* @apiSuccess {Number} commandExecLogModels.triggerExecType 触发类型 {0,手动,1 自动触发}
* @apiSuccess {Boolean} commandExecLogModels.hasLog 日志文件是否存在
*/
@GetMapping(value = "batch_list", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.LIST)
public String batchList(@ValidatorItem String commandId, @ValidatorItem String batchId) {
CommandExecLogModel commandExecLogModel = new CommandExecLogModel();
commandExecLogModel.setCommandId(commandId);
commandExecLogModel.setBatchId(batchId);
List<CommandExecLogModel> commandExecLogModels = commandExecLogService.listByBean(commandExecLogModel);
return JsonMessage.getString(200, "", commandExecLogModels);
}
use of io.jpom.permission.Feature in project Jpom by dromara.
the class SshFileController method download.
@RequestMapping(value = "download.html", method = RequestMethod.GET)
@Feature(method = MethodFeature.DOWNLOAD)
public void download(String id, String path, String name) throws IOException {
HttpServletResponse response = getResponse();
SshModel sshModel = sshService.getByKey(id, false);
if (sshModel == null) {
ServletUtil.write(response, "ssh error", MediaType.TEXT_HTML_VALUE);
return;
}
List<String> fileDirs = sshModel.fileDirs();
//
if (StrUtil.isEmpty(path) || !fileDirs.contains(path)) {
ServletUtil.write(response, "没有配置此文件夹", MediaType.TEXT_HTML_VALUE);
return;
}
if (StrUtil.isEmpty(name)) {
ServletUtil.write(response, "name error", MediaType.TEXT_HTML_VALUE);
return;
}
try {
this.downloadFile(sshModel, path, name, response);
} catch (SftpException e) {
DefaultSystemLog.getLog().error("下载失败", e);
ServletUtil.write(response, "download error", MediaType.TEXT_HTML_VALUE);
}
}
use of io.jpom.permission.Feature in project Jpom by dromara.
the class SshFileController method readFileData.
@RequestMapping(value = "read_file_data.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.LIST)
public String readFileData(String id, String path, String children) {
SshModel sshModel = this.check(id, path, children);
//
List<String> allowEditSuffix = sshModel.allowEditSuffix();
Charset charset = AgentWhitelist.checkFileSuffix(allowEditSuffix, children);
//
String content = this.readFile(sshModel, path, children, charset);
return JsonMessage.getString(200, "ok", content);
}
Aggregations