diff --git a/components/action-mgt/org.wso2.carbon.identity.action.management/src/main/java/org/wso2/carbon/identity/action/management/constant/ActionMgtSQLConstants.java b/components/action-mgt/org.wso2.carbon.identity.action.management/src/main/java/org/wso2/carbon/identity/action/management/constant/ActionMgtSQLConstants.java index 6fecc776c47d..8f6ae2c77200 100644 --- a/components/action-mgt/org.wso2.carbon.identity.action.management/src/main/java/org/wso2/carbon/identity/action/management/constant/ActionMgtSQLConstants.java +++ b/components/action-mgt/org.wso2.carbon.identity.action.management/src/main/java/org/wso2/carbon/identity/action/management/constant/ActionMgtSQLConstants.java @@ -27,9 +27,6 @@ private ActionMgtSQLConstants() { } - public static final String IDN_ACTION_PROPERTIES_TABLE = "IDN_ACTION_PROPERTIES"; - public static final String IDN_ACTION_ENDPOINT_TABLE = "IDN_ACTION_ENDPOINT"; - /** * Column Names. */ @@ -81,19 +78,6 @@ public static class Query { "PROPERTY_VALUE = :PROPERTY_VALUE; WHERE ACTION_UUID = :ACTION_UUID; AND " + "TENANT_ID = :TENANT_ID; AND PROPERTY_NAME = :PROPERTY_NAME;"; - // TODO: Remove this temporary queries once the IDN_ACTION_PROPERTIES table is created. - public static final String ADD_ACTION_ENDPOINT = "INSERT INTO IDN_ACTION_ENDPOINT (ACTION_UUID, " + - "PROPERTY_NAME, PROPERTY_VALUE, TENANT_ID) VALUES (:ACTION_UUID;, :PROPERTY_NAME;, :PROPERTY_VALUE;, " + - ":TENANT_ID;)"; - public static final String GET_ACTION_ENDPOINT_INFO_BY_ID = "SELECT PROPERTY_NAME, PROPERTY_VALUE FROM " + - "IDN_ACTION_ENDPOINT WHERE ACTION_UUID = :ACTION_UUID; AND TENANT_ID = :TENANT_ID;"; - public static final String DELETE_ACTION_ENDPOINT_PROPERTY = "DELETE FROM IDN_ACTION_ENDPOINT WHERE " + - "PROPERTY_NAME = :PROPERTY_NAME; AND ACTION_UUID = :ACTION_UUID; AND TENANT_ID = :TENANT_ID;"; - public static final String UPDATE_ACTION_ENDPOINT_PROPERTY = "UPDATE IDN_ACTION_ENDPOINT SET " + - "PROPERTY_VALUE = :PROPERTY_VALUE; WHERE ACTION_UUID = :ACTION_UUID; AND " + - "TENANT_ID = :TENANT_ID; AND PROPERTY_NAME = :PROPERTY_NAME;"; - - private Query() { } diff --git a/components/action-mgt/org.wso2.carbon.identity.action.management/src/main/java/org/wso2/carbon/identity/action/management/dao/impl/ActionManagementDAOImpl.java b/components/action-mgt/org.wso2.carbon.identity.action.management/src/main/java/org/wso2/carbon/identity/action/management/dao/impl/ActionManagementDAOImpl.java index ad1d425f3183..59850e7efc8d 100644 --- a/components/action-mgt/org.wso2.carbon.identity.action.management/src/main/java/org/wso2/carbon/identity/action/management/dao/impl/ActionManagementDAOImpl.java +++ b/components/action-mgt/org.wso2.carbon.identity.action.management/src/main/java/org/wso2/carbon/identity/action/management/dao/impl/ActionManagementDAOImpl.java @@ -480,9 +480,7 @@ private void addActionPropertiesToDB(String actionId, Map action NamedJdbcTemplate jdbcTemplate = new NamedJdbcTemplate(IdentityDatabaseUtil.getDataSource()); jdbcTemplate.withTransaction(template -> { - String query = isPropertiesTableExists() ? ActionMgtSQLConstants.Query.ADD_ACTION_PROPERTIES - : ActionMgtSQLConstants.Query.ADD_ACTION_ENDPOINT; - template.executeBatchInsert(query, + template.executeBatchInsert(ActionMgtSQLConstants.Query.ADD_ACTION_PROPERTIES, statement -> { for (Map.Entry property : actionProperties.entrySet()) { statement.setString(ActionMgtSQLConstants.Column.ACTION_PROPERTIES_UUID, actionId); @@ -511,10 +509,8 @@ private Map getActionPropertiesFromDB(String actionId, Integer t NamedJdbcTemplate jdbcTemplate = new NamedJdbcTemplate(IdentityDatabaseUtil.getDataSource()); Map actionEndpointProperties = new HashMap<>(); try { - String query = isPropertiesTableExists() ? ActionMgtSQLConstants.Query.GET_ACTION_PROPERTIES_INFO_BY_ID - : ActionMgtSQLConstants.Query.GET_ACTION_ENDPOINT_INFO_BY_ID; jdbcTemplate.withTransaction(template -> - template.executeQuery(query, + template.executeQuery(ActionMgtSQLConstants.Query.GET_ACTION_PROPERTIES_INFO_BY_ID, (resultSet, rowNumber) -> { actionEndpointProperties.put( resultSet.getString(ActionMgtSQLConstants.Column.ACTION_PROPERTIES_PROPERTY_NAME), @@ -527,7 +523,7 @@ private Map getActionPropertiesFromDB(String actionId, Integer t })); return actionEndpointProperties; - } catch (SQLException | TransactionException e) { + } catch (TransactionException e) { throw new ActionMgtServerException("Error while retrieving Action Properties from the system.", e); } } @@ -544,22 +540,19 @@ private void updateActionPropertiesInDB(String actionId, Map upd Integer tenantId) throws TransactionException { NamedJdbcTemplate jdbcTemplate = new NamedJdbcTemplate(IdentityDatabaseUtil.getDataSource()); - jdbcTemplate.withTransaction(template -> { - String query = isPropertiesTableExists() ? ActionMgtSQLConstants.Query.UPDATE_ACTION_PROPERTY - : ActionMgtSQLConstants.Query.UPDATE_ACTION_ENDPOINT_PROPERTY; - return template.executeBatchInsert(query, - statement -> { - for (Map.Entry property : updatingProperties.entrySet()) { - statement.setString(ActionMgtSQLConstants.Column.ACTION_PROPERTIES_PROPERTY_VALUE, - property.getValue()); - statement.setString(ActionMgtSQLConstants.Column.ACTION_PROPERTIES_PROPERTY_NAME, - property.getKey()); - statement.setString(ActionMgtSQLConstants.Column.ACTION_PROPERTIES_UUID, actionId); - statement.setInt(ActionMgtSQLConstants.Column.TENANT_ID, tenantId); - statement.addBatch(); - } - }, null); - }); + jdbcTemplate.withTransaction(template -> + template.executeBatchInsert(ActionMgtSQLConstants.Query.UPDATE_ACTION_PROPERTY, + statement -> { + for (Map.Entry property : updatingProperties.entrySet()) { + statement.setString(ActionMgtSQLConstants.Column.ACTION_PROPERTIES_PROPERTY_VALUE, + property.getValue()); + statement.setString(ActionMgtSQLConstants.Column.ACTION_PROPERTIES_PROPERTY_NAME, + property.getKey()); + statement.setString(ActionMgtSQLConstants.Column.ACTION_PROPERTIES_UUID, actionId); + statement.setInt(ActionMgtSQLConstants.Column.TENANT_ID, tenantId); + statement.addBatch(); + } + }, null)); } /** @@ -574,10 +567,8 @@ private void deleteActionPropertiesInDB(String actionId, List deletingPr throws TransactionException { NamedJdbcTemplate jdbcTemplate = new NamedJdbcTemplate(IdentityDatabaseUtil.getDataSource()); - jdbcTemplate.withTransaction(template -> { - String query = isPropertiesTableExists() ? ActionMgtSQLConstants.Query.DELETE_ACTION_PROPERTY - : ActionMgtSQLConstants.Query.DELETE_ACTION_ENDPOINT_PROPERTY; - return template.executeBatchInsert(query, + jdbcTemplate.withTransaction(template -> + template.executeBatchInsert(ActionMgtSQLConstants.Query.DELETE_ACTION_PROPERTY, statement -> { for (String property : deletingProperties) { statement.setString(ActionMgtSQLConstants.Column.ACTION_PROPERTIES_PROPERTY_NAME, @@ -586,8 +577,7 @@ private void deleteActionPropertiesInDB(String actionId, List deletingPr statement.setInt(ActionMgtSQLConstants.Column.TENANT_ID, tenantId); statement.addBatch(); } - }, null); - }); + }, null)); } /** @@ -622,20 +612,4 @@ private ActionDTO changeActionStatus(String actionType, String actionId, String throw new ActionMgtServerException("Error while updating Action Status to " + status, e); } } - - /** - * Check whether the IDN_ACTION_PROPERTIES table exists in the database. - * TODO: Remove this temporary method once the table is created. - * - * @return True if the table exists, False otherwise. - * @throws SQLException If an error occurs while checking the table existence. - */ - private boolean isPropertiesTableExists() throws SQLException { - - try (Connection connection = IdentityDatabaseUtil.getDBConnection(false); - ResultSet resultSet = connection.getMetaData().getTables(null, null, - ActionMgtSQLConstants.IDN_ACTION_PROPERTIES_TABLE, null)) { - return resultSet.next(); - } - } }