Search in sources :

Example 1 with ConfigurationReadingException

use of com.epam.pipeline.exception.ConfigurationReadingException in project cloud-pipeline by epam.

the class PipelineVersionManager method loadConfigurationEntry.

public ConfigurationEntry loadConfigurationEntry(Long id, String version, String configName) throws GitClientException {
    List<ConfigurationEntry> configurations = loadConfigurationsFromScript(id, version);
    if (CollectionUtils.isEmpty(configurations)) {
        throw new ConfigurationReadingException(CONFIG_FILE_NAME);
    }
    if (StringUtils.hasText(configName)) {
        return configurations.stream().filter(conf -> conf.getName() != null && conf.getName().equals(configName)).findFirst().orElseThrow(() -> new IllegalArgumentException(messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NOT_FOUND, configName)));
    }
    ConfigurationEntry defaultConfig = getDefaultConfig(configurations);
    return defaultConfig == null ? configurations.get(0) : defaultConfig;
}
Also used : ConfigurationReadingException(com.epam.pipeline.exception.ConfigurationReadingException) ConfigurationEntry(com.epam.pipeline.entity.configuration.ConfigurationEntry)

Aggregations

ConfigurationEntry (com.epam.pipeline.entity.configuration.ConfigurationEntry)1 ConfigurationReadingException (com.epam.pipeline.exception.ConfigurationReadingException)1