From b133f569652fd3b0ee307ea6cd893c5025db20e4 Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 25 May 2023 13:17:07 +0530 Subject: [PATCH] Cleanup code base and fix getApiRevision method --- .../pom.xml | 5 ----- .../rest/api/PublisherRESTAPIServices.java | 3 +-- .../rest/api/PublisherRESTAPIServicesImpl.java | 5 +++-- .../api/util/APIUtils/BusinessInformation.java | 1 - .../pom.xml | 1 - .../publisher/APIPublisherServiceImpl.java | 17 ++++++++++------- 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml index 4bb277f623..7dd0c74914 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml @@ -84,11 +84,6 @@ okhttp compile - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-databind - provided - diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java index 33d124e5fa..35134c6610 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java @@ -24,7 +24,6 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIService import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.APIUtils.APIResponseUtil; -import org.json.JSONArray; import org.json.JSONObject; import org.wso2.carbon.apimgt.api.model.APIIdentifier; import org.wso2.carbon.apimgt.api.model.Scope; @@ -82,7 +81,7 @@ public interface PublisherRESTAPIServices { throws APIServicesException, BadRequestException, UnexpectedResponseException; JSONObject getAPIRevisions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String uuid, - String deploymentStatus) + Boolean deploymentStatus) throws APIServicesException, BadRequestException, UnexpectedResponseException; JSONObject addAPIRevision(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServicesImpl.java index bfc2e1661d..dcb9eb6335 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServicesImpl.java @@ -701,10 +701,11 @@ public class PublisherRESTAPIServicesImpl implements PublisherRESTAPIServices { @Override public JSONObject getAPIRevisions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String uuid, - String deploymentStatus) + Boolean deploymentStatus) throws APIServicesException, BadRequestException, UnexpectedResponseException { - String getAPIRevisionsEndPoint = endPointPrefix + Constants.API_ENDPOINT + uuid + "/revisions" + deploymentStatus; + String getAPIRevisionsEndPoint = endPointPrefix + Constants.API_ENDPOINT + uuid + "/revisions?query=deployed:" + + deploymentStatus; Request request = new Request.Builder() .url(getAPIRevisionsEndPoint) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/util/APIUtils/BusinessInformation.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/util/APIUtils/BusinessInformation.java index 8a8d351dae..3384100dd6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/util/APIUtils/BusinessInformation.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/util/APIUtils/BusinessInformation.java @@ -18,7 +18,6 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.util.APIUtils; - /** * This hold the business information of an API. */ diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 3610aa4f36..c82e0cdfc9 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -179,7 +179,6 @@ io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions, io.entgra.device.mgt.core.apimgt.extension.rest.api.constants, io.entgra.device.mgt.core.apimgt.extension.rest.api.util.*, - io.entgra.device.mgt.core.apimgt.annotations, org.wso2.carbon.apimgt.api, org.wso2.carbon.apimgt.api.model, diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index 52d3dc5ebc..6c55bf0f26 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -237,7 +237,8 @@ public class APIPublisherServiceImpl implements APIPublisherService { for (ApiScope apiScope : apiConfig.getScopes()) { // if the scope is not available as shared scope, and it is assigned to an API as a local scope // need remove the local scope and add as a shared scope - if (!publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, apiScope.getKey())) { + if (!publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, + apiScope.getKey())) { if (apiProvider.isScopeKeyAssignedLocally(apiIdentifier, apiScope.getKey(), tenantId)) { // collect scope to move as shared scopes scopesToMoveAsSharedScopes.add(apiScope); @@ -255,7 +256,8 @@ public class APIPublisherServiceImpl implements APIPublisherService { } // Get existing API - JSONObject existingAPI = publisherRESTAPIServices.getApi(apiApplicationKey, accessTokenInfo, apiIdentifier); + JSONObject existingAPI = publisherRESTAPIServices.getApi(apiApplicationKey, accessTokenInfo, + apiIdentifier); if (scopesToMoveAsSharedScopes.size() > 0) { // update API to remove local scopes APIResponseUtil api = getAPI(apiConfig, false); @@ -292,7 +294,8 @@ public class APIPublisherServiceImpl implements APIPublisherService { mediation.setGlobal(false); List mediationList = (List) publisherRESTAPIServices - .getAllApiSpecificMediationPolicies(apiApplicationKey, accessTokenInfo, apiIdentifier).get("list"); + .getAllApiSpecificMediationPolicies(apiApplicationKey, accessTokenInfo, + apiIdentifier).get("list"); boolean isMediationPolicyFound = false; for (Mediation m : mediationList) { @@ -313,12 +316,12 @@ public class APIPublisherServiceImpl implements APIPublisherService { // This will retrieve the deployed revision JSONArray revisionDeploymentList = (JSONArray) publisherRESTAPIServices.getAPIRevisions(apiApplicationKey, - accessTokenInfo, existingAPI.getString("id"), "?query=deployed:true").get("list"); + accessTokenInfo, existingAPI.getString("id"), true).get("list"); // This will retrieve the un deployed revision list - JSONArray undeployedRevisionList = (JSONArray) publisherRESTAPIServices.getAPIRevisions(apiApplicationKey, accessTokenInfo, - existingAPI.getString("id"), "?query=deployed:false").get("list"); + JSONArray undeployedRevisionList = (JSONArray) publisherRESTAPIServices.getAPIRevisions(apiApplicationKey, + accessTokenInfo, existingAPI.getString("id"), false).get("list"); int apiRevisionCount = (int) publisherRESTAPIServices.getAPIRevisions(apiApplicationKey, - accessTokenInfo, existingAPI.getString("id"), "").get("count"); + accessTokenInfo, existingAPI.getString("id"), null).get("count"); if (apiRevisionCount >= 5) { JSONObject latestRevisionDeployment = revisionDeploymentList.getJSONObject(0);