Package africa.absa.inception.config
Class ConfigService
- java.lang.Object
-
- africa.absa.inception.config.ConfigService
-
- All Implemented Interfaces:
IConfigService
@Service public class ConfigService extends Object implements IConfigService
The ConfigService class provides the Config Service implementation.- Author:
- Marcus Portmann
-
-
Constructor Summary
Constructors Constructor Description ConfigService(javax.validation.Validator validator, ConfigRepository configRepository, ConfigSummaryRepository configSummaryRepository)Constructs a new ConfigService.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeleteConfig(String key)Delete the config with the specified key.byte[]getBinary(String key)Retrieve the binary config.byte[]getBinary(String key, byte[] defaultValue)Retrieve the binary config.booleangetBoolean(String key)Retrieve the Boolean config.booleangetBoolean(String key, boolean defaultValue)Retrieve the Boolean config.ConfiggetConfig(String key)Retrieve the config.List<Config>getConfigs()Retrieve all the configs.List<ConfigSummary>getConfigSummaries()Retrieve all the config summaries.DoublegetDouble(String key)Retrieve the Double config.doublegetDouble(String key, double defaultValue)Retrieve the Double config.List<Config>getFilteredConfigs(String filter)Retrieve the filtered configs.List<ConfigSummary>getFilteredConfigSummaries(String filter)Retrieve the filtered config summaries.IntegergetInteger(String key)Retrieve the Integer config.intgetInteger(String key, int defaultValue)Retrieve the Integer config.LonggetLong(String key)Retrieve the Long config.longgetLong(String key, long defaultValue)Retrieve the Long config.StringgetString(String key)Retrieve the value for the String config.StringgetString(String key, String defaultValue)Retrieve the value for the String config.booleankeyExists(String key)Check if a config with the specified key exists.voidsetConfig(Config config)Set the config.voidsetConfig(String key, Object value, String description)Set the config key to the specified value.
-
-
-
Constructor Detail
-
ConfigService
public ConfigService(javax.validation.Validator validator, ConfigRepository configRepository, ConfigSummaryRepository configSummaryRepository)Constructs a new ConfigService.- Parameters:
validator- the JSR-303 validatorconfigRepository- the Config RepositoryconfigSummaryRepository- the Config Summary Repository
-
-
Method Detail
-
deleteConfig
@Transactional public void deleteConfig(String key) throws InvalidArgumentException, ConfigNotFoundException, ServiceUnavailableException
Description copied from interface:IConfigServiceDelete the config with the specified key.- Specified by:
deleteConfigin interfaceIConfigService- Parameters:
key- the key for the config- Throws:
InvalidArgumentException- if an argument is invalidConfigNotFoundException- if the config could not be foundServiceUnavailableException- if the config could not be deleted
-
getBinary
public byte[] getBinary(String key) throws InvalidArgumentException, ConfigNotFoundException, ServiceUnavailableException
Description copied from interface:IConfigServiceRetrieve the binary config.- Specified by:
getBinaryin interfaceIConfigService- Parameters:
key- the key for the config- Returns:
- the binary config
- Throws:
InvalidArgumentException- if an argument is invalidConfigNotFoundException- if the config could not be foundServiceUnavailableException- if the binary config value could not be retrieved
-
getBinary
public byte[] getBinary(String key, byte[] defaultValue) throws InvalidArgumentException, ServiceUnavailableException
Description copied from interface:IConfigServiceRetrieve the binary config.- Specified by:
getBinaryin interfaceIConfigService- Parameters:
key- the key for the configdefaultValue- the default value to return if the config does not exist- Returns:
- the binary config or the default value if the config does not exist
- Throws:
InvalidArgumentException- if an argument is invalidServiceUnavailableException- if the binary config value could not be retrieved
-
getBoolean
public boolean getBoolean(String key) throws InvalidArgumentException, ConfigNotFoundException, ServiceUnavailableException
Description copied from interface:IConfigServiceRetrieve the Boolean config.- Specified by:
getBooleanin interfaceIConfigService- Parameters:
key- the key for the config- Returns:
- the Boolean config
- Throws:
InvalidArgumentException- if an argument is invalidConfigNotFoundException- if the config could not be foundServiceUnavailableException- if the boolean config value could not be retrieved
-
getBoolean
public boolean getBoolean(String key, boolean defaultValue) throws InvalidArgumentException, ServiceUnavailableException
Description copied from interface:IConfigServiceRetrieve the Boolean config.- Specified by:
getBooleanin interfaceIConfigService- Parameters:
key- the key for the configdefaultValue- the default value to return if the config does not exist- Returns:
- the Boolean config or the default value if the config value does not exist
- Throws:
InvalidArgumentException- if an argument is invalidServiceUnavailableException- if the boolean config value could not be retrieved
-
getConfig
public Config getConfig(String key) throws InvalidArgumentException, ConfigNotFoundException, ServiceUnavailableException
Description copied from interface:IConfigServiceRetrieve the config.- Specified by:
getConfigin interfaceIConfigService- Parameters:
key- the key for the config- Returns:
- the config
- Throws:
InvalidArgumentException- if an argument is invalidConfigNotFoundException- if the config could not be foundServiceUnavailableException- if the config could not be retrieved
-
getConfigSummaries
public List<ConfigSummary> getConfigSummaries() throws ServiceUnavailableException
Description copied from interface:IConfigServiceRetrieve all the config summaries.- Specified by:
getConfigSummariesin interfaceIConfigService- Returns:
- the config summaries
- Throws:
ServiceUnavailableException- if the config summaries could not be retrieved
-
getConfigs
public List<Config> getConfigs() throws ServiceUnavailableException
Description copied from interface:IConfigServiceRetrieve all the configs.- Specified by:
getConfigsin interfaceIConfigService- Returns:
- the configs
- Throws:
ServiceUnavailableException- if the configs could not be retrieved
-
getDouble
public Double getDouble(String key) throws InvalidArgumentException, ConfigNotFoundException, ServiceUnavailableException
Description copied from interface:IConfigServiceRetrieve the Double config.- Specified by:
getDoublein interfaceIConfigService- Parameters:
key- the key for the config- Returns:
- the Double config
- Throws:
InvalidArgumentException- if an argument is invalidConfigNotFoundException- if the config could not be foundServiceUnavailableException- if the double config value could not be retrieved
-
getDouble
public double getDouble(String key, double defaultValue) throws InvalidArgumentException, ServiceUnavailableException
Description copied from interface:IConfigServiceRetrieve the Double config.- Specified by:
getDoublein interfaceIConfigService- Parameters:
key- the key for the configdefaultValue- the default value to return if the config does not exist- Returns:
- the Double config or the default value if the config entry does not exist
- Throws:
InvalidArgumentException- if an argument is invalidServiceUnavailableException- if the double config value could not be retrieved
-
getFilteredConfigSummaries
public List<ConfigSummary> getFilteredConfigSummaries(String filter) throws ServiceUnavailableException
Description copied from interface:IConfigServiceRetrieve the filtered config summaries.- Specified by:
getFilteredConfigSummariesin interfaceIConfigService- Parameters:
filter- the filter to apply to the keys for the config summaries- Returns:
- the config summaries
- Throws:
ServiceUnavailableException- if the filtered config summaries could not be retrieved
-
getFilteredConfigs
public List<Config> getFilteredConfigs(String filter) throws ServiceUnavailableException
Description copied from interface:IConfigServiceRetrieve the filtered configs.- Specified by:
getFilteredConfigsin interfaceIConfigService- Parameters:
filter- the filter to apply to the keys for the config- Returns:
- the configs
- Throws:
ServiceUnavailableException- if the filtered configs could not be retrieved
-
getInteger
public Integer getInteger(String key) throws InvalidArgumentException, ConfigNotFoundException, ServiceUnavailableException
Description copied from interface:IConfigServiceRetrieve the Integer config.- Specified by:
getIntegerin interfaceIConfigService- Parameters:
key- the key for the config- Returns:
- the Integer config
- Throws:
InvalidArgumentException- if an argument is invalidConfigNotFoundException- if the config could not be foundServiceUnavailableException- if the integer config value could not be retrieved
-
getInteger
public int getInteger(String key, int defaultValue) throws InvalidArgumentException, ServiceUnavailableException
Description copied from interface:IConfigServiceRetrieve the Integer config.- Specified by:
getIntegerin interfaceIConfigService- Parameters:
key- the key for the configdefaultValue- the default value to return if the config does not exist- Returns:
- the Integer config or the default value if the config entry does not exist
- Throws:
InvalidArgumentException- if an argument is invalidServiceUnavailableException- if the integer config value could not be retrieved
-
getLong
public Long getLong(String key) throws InvalidArgumentException, ConfigNotFoundException, ServiceUnavailableException
Description copied from interface:IConfigServiceRetrieve the Long config.- Specified by:
getLongin interfaceIConfigService- Parameters:
key- the key for the config- Returns:
- the Long config
- Throws:
InvalidArgumentException- if an argument is invalidConfigNotFoundException- if the config could not be foundServiceUnavailableException- if the long config value could not be retrieved
-
getLong
public long getLong(String key, long defaultValue) throws InvalidArgumentException, ServiceUnavailableException
Description copied from interface:IConfigServiceRetrieve the Long config.- Specified by:
getLongin interfaceIConfigService- Parameters:
key- the key for the configdefaultValue- the default value to return if the config does not exist- Returns:
- the Long config or the default value if the config entry does not exist
- Throws:
InvalidArgumentException- if an argument is invalidServiceUnavailableException- if the long config value could not be retrieved
-
getString
public String getString(String key) throws InvalidArgumentException, ConfigNotFoundException, ServiceUnavailableException
Description copied from interface:IConfigServiceRetrieve the value for the String config.- Specified by:
getStringin interfaceIConfigService- Parameters:
key- the key for the config- Returns:
- the value for the String config
- Throws:
InvalidArgumentException- if an argument is invalidConfigNotFoundException- if the config could not be foundServiceUnavailableException- if the string config value could not be retrieved
-
getString
public String getString(String key, String defaultValue) throws InvalidArgumentException, ServiceUnavailableException
Description copied from interface:IConfigServiceRetrieve the value for the String config.- Specified by:
getStringin interfaceIConfigService- Parameters:
key- the key for the configdefaultValue- the default value to return if the config does not exist- Returns:
- the value for the String config or the default value if the config does not exist
- Throws:
InvalidArgumentException- if an argument is invalidServiceUnavailableException- if the string config value could not be retrieved
-
keyExists
public boolean keyExists(String key) throws InvalidArgumentException, ServiceUnavailableException
Description copied from interface:IConfigServiceCheck if a config with the specified key exists.- Specified by:
keyExistsin interfaceIConfigService- Parameters:
key- the key for the config- Returns:
- true if the config with the specified key exists or false otherwise
- Throws:
InvalidArgumentException- if an argument is invalidServiceUnavailableException- if the check for the existing key failed
-
setConfig
@Transactional public void setConfig(Config config) throws InvalidArgumentException, ServiceUnavailableException
Description copied from interface:IConfigServiceSet the config.- Specified by:
setConfigin interfaceIConfigService- Parameters:
config- the config- Throws:
InvalidArgumentException- if an argument is invalidServiceUnavailableException- if the config could not be set
-
setConfig
@Transactional public void setConfig(String key, Object value, String description) throws InvalidArgumentException, ServiceUnavailableException
Description copied from interface:IConfigServiceSet the config key to the specified value.- Specified by:
setConfigin interfaceIConfigService- Parameters:
key- the key for the configvalue- the value for the configdescription- the description for the config- Throws:
InvalidArgumentException- if an argument is invalidServiceUnavailableException- if the config could not be set
-
-