From 79e143d236954dd2966e9b402be9257ba6f1b3a1 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Fri, 19 Feb 2016 06:44:08 +0530 Subject: [PATCH] refactored code comments --- .../impl/android/AndroidDeviceManager.java | 40 +++++++------------ .../impl/windows/WindowsDeviceManager.java | 18 ++++----- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java index 9ea888a98..5b24d2c8e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java @@ -101,13 +101,13 @@ public class AndroidDeviceManager implements DeviceManager { status = true; } catch (MobileDeviceMgtPluginException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance : ", e); + "Error occurred while retrieving the Registry instance", e); } catch (RegistryException e) { throw new DeviceManagementException( - "Error occurred while persisting the Registry resource of Android Configuration : ", e); + "Error occurred while persisting the Registry resource of Android Configuration", e); } catch (JAXBException e) { throw new DeviceManagementException( - "Error occurred while parsing the Android configuration : ", e); + "Error occurred while parsing the Android configuration", e); } return status; } @@ -130,13 +130,13 @@ public class AndroidDeviceManager implements DeviceManager { return null; } catch (MobileDeviceMgtPluginException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance : ", e); + "Error occurred while retrieving the Registry instance", e); } catch (JAXBException e) { throw new DeviceManagementException( - "Error occurred while parsing the Android configuration : ", e); + "Error occurred while parsing the Android configuration", e); } catch (RegistryException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry resource of Android Configuration : ", e); + "Error occurred while retrieving the Registry resource of Android Configuration", e); } } @@ -161,12 +161,10 @@ public class AndroidDeviceManager implements DeviceManager { try { AndroidDAOFactory.rollbackTransaction(); } catch (MobileDeviceManagementDAOException mobileDAOEx) { - String msg = "Error occurred while roll back the device enrol transaction :" + - device.toString(); + String msg = "Error occurred while roll back the device enrol transaction :" + device.toString(); log.warn(msg, mobileDAOEx); } - String msg = - "Error while enrolling the Android device : " + device.getDeviceIdentifier(); + String msg = "Error occurred while enrolling the Android device : " + device.getDeviceIdentifier(); throw new DeviceManagementException(msg, e); } return status; @@ -187,11 +185,10 @@ public class AndroidDeviceManager implements DeviceManager { try { AndroidDAOFactory.rollbackTransaction(); } catch (MobileDeviceManagementDAOException mobileDAOEx) { - String msg = "Error occurred while roll back the update device transaction :" + - device.toString(); + String msg = "Error occurred while roll back the update device transaction :" + device.toString(); log.warn(msg, mobileDAOEx); } - String msg = "Error while updating the enrollment of the Android device : " + + String msg = "Error occurred while updating the enrollment of the Android device : " + device.getDeviceIdentifier(); throw new DeviceManagementException(msg, e); } @@ -217,8 +214,7 @@ public class AndroidDeviceManager implements DeviceManager { isEnrolled = true; } } catch (MobileDeviceManagementDAOException e) { - String msg = "Error while checking the enrollment status of Android device : " + - deviceId.getId(); + String msg = "Error occurred while checking the enrollment status of Android device : " + deviceId.getId(); throw new DeviceManagementException(msg, e); } return isEnrolled; @@ -247,8 +243,7 @@ public class AndroidDeviceManager implements DeviceManager { device = MobileDeviceManagementUtil.convertToDevice(mobileDevice); } catch (MobileDeviceManagementDAOException e) { throw new DeviceManagementException( - "Error occurred while fetching the Android device: '" + - deviceId.getId() + "'", e); + "Error occurred while fetching the Android device: '" + deviceId.getId() + "'", e); } return device; } @@ -292,12 +287,9 @@ public class AndroidDeviceManager implements DeviceManager { boolean status; Device existingDevice = this.getDevice(deviceIdentifier); // This object holds the current persisted device object - MobileDevice existingMobileDevice = - MobileDeviceManagementUtil.convertToMobileDevice(existingDevice); - + MobileDevice existingMobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(existingDevice); // This object holds the newly received device object from response MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); - // Updating current object features using newer ones existingMobileDevice.setLatitude(mobileDevice.getLatitude()); existingMobileDevice.setLongitude(mobileDevice.getLongitude()); @@ -319,8 +311,7 @@ public class AndroidDeviceManager implements DeviceManager { device.toString() + "'", e1); } throw new DeviceManagementException( - "Error occurred while updating the Android device: '" + - device.getDeviceIdentifier() + "'", e); + "Error occurred while updating the Android device: '" + device.getDeviceIdentifier() + "'", e); } return status; } @@ -341,8 +332,7 @@ public class AndroidDeviceManager implements DeviceManager { } } } catch (MobileDeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while fetching all Android devices", - e); + throw new DeviceManagementException("Error occurred while fetching all Android devices", e); } return devices; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java index 6afb793b0..b9f03cf49 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java @@ -100,13 +100,13 @@ public class WindowsDeviceManager implements DeviceManager { status = true; } catch (MobileDeviceMgtPluginException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance : ", e); + "Error occurred while retrieving the Registry instance", e); } catch (RegistryException e) { throw new DeviceManagementException( - "Error occurred while persisting the Registry resource of Windows configuration : ", e); + "Error occurred while persisting the Registry resource of Windows configuration", e); } catch (JAXBException e) { throw new DeviceManagementException( - "Error occurred while parsing the Windows configuration : ", e); + "Error occurred while parsing the Windows configuration", e); } return status; } @@ -128,13 +128,13 @@ public class WindowsDeviceManager implements DeviceManager { return null; } catch (MobileDeviceMgtPluginException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance : ", e); + "Error occurred while retrieving the Registry instance", e); } catch (JAXBException e) { throw new DeviceManagementException( - "Error occurred while parsing the Windows configuration : ", e); + "Error occurred while parsing the Windows configuration", e); } catch (RegistryException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry resource of Windows configuration : ", e); + "Error occurred while retrieving the Registry resource of Windows configuration", e); } } @@ -153,8 +153,8 @@ public class WindowsDeviceManager implements DeviceManager { WindowsDAOFactory.commitTransaction(); } catch (MobileDeviceManagementDAOException e) { WindowsDAOFactory.rollbackTransaction(); - throw new DeviceManagementException("Error while updating the enrollment of the Windows device : " + - device.getDeviceIdentifier(), e); + throw new DeviceManagementException("Error occurred while updating the enrollment of the " + + "Windows device : " + device.getDeviceIdentifier(), e); } finally { WindowsDAOFactory.closeConnection(); } @@ -303,7 +303,7 @@ public class WindowsDeviceManager implements DeviceManager { } } catch (MobileDeviceManagementDAOException e) { WindowsDAOFactory.rollbackTransaction(); - throw new DeviceManagementException("Error while enrolling the windows device : " + throw new DeviceManagementException("Error occurred while enrolling the windows device : " + device.getDeviceIdentifier(), e); } return status;