Skip to content

Commit

Permalink
Refactor method names and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
RusJaI committed Dec 20, 2024
1 parent 61f95e2 commit c595c7f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7316,7 +7316,7 @@ public Map<String, String> getClonedAPISpecificOperationPolicyIdsList(String api
throws APIManagementException {

return apiMgtDAO
.getClonedAPISpecificOperationPolicyIdsList(apiUUID);
.getClonedIdsMappedApiSpecificOperationPolicies(apiUUID);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -20838,35 +20837,34 @@ private OperationPolicyData getAPISpecificOperationPolicyByPolicyID(Connection c
* @return operation policy
* @throws APIManagementException
*/
public Map<String, String> getClonedAPISpecificOperationPolicyIdsList(String apiUUID)
public Map<String, String> 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);
}
return null;
}

private Map<String, String> getClonedAPISpecificOperationPolicyIdsList(Connection connection, String apiUUID)
private Map<String, String> 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<String, String> policyMap = null;
Map<String, String> 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"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4274,15 +4274,15 @@ 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 " +
" AM_API_OPERATION_POLICY " +
" 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 " +
Expand Down

0 comments on commit c595c7f

Please sign in to comment.