Interface IRepositoryConfigService


public interface IRepositoryConfigService
Loads the configurations the repository.

The loading process is depended from a type of configuration and hierarchy and inheritance settings. Configurations are stored and retrieved in a context, or for a user.

If configuration is hierarchy but not inherited the service will try to find first configuration file from a context to a root. If configuration is hierarchy and inherited the service will try to find all configuration files from a context to a root. If configuration isn't hierarchy (and so automatically isn't inherited) the service will try to load file only from context.

The configuration may be global and specific (defined by prefix). Now if prefix specified the service tries to find specific configuration (according the rules above) and only if nothing found switch to a global.

The prefix parameter always attached to a file name (even if file is specified with path) by a '-' character, e.g. if prefix if pref and file name is .set/subs/cooler.xml the file name for specific configuration will be .set/subs/pref-cooler.xml

Author:
POLARION SOFTWARE
  • Method Details

    • getReadConfiguration

      IConfig getReadConfiguration(@NotNull String configId, @NotNull IContextId context)
      Returns the global read-only configuration for direct usage. This configuration is processed with respect to hierarchy and inheritance settings.

      It should NEVER be used as input for saveConfiguration(String, IContextId, Object).

      Same as getReadConfiguration(configId, null, context)

      Parameters:
      configId - The configuration ID. Might not be null.
      context -
      Returns:
      The IConfig object (never null).
      Throws:
      IllegalArgumentException - If the configId is not defined.
    • getReadConfiguration

      IConfig getReadConfiguration(@NotNull String configId, @Nullable String prefix, @NotNull IContextId contextId)
      Returns the specific read-only configuration for direct usage. The typed configuration is processed with respect to hierarchy and inheritance settings.

      This method start to scan all prefix configuration from given context to the root and then scan global (with out prefix) configuration from given context to the root

      It should NEVER be used as input for saveConfiguration(String, IContextId, Object).

      Parameters:
      configId - The configuration ID. Might not be null.
      prefix -
      contextId -
      Returns:
      The IConfig object (Never returns null, but data can be null).
      Throws:
      IllegalArgumentException - If the configId is not defined.
    • existsAnyConfiguration

      boolean existsAnyConfiguration(@NotNull String configId, @Nullable String prefix, @NotNull IContextId contextId)
      Whether the configuration exists exactly in the specified context and with the specified prefix, or it exists in another context or without the prefix according to hierarchy and inheritance settings.
      Since:
      3.23.4
      See Also:
    • existsSpecificConfiguration

      boolean existsSpecificConfiguration(@NotNull String configId, @Nullable String prefix, @NotNull IContextId contextId)
      Whether the configuration exists exactly in the specified context and with the specified prefix (no hierarchy or inheritance processing).
      Since:
      3.23.4
      See Also:
    • getReadUserConfiguration

      IConfig getReadUserConfiguration(String configId, String userId)
      Returns user specific configuration that can be used directly. It should NEVER be used as input for saveUserConfiguration(String, String, Object).
      Parameters:
      configId - The configuration ID. Might not be null.
      userId - User ID or null for the default configuration.
      Returns:
      The IConfig object (Never returns null, but data can be null).
    • addConfigurationListener

      void addConfigurationListener(String configId, String prefix, IContextId contextId, IConfigListener l)
      Registers the listener, which will be notified after change in configuration occurs. The listener gets notified only on permanent changes, not on in-transaction (uncommitted) ones.

      The same instance of the listener might be registered for different config parameters.

      Parameters:
      configId - The configuration ID. Might not be null.
      prefix -
      contextId -
      l -
    • addUserConfigurationListener

      void addUserConfigurationListener(String configId, String userId, IUserConfigListener l)
      Registers the listener, which will be notified after change in configuration occurs. The listener gets notified only on permanent changes, not on in-transaction (uncommitted) ones.

      The same instance of the listener might be registered for different config parameters.

      Parameters:
      configId - The configuration ID. Might not be null.
      userId - User ID or null for the default configuration.
      l -
    • removeConfigurationListener

      void removeConfigurationListener(String configId, String prefix, IContextId contextId, IConfigListener l)
      Removes already registered listener. Nothing happens if the listener is not registered.
      Parameters:
      configId - The configuration ID. Might not be null.
      prefix -
      contextId -
      l -
    • removeUserConfigurationListener

      void removeUserConfigurationListener(String configId, String userId, IUserConfigListener l)
      Removes already registered listener. Nothing happens if the listener is not registered.
      Parameters:
      configId - The configuration ID. Might not be null.
      userId - User ID or null for the default configuration.
      l -
    • getConfigurationForUpdate

      Object getConfigurationForUpdate(String configId, IContextId contextId)
      This method is intended for configuration-editing clients, NOT for configuration-using clients (these should use getReadConfiguration(String, IContextId) instead.

      Same as getConfigurationForUpdate(configId, null, context)

      Parameters:
      configId - The configuration ID. Might not be null.
      contextId -
      Returns:
      The configuration object corresponding to the given context, no hierarchy or inheritance searches or merges are done. Returns null if the given context has no configuration. (Even if its parent configurations have some.)
    • getConfigurationForUpdate

      Object getConfigurationForUpdate(String configId, String prefix, IContextId contextId)
      This method is intended for configuration-editing clients, NOT for configuration-using clients (these should use getReadConfiguration(String, String, IContextId) instead.
      Parameters:
      configId - The configuration ID. Might not be null.
      prefix -
      contextId -
      Returns:
      The configuration object corresponding to the given context, no hierarchy or inheritance searches or merges are done. Returns null if the given context has no configuration. (Even if its parent configurations have some.)
    • getUserConfigurationForUpdate

      Object getUserConfigurationForUpdate(String configId, String userId)
      This method is intended for configuration-editing clients, NOT for configuration-using clients (these should use getReadUserConfiguration(String, String) instead.
      Parameters:
      configId - The configuration ID. Might not be null.
      userId - User ID or null for the default configuration.
      Returns:
      The configuration object corresponding to the given context, no hierarchy or inheritance searches or merges are done. Returns null if the given context has no configuration. (Even if its parent configurations have some.)
    • getConfigurationLocationForUpload

      ILocation getConfigurationLocationForUpload(String configId, IContextId contextId)
      This method is intended only for configuration file uploading clients.
      Parameters:
      configId - The configuration ID. Might not be null.
      contextId -
      Returns:
      the location of the configuration file.
    • getConfigurationLocationForUpload

      ILocation getConfigurationLocationForUpload(String configId, String prefix, IContextId contextId)
      This method is intended only for configuration file uploading clients.
      Parameters:
      configId - The configuration ID. Might not be null.
      prefix -
      contextId -
      Returns:
      the location of the configuration file.
    • getUserConfigurationLocationForUpload

      ILocation getUserConfigurationLocationForUpload(String configId, String userId)
      This method is intended only for configuration file uploading clients.
      Parameters:
      configId - The configuration ID. Might not be null.
      userId - User ID or null for the default configuration.
      Returns:
      the location of the configuration file.
    • saveConfiguration

      void saveConfiguration(String configId, IContextId contextId, Object config)
      Saves the global configuration. Saves the configuration.

      Same as saveConfiguration(configId, null, context, config)

      Parameters:
      configId - The configuration ID. Might not be null.
      contextId -
      config -
    • saveConfiguration

      void saveConfiguration(@NotNull String configId, @Nullable String prefix, @NotNull IContextId contextId, @Nullable Object config)
      Saves the specific configuration.
      Parameters:
      configId - The configuration ID. Might not be null.
      prefix -
      contextId -
      config - The configuration to save. Its conversion to stream is handled by the IDataHandler. If the config is null, then the existing configuration is deleted.
    • saveUserConfiguration

      void saveUserConfiguration(String configId, String userId, Object config)
      Saves user specific configuration.
      Parameters:
      configId - The configuration ID. Might not be null.
      userId - User ID or null for the default configuration.
      config - The configuration to save. Its conversion to stream is handled by the IDataHandler. If the config is null, then the existing configuration is deleted.
    • getExistingPrefixes

      IConfig getExistingPrefixes(String configId, IContextId contextId)
      This method returns the existing prefixes for given configuration.

      Note, that this will return only prefixes, which could affect the results for the current context. Therefore

      • For non-hierarchical config only the current context is searched.
      • For hierarchy the search will stop in context, which contains the generic (prefix-less) configuration
      • For inheritable config, all parent contexts will be processed

      The collection of prefixes is wrapped in IConfig, so that client can cache results build on top of the prefixes.

      The null prefix is never included in the collection.

      Parameters:
      configId - The configuration ID. Might not be null.
      contextId -
      Returns:
      IConfig with data Collection of String prefixes.
    • validateConfiguration

      String validateConfiguration(String configId, String prefix, IContextId contextId, Object config)
      Validates the specific configuration.
      Parameters:
      configId - The configuration ID. Might not be null.
      prefix -
      contextId -
      config - The configuration to validate. Its conversion to stream is handled by the IDataHandler.
      Since:
      3.6.2
    • defineConfiguration

      void defineConfiguration(String configId, boolean hierarchic, boolean inheritable, String cfgFilePath, IDataHandler<?,?> dataHandler)
      Defines the configuration programmatically - this is an alternative to definition by deployment.

      The meaning of parameters is the same as in deployment.

      Once a configuration is defined, it can never be removed during runtime.

      Parameters:
      configId - The configuration ID. Might not be null.
      hierarchic - If true, and it is not found in the specified context, the parent contexts are checked for configurations.
      inheritable - Can be true only if hierarchic is also . If true, then all configurations from the given context up to the root are taken into account and merged for the final result.
      cfgFilePath - Path to the config file. Must not be null.
      dataHandler - Data handler, if null, then the default is used (DOMDataHandler).
      Throws:
      IllegalArgumentException - If a configuration with the same ID is already defined.
    • defineUserConfiguration

      void defineUserConfiguration(String configId, boolean inheritable, String cfgFilePath, String defaultCfgFilePath, IDataHandler<?,?> dataHandler)
      Defines the configuration programmatically - this is an alternative to definition by deployment.

      The meaning of parameters is the same as in deployment.

      Once a configuration is defined, it can never be removed during runtime.

      Parameters:
      configId - The configuration ID. Might not be null.
      inheritable -
      cfgFilePath - Path to the config file. Must not be null.
      defaultCfgFilePath - Path to the default config file or null.
      dataHandler - Data handler, if null, then the default one is used (DOMDataHandler).
      Throws:
      IllegalArgumentException - if configuration with such ID is already defined.
    • isConfigurationDefined

      boolean isConfigurationDefined(String configId)
      Parameters:
      configId - The configuration ID. Might not be null.
      Returns:
      true if the configuration with given ID is defined, false otherwise.
    • getConfigProblemCatcher

      IConfigProblemCatcher getConfigProblemCatcher()
      Returns problem catcher.
      Returns:
      problem catcher (not null)
      Since:
      3.1.2
    • executeInDataHandlerResultsCachingContext

      void executeInDataHandlerResultsCachingContext(@NotNull RunnableWEx r)
      Since:
      3.2.1
    • executeInDataHandlerResultsCachingContext

      @Deprecated void executeInDataHandlerResultsCachingContext(@NotNull Object[] locationsCacheRef, @NotNull RunnableWEx r)
      Deprecated.
      the locationsCacheRef parameter is no longer used. Please consider using IRepositoryConfigService.executeInDataHandlerResultsCachingContext(RunnableWEx).
      Since:
      3.4.3
    • invalidateLocation

      void invalidateLocation(ILocation loc)
      Since:
      3.5.0
    • invalidateAll

      void invalidateAll()
      Invalidates configuration cache
      Since:
      3.17.0