Search in sources :

Example 11 with Feature

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, "删除成功");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature) ClassFeature(io.jpom.permission.ClassFeature) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with Feature

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, "删除成功");
}
Also used : ScriptModel(io.jpom.model.script.ScriptModel) File(java.io.File) ClassFeature(io.jpom.permission.ClassFeature) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with Feature

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);
}
Also used : CommandExecLogModel(io.jpom.model.data.CommandExecLogModel) ClassFeature(io.jpom.permission.ClassFeature) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature)

Example 14 with Feature

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);
    }
}
Also used : SshModel(io.jpom.model.data.SshModel) SftpException(com.jcraft.jsch.SftpException) HttpServletResponse(javax.servlet.http.HttpServletResponse) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature) ClassFeature(io.jpom.permission.ClassFeature) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with Feature

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);
}
Also used : SshModel(io.jpom.model.data.SshModel) Charset(java.nio.charset.Charset) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature) ClassFeature(io.jpom.permission.ClassFeature) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Feature (io.jpom.permission.Feature)129 MethodFeature (io.jpom.permission.MethodFeature)129 ClassFeature (io.jpom.permission.ClassFeature)128 JSONObject (com.alibaba.fastjson.JSONObject)49 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)48 File (java.io.File)36 PostMapping (org.springframework.web.bind.annotation.PostMapping)25 DockerInfoModel (io.jpom.model.docker.DockerInfoModel)22 HttpServletRequest (javax.servlet.http.HttpServletRequest)22 NodeModel (io.jpom.model.data.NodeModel)21 GetMapping (org.springframework.web.bind.annotation.GetMapping)21 UserModel (io.jpom.model.data.UserModel)14 SystemPermission (io.jpom.permission.SystemPermission)14 BuildInfoModel (io.jpom.model.data.BuildInfoModel)12 SshModel (io.jpom.model.data.SshModel)10 Entity (cn.hutool.db.Entity)8 MultipartFileBuilder (cn.jiangzeyin.controller.multipart.MultipartFileBuilder)8 JSONArray (com.alibaba.fastjson.JSONArray)8 JsonMessage (cn.jiangzeyin.common.JsonMessage)7 List (java.util.List)7