From dbd9ad77ae411f4b5571fba99b10e4b3b44184b7 Mon Sep 17 00:00:00 2001 From: nishadi Date: Tue, 16 Jan 2018 15:37:03 +0530 Subject: [PATCH] Modified API Util getComment method is added to the APIUtil file. --- .../device/application/mgt/api/APIUtil.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/APIUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/APIUtil.java index 8be02fc146..8549f7b961 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/APIUtil.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/APIUtil.java @@ -22,14 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.application.mgt.api.beans.ErrorResponse; -import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; -import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager; -import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager; -import org.wso2.carbon.device.application.mgt.common.services.CategoryManager; -import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager; -import org.wso2.carbon.device.application.mgt.common.services.PlatformManager; -import org.wso2.carbon.device.application.mgt.common.services.PlatformStorageManager; -import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; +import org.wso2.carbon.device.application.mgt.common.services.*; import javax.ws.rs.core.Response; @@ -49,6 +42,7 @@ public class APIUtil { private static SubscriptionManager subscriptionManager; private static PlatformStorageManager platformStorageManager; private static CategoryManager categoryManager; + private static CommentsManager commentsManager; public static ApplicationManager getApplicationManager() { if (applicationManager == null) { @@ -232,4 +226,22 @@ public class APIUtil { return subscriptionManager; } + + public static CommentsManager getCommentsManager() { + if (commentsManager == null) { + synchronized (APIUtil.class) { + if (commentsManager == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + commentsManager = + (CommentsManager) ctx.getOSGiService(CommentsManager.class, null); + if (commentsManager == null) { + String msg = "Comments Manager service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + } + } + } + return commentsManager; + } }