Search in sources :

Example 26 with NodeModel

use of io.jpom.model.data.NodeModel in project Jpom by dromara.

the class WorkspaceEnvVarController method syncDelNodeEnvVar.

private void syncDelNodeEnvVar(String name, UserModel user, Collection<String> delNode, String workspaceId) {
    for (String s : delNode) {
        NodeModel byKey = nodeService.getByKey(s);
        Assert.state(StrUtil.equals(workspaceId, byKey.getWorkspaceId()), "选择节点错误");
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("name", name);
        JsonMessage<String> jsonMessage = NodeForward.request(byKey, NodeUrl.Workspace_EnvVar_Delete, user, jsonObject);
        Assert.state(jsonMessage.getCode() == 200, "处理 " + byKey.getName() + " 节点删除脚本失败" + jsonMessage.getMsg());
    }
}
Also used : NodeModel(io.jpom.model.data.NodeModel) JSONObject(com.alibaba.fastjson.JSONObject)

Example 27 with NodeModel

use of io.jpom.model.data.NodeModel in project Jpom by dromara.

the class NodeInfoController method createModel.

private NodeModel createModel(String ip, String loginName, String loginPwd, int port, String workspaceId) {
    NodeModel nodeModel = new NodeModel();
    nodeModel.setWorkspaceId(workspaceId);
    nodeModel.setName(ip);
    nodeModel.setOpenStatus(1);
    nodeModel.setLoginName(loginName);
    nodeModel.setLoginPwd(loginPwd);
    nodeModel.setUrl(ip + StrUtil.COLON + port);
    nodeModel.setProtocol("http");
    return nodeModel;
}
Also used : NodeModel(io.jpom.model.data.NodeModel)

Example 28 with NodeModel

use of io.jpom.model.data.NodeModel in project Jpom by dromara.

the class ReleaseManage method doProject.

/**
 * 发布项目
 */
private void doProject() {
    // AfterOpt afterOpt, boolean clearOld, boolean diffSync
    AfterOpt afterOpt = BaseEnum.getEnum(AfterOpt.class, this.buildExtraModule.getAfterOpt(), AfterOpt.No);
    boolean clearOld = this.buildExtraModule.isClearOld();
    boolean diffSync = this.buildExtraModule.isDiffSync();
    String releaseMethodDataId = this.buildExtraModule.getReleaseMethodDataId();
    String[] strings = StrUtil.splitToArray(releaseMethodDataId, CharPool.COLON);
    if (ArrayUtil.length(strings) != 2) {
        throw new IllegalArgumentException(releaseMethodDataId + " error");
    }
    NodeService nodeService = SpringUtil.getBean(NodeService.class);
    NodeModel nodeModel = nodeService.getByKey(strings[0]);
    Objects.requireNonNull(nodeModel, "节点不存在");
    String projectId = strings[1];
    if (diffSync) {
        this.diffSyncProject(nodeModel, projectId, afterOpt, clearOld);
        return;
    }
    File zipFile = BuildUtil.isDirPackage(this.resultFile);
    boolean unZip = true;
    if (zipFile == null) {
        zipFile = this.resultFile;
        unZip = false;
    }
    JsonMessage<String> jsonMessage = OutGivingRun.fileUpload(zipFile, null, projectId, unZip, afterOpt, nodeModel, this.userModel, clearOld);
    if (jsonMessage.getCode() == HttpStatus.HTTP_OK) {
        logRecorder.info("发布项目包成功:" + jsonMessage);
    } else {
        throw new JpomRuntimeException("发布项目包失败:" + jsonMessage);
    }
}
Also used : NodeModel(io.jpom.model.data.NodeModel) NodeService(io.jpom.service.node.NodeService) JpomRuntimeException(io.jpom.system.JpomRuntimeException) AfterOpt(io.jpom.model.AfterOpt) File(java.io.File)

Example 29 with NodeModel

use of io.jpom.model.data.NodeModel in project Jpom by dromara.

the class BaseServerController method getNode.

protected NodeModel getNode() {
    NodeModel nodeModel = tryGetNode();
    Assert.notNull(nodeModel, "节点信息不正确,对应对节点不存在");
    return nodeModel;
}
Also used : NodeModel(io.jpom.model.data.NodeModel)

Example 30 with NodeModel

use of io.jpom.model.data.NodeModel in project Jpom by dromara.

the class PermissionInterceptor method addNode.

private void addNode(HttpServletRequest request) {
    String nodeId = request.getParameter("nodeId");
    if (!StrUtil.isBlankOrUndefined(nodeId)) {
        // 节点信息
        NodeModel nodeModel = nodeService.getByKey(nodeId);
        if (nodeModel != null && !nodeModel.isOpenStatus()) {
            throw new AgentException(nodeModel.getName() + "节点未启用");
        }
        request.setAttribute("node", nodeModel);
    }
}
Also used : BaseNodeModel(io.jpom.model.BaseNodeModel) NodeModel(io.jpom.model.data.NodeModel) AgentException(io.jpom.system.AgentException)

Aggregations

NodeModel (io.jpom.model.data.NodeModel)64 JSONObject (com.alibaba.fastjson.JSONObject)27 Feature (io.jpom.permission.Feature)23 MethodFeature (io.jpom.permission.MethodFeature)23 ClassFeature (io.jpom.permission.ClassFeature)22 UserModel (io.jpom.model.data.UserModel)17 StrUtil (cn.hutool.core.util.StrUtil)12 NodeService (io.jpom.service.node.NodeService)12 Collectors (java.util.stream.Collectors)12 JsonMessage (cn.jiangzeyin.common.JsonMessage)11 List (java.util.List)11 HttpServletRequest (javax.servlet.http.HttpServletRequest)11 CollUtil (cn.hutool.core.collection.CollUtil)9 DefaultSystemLog (cn.jiangzeyin.common.DefaultSystemLog)9 NodeForward (io.jpom.common.forward.NodeForward)8 NodeUrl (io.jpom.common.forward.NodeUrl)8 Assert (org.springframework.util.Assert)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 JSONArray (com.alibaba.fastjson.JSONArray)7 BaseServerController (io.jpom.common.BaseServerController)7