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 4cbe3e77db5..56d91b2d9f5 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 @@ -48,6 +48,7 @@ import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.core.report.mgt.Constants; +import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import org.wso2.carbon.device.mgt.core.util.HttpReportingUtil; import org.wso2.carbon.user.api.UserRealm; @@ -90,6 +91,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { @Override public void addDeviceInfo(Device device, DeviceInfo deviceInfo) throws DeviceDetailsMgtException { try { + publishEvents(device, deviceInfo); DeviceManagementDAOFactory.beginTransaction(); DeviceInfo newDeviceInfo; @@ -471,21 +473,6 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { } - private String[] getRolesOfUser(String userName) throws UserStoreException { - UserRealm userRealm = CarbonContext.getThreadLocalCarbonContext().getUserRealm(); - String[] roleList; - if (userRealm != null) { - userRealm.getUserStoreManager().getRoleNames(); - roleList = userRealm.getUserStoreManager().getRoleListOfUser(userName); - } else { - String msg = "User realm is not initiated. Logged in user: " + userName; - log.error(msg); - throw new UserStoreException(msg); - } - return roleList; - } - - /** * Generate and add a value depending on the device's OS version included in device info * @@ -520,5 +507,20 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { } } } + + private String[] getRolesOfUser(String userName) throws UserStoreException { + UserRealm userRealm = CarbonContext.getThreadLocalCarbonContext().getUserRealm(); + String[] roleList; + if (userRealm != null) { + userRealm.getUserStoreManager().getRoleNames(); + roleList = userRealm.getUserStoreManager().getRoleListOfUser(userName); + } else { + String msg = "User realm is not initiated. Logged in user: " + userName; + log.error(msg); + throw new UserStoreException(msg); + } + return roleList; + } + } 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 454110e126d..5ed3470c5c8 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 @@ -103,7 +103,7 @@ import java.util.regex.Pattern; import java.util.stream.IntStream; -public final class DeviceManagerUtil { + public final class DeviceManagerUtil { private static final Log log = LogFactory.getLog(DeviceManagerUtil.class); public static final String GENERAL_CONFIG_RESOURCE_PATH = "general"; @@ -712,30 +712,6 @@ public final class DeviceManagerUtil { return jwtClient.getAccessToken(clientId, clientSecret, deviceOwner, scopes); } - public static Object getConfiguration(String key) { - - PlatformConfigurationManagementService configMgtService = - new PlatformConfigurationManagementServiceImpl(); - - try { - PlatformConfiguration tenantConfiguration = configMgtService.getConfiguration - (GENERAL_CONFIG_RESOURCE_PATH); - List configuration = tenantConfiguration.getConfiguration(); - - if (configuration != null && !configuration.isEmpty()) { - for (ConfigurationEntry cEntry : configuration) { - if (key.equalsIgnoreCase(cEntry.getName())) { - return cEntry.getValue(); - } - } - } - } catch (ConfigurationManagementException e) { - log.error("Error while getting the configurations from registry.", e); - return null; - } - return null; - } - /** *

Generate a value for the passed os version

* @@ -840,4 +816,28 @@ public final class DeviceManagerUtil { } return joiner.toString(); } + + public static Object getConfiguration(String key) { + + PlatformConfigurationManagementService configMgtService = + new PlatformConfigurationManagementServiceImpl(); + + try { + PlatformConfiguration tenantConfiguration = configMgtService.getConfiguration + (GENERAL_CONFIG_RESOURCE_PATH); + List configuration = tenantConfiguration.getConfiguration(); + + if (configuration != null && !configuration.isEmpty()) { + for (ConfigurationEntry cEntry : configuration) { + if (key.equalsIgnoreCase(cEntry.getName())) { + return cEntry.getValue(); + } + } + } + } catch (ConfigurationManagementException e) { + log.error("Error while getting the configurations from registry.", e); + return null; + } + return null; + } }