From d2940bf7a136518dbc7f10e4c5ce724767f7c9fe Mon Sep 17 00:00:00 2001 From: charitha Date: Mon, 13 Aug 2018 09:44:40 +0530 Subject: [PATCH] Refactoring --- .../DeviceManagementProviderServiceImpl.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index e87711e7ab..d76b281e01 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -116,7 +116,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv this.pluginRepository = new DeviceManagementPluginRepository(); initDataAccessObjects(); /* Registering a listener to retrieve events when some device management service plugin is installed after - * the component is done getting initialized */ + * the component is done getting initialized */ DeviceManagementServiceComponent.registerPluginInitializationListener(this); } @@ -1457,7 +1457,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv if (DeviceManagerUtil.isPublishOperationResponseEnabled()) { List permittedOperations = DeviceManagerUtil.getEnabledOperationsForResponsePublish(); if (permittedOperations.contains(operation.getCode()) - || permittedOperations.contains("*")) { + || permittedOperations.contains("*")) { Object[] metaData = {deviceId.getId(), deviceId.getType()}; Object[] payload = new Object[]{ Calendar.getInstance().getTimeInMillis(), @@ -1531,7 +1531,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } @Override - public List getOperationByActivityIds(List idList) throws OperationManagementException{ + public List getOperationByActivityIds(List idList) throws OperationManagementException { return DeviceManagementDataHolder.getInstance().getOperationManager().getOperationByActivityIds(idList); } @@ -2511,11 +2511,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv /** * Returns all the installed apps of the given device. */ - private List getInstalledApplications(Device device) throws DeviceManagementException { + private List getInstalledApplications(Device device) throws DeviceManagementException { if (log.isDebugEnabled()) { log.debug("Get installed applications of device: " + device.getId() + " of type '" + device.getType() + "'"); } - List applications = new ArrayList<>(); + List applications; try { DeviceManagementDAOFactory.openConnection(); applications = applicationDAO.getInstalledApplications(device.getId(), device.getEnrolmentInfo().getId()); @@ -2671,8 +2671,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv deviceInformationManager.addDeviceLocation(deviceLocation); } catch (Exception e) { //We are not failing the execution since this is not critical for the functionality. But logging as - // an error for reference. - log.error("Exception occurred while trying to add device location.", e); + // a warning for reference. + log.warn("Error occurred while trying to add '" + device.getType() + "' device '" + + device.getDeviceIdentifier() + "' (id:'" + device.getId() + "') location (lat:" + latitude + + ", lon:" + longitude + ") due to:" + e.getMessage()); } } }