diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java index ca9150b0760b..90e35b7e5020 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java @@ -7316,7 +7316,7 @@ public Map getClonedAPISpecificOperationPolicyIdsList(String api throws APIManagementException { return apiMgtDAO - .getClonedAPISpecificOperationPolicyIdsList(apiUUID); + .getClonedIdsMappedApiSpecificOperationPolicies(apiUUID); } @Override 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 4859fac746c1..2ce75fc5bed0 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 @@ -124,7 +124,6 @@ import org.wso2.carbon.apimgt.impl.dto.WorkflowDTO; import org.wso2.carbon.apimgt.impl.factory.KeyManagerHolder; import org.wso2.carbon.apimgt.impl.factory.SQLConstantManagerFactory; -import org.wso2.carbon.apimgt.impl.importexport.ImportExportConstants; import org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder; import org.wso2.carbon.apimgt.impl.utils.APIMgtDBUtil; import org.wso2.carbon.apimgt.impl.utils.APIUtil; @@ -20838,11 +20837,11 @@ private OperationPolicyData getAPISpecificOperationPolicyByPolicyID(Connection c * @return operation policy * @throws APIManagementException */ - public Map getClonedAPISpecificOperationPolicyIdsList(String apiUUID) + public Map getClonedIdsMappedApiSpecificOperationPolicies(String apiUUID) throws APIManagementException { try (Connection connection = APIMgtDBUtil.getConnection()) { - return getClonedAPISpecificOperationPolicyIdsList(connection, apiUUID); + return getClonedIdsMappedApiSpecificOperationPolicies(connection, apiUUID); } catch (SQLException e) { handleException("Failed to get the API specific operation policy IDs from API " + apiUUID, e); @@ -20850,23 +20849,22 @@ public Map getClonedAPISpecificOperationPolicyIdsList(String api return null; } - private Map getClonedAPISpecificOperationPolicyIdsList(Connection connection, String apiUUID) + private Map getClonedIdsMappedApiSpecificOperationPolicies(Connection connection, String apiUUID) throws SQLException, APIManagementException { String dbQuery; boolean isAPIRevision = checkAPIUUIDIsARevisionUUID(apiUUID) != null; if (isAPIRevision) { dbQuery = SQLConstants.OperationPolicyConstants. - GET_REVISION_SPECIFIC_OPERATION_POLICY_LIST_FROM_REVISION_UUID; + GET_REVISION_SPECIFIC_OPERATION_POLICY_IDS_FROM_REVISION_UUID; } else { - dbQuery = SQLConstants.OperationPolicyConstants.GET_API_SPECIFIC_OPERATION_POLICY_LIST_FROM_API_UUID; + dbQuery = SQLConstants.OperationPolicyConstants.GET_API_SPECIFIC_OPERATION_POLICY_IDS_FROM_API_UUID; } - Map policyMap = null; + Map policyMap = new HashMap<>(); try (PreparedStatement statement = connection.prepareStatement(dbQuery)) { statement.setString(1, apiUUID); try (ResultSet rs = statement.executeQuery()) { - if (rs.next()) { - policyMap = new HashMap<>(); + while (rs.next()) { policyMap.put(rs.getString("POLICY_UUID"), rs.getString("CLONED_POLICY_UUID")); } } 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 4648eb8f2c56..4e604edd29c1 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 @@ -4274,7 +4274,7 @@ public static class OperationPolicyConstants { " WHERE " + " OP.POLICY_UUID = ? AND OP.ORGANIZATION = ? AND AOP.REVISION_UUID = ?"; - public static final String GET_API_SPECIFIC_OPERATION_POLICY_LIST_FROM_API_UUID = + public static final String GET_API_SPECIFIC_OPERATION_POLICY_IDS_FROM_API_UUID = "SELECT " + " POLICY_UUID, CLONED_POLICY_UUID " + " FROM " + @@ -4282,7 +4282,7 @@ public static class OperationPolicyConstants { " WHERE " + " API_UUID = ?"; - public static final String GET_REVISION_SPECIFIC_OPERATION_POLICY_LIST_FROM_REVISION_UUID = + public static final String GET_REVISION_SPECIFIC_OPERATION_POLICY_IDS_FROM_REVISION_UUID = "SELECT " + " POLICY_UUID, CLONED_POLICY_UUID " + " FROM " +