Skip to content

Commit

Permalink
Refactoring codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
HiranyaKavishani committed Oct 10, 2023
1 parent 1f28aa1 commit 0cd359c
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,8 @@ public String getPublishedDefaultVersion(Identifier apiid) throws APIManagementE
}


private void sendUpdateEventToPreviousDefaultVersion(APIIdentifier apiIdentifier, String organization) throws APIManagementException {
private void sendUpdateEventToPreviousDefaultVersion(APIIdentifier apiIdentifier, String organization)
throws APIManagementException {
API api = apiMgtDAO.getLightWeightAPIInfoByAPIIdentifier(apiIdentifier, organization);
APIEvent apiEvent = new APIEvent(UUID.randomUUID().toString(), System.currentTimeMillis(),
APIConstants.EventType.API_UPDATE.name(), tenantId, organization, apiIdentifier.getApiName(),
Expand Down Expand Up @@ -4354,17 +4355,16 @@ public Map<API, List<APIProductResource>> updateAPIProduct(APIProduct product)
updateApiProductArtifact(product, true, true);
apiMgtDAO.updateAPIProduct(product, userNameWithoutChange);

int productId = apiMgtDAO.getAPIProductId(product.getId());
String publishedDefaultVersion = getPublishedDefaultVersion(product.getId());

if (publishedDefaultVersion != null) {
if (product.isPublishedDefaultVersion() && !product.getId().getVersion().equals(publishedDefaultVersion)) {
sendUpdateEventToPreviousDefaultVersion(product.getId().getProviderName(), product.getId().getName(),
organization);
}
if (publishedDefaultVersion != null && product.isPublishedDefaultVersion() && !product.getId().getVersion()
.equals(publishedDefaultVersion)) {
sendUpdateEventToPreviousDefaultVersion(product.getId().getProviderName(), product.getId().getName(),
publishedDefaultVersion);
}

APIConstants.EventAction action = null;
int productId = apiMgtDAO.getAPIProductId(product.getId());

if (product.isDefaultVersion() ^ product.getId().getVersion().equals(prevDefaultVersion)) {
action = APIConstants.EventAction.DEFAULT_VERSION;
}
Expand Down Expand Up @@ -6056,7 +6056,7 @@ public void deployAPIProductRevision(String apiProductId, String apiRevisionId,
if (product.isPublishedDefaultVersion() && !apiProductIdentifier.getVersion()
.equals(publishedDefaultVersion)) {
sendUpdateEventToPreviousDefaultVersion(product.getId().getProviderName(), product.getId().getName(),
organization);
publishedDefaultVersion);
}
}
}
Expand Down

0 comments on commit 0cd359c

Please sign in to comment.