From 0cd359ce330f18d4763b63d79dd38a997bccdf64 Mon Sep 17 00:00:00 2001 From: hiranyakavishani Date: Tue, 10 Oct 2023 12:02:17 +0530 Subject: [PATCH] Refactoring codebase --- .../carbon/apimgt/impl/APIProviderImpl.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java index badd8fa55727..7f928f2c06ec 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java @@ -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(), @@ -4354,17 +4355,16 @@ public Map> 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; } @@ -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); } } }