From 8df21f8af139e77921aa6be1222765947cef17e6 Mon Sep 17 00:00:00 2001 From: inoshperera Date: Thu, 5 Mar 2020 20:59:00 +0530 Subject: [PATCH] minor refactoring for getTenantId --- .../details/mgt/impl/DeviceInformationManagerImpl.java | 7 ++++++- .../carbon/device/mgt/core/util/DeviceManagerUtil.java | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java index f5b7d141dcd..4ba774b4c7c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java @@ -182,7 +182,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { DeviceDetailsWrapper deviceDetailsWrapper = new DeviceDetailsWrapper(); deviceDetailsWrapper.setDevice(device); deviceDetailsWrapper.setDeviceInfo(deviceInfo); - deviceDetailsWrapper.getJSONString(); + deviceDetailsWrapper.setTenantId(DeviceManagerUtil.getTenantId()); GroupManagementProviderService groupManagementService = DeviceManagementDataHolder .getInstance().getGroupManagementProviderService(); @@ -206,6 +206,11 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { } catch (UserStoreException e) { log.error("Error occurred while getting role list", e); } + } else { + if(log.isTraceEnabled()) { + log.trace("Event publishing is not enabled for tenant " + + DeviceManagerUtil.getTenantId()); + } } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java index c137432f8ee..93fa387d0b7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java @@ -350,6 +350,11 @@ public final class DeviceManagerUtil { } } + public static int getTenantId() { + return PrivilegedCarbonContext + .getThreadLocalCarbonContext().getTenantId(); + } + public static int validateActivityListPageSize(int limit) throws OperationManagementException { if (limit == 0) { DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().