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 -
      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 -
      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 -
      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 -
      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 -
      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 -
      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 -
      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 -
      contextId -
      Returns:
      The configuration object corresponding to the given context, NO hierarchy/inheritance searches/merges are done. Returns null if the given context has no configuration (even if it's parent configs 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 -
      prefix -
      contextId -
      Returns:
      The configuration object corresponding to the given context, NO hierarchy/inheritance searches/merges are done. Returns null if the given context has no configuration (even if it's parent configs 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 -
      userId - user id or null for the default configuration
      Returns:
      The configuration object corresponding to the given context, NO inheritance searches/merges are done. Returns null if the given context has no configuration (even if it's parent configs have some).
    • getConfigurationLocationForUpload

      ILocation getConfigurationLocationForUpload(String configId, IContextId contextId)
      This method is intended only for configuration file uploading clients.
      Parameters:
      configId -
      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 -
      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 -
      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 -
      contextId -
      config -
    • saveConfiguration

      void saveConfiguration(@NotNull String configId, @Nullable String prefix, @NotNull IContextId contextId, @Nullable Object config)
      Saves the specific configuration.
      Parameters:
      configId -
      prefix -
      contextId -
      config - The configuration to save. It's 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 -
      userId - user id or null for the default configuration
      config - The configuration to save. It's 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 -
      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 -
      prefix -
      contextId -
      config - The configuration to validate. It's 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 then config will be looked in parent contexts if will be absent in the specific one.
      inheritable - Can be true only if hierarchic == true as well. If true then all configurations from given context up to the root will be 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 one is used (DOMDataHandler).
      Throws:
      IllegalArgumentException - if configuration with such 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 -
      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

      void executeInDataHandlerResultsCachingContext(@NotNull Object[] locationsCacheRef, @NotNull RunnableWEx r)
      Since:
      3.4.3
    • invalidateLocation

      void invalidateLocation(ILocation loc)
      Since:
      3.5.0
    • invalidateAll

      void invalidateAll()
      Invalidates configuration cache
      Since:
      3.17.0