Search in sources :

Example 1 with Env

use of com.baidu.disconf.web.service.env.bo.Env in project disconf by knightliao.

the class ConfigValidator method validateNew.

/**
 * 校验新建 配置
 *
 * @param confNewForm
 * @param disConfigTypeEnum
 */
public void validateNew(ConfNewItemForm confNewForm, DisConfigTypeEnum disConfigTypeEnum) {
    // 
    // app
    // 
    App app = appMgr.getById(confNewForm.getAppId());
    if (app == null) {
        throw new FieldException(ConfNewForm.APPID, "app.not.exist", null);
    }
    // 
    validateAppAuth(app.getId());
    // 
    // env
    // 
    Env env = envMgr.getById(confNewForm.getEnvId());
    if (env == null) {
        throw new FieldException(ConfNewForm.ENVID, "env.not.exist", null);
    }
    // 
    // key
    // 
    Config config = configFetchMgr.getConfByParameter(app.getId(), env.getId(), confNewForm.getVersion(), confNewForm.getKey(), disConfigTypeEnum);
    if (config != null) {
        throw new FieldException(ConfNewItemForm.KEY, "key.exist", null);
    }
}
Also used : App(com.baidu.disconf.web.service.app.bo.App) FieldException(com.baidu.dsp.common.exception.FieldException) Config(com.baidu.disconf.web.service.config.bo.Config) Env(com.baidu.disconf.web.service.env.bo.Env)

Example 2 with Env

use of com.baidu.disconf.web.service.env.bo.Env in project disconf by knightliao.

the class ConfigValidator4Fetch method verifyConfForm.

/**
 * 此接口是客户的接口,非常 重要,目前没有权限的控制
 *
 * @param confForm
 */
public ConfigFullModel verifyConfForm(ConfForm confForm, boolean unCheckKey) {
    // 
    if (StringUtils.isEmpty(confForm.getApp())) {
        throw new FieldException("app", "app is empty", null);
    }
    App app = appMgr.getByName(confForm.getApp());
    if (app == null) {
        throw new FieldException("app", "app " + confForm.getApp() + " doesn't exist in db.", null);
    }
    // 
    if (StringUtils.isEmpty(confForm.getEnv())) {
        throw new FieldException("env", "env is empty", null);
    }
    Env env = envMgr.getByName(confForm.getEnv());
    if (env == null) {
        throw new FieldException("env", "env " + confForm.getEnv() + " doesn't exist in db.", null);
    }
    // 
    if (!unCheckKey && StringUtils.isEmpty(confForm.getKey())) {
        throw new FieldException("key", "key is empty", null);
    }
    // 
    if (StringUtils.isEmpty(confForm.getVersion())) {
        throw new FieldException("version", "version is empty", null);
    }
    return new ConfigFullModel(app, env, confForm.getVersion(), confForm.getKey());
}
Also used : App(com.baidu.disconf.web.service.app.bo.App) FieldException(com.baidu.dsp.common.exception.FieldException) ConfigFullModel(com.baidu.disconf.web.web.config.dto.ConfigFullModel) Env(com.baidu.disconf.web.service.env.bo.Env)

Example 3 with Env

use of com.baidu.disconf.web.service.env.bo.Env in project disconf by knightliao.

the class ConfigMgrImpl method getConfVo.

/**
 * 根据 配置ID获取配置返回
 */
@Override
public ConfListVo getConfVo(Long configId) {
    Config config = configDao.get(configId);
    App app = appMgr.getById(config.getAppId());
    Env env = envMgr.getById(config.getEnvId());
    return convert(config, app.getName(), env.getName(), null);
}
Also used : App(com.baidu.disconf.web.service.app.bo.App) Config(com.baidu.disconf.web.service.config.bo.Config) ApplicationPropertyConfig(com.baidu.disconf.web.config.ApplicationPropertyConfig) Env(com.baidu.disconf.web.service.env.bo.Env)

Example 4 with Env

use of com.baidu.disconf.web.service.env.bo.Env in project disconf by knightliao.

the class EnvMgrImpl method getVoList.

/**
 */
@Override
public List<EnvListVo> getVoList() {
    List<Env> envs = envDao.findAll();
    List<EnvListVo> envListVos = new ArrayList<EnvListVo>();
    for (Env env : envs) {
        EnvListVo envListVo = new EnvListVo();
        envListVo.setId(env.getId());
        envListVo.setName(env.getName());
        envListVos.add(envListVo);
    }
    return envListVos;
}
Also used : EnvListVo(com.baidu.disconf.web.service.env.vo.EnvListVo) ArrayList(java.util.ArrayList) Env(com.baidu.disconf.web.service.env.bo.Env)

Example 5 with Env

use of com.baidu.disconf.web.service.env.bo.Env in project disconf by knightliao.

the class ConfigMgrImpl method getConfVoWithZk.

/**
 * 根据 配置ID获取ZK对比数据
 */
@Override
public MachineListVo getConfVoWithZk(Long configId) {
    Config config = configDao.get(configId);
    App app = appMgr.getById(config.getAppId());
    Env env = envMgr.getById(config.getEnvId());
    // 
    // 
    // 
    DisConfigTypeEnum disConfigTypeEnum = DisConfigTypeEnum.FILE;
    if (config.getType().equals(DisConfigTypeEnum.ITEM.getType())) {
        disConfigTypeEnum = DisConfigTypeEnum.ITEM;
    }
    ZkDisconfData zkDisconfData = zkDeployMgr.getZkDisconfData(app.getName(), env.getName(), config.getVersion(), disConfigTypeEnum, config.getName());
    if (zkDisconfData == null) {
        return new MachineListVo();
    }
    MachineListVo machineListVo = getZkData(zkDisconfData.getData(), config);
    return machineListVo;
}
Also used : App(com.baidu.disconf.web.service.app.bo.App) ZkDisconfData(com.baidu.disconf.web.service.zookeeper.dto.ZkDisconfData) DisConfigTypeEnum(com.baidu.disconf.core.common.constants.DisConfigTypeEnum) Config(com.baidu.disconf.web.service.config.bo.Config) ApplicationPropertyConfig(com.baidu.disconf.web.config.ApplicationPropertyConfig) MachineListVo(com.baidu.disconf.web.service.config.vo.MachineListVo) Env(com.baidu.disconf.web.service.env.bo.Env)

Aggregations

Env (com.baidu.disconf.web.service.env.bo.Env)9 App (com.baidu.disconf.web.service.app.bo.App)7 Config (com.baidu.disconf.web.service.config.bo.Config)4 ApplicationPropertyConfig (com.baidu.disconf.web.config.ApplicationPropertyConfig)3 FieldException (com.baidu.dsp.common.exception.FieldException)3 ZkDisconfData (com.baidu.disconf.web.service.zookeeper.dto.ZkDisconfData)2 ConfigFullModel (com.baidu.disconf.web.web.config.dto.ConfigFullModel)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 DisConfigTypeEnum (com.baidu.disconf.core.common.constants.DisConfigTypeEnum)1 ConfListVo (com.baidu.disconf.web.service.config.vo.ConfListVo)1 MachineListVo (com.baidu.disconf.web.service.config.vo.MachineListVo)1 EnvListVo (com.baidu.disconf.web.service.env.vo.EnvListVo)1