Search in sources :

Example 91 with Feature

use of io.jpom.permission.Feature in project Jpom by dromara.

the class NodeScriptController method save.

/**
 * 保存脚本
 *
 * @return json
 */
@RequestMapping(value = "save.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.EDIT)
public String save(String autoExecCron) {
    NodeModel node = getNode();
    this.checkCron(autoExecCron);
    JsonMessage<Object> request = NodeForward.request(node, getRequest(), NodeUrl.Script_Save);
    if (request.getCode() == HttpStatus.OK.value()) {
        nodeScriptServer.syncNode(node);
    }
    return request.toString();
}
Also used : NodeModel(io.jpom.model.data.NodeModel) ClassFeature(io.jpom.permission.ClassFeature) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature)

Example 92 with Feature

use of io.jpom.permission.Feature in project Jpom by dromara.

the class NodeScriptController method clearAll.

/**
 * 删除节点缓存的所有脚本模版
 *
 * @return json
 */
@GetMapping(value = "clear_all", produces = MediaType.APPLICATION_JSON_VALUE)
@SystemPermission(superUser = true)
@Feature(method = MethodFeature.DEL)
public String clearAll() {
    Entity where = Entity.create();
    where.set("id", " <> id");
    int del = nodeScriptServer.del(where);
    return JsonMessage.getString(200, "成功删除" + del + "条脚本模版缓存");
}
Also used : Entity(cn.hutool.db.Entity) SystemPermission(io.jpom.permission.SystemPermission) ClassFeature(io.jpom.permission.ClassFeature) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature)

Example 93 with Feature

use of io.jpom.permission.Feature in project Jpom by dromara.

the class CacheManageController method serverCache.

/**
 * get server's cache data
 * 获取 Server 的缓存数据
 *
 * @return json
 * @author Hotstrip
 */
@PostMapping(value = "server-cache", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.LIST)
public String serverCache() {
    Map<String, Object> map = new HashMap<>(10);
    String fileSize = FileUtil.readableFileSize(BuildUtil.tempFileCacheSize);
    map.put("cacheFileSize", fileSize);
    map.put("dataSize", FileUtil.readableFileSize(ConfigBean.getInstance().getDataSizeCache()));
    int size = LoginControl.LFU_CACHE.size();
    File oldJarsPath = JpomManifest.getOldJarsPath();
    map.put("oldJarsSize", FileUtil.readableFileSize(FileUtil.size(oldJarsPath)));
    map.put("ipSize", size);
    int oneLineCount = ServiceFileTailWatcher.getOneLineCount();
    map.put("readFileOnLineCount", oneLineCount);
    fileSize = FileUtil.readableFileSize(BuildUtil.buildCacheSize);
    map.put("cacheBuildFileSize", fileSize);
    map.put("taskList", CronUtils.list());
    map.put("pluginSize", PluginFactory.size());
    return JsonMessage.getString(200, "ok", map);
}
Also used : HashMap(java.util.HashMap) File(java.io.File) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature) ClassFeature(io.jpom.permission.ClassFeature)

Example 94 with Feature

use of io.jpom.permission.Feature in project Jpom by dromara.

the class SystemConfigController method ipConfigData.

/**
 * 加载服务端的 ip 白名单配置
 *
 * @return json
 */
@RequestMapping(value = "ip-config-data", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(cls = ClassFeature.SYSTEM_CONFIG_IP, method = MethodFeature.LIST)
public String ipConfigData() {
    SystemIpConfigModel config = systemParametersServer.getConfig(SystemIpConfigModel.ID, SystemIpConfigModel.class);
    JSONObject jsonObject = new JSONObject();
    if (config != null) {
        jsonObject.put("allowed", config.getAllowed());
        jsonObject.put("prohibited", config.getProhibited());
    }
    // jsonObject.put("path", FileUtil.getAbsolutePath(systemIpConfigService.filePath()));
    jsonObject.put("ip", getIp());
    return JsonMessage.getString(200, "加载成功", jsonObject);
}
Also used : SystemIpConfigModel(io.jpom.model.data.SystemIpConfigModel) JSONObject(com.alibaba.fastjson.JSONObject) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature) ClassFeature(io.jpom.permission.ClassFeature) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 95 with Feature

use of io.jpom.permission.Feature in project Jpom by dromara.

the class SystemConfigController method getWhitelist.

/**
 * 加载白名单配置
 *
 * @return json
 */
@RequestMapping(value = "get_whitelist", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(cls = ClassFeature.SYSTEM_NODE_WHITELIST, method = MethodFeature.LIST)
public String getWhitelist() {
    String workspaceId = nodeService.getCheckUserWorkspace(getRequest());
    NodeAgentWhitelist config = systemParametersServer.getConfigDefNewInstance(StrUtil.format("node_whitelist_{}", workspaceId), NodeAgentWhitelist.class);
    return JsonMessage.getString(200, "加载成功", config);
}
Also used : NodeAgentWhitelist(io.jpom.model.node.NodeAgentWhitelist) 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