Search in sources :

Example 1 with WorkspaceEnvVarModel

use of io.jpom.model.system.WorkspaceEnvVarModel in project Jpom by dromara.

the class AgentWorkspaceEnvVarController method updateWorkspaceEnvVar.

/**
 * 更新环境变量
 *
 * @param name        名称
 * @param value       值
 * @param description 描述
 * @return json
 */
@PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
public String updateWorkspaceEnvVar(@ValidatorItem String name, @ValidatorItem String value, @ValidatorItem String description) {
    String workspaceId = getWorkspaceId();
    synchronized (AgentWorkspaceEnvVarController.class) {
        WorkspaceEnvVarModel.WorkspaceEnvVarItemModel workspaceEnvVarModel = new WorkspaceEnvVarModel.WorkspaceEnvVarItemModel();
        workspaceEnvVarModel.setName(name);
        workspaceEnvVarModel.setValue(value);
        workspaceEnvVarModel.setDescription(description);
        // 
        WorkspaceEnvVarModel item = agentWorkspaceEnvVarService.getItem(workspaceId);
        if (null == item) {
            item = new WorkspaceEnvVarModel();
            item.setVarData(MapUtil.of(name, workspaceEnvVarModel));
            item.setName(workspaceId);
            item.setId(workspaceId);
            agentWorkspaceEnvVarService.addItem(item);
        } else {
            item.put(name, workspaceEnvVarModel);
            agentWorkspaceEnvVarService.updateItem(item);
        }
    }
    return JsonMessage.getString(200, "更新成功");
}
Also used : WorkspaceEnvVarModel(io.jpom.model.system.WorkspaceEnvVarModel) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 2 with WorkspaceEnvVarModel

use of io.jpom.model.system.WorkspaceEnvVarModel in project Jpom by dromara.

the class AgentCacheManageController method cache.

/**
 * 缓存信息
 *
 * @return json
 */
@PostMapping(value = "cache", produces = MediaType.APPLICATION_JSON_VALUE)
public String cache() {
    JSONObject jsonObject = new JSONObject();
    // 
    ConfigBean instance = ConfigBean.getInstance();
    File file = instance.getTempPath();
    String fileSize = FileUtil.readableFileSize(FileUtil.size(file));
    jsonObject.put("fileSize", fileSize);
    jsonObject.put("dataSize", FileUtil.readableFileSize(instance.dataSize()));
    File oldJarsPath = JpomManifest.getOldJarsPath();
    jsonObject.put("oldJarsSize", FileUtil.readableFileSize(FileUtil.size(oldJarsPath)));
    // 
    jsonObject.put("pidName", AbstractProjectCommander.PID_JPOM_NAME.size());
    jsonObject.put("pidPort", AbstractProjectCommander.PID_PORT.size());
    int oneLineCount = AgentFileTailWatcher.getOneLineCount();
    jsonObject.put("readFileOnLineCount", oneLineCount);
    jsonObject.put("taskList", CronUtils.list());
    jsonObject.put("pluginSize", PluginFactory.size());
    // 
    WorkspaceEnvVarModel item = agentWorkspaceEnvVarService.getItem(getWorkspaceId());
    if (item != null) {
        Map<String, WorkspaceEnvVarModel.WorkspaceEnvVarItemModel> varData = item.getVarData();
        if (varData != null) {
            jsonObject.put("envVarKeys", varData.keySet());
        }
    }
    // 
    return JsonMessage.getString(200, "ok", jsonObject);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) WorkspaceEnvVarModel(io.jpom.model.system.WorkspaceEnvVarModel) ConfigBean(io.jpom.system.ConfigBean) File(java.io.File) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 3 with WorkspaceEnvVarModel

use of io.jpom.model.system.WorkspaceEnvVarModel in project Jpom by dromara.

the class AgentWorkspaceEnvVarController method delete.

/**
 * 删除环境变量
 *
 * @param name 名称
 * @return json
 */
@PostMapping(value = "/delete", produces = MediaType.APPLICATION_JSON_VALUE)
public String delete(@ValidatorItem String name) {
    String workspaceId = getWorkspaceId();
    synchronized (AgentWorkspaceEnvVarController.class) {
        // 
        WorkspaceEnvVarModel item = agentWorkspaceEnvVarService.getItem(workspaceId);
        if (null != item) {
            item.remove(name);
            agentWorkspaceEnvVarService.updateItem(item);
        }
    }
    return JsonMessage.getString(200, "删除成功");
}
Also used : WorkspaceEnvVarModel(io.jpom.model.system.WorkspaceEnvVarModel) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

WorkspaceEnvVarModel (io.jpom.model.system.WorkspaceEnvVarModel)3 PostMapping (org.springframework.web.bind.annotation.PostMapping)3 JSONObject (com.alibaba.fastjson.JSONObject)1 ConfigBean (io.jpom.system.ConfigBean)1 File (java.io.File)1