Search in sources :

Example 1 with ScriptCacheModel

use of io.jpom.model.node.ScriptCacheModel in project Jpom by dromara.

the class NodeEditController method del.

/**
 * 删除节点
 *
 * @param id 节点id
 * @return json
 */
@PostMapping(value = "del.json", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.DEL)
public String del(@ValidatorItem String id) {
    HttpServletRequest request = getRequest();
    this.checkDataBind(id, request);
    // 
    {
        ProjectInfoCacheModel projectInfoCacheModel = new ProjectInfoCacheModel();
        projectInfoCacheModel.setNodeId(id);
        projectInfoCacheModel.setWorkspaceId(projectInfoCacheService.getCheckUserWorkspace(request));
        boolean exists = projectInfoCacheService.exists(projectInfoCacheModel);
        Assert.state(!exists, "该节点下还存在项目,不能删除");
    }
    // 
    {
        ScriptCacheModel scriptCacheModel = new ScriptCacheModel();
        scriptCacheModel.setNodeId(id);
        scriptCacheModel.setWorkspaceId(nodeScriptServer.getCheckUserWorkspace(request));
        boolean exists = nodeScriptServer.exists(scriptCacheModel);
        Assert.state(!exists, "该节点下还存在脚本模版,不能删除");
    }
    // 
    this.delNodeData(id, request);
    return JsonMessage.getString(200, "操作成功");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ProjectInfoCacheModel(io.jpom.model.node.ProjectInfoCacheModel) ScriptCacheModel(io.jpom.model.node.ScriptCacheModel) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature) ClassFeature(io.jpom.permission.ClassFeature)

Example 2 with ScriptCacheModel

use of io.jpom.model.node.ScriptCacheModel in project Jpom by dromara.

the class NodeScriptHandler method createLog.

/**
 * 创建执行日志
 *
 * @param attributes 参数属性
 * @return 执行ID
 */
private String createLog(Map<String, Object> attributes) {
    NodeModel nodeInfo = (NodeModel) attributes.get("nodeInfo");
    UserModel userModel = (UserModel) attributes.get("userInfo");
    ScriptCacheModel dataItem = (ScriptCacheModel) attributes.get("dataItem");
    NodeScriptExecuteLogServer logServer = SpringUtil.getBean(NodeScriptExecuteLogServer.class);
    NodeScriptServer nodeScriptServer = SpringUtil.getBean(NodeScriptServer.class);
    // 
    try {
        BaseServerController.resetInfo(userModel);
        // 
        ScriptCacheModel scriptCacheModel = new ScriptCacheModel();
        scriptCacheModel.setId(dataItem.getId());
        scriptCacheModel.setLastRunUser(userModel.getId());
        nodeScriptServer.update(scriptCacheModel);
        // 
        ScriptExecuteLogCacheModel scriptExecuteLogCacheModel = new ScriptExecuteLogCacheModel();
        scriptExecuteLogCacheModel.setScriptId(dataItem.getScriptId());
        scriptExecuteLogCacheModel.setNodeId(nodeInfo.getId());
        scriptExecuteLogCacheModel.setScriptName(dataItem.getName());
        scriptExecuteLogCacheModel.setTriggerExecType(0);
        scriptExecuteLogCacheModel.setWorkspaceId(nodeInfo.getWorkspaceId());
        logServer.insert(scriptExecuteLogCacheModel);
        return scriptExecuteLogCacheModel.getId();
    } finally {
        BaseServerController.removeAll();
    }
}
Also used : UserModel(io.jpom.model.data.UserModel) NodeModel(io.jpom.model.data.NodeModel) NodeScriptServer(io.jpom.service.node.script.NodeScriptServer) NodeScriptExecuteLogServer(io.jpom.service.node.script.NodeScriptExecuteLogServer) ScriptExecuteLogCacheModel(io.jpom.model.node.ScriptExecuteLogCacheModel) ScriptCacheModel(io.jpom.model.node.ScriptCacheModel)

Aggregations

ScriptCacheModel (io.jpom.model.node.ScriptCacheModel)2 NodeModel (io.jpom.model.data.NodeModel)1 UserModel (io.jpom.model.data.UserModel)1 ProjectInfoCacheModel (io.jpom.model.node.ProjectInfoCacheModel)1 ScriptExecuteLogCacheModel (io.jpom.model.node.ScriptExecuteLogCacheModel)1 ClassFeature (io.jpom.permission.ClassFeature)1 Feature (io.jpom.permission.Feature)1 MethodFeature (io.jpom.permission.MethodFeature)1 NodeScriptExecuteLogServer (io.jpom.service.node.script.NodeScriptExecuteLogServer)1 NodeScriptServer (io.jpom.service.node.script.NodeScriptServer)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1