use of com.baidu.disconf.web.service.config.bo.Config in project disconf by knightliao.
the class ConfigMgrImpl method newConfig.
/**
* 新建配置
*/
@Override
public void newConfig(ConfNewItemForm confNewForm, DisConfigTypeEnum disConfigTypeEnum) {
Config config = new Config();
config.setAppId(confNewForm.getAppId());
config.setEnvId(confNewForm.getEnvId());
config.setName(confNewForm.getKey());
config.setType(disConfigTypeEnum.getType());
config.setVersion(confNewForm.getVersion());
config.setValue(CodeUtils.utf8ToUnicode(confNewForm.getValue()));
config.setStatus(Constants.STATUS_NORMAL);
// 时间
String curTime = DateUtils.format(new Date(), DataFormatConstants.COMMON_TIME_FORMAT);
config.setCreateTime(curTime);
config.setUpdateTime(curTime);
configDao.create(config);
configHistoryMgr.createOne(config.getId(), "", config.getValue());
// 发送邮件通知
//
String toEmails = appMgr.getEmails(config.getAppId());
if (applicationPropertyConfig.isEmailMonitorOn() == true) {
logMailBean.sendHtmlEmail(toEmails, " config new", getNewValue(confNewForm.getValue(), config.toString(), getConfigUrlHtml(config)));
}
}
use of com.baidu.disconf.web.service.config.bo.Config 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;
}
use of com.baidu.disconf.web.service.config.bo.Config in project disconf by knightliao.
the class ConfigMgrImpl method getConfigList.
/**
* 配置列表
*/
@Override
public DaoPageResult<ConfListVo> getConfigList(ConfListForm confListForm, boolean fetchZk, final boolean getErrorMessage) {
//
// 数据据结果
//
DaoPageResult<Config> configList = configDao.getConfigList(confListForm.getAppId(), confListForm.getEnvId(), confListForm.getVersion(), confListForm.getPage());
//
//
//
final App app = appMgr.getById(confListForm.getAppId());
final Env env = envMgr.getById(confListForm.getEnvId());
//
//
//
final boolean myFetchZk = fetchZk;
Map<String, ZkDisconfData> zkDataMap = new HashMap<String, ZkDisconfData>();
if (myFetchZk) {
zkDataMap = zkDeployMgr.getZkDisconfDataMap(app.getName(), env.getName(), confListForm.getVersion());
}
final Map<String, ZkDisconfData> myzkDataMap = zkDataMap;
//
// 进行转换
//
DaoPageResult<ConfListVo> configListVo = ServiceUtil.getResult(configList, new DataTransfer<Config, ConfListVo>() {
@Override
public ConfListVo transfer(Config input) {
String appNameString = app.getName();
String envName = env.getName();
ZkDisconfData zkDisconfData = null;
if (myzkDataMap != null && myzkDataMap.keySet().contains(input.getName())) {
zkDisconfData = myzkDataMap.get(input.getName());
}
ConfListVo configListVo = convert(input, appNameString, envName, zkDisconfData);
// 列表操作不要显示值, 为了前端显示快速(只是内存里操作)
if (!myFetchZk && !getErrorMessage) {
// 列表 value 设置为 ""
configListVo.setValue("");
configListVo.setMachineList(new ArrayList<ZkDisconfData.ZkDisconfDataItem>());
}
return configListVo;
}
});
return configListVo;
}
use of com.baidu.disconf.web.service.config.bo.Config in project disconf by knightliao.
the class ConfigMgrImpl method delete.
/**
* 删除配置
*
* @param configId
*/
@Override
public void delete(Long configId) {
Config config = configDao.get(configId);
configHistoryMgr.createOne(configId, config.getValue(), "");
configDao.deleteItem(configId);
}
use of com.baidu.disconf.web.service.config.bo.Config in project disconf by knightliao.
the class ConfigFetchMgrImpl method getConfItemByParameter.
/**
* 根据详细参数获取配置返回
*/
public ValueVo getConfItemByParameter(Long appId, Long envId, String version, String key) {
Config config = configDao.getByParameter(appId, envId, version, key, DisConfigTypeEnum.ITEM);
if (config == null) {
return ConfigUtils.getErrorVo("cannot find this config");
}
ValueVo valueVo = new ValueVo();
valueVo.setValue(config.getValue());
valueVo.setStatus(Constants.OK);
return valueVo;
}
Aggregations