use of com.sohu.cache.entity.SystemConfig in project cachecloud by sohutv.
the class ConfigManageController method getDifConfigMap.
private Map<String, String> getDifConfigMap(List<SystemConfig> oldConfigList, Map<String, String> configMap) {
Map<String, String> systemDifConfigMap = new HashMap<String, String>();
for (SystemConfig systemConfig : oldConfigList) {
String key = systemConfig.getConfigKey();
String oldValue = systemConfig.getConfigValue();
String newValue = configMap.get(key);
if (newValue != null && !oldValue.equals(newValue)) {
systemDifConfigMap.put(systemConfig.getInfo(), String.format("old value: %s, new value: %s", oldValue, newValue));
}
}
return systemDifConfigMap;
}
use of com.sohu.cache.entity.SystemConfig in project cachecloud by sohutv.
the class ConfigServiceImpl method getConfigMap.
/**
* 获取所有配置的key-value
*
* @return
*/
private Map<String, String> getConfigMap() {
Map<String, String> configMap = new LinkedHashMap<String, String>();
List<SystemConfig> systemConfigList = getConfigList(1);
for (SystemConfig systemConfig : systemConfigList) {
configMap.put(systemConfig.getConfigKey(), systemConfig.getConfigValue());
}
return configMap;
}
use of com.sohu.cache.entity.SystemConfig in project cachecloud by sohutv.
the class ConfigManageController method update.
/**
* 修改配置
*
* @param request
* @param response
* @param model
* @return
*/
@RequestMapping(value = "/update")
public ModelAndView update(HttpServletRequest request, HttpServletResponse response, Model model) {
AppUser appUser = getUserInfo(request);
logger.warn("user {} want to change config!", appUser.getName());
List<SystemConfig> oldConfigList = configService.getConfigList(1);
SuccessEnum successEnum;
Map<String, String> configMap = new HashMap<String, String>();
try {
Map<String, String[]> paramMap = request.getParameterMap();
for (Entry<String, String[]> entry : paramMap.entrySet()) {
String key = entry.getKey();
String value = entry.getValue()[0];
if (StringUtils.isNotBlank(key)) {
configMap.put(key, value);
}
}
if (MapUtils.isEmpty(configMap)) {
logger.error("params {} may be empty!!", paramMap);
}
successEnum = configService.updateConfig(configMap);
if (successEnum.equals(SuccessEnum.SUCCESS)) {
configService.reloadSystemConfig();
}
} catch (Exception e) {
successEnum = SuccessEnum.FAIL;
logger.error(e.getMessage(), e);
}
Map<String, String> systemDifConfigMap = getDifConfigMap(oldConfigList, configMap);
appEmailUtil.sendSystemConfigDifEmail(appUser, systemDifConfigMap, successEnum);
logger.warn("user {} change config result is {}!", appUser.getName(), successEnum.value());
return new ModelAndView("redirect:/manage/config/init?success=" + successEnum.value());
}
Aggregations