Interface ConfigurationService

All Known Implementing Classes:
ConfigurationServiceImpl

public interface ConfigurationService

Service which provides access to process configurations: key/value pairs which are either global or scoped to a single tenant.

  • Method Details

    • createConfiguration

      Configuration createConfiguration(String configKey, String configValue, String tenantId)

      Creates a new configuration entry.

      If tenantId is null the entry is created as a global configuration which applies to all tenants.

      The version starts at 1, or continues after the highest existing version when a previously deleted key is re-created in the same scope.

      Parameters:
      configKey - the configuration key, must not be null
      configValue - the configuration value, must not be null or blank
      tenantId - the tenant to scope the entry to, or null for a global entry
      Returns:
      the newly created configuration
      Throws:
      NotValidException - if configKey or configValue is null, or configValue is blank
      BadUserRequestException - if an active configuration with the same key already exists in the same scope
    • getConfiguration

      Configuration getConfiguration(String configurationId)

      Returns the configuration with the given id.

      Parameters:
      configurationId - the id of the configuration, must not be null
      Returns:
      the configuration, or null if no configuration exists for that id
    • getConfigurations

      List<Configuration> getConfigurations(String tenantId, boolean includeInactive)
      Returns the configurations applicable to the requested scope.

      If tenantId is null, the global default configurations are returned. For a tenant, active global configurations are returned with any active tenant entry replacing the global entry of the same key.

      If includeInactive is true, all entries of every status are returned without merging: the global entries and, when tenantId is set, the tenant's entries.

      Parameters:
      tenantId - the tenant scope, or null for global defaults
      includeInactive - whether to include inactive configurations
      Returns:
      configurations ordered by key, then global before tenant, then version
    • updateConfiguration

      Configuration updateConfiguration(String configurationId, String configValue)

      Updates the value of an active configuration by creating a new version.

      The existing entry is marked Configuration.STATUS_INACTIVE and a new Configuration.STATUS_ACTIVE entry with the same key and tenant scope is created. Its version is one greater than the highest existing version for that key and scope.

      Parameters:
      configurationId - the id of the active configuration to update
      configValue - the new configuration value, must not be blank
      Returns:
      the newly created active configuration version
      Throws:
      NotValidException - if configurationId or configValue is missing or blank
      NotFoundException - if no configuration exists for configurationId
      BadUserRequestException - if the configuration is not active
    • deleteConfiguration

      void deleteConfiguration(String configurationId)

      Soft-deletes an active configuration by marking it Configuration.STATUS_DELETED. The entry is retained and can still be retrieved by id or with includeInactive.

      Parameters:
      configurationId - the id of the active configuration to delete
      Throws:
      NotValidException - if configurationId is null
      NotFoundException - if no configuration exists for configurationId
      BadUserRequestException - if the configuration is not active