|
|
@ -314,23 +314,28 @@ public class APIPublisherServiceImpl implements APIPublisherService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// This will retrieve the deployed revision
|
|
|
|
|
|
|
|
JSONArray revisionDeploymentList = (JSONArray) publisherRESTAPIServices.getAPIRevisions(apiApplicationKey,
|
|
|
|
|
|
|
|
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"), false).get("list");
|
|
|
|
|
|
|
|
int apiRevisionCount = (int) publisherRESTAPIServices.getAPIRevisions(apiApplicationKey,
|
|
|
|
int apiRevisionCount = (int) publisherRESTAPIServices.getAPIRevisions(apiApplicationKey,
|
|
|
|
accessTokenInfo, existingAPI.getString("id"), null).get("count");
|
|
|
|
accessTokenInfo, existingAPI.getString("id"), null).get("count");
|
|
|
|
|
|
|
|
|
|
|
|
if (apiRevisionCount >= 5) {
|
|
|
|
if (apiRevisionCount >= 5) {
|
|
|
|
|
|
|
|
// This will retrieve the deployed revision
|
|
|
|
|
|
|
|
JSONArray revisionDeploymentList = (JSONArray) publisherRESTAPIServices.getAPIRevisions(
|
|
|
|
|
|
|
|
apiApplicationKey, accessTokenInfo, existingAPI.getString("id"),
|
|
|
|
|
|
|
|
true).get("list");
|
|
|
|
|
|
|
|
if (revisionDeploymentList.length() > 0) {
|
|
|
|
JSONObject latestRevisionDeployment = revisionDeploymentList.getJSONObject(0);
|
|
|
|
JSONObject latestRevisionDeployment = revisionDeploymentList.getJSONObject(0);
|
|
|
|
JSONObject earliestUndeployRevision = undeployedRevisionList.getJSONObject(0);
|
|
|
|
|
|
|
|
publisherRESTAPIServices.undeployAPIRevisionDeployment(apiApplicationKey,
|
|
|
|
publisherRESTAPIServices.undeployAPIRevisionDeployment(apiApplicationKey,
|
|
|
|
accessTokenInfo, latestRevisionDeployment, existingAPI.getString("id"));
|
|
|
|
accessTokenInfo, latestRevisionDeployment, existingAPI.getString("id"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// This will retrieve the un deployed revision list
|
|
|
|
|
|
|
|
JSONArray undeployedRevisionList = (JSONArray) publisherRESTAPIServices.getAPIRevisions(
|
|
|
|
|
|
|
|
apiApplicationKey, accessTokenInfo, existingAPI.getString("id"),
|
|
|
|
|
|
|
|
false).get("list");
|
|
|
|
|
|
|
|
if (undeployedRevisionList.length() > 0) {
|
|
|
|
|
|
|
|
JSONObject earliestUndeployRevision = undeployedRevisionList.getJSONObject(0);
|
|
|
|
publisherRESTAPIServices.deleteAPIRevision(apiApplicationKey, accessTokenInfo,
|
|
|
|
publisherRESTAPIServices.deleteAPIRevision(apiApplicationKey, accessTokenInfo,
|
|
|
|
earliestUndeployRevision, existingAPI.getString("id"));
|
|
|
|
earliestUndeployRevision, existingAPI.getString("id"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// create new revision
|
|
|
|
// create new revision
|
|
|
|
APIRevision apiRevision = new APIRevision();
|
|
|
|
APIRevision apiRevision = new APIRevision();
|
|
|
|