com.ibm.di.api
Class ConfigurationRegistry

java.lang.Object
  extended by com.ibm.di.api.ConfigurationRegistry

public final class ConfigurationRegistry
extends Object

This class represents the repository used for manipulating configInstances.


Field Summary
static String CM_PREFIX
          This is the prefix used when creating a temporary config instances.
static String PROPERTY_LOCK_TIMEOUT
          Property name used to specify the timeout in minutes for configuration locks.
static String PROPERTY_ROOT_PATH
          Property name which value is used as the configurations root directory.
 
Constructor Summary
ConfigurationRegistry()
          Default constructor used for creation and initialization of the configuration registry.
 
Method Summary
 void checkInAndLeaveCheckedOut(MetamergeConfig configuration, String configToken, Identity identity)
          Checks in the specified configuration and leaves it checked out.
 void checkInConfiguration(MetamergeConfig configuration, String configToken, Identity identity)
          Saves the specified configuration and releases the lock.
 void checkInConfiguration(MetamergeConfig configuration, String configToken, Identity identity, boolean encrypt)
          Encrypts and saves the specified configuration and releases the lock.
 MetamergeConfig checkOutConfiguration(String configToken, Identity identity)
          Checks out the specified configuration.
 MetamergeConfig checkOutConfiguration(String configToken, String password, Identity identity)
          Checks out the specified password protected configuration.
 ConfigInstance checkOutConfigurationAndLoad(String configToken, Identity identity, SessionImpl session)
          Checks out the specified configuration and starts a temporary Config Instance on the Server.
 ConfigInstance checkOutConfigurationAndLoad(String configToken, String password, Identity identity, SessionImpl session)
          Checks out the specified configuration and starts a temporary Config Instance on the Server.
 MetamergeConfig createNewConfiguration(String aRelativePath, boolean aOverwrite, Identity aIdentity)
          Creates a new empty configuration and immediately checks it out.
 ConfigInstance createNewConfigurationAndLoad(String aRelativePath, boolean aOverwrite, Identity aIdentity, SessionImpl aSession)
          Creates a new empty configuration, immediately checks it out and loads a temporary Config Instance on the Server.
 void deleteConfiguration(String relativePathOrSolutionName)
          Delete a file from the configuration codebase folder.
 String getConfigFilePath(String token)
          Resolves a token to a configuration file path.
 String getConfigFolderPath()
          Returns the value of api.config.folder property.
 String getSolutionName(File configFile)
          Retrieves the Solution Name of a TDI configuration file in the configuration codebase folder.
 boolean isConfigurationCheckedOut(String configToken)
          Checks if the specified configuration is checked out on the Server.
 ArrayList<String> listAllConfigurations()
          Returns a list all configurations in the directory subtree of the Server configuration codebase folder.
 ArrayList<String> listConfigurations(String aRelativePath)
          Returns a list of all configurations in the specified folder.
 ArrayList<String> listFolders(String aRelativePath)
          Returns a list of the child folders of the specified folder.
 boolean releaseConfigurationLock(String configToken)
          This method is used to release the lock of a configuration file.
 void startAutoUnlock()
          Starts a new thread that on a given interval unlock configurations checked out for a long time
 boolean undoCheckOut(String configToken, Identity identity)
          This method is used to release the lock of a previously checked out configuration file.
 void updateLockTime(String path)
          Updates the time the configuration is checked out.
 boolean userCanSetConfiguration(String configId, Identity identity)
          Check that the specified user can set the configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_ROOT_PATH

public static final 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 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 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(String configToken)
                                 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.
Returns:
true if the file was previously locked, false otherwise.
Throws:
DIException - if an error occurs.

undoCheckOut

public boolean undoCheckOut(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 ArrayList<String> listConfigurations(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 ArrayList<String> listFolders(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 ArrayList<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(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(String configToken,
                                             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(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(String configToken,
                                                   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,
                                 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,
                                 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,
                                      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.
Throws:
DIException - If an error occurs while checking in the configuration.

createNewConfiguration

public MetamergeConfig createNewConfiguration(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(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 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(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(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(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 String getSolutionName(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 String getConfigFilePath(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

deleteConfiguration

public void deleteConfiguration(String relativePathOrSolutionName)
                         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).
Throws:
DIException - The file is currently checked-out or deletion failed (e.g. the file does not exist).
Since:
7.0