Merge branch 'kernel-4.6.2' into 'kernel-4.6.x'

fixed issue in updating apis

See merge request entgra/carbon-device-mgt!806
kernel-4.6.x
Pahansith Gunathilake 3 years ago
commit 06935fd5fb

@ -162,15 +162,30 @@ public class APIPublisherServiceImpl implements APIPublisherService {
api.setStatus(existingAPI.getStatus()); api.setStatus(existingAPI.getStatus());
apiProvider.updateAPI(api); apiProvider.updateAPI(api);
if (CREATED_STATUS.equals(existingAPI.getStatus())) { // Assumption: Assume the latest revision is the published one
apiProvider.changeLifeCycleStatus(tenantDomain, existingAPI.getUuid(), PUBLISH_ACTION, null); String latestRevisionUUID = apiProvider.getLatestRevisionUUID(existingAPI.getUuid());
List<APIRevisionDeployment> latestRevisionDeploymentList =
apiProvider.getAPIRevisionDeploymentList(latestRevisionUUID);
List<APIRevision> apiRevisionList = apiProvider.getAPIRevisions(existingAPI.getUuid());
if (apiRevisionList.size() >= 5) {
String earliestRevisionUUID = apiProvider.getEarliestRevisionUUID(existingAPI.getUuid());
List<APIRevisionDeployment> earliestRevisionDeploymentList =
apiProvider.getAPIRevisionDeploymentList(earliestRevisionUUID);
apiProvider.undeployAPIRevisionDeployment(existingAPI.getUuid(), earliestRevisionUUID, earliestRevisionDeploymentList);
apiProvider.deleteAPIRevision(existingAPI.getUuid(), earliestRevisionUUID, tenantDomain);
}
// create new revision
APIRevision apiRevision = new APIRevision(); APIRevision apiRevision = new APIRevision();
apiRevision.setApiUUID(existingAPI.getUuid()); apiRevision.setApiUUID(existingAPI.getUuid());
apiRevision.setDescription("Updated Revision"); apiRevision.setDescription("Updated Revision");
String apiRevisionId = apiProvider.addAPIRevision(apiRevision, tenantDomain); String apiRevisionId = apiProvider.addAPIRevision(apiRevision, tenantDomain);
List<APIRevisionDeployment> apiRevisionDeploymentList = apiProvider.getAPIRevisionDeploymentList(apiRevisionId); apiProvider.deployAPIRevision(existingAPI.getUuid(), apiRevisionId, latestRevisionDeploymentList);
apiProvider.deployAPIRevision(existingAPI.getUuid(), apiRevisionId, apiRevisionDeploymentList);
if (CREATED_STATUS.equals(existingAPI.getStatus())) {
apiProvider.changeLifeCycleStatus(tenantDomain, existingAPI.getUuid(), PUBLISH_ACTION, null);
} }
} }
} }

Loading…
Cancel
Save