use of com.thoughtworks.go.config.commands.CheckedUpdateCommand in project gocd by gocd.
the class GoConfigDao method updateConfig.
public ConfigSaveState updateConfig(UpdateConfigCommand command) {
ConfigSaveState configSaveState = null;
LOGGER.info("Config update request by {} is in queue - {}", UserHelper.getUserName().getUsername(), command);
synchronized (GoConfigWriteLock.class) {
try {
LOGGER.info("Config update request {} by {} is being processed", command, UserHelper.getUserName().getUsername());
if (command instanceof CheckedUpdateCommand) {
CheckedUpdateCommand checkedCommand = (CheckedUpdateCommand) command;
if (!checkedCommand.canContinue(cachedConfigService.currentConfig())) {
throw new ConfigUpdateCheckFailedException();
}
}
configSaveState = cachedConfigService.writeWithLock(command);
} catch (Exception e) {
LOGGER.error("Config update failed.", e);
throw e;
} finally {
if (command instanceof ConfigAwareUpdate) {
((ConfigAwareUpdate) command).afterUpdate(clonedConfig());
}
LOGGER.info("Config update request by {} is completed", UserHelper.getUserName().getUsername());
}
}
return configSaveState;
}
Aggregations