use of com.vip.saturn.job.console.mybatis.entity.SystemConfig in project Saturn by vipshop.
the class SystemConfigServiceImplTest method initSystemConfig.
private SystemConfig initSystemConfig(String property, String value) {
SystemConfig systemConfig = new SystemConfig();
systemConfig.setProperty(property);
systemConfig.setValue(value);
return systemConfig;
}
use of com.vip.saturn.job.console.mybatis.entity.SystemConfig in project Saturn by vipshop.
the class RegistryCenterServiceImpl method notifyRefreshRegCenter.
@Override
public void notifyRefreshRegCenter() throws SaturnJobConsoleException {
SystemConfig systemConfig = new SystemConfig();
systemConfig.setProperty(SystemConfigProperties.REFRESH_REGISTRY_CENTER_UUID);
systemConfig.setValue(UUID.randomUUID().toString());
systemConfigService.insertOrUpdate(systemConfig);
}
use of com.vip.saturn.job.console.mybatis.entity.SystemConfig in project Saturn by vipshop.
the class SystemConfigServiceImpl method createConfig.
@Override
public Integer createConfig(SystemConfig systemConfig) throws SaturnJobConsoleException {
List<String> properties = new ArrayList<>();
properties.add(systemConfig.getProperty());
List<SystemConfig> systemConfigs = systemConfig4SqlService.selectByProperty(systemConfig.getProperty());
boolean found = false;
if (systemConfigs != null) {
for (int i = 0; i < systemConfigs.size(); i++) {
SystemConfig config = systemConfigs.get(i);
if (StringUtils.equals(config.getProperty(), systemConfig.getProperty())) {
found = true;
break;
}
}
}
if (found) {
throw new SaturnJobConsoleException(String.format("systemConfig %s already existed", systemConfig.getProperty()));
}
int result = systemConfig4SqlService.insert(systemConfig);
updateCacheIfNeed(systemConfig, result);
return result;
}
use of com.vip.saturn.job.console.mybatis.entity.SystemConfig in project Saturn by vipshop.
the class SystemConfigController method insertOrUpdate.
@RequestMapping(value = "system_config/insertOrUpdate", method = RequestMethod.POST)
@ResponseBody
public RequestResult insertOrUpdate(HttpServletRequest request, String property2, String value2) {
RequestResult requestResult = new RequestResult();
try {
if (property2 == null) {
throw new SaturnJobConsoleException("property cannot be null");
}
SystemConfig systemConfig = new SystemConfig();
systemConfig.setProperty(property2);
systemConfig.setValue(value2);
systemConfigService.insertOrUpdate(systemConfig);
requestResult.setSuccess(true);
} catch (SaturnJobConsoleException e) {
requestResult.setSuccess(false);
requestResult.setMessage(e.getMessage());
return requestResult;
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
requestResult.setSuccess(false);
requestResult.setMessage(e.toString());
}
return requestResult;
}
use of com.vip.saturn.job.console.mybatis.entity.SystemConfig in project Saturn by vipshop.
the class SystemConfigController method queryValue.
@RequestMapping(value = "system_config/queryValue", method = RequestMethod.POST)
@ResponseBody
public RequestResult queryValue(HttpServletRequest request, String property1) {
RequestResult requestResult = new RequestResult();
try {
List<String> properties = new ArrayList<>();
if (property1 != null) {
String[] split = property1.split(",");
if (split != null) {
for (String s : split) {
if (s != null && s.trim().length() > 0) {
String tmp = s.trim();
if (!properties.contains(tmp)) {
properties.add(tmp);
}
}
}
}
}
List<SystemConfig> systemConfigs = systemConfigService.getSystemConfigsDirectly(properties);
requestResult.setSuccess(true);
requestResult.setObj(systemConfigs);
} catch (SaturnJobConsoleException e) {
requestResult.setSuccess(false);
requestResult.setMessage(e.getMessage());
return requestResult;
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
requestResult.setSuccess(false);
requestResult.setMessage(e.toString());
}
return requestResult;
}
Aggregations