Refactor operations mgt connection handling

This commit is contained in:
manoj 2015-04-08 20:27:16 +05:30
parent 749f2b782e
commit 2e051d8df5
2 changed files with 1 additions and 9 deletions

View File

@ -120,19 +120,11 @@ public class OperationManagerImpl implements OperationManager {
try {
List<Operation> operations = new ArrayList<Operation>();
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);

View File

@ -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);