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);
}
}
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());
}
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);
}
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;
}
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;
}
Aggregations