@Test public void execute() throws Exception { final Map<String, String> resultMap = new SQLCommand().execute(EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY); assertThat(resultMap.get(RETURN_CODE), is(FAILURE)); assertThat(resultMap.get(RETURN_RESULT), is("dbServerName can't be empty\nusername input is empty.\npassword input is empty.\ndatabase input is empty.\ntrustStore or trustStorePassword is mandatory if trustAllRoots is false\ncommand input is empty.")); }
@Action(name = "SQL Command", outputs = { @Output(RETURN_CODE), @Output(RETURN_RESULT), @Output(UPDATE_COUNT), @Output(OUTPUT_TEXT), @Output(EXCEPTION), }, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) public Map<String, String> execute(@Param(value = DB_SERVER_NAME, required = true) String dbServerName, @Param(value = DB_TYPE) String dbType, @Param(value = USERNAME) String username, @Param(value = PASSWORD, encrypted = true) String password, @Param(value = INSTANCE) String instance, @Param(value = DB_PORT) String dbPort, @Param(value = DATABASE_NAME, required = true) String databaseName, @Param(value = AUTHENTICATION_TYPE) String authenticationType, @Param(value = DB_CLASS) String dbClass, @Param(value = DB_URL) String dbURL, @Param(value = COMMAND, required = true) String command, @Param(value = TRUST_ALL_ROOTS) String trustAllRoots, @Param(value = TRUST_STORE) String trustStore, @Param(value = TRUST_STORE_PASSWORD) String trustStorePassword, @Param(value = AUTH_LIBRARY_PATH) String authLibraryPath, @Param(value = DATABASE_POOLING_PROPERTIES) String databasePoolingProperties, @Param(value = RESULT_SET_TYPE) String resultSetType, @Param(value = RESULT_SET_CONCURRENCY) String resultSetConcurrency) { dbType = defaultIfEmpty(dbType, ORACLE_DB_TYPE); username = defaultIfEmpty(username, EMPTY); password = defaultIfEmpty(password, EMPTY); trustAllRoots = defaultIfEmpty(trustAllRoots, FALSE); authenticationType = defaultIfEmpty(authenticationType, AUTH_SQL); resultSetType = defaultIfEmpty(resultSetType, TYPE_FORWARD_ONLY); resultSetConcurrency = defaultIfEmpty(resultSetConcurrency, CONCUR_READ_ONLY); trustStore = defaultIfEmpty(trustStore, EMPTY); trustStorePassword = defaultIfEmpty(trustStorePassword, EMPTY); authLibraryPath = defaultIfEmpty(authLibraryPath, EMPTY); instance = defaultIfEmpty(instance, EMPTY); final List<String> preInputsValidation = validateSqlCommandInputs(dbServerName, dbType, username, password, instance, dbPort, databaseName, authenticationType, command, trustAllRoots, resultSetType, resultSetConcurrency, trustStore, trustStorePassword, authLibraryPath); if (!preInputsValidation.isEmpty()) { return getFailureResultsMap(StringUtils.join(preInputsValidation, NEW_LINE)); } try { dbType = getDbType(dbType); final SQLInputs sqlInputs = SQLInputs.builder() .dbServer(dbServerName) .dbType(dbType) .username(username) .password(password) .instance(instance) .dbPort(getOrDefaultDBPort(dbPort, dbType)) .dbName(defaultIfEmpty(databaseName, EMPTY)) .authenticationType(authenticationType) .dbClass(getOrDefaultDBClass(dbClass, dbType)) .dbUrl(defaultIfEmpty(dbURL, EMPTY)) .sqlCommand(command) .trustAllRoots(toBoolean(trustAllRoots)) .trustStore(trustStore) .trustStorePassword(trustStorePassword) .authLibraryPath(authLibraryPath) .databasePoolingProperties(getOrDefaultDBPoolingProperties(databasePoolingProperties, EMPTY)) .resultSetType(getResultSetType(resultSetType)) .resultSetConcurrency(getResultSetConcurrency(resultSetConcurrency)) .isNetcool(checkIsNetcool(dbType)) .build(); String res = SQLCommandService.executeSqlCommand(sqlInputs); String outputText = ""; if (ORACLE_DB_TYPE.equalsIgnoreCase(sqlInputs.getDbType()) && sqlInputs.getSqlCommand().toLowerCase().contains(DBMS_OUTPUT)) { if (isNoneEmpty(res)) { outputText = res; } res = "Command completed successfully"; } else if (sqlInputs.getLRows().size() == 0 && sqlInputs.getIUpdateCount() != -1) { outputText = String.valueOf(sqlInputs.getIUpdateCount()) + " row(s) affected"; } else if (sqlInputs.getLRows().size() == 0 && sqlInputs.getIUpdateCount() == -1) { outputText = "The command has no results!"; if (sqlInputs.getSqlCommand().toUpperCase().contains(SET_NOCOUNT_ON)) { outputText = res; } } else { outputText = StringUtilities.join(sqlInputs.getLRows(), NEW_LINE); } final Map<String, String> result = getSuccessResultsMap(res); result.put(UPDATE_COUNT, String.valueOf(sqlInputs.getIUpdateCount())); result.put(OUTPUT_TEXT, outputText); return result; } catch (Exception e) { return getFailureResultsMap(e); } }
SQLCommand { @Action(name = "SQL Command", outputs = { @Output(RETURN_CODE), @Output(RETURN_RESULT), @Output(UPDATE_COUNT), @Output(OUTPUT_TEXT), @Output(EXCEPTION), }, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) public Map<String, String> execute(@Param(value = DB_SERVER_NAME, required = true) String dbServerName, @Param(value = DB_TYPE) String dbType, @Param(value = USERNAME) String username, @Param(value = PASSWORD, encrypted = true) String password, @Param(value = INSTANCE) String instance, @Param(value = DB_PORT) String dbPort, @Param(value = DATABASE_NAME, required = true) String databaseName, @Param(value = AUTHENTICATION_TYPE) String authenticationType, @Param(value = DB_CLASS) String dbClass, @Param(value = DB_URL) String dbURL, @Param(value = COMMAND, required = true) String command, @Param(value = TRUST_ALL_ROOTS) String trustAllRoots, @Param(value = TRUST_STORE) String trustStore, @Param(value = TRUST_STORE_PASSWORD) String trustStorePassword, @Param(value = AUTH_LIBRARY_PATH) String authLibraryPath, @Param(value = DATABASE_POOLING_PROPERTIES) String databasePoolingProperties, @Param(value = RESULT_SET_TYPE) String resultSetType, @Param(value = RESULT_SET_CONCURRENCY) String resultSetConcurrency) { dbType = defaultIfEmpty(dbType, ORACLE_DB_TYPE); username = defaultIfEmpty(username, EMPTY); password = defaultIfEmpty(password, EMPTY); trustAllRoots = defaultIfEmpty(trustAllRoots, FALSE); authenticationType = defaultIfEmpty(authenticationType, AUTH_SQL); resultSetType = defaultIfEmpty(resultSetType, TYPE_FORWARD_ONLY); resultSetConcurrency = defaultIfEmpty(resultSetConcurrency, CONCUR_READ_ONLY); trustStore = defaultIfEmpty(trustStore, EMPTY); trustStorePassword = defaultIfEmpty(trustStorePassword, EMPTY); authLibraryPath = defaultIfEmpty(authLibraryPath, EMPTY); instance = defaultIfEmpty(instance, EMPTY); final List<String> preInputsValidation = validateSqlCommandInputs(dbServerName, dbType, username, password, instance, dbPort, databaseName, authenticationType, command, trustAllRoots, resultSetType, resultSetConcurrency, trustStore, trustStorePassword, authLibraryPath); if (!preInputsValidation.isEmpty()) { return getFailureResultsMap(StringUtils.join(preInputsValidation, NEW_LINE)); } try { dbType = getDbType(dbType); final SQLInputs sqlInputs = SQLInputs.builder() .dbServer(dbServerName) .dbType(dbType) .username(username) .password(password) .instance(instance) .dbPort(getOrDefaultDBPort(dbPort, dbType)) .dbName(defaultIfEmpty(databaseName, EMPTY)) .authenticationType(authenticationType) .dbClass(getOrDefaultDBClass(dbClass, dbType)) .dbUrl(defaultIfEmpty(dbURL, EMPTY)) .sqlCommand(command) .trustAllRoots(toBoolean(trustAllRoots)) .trustStore(trustStore) .trustStorePassword(trustStorePassword) .authLibraryPath(authLibraryPath) .databasePoolingProperties(getOrDefaultDBPoolingProperties(databasePoolingProperties, EMPTY)) .resultSetType(getResultSetType(resultSetType)) .resultSetConcurrency(getResultSetConcurrency(resultSetConcurrency)) .isNetcool(checkIsNetcool(dbType)) .build(); String res = SQLCommandService.executeSqlCommand(sqlInputs); String outputText = ""; if (ORACLE_DB_TYPE.equalsIgnoreCase(sqlInputs.getDbType()) && sqlInputs.getSqlCommand().toLowerCase().contains(DBMS_OUTPUT)) { if (isNoneEmpty(res)) { outputText = res; } res = "Command completed successfully"; } else if (sqlInputs.getLRows().size() == 0 && sqlInputs.getIUpdateCount() != -1) { outputText = String.valueOf(sqlInputs.getIUpdateCount()) + " row(s) affected"; } else if (sqlInputs.getLRows().size() == 0 && sqlInputs.getIUpdateCount() == -1) { outputText = "The command has no results!"; if (sqlInputs.getSqlCommand().toUpperCase().contains(SET_NOCOUNT_ON)) { outputText = res; } } else { outputText = StringUtilities.join(sqlInputs.getLRows(), NEW_LINE); } final Map<String, String> result = getSuccessResultsMap(res); result.put(UPDATE_COUNT, String.valueOf(sqlInputs.getIUpdateCount())); result.put(OUTPUT_TEXT, outputText); return result; } catch (Exception e) { return getFailureResultsMap(e); } } }
SQLCommand { @Action(name = "SQL Command", outputs = { @Output(RETURN_CODE), @Output(RETURN_RESULT), @Output(UPDATE_COUNT), @Output(OUTPUT_TEXT), @Output(EXCEPTION), }, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) public Map<String, String> execute(@Param(value = DB_SERVER_NAME, required = true) String dbServerName, @Param(value = DB_TYPE) String dbType, @Param(value = USERNAME) String username, @Param(value = PASSWORD, encrypted = true) String password, @Param(value = INSTANCE) String instance, @Param(value = DB_PORT) String dbPort, @Param(value = DATABASE_NAME, required = true) String databaseName, @Param(value = AUTHENTICATION_TYPE) String authenticationType, @Param(value = DB_CLASS) String dbClass, @Param(value = DB_URL) String dbURL, @Param(value = COMMAND, required = true) String command, @Param(value = TRUST_ALL_ROOTS) String trustAllRoots, @Param(value = TRUST_STORE) String trustStore, @Param(value = TRUST_STORE_PASSWORD) String trustStorePassword, @Param(value = AUTH_LIBRARY_PATH) String authLibraryPath, @Param(value = DATABASE_POOLING_PROPERTIES) String databasePoolingProperties, @Param(value = RESULT_SET_TYPE) String resultSetType, @Param(value = RESULT_SET_CONCURRENCY) String resultSetConcurrency) { dbType = defaultIfEmpty(dbType, ORACLE_DB_TYPE); username = defaultIfEmpty(username, EMPTY); password = defaultIfEmpty(password, EMPTY); trustAllRoots = defaultIfEmpty(trustAllRoots, FALSE); authenticationType = defaultIfEmpty(authenticationType, AUTH_SQL); resultSetType = defaultIfEmpty(resultSetType, TYPE_FORWARD_ONLY); resultSetConcurrency = defaultIfEmpty(resultSetConcurrency, CONCUR_READ_ONLY); trustStore = defaultIfEmpty(trustStore, EMPTY); trustStorePassword = defaultIfEmpty(trustStorePassword, EMPTY); authLibraryPath = defaultIfEmpty(authLibraryPath, EMPTY); instance = defaultIfEmpty(instance, EMPTY); final List<String> preInputsValidation = validateSqlCommandInputs(dbServerName, dbType, username, password, instance, dbPort, databaseName, authenticationType, command, trustAllRoots, resultSetType, resultSetConcurrency, trustStore, trustStorePassword, authLibraryPath); if (!preInputsValidation.isEmpty()) { return getFailureResultsMap(StringUtils.join(preInputsValidation, NEW_LINE)); } try { dbType = getDbType(dbType); final SQLInputs sqlInputs = SQLInputs.builder() .dbServer(dbServerName) .dbType(dbType) .username(username) .password(password) .instance(instance) .dbPort(getOrDefaultDBPort(dbPort, dbType)) .dbName(defaultIfEmpty(databaseName, EMPTY)) .authenticationType(authenticationType) .dbClass(getOrDefaultDBClass(dbClass, dbType)) .dbUrl(defaultIfEmpty(dbURL, EMPTY)) .sqlCommand(command) .trustAllRoots(toBoolean(trustAllRoots)) .trustStore(trustStore) .trustStorePassword(trustStorePassword) .authLibraryPath(authLibraryPath) .databasePoolingProperties(getOrDefaultDBPoolingProperties(databasePoolingProperties, EMPTY)) .resultSetType(getResultSetType(resultSetType)) .resultSetConcurrency(getResultSetConcurrency(resultSetConcurrency)) .isNetcool(checkIsNetcool(dbType)) .build(); String res = SQLCommandService.executeSqlCommand(sqlInputs); String outputText = ""; if (ORACLE_DB_TYPE.equalsIgnoreCase(sqlInputs.getDbType()) && sqlInputs.getSqlCommand().toLowerCase().contains(DBMS_OUTPUT)) { if (isNoneEmpty(res)) { outputText = res; } res = "Command completed successfully"; } else if (sqlInputs.getLRows().size() == 0 && sqlInputs.getIUpdateCount() != -1) { outputText = String.valueOf(sqlInputs.getIUpdateCount()) + " row(s) affected"; } else if (sqlInputs.getLRows().size() == 0 && sqlInputs.getIUpdateCount() == -1) { outputText = "The command has no results!"; if (sqlInputs.getSqlCommand().toUpperCase().contains(SET_NOCOUNT_ON)) { outputText = res; } } else { outputText = StringUtilities.join(sqlInputs.getLRows(), NEW_LINE); } final Map<String, String> result = getSuccessResultsMap(res); result.put(UPDATE_COUNT, String.valueOf(sqlInputs.getIUpdateCount())); result.put(OUTPUT_TEXT, outputText); return result; } catch (Exception e) { return getFailureResultsMap(e); } }  }
SQLCommand { @Action(name = "SQL Command", outputs = { @Output(RETURN_CODE), @Output(RETURN_RESULT), @Output(UPDATE_COUNT), @Output(OUTPUT_TEXT), @Output(EXCEPTION), }, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) public Map<String, String> execute(@Param(value = DB_SERVER_NAME, required = true) String dbServerName, @Param(value = DB_TYPE) String dbType, @Param(value = USERNAME) String username, @Param(value = PASSWORD, encrypted = true) String password, @Param(value = INSTANCE) String instance, @Param(value = DB_PORT) String dbPort, @Param(value = DATABASE_NAME, required = true) String databaseName, @Param(value = AUTHENTICATION_TYPE) String authenticationType, @Param(value = DB_CLASS) String dbClass, @Param(value = DB_URL) String dbURL, @Param(value = COMMAND, required = true) String command, @Param(value = TRUST_ALL_ROOTS) String trustAllRoots, @Param(value = TRUST_STORE) String trustStore, @Param(value = TRUST_STORE_PASSWORD) String trustStorePassword, @Param(value = AUTH_LIBRARY_PATH) String authLibraryPath, @Param(value = DATABASE_POOLING_PROPERTIES) String databasePoolingProperties, @Param(value = RESULT_SET_TYPE) String resultSetType, @Param(value = RESULT_SET_CONCURRENCY) String resultSetConcurrency) { dbType = defaultIfEmpty(dbType, ORACLE_DB_TYPE); username = defaultIfEmpty(username, EMPTY); password = defaultIfEmpty(password, EMPTY); trustAllRoots = defaultIfEmpty(trustAllRoots, FALSE); authenticationType = defaultIfEmpty(authenticationType, AUTH_SQL); resultSetType = defaultIfEmpty(resultSetType, TYPE_FORWARD_ONLY); resultSetConcurrency = defaultIfEmpty(resultSetConcurrency, CONCUR_READ_ONLY); trustStore = defaultIfEmpty(trustStore, EMPTY); trustStorePassword = defaultIfEmpty(trustStorePassword, EMPTY); authLibraryPath = defaultIfEmpty(authLibraryPath, EMPTY); instance = defaultIfEmpty(instance, EMPTY); final List<String> preInputsValidation = validateSqlCommandInputs(dbServerName, dbType, username, password, instance, dbPort, databaseName, authenticationType, command, trustAllRoots, resultSetType, resultSetConcurrency, trustStore, trustStorePassword, authLibraryPath); if (!preInputsValidation.isEmpty()) { return getFailureResultsMap(StringUtils.join(preInputsValidation, NEW_LINE)); } try { dbType = getDbType(dbType); final SQLInputs sqlInputs = SQLInputs.builder() .dbServer(dbServerName) .dbType(dbType) .username(username) .password(password) .instance(instance) .dbPort(getOrDefaultDBPort(dbPort, dbType)) .dbName(defaultIfEmpty(databaseName, EMPTY)) .authenticationType(authenticationType) .dbClass(getOrDefaultDBClass(dbClass, dbType)) .dbUrl(defaultIfEmpty(dbURL, EMPTY)) .sqlCommand(command) .trustAllRoots(toBoolean(trustAllRoots)) .trustStore(trustStore) .trustStorePassword(trustStorePassword) .authLibraryPath(authLibraryPath) .databasePoolingProperties(getOrDefaultDBPoolingProperties(databasePoolingProperties, EMPTY)) .resultSetType(getResultSetType(resultSetType)) .resultSetConcurrency(getResultSetConcurrency(resultSetConcurrency)) .isNetcool(checkIsNetcool(dbType)) .build(); String res = SQLCommandService.executeSqlCommand(sqlInputs); String outputText = ""; if (ORACLE_DB_TYPE.equalsIgnoreCase(sqlInputs.getDbType()) && sqlInputs.getSqlCommand().toLowerCase().contains(DBMS_OUTPUT)) { if (isNoneEmpty(res)) { outputText = res; } res = "Command completed successfully"; } else if (sqlInputs.getLRows().size() == 0 && sqlInputs.getIUpdateCount() != -1) { outputText = String.valueOf(sqlInputs.getIUpdateCount()) + " row(s) affected"; } else if (sqlInputs.getLRows().size() == 0 && sqlInputs.getIUpdateCount() == -1) { outputText = "The command has no results!"; if (sqlInputs.getSqlCommand().toUpperCase().contains(SET_NOCOUNT_ON)) { outputText = res; } } else { outputText = StringUtilities.join(sqlInputs.getLRows(), NEW_LINE); } final Map<String, String> result = getSuccessResultsMap(res); result.put(UPDATE_COUNT, String.valueOf(sqlInputs.getIUpdateCount())); result.put(OUTPUT_TEXT, outputText); return result; } catch (Exception e) { return getFailureResultsMap(e); } }  @Action(name = "SQL Command", outputs = { @Output(RETURN_CODE), @Output(RETURN_RESULT), @Output(UPDATE_COUNT), @Output(OUTPUT_TEXT), @Output(EXCEPTION), }, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) Map<String, String> execute(@Param(value = DB_SERVER_NAME, required = true) String dbServerName,
                                       @Param(value = DB_TYPE) String dbType,
                                       @Param(value = USERNAME) String username,
                                       @Param(value = PASSWORD, encrypted = true) String password,
                                       @Param(value = INSTANCE) String instance,
                                       @Param(value = DB_PORT) String dbPort,
                                       @Param(value = DATABASE_NAME, required = true) String databaseName,
                                       @Param(value = AUTHENTICATION_TYPE) String authenticationType,
                                       @Param(value = DB_CLASS) String dbClass,
                                       @Param(value = DB_URL) String dbURL,
                                       @Param(value = COMMAND, required = true) String command,
                                       @Param(value = TRUST_ALL_ROOTS) String trustAllRoots,
                                       @Param(value = TRUST_STORE) String trustStore,
                                       @Param(value = TRUST_STORE_PASSWORD) String trustStorePassword,
                                       @Param(value = AUTH_LIBRARY_PATH) String authLibraryPath,
                                       @Param(value = DATABASE_POOLING_PROPERTIES) String databasePoolingProperties,
                                       @Param(value = RESULT_SET_TYPE) String resultSetType,
                                       @Param(value = RESULT_SET_CONCURRENCY) String resultSetConcurrency); }
