From 88303f7f94d59e9cfa78c8e5f97c859d38fa2843 Mon Sep 17 00:00:00 2001 From: Harshan Liyanage Date: Wed, 30 Aug 2017 16:56:02 +0530 Subject: [PATCH 1/2] Resolved wso2/product-iots#1358 --- .../mgt/dao/impl/GenericOperationDAOImpl.java | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java index b0cc226c43d..8fde546cce9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java @@ -170,7 +170,6 @@ public class GenericOperationDAOImpl implements OperationDAO { throws OperationManagementDAOException { PreparedStatement stmt = null; ResultSet rs = null; - boolean result = false; try { Connection connection = OperationManagementDAOFactory.getConnection(); String query = "SELECT EOM.ID FROM DM_ENROLMENT_OP_MAPPING EOM INNER JOIN DM_OPERATION DM " @@ -182,25 +181,13 @@ public class GenericOperationDAOImpl implements OperationDAO { stmt.setString(3, Operation.Status.PENDING.toString()); // This will return only one result always. rs = stmt.executeQuery(); - int id = 0; - if (rs.next()) { - id = rs.getInt("ID"); - } - if (id != 0) { - stmt = connection.prepareStatement( - "UPDATE DM_ENROLMENT_OP_MAPPING SET UPDATED_TIMESTAMP = ? " + "WHERE ID = ?"); - stmt.setLong(1, System.currentTimeMillis() / 1000); - stmt.setInt(2, id); - stmt.executeUpdate(); - result = true; - } + return true; } catch (SQLException e) { throw new OperationManagementDAOException( "Error occurred while update device mapping operation status " + "metadata", e); } finally { OperationManagementDAOUtil.cleanupResources(stmt, rs); } - return result; } @Override From 21692f1ab62dd4af8834c5b0a2da9169522a2150 Mon Sep 17 00:00:00 2001 From: Harshan Liyanage Date: Wed, 30 Aug 2017 17:03:13 +0530 Subject: [PATCH 2/2] Fixes for wso2/product-iots#1358 --- .../operation/mgt/dao/impl/GenericOperationDAOImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java index 8fde546cce9..7e174ec714a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java @@ -170,6 +170,7 @@ public class GenericOperationDAOImpl implements OperationDAO { throws OperationManagementDAOException { PreparedStatement stmt = null; ResultSet rs = null; + boolean result = false; try { Connection connection = OperationManagementDAOFactory.getConnection(); String query = "SELECT EOM.ID FROM DM_ENROLMENT_OP_MAPPING EOM INNER JOIN DM_OPERATION DM " @@ -181,13 +182,16 @@ public class GenericOperationDAOImpl implements OperationDAO { stmt.setString(3, Operation.Status.PENDING.toString()); // This will return only one result always. rs = stmt.executeQuery(); - return true; + if (rs.next()) { + result = true; + } } catch (SQLException e) { throw new OperationManagementDAOException( "Error occurred while update device mapping operation status " + "metadata", e); } finally { OperationManagementDAOUtil.cleanupResources(stmt, rs); } + return result; } @Override