use of com.baidu.disconf.web.service.config.bo.Config in project disconf by knightliao.
the class ConfigMgrImpl method getDisconfFileList.
/**
* 配置文件的整合
*
* @param confListForm
*
* @return
*/
public List<File> getDisconfFileList(ConfListForm confListForm) {
List<Config> configList = configDao.getConfigList(confListForm.getAppId(), confListForm.getEnvId(), confListForm.getVersion(), true);
// 时间作为当前文件夹
String curTime = DateUtils.format(new Date(), DataFormatConstants.COMMON_TIME_FORMAT);
curTime = "tmp" + File.separator + curTime;
OsUtil.makeDirs(curTime);
List<File> files = new ArrayList<File>();
for (Config config : configList) {
if (config.getType().equals(DisConfigTypeEnum.FILE.getType())) {
File file = new File(curTime, config.getName());
try {
FileUtils.writeByteArrayToFile(file, config.getValue().getBytes());
} catch (IOException e) {
LOG.warn(e.toString());
}
files.add(file);
}
}
return files;
}
use of com.baidu.disconf.web.service.config.bo.Config 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.config.bo.Config 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.config.bo.Config in project disconf by knightliao.
the class ConfigValidator method validateDelete.
/**
* 验证删除
*/
public void validateDelete(Long configId) {
Config config = configMgr.getConfigById(configId);
if (config == null) {
throw new FieldException("configId", "config.not.exist", null);
}
//
validateAppAuth(config.getAppId());
}
use of com.baidu.disconf.web.service.config.bo.Config in project disconf by knightliao.
the class ConfigValidator method valideConfigExist.
/**
* 校验
*
* @param id
*
* @return
*/
public Config valideConfigExist(Long id) {
//
// config
//
Config config = configMgr.getConfigById(id);
if (config == null) {
throw new FieldException("configId", "config.id.not.exist", null);
}
//
// validate app
//
validateAppAuth(config.getAppId());
return config;
}
Aggregations