Search in sources :

Example 1 with EnvironmentConfigurator

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);
}
Also used : EnvironmentConfigurator(com.axway.ats.agent.core.configuration.EnvironmentConfigurator) ArrayList(java.util.ArrayList) Properties(java.util.Properties) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

EnvironmentConfigurator (com.axway.ats.agent.core.configuration.EnvironmentConfigurator)1 PublicAtsApi (com.axway.ats.common.PublicAtsApi)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1