From 2e051d8df52c742b875fded835209d9be5b73be1 Mon Sep 17 00:00:00 2001 From: manoj Date: Wed, 8 Apr 2015 20:27:16 +0530 Subject: [PATCH] Refactor operations mgt connection handling --- .../mgt/core/operation/mgt/OperationManagerImpl.java | 8 -------- .../operation/mgt/dao/impl/ProfileOperationDAOImpl.java | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java index 9542fa8774f..238a61c9f03 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -120,19 +120,11 @@ public class OperationManagerImpl implements OperationManager { try { List operations = new ArrayList(); - OperationManagementDAOFactory.beginTransaction(); operations.addAll(profileOperationDAO.getOperations(deviceId, Operation.Status.PENDING)); operations.addAll(configOperationDAO.getOperations(deviceId, Operation.Status.PENDING)); operations.addAll(commandOperationDAO.getOperations(deviceId, Operation.Status.PENDING)); - OperationManagementDAOFactory.commitTransaction(); - return operations; } catch (OperationManagementDAOException e) { - try { - OperationManagementDAOFactory.rollbackTransaction(); - } catch (OperationManagementDAOException e1) { - log.warn("Error occurred while roll-backing the transaction", e1); - } throw new OperationManagementException("Error occurred while retrieving the list of " + "pending operations assigned for '" + deviceId.getType() + "' device '" + deviceId.getId() + "'", e); 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/ProfileOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java index 8a4355e36fc..b1b4acb462c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java @@ -54,7 +54,7 @@ public class ProfileOperationDAOImpl extends OperationDAOImpl { stmt = conn.prepareStatement("INSERT INTO DM_PROFILE_OPERATION(OPERATION_ID, OPERATION_DETAILS) " + "VALUES(?, ?)"); stmt.setInt(1, operationId); - stmt.setBytes(2, bao.toByteArray()); + stmt.setObject(2, bao.toByteArray()); stmt.executeUpdate(); } catch (SQLException e) { throw new OperationManagementDAOException("Error occurred while adding profile operation", e);