From 8ff264a044f165f298c482a45006756a50f6de2e Mon Sep 17 00:00:00 2001 From: Shamalka Navod Date: Thu, 26 Sep 2019 12:23:10 +0000 Subject: [PATCH] Fix error logs of DAO implementations --- .../service/impl/ReportManagementServiceImpl.java | 1 - .../core/dao/impl/device/GenericDeviceDAOImpl.java | 12 ++++++++---- .../core/dao/impl/device/OracleDeviceDAOImpl.java | 13 +++++++------ .../dao/impl/device/PostgreSQLDeviceDAOImpl.java | 12 ++++++++---- .../dao/impl/device/SQLServerDeviceDAOImpl.java | 12 ++++++++---- 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/ReportManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/ReportManagementServiceImpl.java index 91788e27d3d..c06542ea15d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/ReportManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/ReportManagementServiceImpl.java @@ -81,7 +81,6 @@ public class ReportManagementServiceImpl implements ReportManagementService { String msg = "No devices have enrolled between " + fromDate + " to " + toDate + " or doesn't match with" + " given parameters"; - log.error(msg); return Response.status(Response.Status.OK).entity(msg).build(); } else { devices.setList((List) result.getData()); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index 2734a02dbf4..369085c3dda 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -422,8 +422,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { devices.add(device); } } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while fetching the list of devices that matches to status " + - "'" + request.getStatus() + "'", e); + String msg = "Error occurred while fetching the list of devices that matches to status " + + "'" + request.getStatus() + "'"; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, null); } @@ -551,8 +553,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { devices.add(device); } } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while fetching the list of devices corresponding" + - "to the mentioned filtering criteria", e); + String msg = "Error occurred while fetching the list of devices corresponding" + + "to the mentioned filtering criteria"; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java index 2cdcc83d21e..11d2896fc79 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java @@ -428,8 +428,10 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { devices.add(device); } } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while fetching the list of devices that matches to status " + - "'" + request.getStatus() + "'", e); + String msg = "Error occurred while fetching the list of devices that matches to status " + + "'" + request.getStatus() + "'"; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, null); } @@ -556,11 +558,10 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { devices.add(device); } } catch (SQLException e) { - String msg = "Error occurred while retrieving information of all " + - "registered devices"; + String msg = "Error occurred while fetching the list of devices corresponding" + + "to the mentioned filtering criteria"; log.error(msg, e); - throw new DeviceManagementDAOException("Error occurred while fetching the list of devices corresponding" + - "to the mentioned filtering criteria", e); + throw new DeviceManagementDAOException(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java index 5515fe4ee77..b1dcc57390d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java @@ -405,8 +405,10 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { devices.add(device); } } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while fetching the list of devices that matches to status " + - "'" + request.getStatus() + "'", e); + String msg = "Error occurred while fetching the list of devices that matches to status " + + "'" + request.getStatus() + "'"; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, null); } @@ -534,8 +536,10 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { devices.add(device); } } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while fetching the list of devices corresponding" + - "to the mentioned filtering criteria", e); + String msg = "Error occurred while fetching the list of devices corresponding" + + "to the mentioned filtering criteria"; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index 070e3b53815..98cfae84ce6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -424,8 +424,10 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { devices.add(device); } } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while fetching the list of devices that matches to status " + - "'" + request.getStatus() + "'", e); + String msg = "Error occurred while fetching the list of devices that matches to status " + + "'" + request.getStatus() + "'"; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, null); } @@ -489,8 +491,10 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { devices.add(device); } } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while fetching the list of devices corresponding" + - "to the mentioned filtering criteria", e); + String msg = "Error occurred while fetching the list of devices corresponding" + + "to the mentioned filtering criteria"; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); }