Cleanup code base and fix getApiRevision method

master-sync^2
Pasindu Rupasinghe 1 year ago
parent 7246209bd8
commit b133f56965

@ -84,11 +84,6 @@
<artifactId>okhttp</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.wso2.orbit.com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>

@ -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,

@ -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)

@ -18,7 +18,6 @@
package io.entgra.device.mgt.core.apimgt.extension.rest.api.util.APIUtils;
/**
* This hold the business information of an API.
*/

@ -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.extension.rest.api.util.APIUtils-->
io.entgra.device.mgt.core.apimgt.annotations,
org.wso2.carbon.apimgt.api,
org.wso2.carbon.apimgt.api.model,

@ -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<Mediation> 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);

Loading…
Cancel
Save