Search in sources :

Example 1 with CheckedUpdateCommand

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;
}
Also used : ConfigUpdateCheckFailedException(com.thoughtworks.go.config.update.ConfigUpdateCheckFailedException) CheckedUpdateCommand(com.thoughtworks.go.config.commands.CheckedUpdateCommand) ConfigUpdateCheckFailedException(com.thoughtworks.go.config.update.ConfigUpdateCheckFailedException)

Aggregations

CheckedUpdateCommand (com.thoughtworks.go.config.commands.CheckedUpdateCommand)1 ConfigUpdateCheckFailedException (com.thoughtworks.go.config.update.ConfigUpdateCheckFailedException)1