Package com.ibm.di.api
Class ConfigurationRegistry
- java.lang.Object
-
- com.ibm.di.api.ConfigurationRegistry
-
- All Implemented Interfaces:
Listenable<ConfigurationFileListener>
public final class ConfigurationRegistry extends java.lang.Object implements Listenable<ConfigurationFileListener>
This class represents the repository used for manipulating configInstances.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCM_PREFIXThis is the prefix used when creating a temporary config instances.static java.lang.StringPROPERTY_LOCK_TIMEOUTProperty name used to specify the timeout in minutes for configuration locks.static java.lang.StringPROPERTY_ROOT_PATHProperty name which value is used as the configurations root directory.
-
Constructor Summary
Constructors Constructor Description ConfigurationRegistry()Default constructor used for creation and initialization of the configuration registry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(ConfigurationFileListener listener)Register new listener.voidcheckInAndLeaveCheckedOut(MetamergeConfig configuration, java.lang.String configToken, Identity identity)Checks in the specified configuration and leaves it checked out.voidcheckInAndLeaveCheckedOut(MetamergeConfig configuration, java.lang.String configToken, Identity identity, boolean encrypt)Checks in the specified configuration and leaves it checked out.voidcheckInConfiguration(MetamergeConfig configuration, java.lang.String configToken, Identity identity)Saves the specified configuration and releases the lock.voidcheckInConfiguration(MetamergeConfig configuration, java.lang.String configToken, Identity identity, boolean encrypt)Encrypts and saves the specified configuration and releases the lock.MetamergeConfigcheckOutConfiguration(java.lang.String configToken, Identity identity)Checks out the specified configuration.MetamergeConfigcheckOutConfiguration(java.lang.String configToken, java.lang.String password, Identity identity)Checks out the specified password protected configuration.ConfigInstancecheckOutConfigurationAndLoad(java.lang.String configToken, Identity identity, SessionImpl session)Checks out the specified configuration and starts a temporary Config Instance on the Server.ConfigInstancecheckOutConfigurationAndLoad(java.lang.String configToken, java.lang.String password, Identity identity, SessionImpl session)Checks out the specified configuration and starts a temporary Config Instance on the Server.MetamergeConfigcreateNewConfiguration(java.lang.String aRelativePath, boolean aOverwrite, Identity aIdentity)Creates a new empty configuration and immediately checks it out.ConfigInstancecreateNewConfigurationAndLoad(java.lang.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.voiddeleteConfiguration(java.lang.String relativePathOrSolutionName, Identity identity)Delete a file from the configuration codebase folder.java.lang.StringgetConfigFilePath(java.lang.String token)Resolves a token to a configuration file path.java.lang.StringgetConfigFolderPath()Returns the value of api.config.folder property.java.util.List<java.io.File>getConfigsWithActiveSchedules()java.lang.StringgetConfigToken(java.io.File configFile)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.java.lang.StringgetSolutionName(java.io.File configFile)Retrieves the Solution Name of a TDI configuration file in the configuration codebase folder.booleanisConfigurationCheckedOut(java.lang.String configToken)Checks if the specified configuration is checked out on the Server.java.util.ArrayList<java.lang.String>listAllConfigurations()Returns a list all configurations in the directory subtree of the Server configuration codebase folder.java.util.ArrayList<java.lang.String>listConfigurations(java.lang.String aRelativePath)Returns a list of all configurations in the specified folder.java.util.ArrayList<java.lang.String>listFolders(java.lang.String aRelativePath)Returns a list of the child folders of the specified folder.booleanreleaseConfigurationLock(java.lang.String configToken, Identity identity)This method is used to release the lock of a configuration file.ConfigurationFileListenerremoveListener(ConfigurationFileListener listener)Unregister listener.voidstartAutoUnlock()Starts a new thread that on a given interval unlock configurations checked out for a long timebooleanundoCheckOut(java.lang.String configToken, Identity identity)This method is used to release the lock of a previously checked out configuration file.voidupdateLockTime(java.lang.String path)Updates the time the configuration is checked out.booleanuserCanSetConfiguration(java.lang.String configId, Identity identity)Check that the specified user can set the configuration.
-
-
-
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 DIExceptionDefault 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 DIExceptionThis 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 userIdentityobject 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 DIExceptionThis 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 userIdentityobject 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 DIExceptionReturns 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 DIExceptionReturns 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 DIExceptionReturns 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- theIdentityobject 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- theIdentityobject 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- theIdentityobject used to verify the user's authorities.session- this is the reference to theSessionobject 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- theIdentityobject used to verify the user's authorities.session- this is the reference to theSessionobject 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- theIdentityobject 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- theIdentityobject 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- theIdentityobject 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- theIdentityobject 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- theIdentityobject 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- theIdentityobject used to verify the user's authorities.aSession- theSessionobject 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 DIExceptionChecks 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 DIExceptionUpdates the time the configuration is checked out. The configuration is specified by thepathparameter. 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 DIExceptionCheck that the specified user can set the configuration.- Parameters:
configId- the configuration id used to identify the configInstanceidentity- theIdentityobject 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 DIExceptionRetrieves 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 DIExceptionResolves 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 DIExceptionIf 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 DIExceptionDelete 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
-
addListener
public void addListener(ConfigurationFileListener listener)
Description copied from interface:ListenableRegister new listener.- Specified by:
addListenerin interfaceListenable<ConfigurationFileListener>- Parameters:
listener- Listener.
-
removeListener
public ConfigurationFileListener removeListener(ConfigurationFileListener listener)
Description copied from interface:ListenableUnregister listener.- Specified by:
removeListenerin interfaceListenable<ConfigurationFileListener>- Parameters:
listener- Registered listener.- Returns:
- the actual listener being registered. This is useful when the passed in instance is only used for identification and the actual listener needs to be properly disposed of.
-
getConfigsWithActiveSchedules
public java.util.List<java.io.File> getConfigsWithActiveSchedules()
-
-