SQLCommand { @Action(name = "SQL Command", outputs = { @Output(RETURN_CODE), @Output(RETURN_RESULT), @Output(UPDATE_COUNT), @Output(OUTPUT_TEXT), @Output(EXCEPTION), }, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) public Map<String, String> execute(@Param(value = DB_SERVER_NAME, required = true) String dbServerName, @Param(value = DB_TYPE) String dbType, @Param(value = USERNAME) String username, @Param(value = PASSWORD, encrypted = true) String password, @Param(value = INSTANCE) String instance, @Param(value = DB_PORT) String dbPort, @Param(value = DATABASE_NAME, required = true) String databaseName, @Param(value = AUTHENTICATION_TYPE) String authenticationType, @Param(value = DB_CLASS) String dbClass, @Param(value = DB_URL) String dbURL, @Param(value = COMMAND, required = true) String command, @Param(value = TRUST_ALL_ROOTS) String trustAllRoots, @Param(value = TRUST_STORE) String trustStore, @Param(value = TRUST_STORE_PASSWORD) String trustStorePassword, @Param(value = AUTH_LIBRARY_PATH) String authLibraryPath, @Param(value = DATABASE_POOLING_PROPERTIES) String databasePoolingProperties, @Param(value = RESULT_SET_TYPE) String resultSetType, @Param(value = RESULT_SET_CONCURRENCY) String resultSetConcurrency) { dbType = defaultIfEmpty(dbType, ORACLE_DB_TYPE); username = defaultIfEmpty(username, EMPTY); password = defaultIfEmpty(password, EMPTY); trustAllRoots = defaultIfEmpty(trustAllRoots, FALSE); authenticationType = defaultIfEmpty(authenticationType, AUTH_SQL); resultSetType = defaultIfEmpty(resultSetType, TYPE_FORWARD_ONLY); resultSetConcurrency = defaultIfEmpty(resultSetConcurrency, CONCUR_READ_ONLY); trustStore = defaultIfEmpty(trustStore, EMPTY); trustStorePassword = defaultIfEmpty(trustStorePassword, EMPTY); authLibraryPath = defaultIfEmpty(authLibraryPath, EMPTY); instance = defaultIfEmpty(instance, EMPTY); final List<String> preInputsValidation = validateSqlCommandInputs(dbServerName, dbType, username, password, instance, dbPort, databaseName, authenticationType, command, trustAllRoots, resultSetType, resultSetConcurrency, trustStore, trustStorePassword, authLibraryPath); if (!preInputsValidation.isEmpty()) { return getFailureResultsMap(StringUtils.join(preInputsValidation, NEW_LINE)); } try { dbType = getDbType(dbType); final SQLInputs sqlInputs = SQLInputs.builder() .dbServer(dbServerName) .dbType(dbType) .username(username) .password(password) .instance(instance) .dbPort(getOrDefaultDBPort(dbPort, dbType)) .dbName(defaultIfEmpty(databaseName, EMPTY)) .authenticationType(authenticationType) .dbClass(getOrDefaultDBClass(dbClass, dbType)) .dbUrl(defaultIfEmpty(dbURL, EMPTY)) .sqlCommand(command) .trustAllRoots(toBoolean(trustAllRoots)) .trustStore(trustStore) .trustStorePassword(trustStorePassword) .authLibraryPath(authLibraryPath) .databasePoolingProperties(getOrDefaultDBPoolingProperties(databasePoolingProperties, EMPTY)) .resultSetType(getResultSetType(resultSetType)) .resultSetConcurrency(getResultSetConcurrency(resultSetConcurrency)) .isNetcool(checkIsNetcool(dbType)) .build(); String res = SQLCommandService.executeSqlCommand(sqlInputs); String outputText = ""; if (ORACLE_DB_TYPE.equalsIgnoreCase(sqlInputs.getDbType()) && sqlInputs.getSqlCommand().toLowerCase().contains(DBMS_OUTPUT)) { if (isNoneEmpty(res)) { outputText = res; } res = "Command completed successfully"; } else if (sqlInputs.getLRows().size() == 0 && sqlInputs.getIUpdateCount() != -1) { outputText = String.valueOf(sqlInputs.getIUpdateCount()) + " row(s) affected"; } else if (sqlInputs.getLRows().size() == 0 && sqlInputs.getIUpdateCount() == -1) { outputText = "The command has no results!"; if (sqlInputs.getSqlCommand().toUpperCase().contains(SET_NOCOUNT_ON)) { outputText = res; } } else { outputText = StringUtilities.join(sqlInputs.getLRows(), NEW_LINE); } final Map<String, String> result = getSuccessResultsMap(res); result.put(UPDATE_COUNT, String.valueOf(sqlInputs.getIUpdateCount())); result.put(OUTPUT_TEXT, outputText); return result; } catch (Exception e) { return getFailureResultsMap(e); } }  @Action(name = "SQL Command", outputs = { @Output(RETURN_CODE), @Output(RETURN_RESULT), @Output(UPDATE_COUNT), @Output(OUTPUT_TEXT), @Output(EXCEPTION), }, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) Map<String, String> execute(@Param(value = DB_SERVER_NAME, required = true) String dbServerName,
                                       @Param(value = DB_TYPE) String dbType,
                                       @Param(value = USERNAME) String username,
                                       @Param(value = PASSWORD, encrypted = true) String password,
                                       @Param(value = INSTANCE) String instance,
                                       @Param(value = DB_PORT) String dbPort,
                                       @Param(value = DATABASE_NAME, required = true) String databaseName,
                                       @Param(value = AUTHENTICATION_TYPE) String authenticationType,
                                       @Param(value = DB_CLASS) String dbClass,
                                       @Param(value = DB_URL) String dbURL,
                                       @Param(value = COMMAND, required = true) String command,
                                       @Param(value = TRUST_ALL_ROOTS) String trustAllRoots,
                                       @Param(value = TRUST_STORE) String trustStore,
                                       @Param(value = TRUST_STORE_PASSWORD) String trustStorePassword,
                                       @Param(value = AUTH_LIBRARY_PATH) String authLibraryPath,
                                       @Param(value = DATABASE_POOLING_PROPERTIES) String databasePoolingProperties,
                                       @Param(value = RESULT_SET_TYPE) String resultSetType,
                                       @Param(value = RESULT_SET_CONCURRENCY) String resultSetConcurrency);  }