From 36dea72e02ee99f481a77b9ea0eddf87fa8ee323 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Tue, 31 Mar 2015 11:53:33 +0530 Subject: [PATCH] Fixing API publishing related issues --- .../mgt/core/api/mgt/APIPublisherServiceImpl.java | 12 ++++++++---- .../core/api/mgt/APIRegistrationStartupObserver.java | 3 --- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/api/mgt/APIPublisherServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/api/mgt/APIPublisherServiceImpl.java index 904fdcd8f9..5b5a9d59bc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/api/mgt/APIPublisherServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/api/mgt/APIPublisherServiceImpl.java @@ -43,10 +43,14 @@ public class APIPublisherServiceImpl implements APIPublisherService { } APIProvider provider = APIManagerFactory.getInstance().getAPIProvider(api.getApiOwner()); if (provider != null) { - provider.addAPI(api); - if (log.isDebugEnabled()) { - log.debug("Successfully published API '" + api.getId() + "' with the context '" + - api.getContext() + "'"); + if (!provider.isAPIAvailable(api.getId())) { + provider.addAPI(api); + log.info("Successfully published API '" + api.getId().getApiName() + "' with context '" + + api.getContext() + "' and version '" + api.getId().getVersion() + "'"); + } else { + log.info("An API already exists with the name '" + api.getId() + "', context '" + + api.getContext() + "' and verison '" + api.getId().getVersion() + + "'. Thus, the API config is not re-published"); } } else { log.error("API provider configured for the given API configuration is null. Thus, the API is not " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/api/mgt/APIRegistrationStartupObserver.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/api/mgt/APIRegistrationStartupObserver.java index af1fc351a1..c0c8207b8e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/api/mgt/APIRegistrationStartupObserver.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/api/mgt/APIRegistrationStartupObserver.java @@ -67,9 +67,6 @@ public class APIRegistrationStartupObserver implements ServerStartupObserver { API api = DeviceManagerUtil.getAPI(apiConfig); DeviceManagementDataHolder.getInstance().getApiPublisherService().publishAPI(api); - - log.info("Successfully published API '" + apiConfig.getName() + "' with the context '" + - apiConfig.getContext() + "' and version '" + apiConfig.getVersion() + "'"); } catch (Throwable e) { /* Throwable is caught as none of the RuntimeExceptions that can potentially occur at this point does not seem to be logged anywhere else within the framework */