Configs

public class Configs

Stores information about all the created Commcare configurations.

Constructors

Configs

public Configs()

Configs

public Configs(List<Config> configs)

Methods

contains

public boolean contains(Config configuration)

Checks whether given configuration already exists.

Parameters:
  • configuration – the configuration to be checked
Returns:

true if configuration exists, false otherwise

deleteConfig

public void deleteConfig(String name)

Deletes the configuration with the given name.

Parameters:
  • name – the name of the configuration

getByName

public Config getByName(String name)

Returns configuration by its name.

Parameters:
  • name – the name of the configuration, null will return default configuration
Throws:
  • ConfigurationNotFoundException – when configuration with the given name doesn’t exists or if no default configuration was defined(only if null was passes as parameter)
Returns:

the configuration with given name or default configuration if null was given

getConfigs

public List<Config> getConfigs()

getDefault

public Config getDefault()

Returns default configuration.

Throws:
Returns:

the default configuration

getDefaultConfigName

public String getDefaultConfigName()

hasDefault

public boolean hasDefault()

Checks whether default configuration has been set.

Returns:true if there is default configuration, else otherwise

nameInUse

public boolean nameInUse(String name)

Checks whether configuration with given name already exists.

Parameters:
  • name – the name of the configuration
Returns:

true if configuration with given name already exists, false otherwise

saveConfig

public void saveConfig(Config config)

Saves given configuration.

Parameters:
  • config – the configuration to save

setConfigs

public void setConfigs(List<Config> configs)

setDefaultConfigName

public boolean setDefaultConfigName(String name)

updateConfig

public void updateConfig(Config config, String oldName)

Updates given configuration

Parameters:
  • config – the update source
  • oldName – the name of configuration before updates

validateUrlAndDomain

public boolean validateUrlAndDomain(String baseUrl, String domain)

Checks if there is configuration for given URL and domain combination.

Parameters:
  • baseUrl – the base URL of the configuration
  • domain – the domain of the configuration
Returns:

true of configuration exists, false otherwise