From 312e7b1d32a3ba09abf38ddbe917a6a653d101c4 Mon Sep 17 00:00:00 2001 From: tharikaGitHub Date: Mon, 27 May 2024 19:59:19 +0530 Subject: [PATCH] Fix error creating new revision --- .../org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java | 12 ++++++++++++ .../apimgt/impl/dao/constants/SQLConstants.java | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java index 6829667932c8..b45ae4b7bb5c 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java @@ -16935,6 +16935,10 @@ public void addAPIRevision(APIRevision apiRevision) throws APIManagementExceptio // Add to AM_API_RESOURCE_SCOPE_MAPPING table and to AM_API_PRODUCT_MAPPING PreparedStatement getRevisionedURLMappingsStatement = connection .prepareStatement(SQLConstants.APIRevisionSqlConstants.GET_REVISIONED_URL_MAPPINGS_ID); + if (connection.getMetaData().getDriverName().contains("MySQL")) { + getRevisionedURLMappingsStatement = connection.prepareStatement( + SQLConstants.APIRevisionSqlConstants.GET_REVISIONED_URL_MAPPINGS_ID_CASE_SENSITIVE_MYSQL); + } PreparedStatement insertScopeResourceMappingStatement = connection .prepareStatement(SQLConstants.APIRevisionSqlConstants.INSERT_SCOPE_RESOURCE_MAPPING); PreparedStatement insertProductResourceMappingStatement = connection @@ -18139,6 +18143,10 @@ public void addAPIProductRevision(APIRevision apiRevision) throws APIManagementE // Add to AM_API_RESOURCE_SCOPE_MAPPING table and to AM_API_PRODUCT_MAPPING PreparedStatement getRevisionedURLMappingsStatement = connection .prepareStatement(SQLConstants.APIRevisionSqlConstants.GET_REVISIONED_URL_MAPPINGS_ID); + if (connection.getMetaData().getDriverName().contains("MySQL")) { + getRevisionedURLMappingsStatement = connection.prepareStatement( + SQLConstants.APIRevisionSqlConstants.GET_REVISIONED_URL_MAPPINGS_ID_CASE_SENSITIVE_MYSQL); + } PreparedStatement insertScopeResourceMappingStatement = connection .prepareStatement(SQLConstants.APIRevisionSqlConstants.INSERT_SCOPE_RESOURCE_MAPPING); PreparedStatement insertProductResourceMappingStatement = connection @@ -18372,6 +18380,10 @@ public void restoreAPIProductRevision(APIRevision apiRevision) throws APIManagem //Insert Scope Mappings and operation policy mappings PreparedStatement getRevisionedURLMappingsStatement = connection .prepareStatement(SQLConstants.APIRevisionSqlConstants.GET_REVISIONED_URL_MAPPINGS_ID); + if (connection.getMetaData().getDriverName().contains("MySQL")) { + getRevisionedURLMappingsStatement = connection.prepareStatement( + SQLConstants.APIRevisionSqlConstants.GET_REVISIONED_URL_MAPPINGS_ID_CASE_SENSITIVE_MYSQL); + } PreparedStatement addResourceScopeMapping = connection.prepareStatement( SQLConstants.ADD_API_RESOURCE_SCOPE_MAPPING); PreparedStatement addOperationPolicyStatement = connection diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java index 1fb0e3a2e44d..1359e07dbd89 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java @@ -3777,6 +3777,12 @@ public static class APIRevisionSqlConstants { public static final String GET_REVISIONED_URL_MAPPINGS_ID = "SELECT URL_MAPPING_ID FROM AM_API_URL_MAPPING " + "WHERE API_ID = ? AND REVISION_UUID = ? AND HTTP_METHOD = ? AND AUTH_SCHEME = ? AND URL_PATTERN = ? " + "AND THROTTLING_TIER = ? "; + + public static final String GET_REVISIONED_URL_MAPPINGS_ID_CASE_SENSITIVE_MYSQL = "SELECT URL_MAPPING_ID " + + "FROM AM_API_URL_MAPPING " + "WHERE API_ID = ? AND REVISION_UUID = ? AND HTTP_METHOD = ? AND " + + "AUTH_SCHEME = ? AND URL_PATTERN = CONVERT(? USING utf8mb4) COLLATE utf8mb4_bin " + + "AND THROTTLING_TIER = ? "; + public static final String GET_URL_MAPPINGS_ID = "SELECT URL_MAPPING_ID FROM AM_API_URL_MAPPING " + "WHERE API_ID = ? AND HTTP_METHOD = ? AND AUTH_SCHEME = ? AND URL_PATTERN = ? " + "AND THROTTLING_TIER = ? AND REVISION_UUID = ?";