use of com.axway.ats.agent.core.configuration.EnvironmentConfigurator in project ats-framework by Axway.
the class EnvironmentCleanupClient method setDatabaseConnection.
/**
* Set database connection properties for the specified database listed in the configuration file (descriptor xml)
*
* @param databaseIndex - the number(index) of database element in the configuration file (descriptor xml)
* @param dbHost database host
* @param dbName database name
* @param dbPort database port
* @param userName user name
* @param userPassword user password
* @throws AgentException
*/
@PublicAtsApi
public void setDatabaseConnection(int databaseIndex, String dbHost, String dbName, int dbPort, String userName, String userPassword) throws AgentException {
Properties dbProperties = new Properties();
dbProperties.put(EnvironmentConfigurator.DB_CONFIGURATION_INDEX, databaseIndex);
if (!StringUtils.isNullOrEmpty(dbHost)) {
dbProperties.put(EnvironmentConfigurator.DB_HOST, dbHost);
}
if (dbPort > 0) {
dbProperties.put(EnvironmentConfigurator.DB_PORT, dbPort);
}
if (!StringUtils.isNullOrEmpty(dbName)) {
dbProperties.put(EnvironmentConfigurator.DB_NAME, dbName);
}
if (!StringUtils.isNullOrEmpty(userName)) {
dbProperties.put(EnvironmentConfigurator.DB_USER_NAME, userName);
}
if (!StringUtils.isNullOrEmpty(userPassword)) {
dbProperties.put(EnvironmentConfigurator.DB_USER_PASSWORD, userPassword);
}
List<Properties> dbPropertiesList = new ArrayList<Properties>();
dbPropertiesList.add(dbProperties);
EnvironmentConfigurator envronmentConfigurator = new EnvironmentConfigurator(component, dbPropertiesList);
pushConfiguration(envronmentConfigurator);
}
Aggregations