Class ConfigurationRegistry

    • Field Detail

      • PROPERTY_ROOT_PATH

        public static final java.lang.String PROPERTY_ROOT_PATH
        Property name which value is used as the configurations root directory. Only the configuration files placed in this directory can be edited through the Server API.
        See Also:
        Constant Field Values
      • PROPERTY_LOCK_TIMEOUT

        public static final java.lang.String PROPERTY_LOCK_TIMEOUT
        Property name used to specify the timeout in minutes for configuration locks. A value of 0 means no timeout.
        See Also:
        Constant Field Values
      • CM_PREFIX

        public static final java.lang.String CM_PREFIX
        This is the prefix used when creating a temporary config instances.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ConfigurationRegistry

        public ConfigurationRegistry()
                              throws DIException
        Default constructor used for creation and initialization of the configuration registry.
        Throws:
        DIException - if an error occurs.
    • Method Detail

      • startAutoUnlock

        public void startAutoUnlock()
        Starts a new thread that on a given interval unlock configurations checked out for a long time
      • releaseConfigurationLock

        public boolean releaseConfigurationLock​(java.lang.String configToken,
                                                Identity identity)
                                         throws DIException
        This method is used to release the lock of a configuration file.
        Parameters:
        configToken - a configuration file path relative to the configuration codebase folder or a Solution Name.
        mIdentity - the user Identity object with enough authorities to unlock the configuration
        Returns:
        true if the file was previously locked, false otherwise.
        Throws:
        DIException - if an error occurs.
      • undoCheckOut

        public boolean undoCheckOut​(java.lang.String configToken,
                                    Identity identity)
                             throws DIException
        This method is used to release the lock of a previously checked out configuration file.
        Parameters:
        configToken - a configuration file path relative to the configuration codebase folder or a Solution Name.
        identity - the user Identity object used to verify the user that have checked out the configuration.
        Returns:
        true if the file was previously locked, false otherwise.
        Throws:
        DIException - if an error occurs.
      • listConfigurations

        public java.util.ArrayList<java.lang.String> listConfigurations​(java.lang.String aRelativePath)
                                                                 throws DIException
        Returns a list of all configurations in the specified folder. If a configuration has a Solution Name, this name appears in the list, otherwise in the list appears the file path of the configuration. The configurations file paths returned are relative to the Server configuration codebase folder. The returned list is based on information, gathered by the Server on startup. If a new configuration file is added in the configuration codebase folder when the Server is already running, that configuration will not be listed by the method.
        Parameters:
        aRelativePath - A folder relative to the Server configuration codebase folder.
        Returns:
        A list of all configurations in the specified folder.
        Throws:
        DIException - If an error occurs while retrieving configurations.
      • listFolders

        public java.util.ArrayList<java.lang.String> listFolders​(java.lang.String aRelativePath)
                                                          throws DIException
        Returns a list of the child folders of the specified folder.
        Parameters:
        aRelativePath - A folder relative to the Server configuration codebase folder.
        Returns:
        A list of the child folders of the specified folder.
        Throws:
        DIException - If an error occurs while retrieving child folder.
      • listAllConfigurations

        public java.util.ArrayList<java.lang.String> listAllConfigurations()
                                                                    throws DIException
        Returns a list all configurations in the directory subtree of the Server configuration codebase folder. If a configuration has a Solution Name, this name appears in the list, otherwise in the list appears the file path of the configuration. The configurations file paths returned are relative to the TDI Server configuration codebase folder. The returned list is based on information, gathered by the Server on startup. If a new configuration file is added in the configuration codebase folder when the Server is already running, that configuration will not be listed by the method.
        Returns:
        A list of all configurations from the whole configuration codebase directory subtree.
        Throws:
        DIException - If an error occurs while retrieving configurations.
      • checkOutConfiguration

        public MetamergeConfig checkOutConfiguration​(java.lang.String configToken,
                                                     Identity identity)
                                              throws DIException
        Checks out the specified configuration. Returns the MetamergeConfig object representing the configuration and locks that configuration on the Server.
        Parameters:
        configToken - The path to the configuration relative to the Server configuration codebase folder or the Solution Name of the configuration (the configuration must be inside the configuration codebase folder).
        identity - the Identity object used to verify the user's authorities.
        Returns:
        The MetamergeConfig object representing the specified configuration.
        Throws:
        DIException - If an error occurs while checking out the configuration.
      • checkOutConfiguration

        public MetamergeConfig checkOutConfiguration​(java.lang.String configToken,
                                                     java.lang.String password,
                                                     Identity identity)
                                              throws DIException
        Checks out the specified password protected configuration. Returns the MetamergeConfig object representing the configuration and locks that configuration on the Server.
        Parameters:
        configToken - The path to the configuration relative to the Server configuration codebase folder or the Solution Name of the configuration (the configuration must be inside the configuration codebase folder).
        password - Specify the password for password protected configurations.
        identity - the Identity object used to verify the user's authorities.
        Returns:
        The MetamergeConfig object representing the specified configuration.
        Throws:
        DIException - If an error occurs while checking out the configuration.
      • checkOutConfigurationAndLoad

        public ConfigInstance checkOutConfigurationAndLoad​(java.lang.String configToken,
                                                           Identity identity,
                                                           SessionImpl session)
                                                    throws DIException
        Checks out the specified configuration and starts a temporary Config Instance on the Server.
        Parameters:
        configToken - The path to the configuration relative to the Server configuration codebase folder or the Solution Name of the configuration (the configuration must be inside the configuration codebase folder).
        identity - the Identity object used to verify the user's authorities.
        session - this is the reference to the Session object used to start the confiInstance object.
        Returns:
        The ConfigInstance object representing the temporary ConfigIsntance started on the Server.
        Throws:
        DIException - If an error occurs while checking out the configuration.
      • checkOutConfigurationAndLoad

        public ConfigInstance checkOutConfigurationAndLoad​(java.lang.String configToken,
                                                           java.lang.String password,
                                                           Identity identity,
                                                           SessionImpl session)
                                                    throws DIException
        Checks out the specified configuration and starts a temporary Config Instance on the Server.
        Parameters:
        configToken - The path to the configuration relative to the Server configuration codebase folder or the Solution Name of the configuration (the configuration must be inside the configuration codebase folder).
        password - Specify the password for password protected configurations.
        identity - the Identity object used to verify the user's authorities.
        session - this is the reference to the Session object used to start the confiInstance object.
        Returns:
        The ConfigInstance object representing the temporary ConfigIsntance started on the Server.
        Throws:
        DIException - If an error occurs while checking out the configuration.
      • checkInConfiguration

        public void checkInConfiguration​(MetamergeConfig configuration,
                                         java.lang.String configToken,
                                         Identity identity)
                                  throws DIException
        Saves the specified configuration and releases the lock. If a temporary ConfigInstance has been started on check out, it will be stopped as well.
        Parameters:
        configuration - The MetamergeConfig object representing the configuration to be checked in.
        configToken - The path to the configuration relative to the Server configuration codebase folder or the Solution Name of the configuration (the configuration must be inside the configuration codebase folder).
        identity - the Identity object used to verify the user's authorities.
        Throws:
        DIException - If an error occurs while checking in the configuration.
      • checkInConfiguration

        public void checkInConfiguration​(MetamergeConfig configuration,
                                         java.lang.String configToken,
                                         Identity identity,
                                         boolean encrypt)
                                  throws DIException
        Encrypts and saves the specified configuration and releases the lock. If a temporary Config Instance has been started on check out, it will be stopped as well.
        Parameters:
        configuration - The MetamergeConfig object representing the configuration to be checked in.
        configToken - The path to the configuration relative to the Server configuration codebase folder or the Solution Name of the configuration (the configuration must be inside the configuration codebase folder).
        identity - the Identity object used to verify the user's authorities.
        encrypt - If set to true, the configuration will be encrypted on the Server.
        Throws:
        DIException - If an error occurs while checking in the configuration.
      • checkInAndLeaveCheckedOut

        public void checkInAndLeaveCheckedOut​(MetamergeConfig configuration,
                                              java.lang.String configToken,
                                              Identity identity)
                                       throws DIException
        Checks in the specified configuration and leaves it checked out. The timeout for the lock on the configuration is reset.
        Parameters:
        configuration - The MetamergeConfig object representing the configuration to be checked in.
        configToken - The path to the configuration relative to the Server configuration codebase folder or the Solution Name of the configuration (the configuration must be inside the configuration codebase folder).
        identity - the Identity object used to verify the user's authorities.
        encrypt - If set to true, the configuration will be encrypted on the Server.
        Throws:
        DIException - If an error occurs while checking in the configuration.
      • checkInAndLeaveCheckedOut

        public void checkInAndLeaveCheckedOut​(MetamergeConfig configuration,
                                              java.lang.String configToken,
                                              Identity identity,
                                              boolean encrypt)
                                       throws DIException
        Checks in the specified configuration and leaves it checked out. The timeout for the lock on the configuration is reset.
        Parameters:
        configuration - The MetamergeConfig object representing the configuration to be checked in.
        configToken - The path to the configuration relative to the Server configuration codebase folder or the Solution Name of the configuration (the configuration must be inside the configuration codebase folder).
        identity - the Identity object used to verify the user's authorities.
        Throws:
        DIException - If an error occurs while checking in the configuration.
      • createNewConfiguration

        public MetamergeConfig createNewConfiguration​(java.lang.String aRelativePath,
                                                      boolean aOverwrite,
                                                      Identity aIdentity)
                                               throws DIException
        Creates a new empty configuration and immediately checks it out. If a configuration with the specified path already exists and the aOverwrite parameter is set to false the operation will fail and an Exception will be thrown.
        Parameters:
        aRelativePath - The path of the new configuration file relative to the Server configuration codebase folder.
        aOverwrite - Specify whether to overwrite or not an already exising configuration file.
        aIdentity - the Identity object used to verify the user's authorities.
        Returns:
        The MetamergeConfig object representing the newly created configuration.
        Throws:
        DIException - If an error occurs while creating the new configuration.
      • createNewConfigurationAndLoad

        public ConfigInstance createNewConfigurationAndLoad​(java.lang.String aRelativePath,
                                                            boolean aOverwrite,
                                                            Identity aIdentity,
                                                            SessionImpl aSession)
                                                     throws DIException
        Creates a new empty configuration, immediately checks it out and loads a temporary Config Instance on the Server. If a configuration with the specified path already exists and the aOverwrite parameter is set to false the operation will fail and an Exception will be thrown.
        Parameters:
        aRelativePath - The path of the new configuration file relative to the Server configuration codebase folder.
        aOverwrite - Specify whether to overwrite or not an already existing configuration file.
        aIdentity - the Identity object used to verify the user's authorities.
        aSession - the Session object used to start the configInstance.
        Returns:
        The ConfigInstance object representing the temporary ConfigIsntance started on the Server.
        Throws:
        DIException - If an error occurs while creating the new configuration.
      • getConfigFolderPath

        public java.lang.String getConfigFolderPath()
        Returns the value of api.config.folder property.
        Returns:
        The canonical path of the config folder. If api.config.folder is NOT defined then return an empty string.
      • isConfigurationCheckedOut

        public boolean isConfigurationCheckedOut​(java.lang.String configToken)
                                          throws DIException
        Checks if the specified configuration is checked out on the Server.
        Parameters:
        configToken - The path to the configuration relative to the Server configuration codebase folder or the Solution Name of the configuration (the configuration must be inside the configuration codebase folder).
        Returns:
        true if the specified configuration is checked out, false otherwise.
        Throws:
        DIException - If an error occurs while checking the configuration.
      • updateLockTime

        public void updateLockTime​(java.lang.String path)
                            throws DIException
        Updates the time the configuration is checked out. The configuration is specified by the path parameter. This time is set to the current time as if the configuration was just checked out.
        Parameters:
        path - the configuration path.
        Throws:
        DIException - if an error occurs.
      • userCanSetConfiguration

        public boolean userCanSetConfiguration​(java.lang.String configId,
                                               Identity identity)
                                        throws DIException
        Check that the specified user can set the configuration.
        Parameters:
        configId - the configuration id used to identify the configInstance
        identity - the Identity object used to verify the user's rights.
        Returns:
        true if the user have the necessary rights for the operation, false otherwise.
        Throws:
        DIException - if an error occurs.
      • getSolutionName

        public java.lang.String getSolutionName​(java.io.File configFile)
                                         throws DIException
        Retrieves the Solution Name of a TDI configuration file in the configuration codebase folder. The Solution Name is looked up in the internal Solution Names cache. If the specified configuration file cannot be found in the cache, it is parsed for its Solution Name. If the Solution Name is a duplicate, an exception is thrown, otherwise the Solution Names cache is updated.
        Parameters:
        configFile - A TDI configuration file in the configuration codebase folder.
        Returns:
        The Solution Name of the specified configuration file.
        Throws:
        DIException - if detected a duplication of Solution Names or failed retrieval of the canonical path of a file.
      • getConfigFilePath

        public java.lang.String getConfigFilePath​(java.lang.String token)
                                           throws DIException
        Resolves a token to a configuration file path. The token can be either a Solution Name of a configuration file in the configuration codebase folder or a configuration file path. The method never returns null as long as the token is not null. If the token is not a path of an existing file and is not a Solution Name of an existing file, the method assumes the token is a path of a non-existing file and returns it as it is.
        Parameters:
        token - A configuration file path or a Solution Name.
        Returns:
        The configuration file path, which corresponds to the provided token.
        Throws:
        DIException - if detected a duplication of Solution Names or failed retrieval of the canonical path of a file or Solution Name coincides with the path of an existing file.
        Since:
        6.1.1
      • getConfigToken

        public java.lang.String getConfigToken​(java.io.File configFile)
                                        throws DIException
        If the specified config file has a Solution Name, then that name is returned, otherwise the path of the configuration, relative to the configuration codebase folder is returned. The returned token is never null for configuration files located in the configurations codebase folder.
        Parameters:
        configFile - A TDI configuration file in the configuration codebase folder.
        Returns:
        A token (relative path or a Solution Name), which identifies the configuration.
        Throws:
        DIException - if an error occurs.
      • deleteConfiguration

        public void deleteConfiguration​(java.lang.String relativePathOrSolutionName,
                                        Identity identity)
                                 throws DIException
        Delete a file from the configuration codebase folder.
        Parameters:
        relativePathOrSolutionName - The path to the configuration relative to the Server configuration codebase folder or the Solution Name of the configuration (the configuration must be inside the configuration codebase folder).
        identity - the user idenity
        Throws:
        DIException - The file is currently checked-out or deletion failed (e.g. the file does not exist).
        Since:
        7.0
      • getConfigsWithActiveSchedules

        public java.util.List<java.io.File> getConfigsWithActiveSchedules()