From 416ef5a7457bad68145c08006e51ee99fc9b4411 Mon Sep 17 00:00:00 2001 From: manoj Date: Tue, 7 Apr 2015 19:07:21 +0530 Subject: [PATCH] Update Operation manager implementation --- .../operation/mgt/OperationManager.java | 3 +- .../DeviceManagementServiceProviderImpl.java | 7 +- .../operation/mgt/OperationManagerImpl.java | 16 ++- .../core/operation/mgt/dao/OperationDAO.java | 2 +- .../mgt/dao/impl/CommandOperationDAOImpl.java | 90 ++++++++++++---- .../mgt/dao/impl/OperationDAOImpl.java | 102 +++++++++++++++--- .../mgt/dao/impl/ProfileOperationDAOImpl.java | 7 +- .../service/DeviceManagementServiceImpl.java | 10 +- 8 files changed, 189 insertions(+), 48 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/OperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/OperationManager.java index 0b6f6e0cd6..70ccd8e113 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/OperationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/OperationManager.java @@ -58,7 +58,6 @@ public interface OperationManager { public Operation getNextPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException; - public Operation updateOperation( - int id, DeviceIdentifier deviceIdentifier, String payLoad) throws OperationManagementException; + public void updateOperation(int operationId, Operation.Status operationStatus) throws OperationManagementException; } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java index 4fbfde4dac..8039b2db63 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java @@ -361,9 +361,8 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ } @Override - public Operation updateOperation(int id, DeviceIdentifier deviceIdentifier, - String payLoad) throws OperationManagementException { - return operationManager.updateOperation(id, deviceIdentifier, payLoad); + public void updateOperation(int operationId, Operation.Status operationStatus) + throws OperationManagementException { + operationManager.updateOperation(operationId,operationStatus); } - } 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 eeeca86021..8f74a23549 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 @@ -155,9 +155,19 @@ public class OperationManagerImpl implements OperationManager { } @Override - public Operation updateOperation(int id, DeviceIdentifier deviceIdentifier, - String responsePayLoad) throws OperationManagementException { - return null; + public void updateOperation(int operationId, Operation.Status operationStatus) + throws OperationManagementException { + try { + OperationManagementDAOFactory.beginTransaction(); + Operation operation = operationDAO.getOperation(operationId); + operation.setStatus(operationStatus); + operationDAO.updateOperation(operation); + OperationManagementDAOFactory.commitTransaction(); + }catch(OperationManagementDAOException ex){ + log.error("Error occurred while updating the operation: "+operationId); + throw new OperationManagementException("Error occurred while update operation", ex); + } + } private OperationDAO lookupOperationDAO(Operation operation) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java index 1bfc1563dd..77bb066b0a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java @@ -35,7 +35,7 @@ public interface OperationDAO { Operation getOperation(DeviceIdentifier deviceId, int operationId) throws OperationManagementDAOException; - Operation getOperation(DeviceIdentifier deviceId, Operation.Status status) throws OperationManagementDAOException; + Operation getOperation(DeviceIdentifier deviceIdentifier, Operation.Status status) throws OperationManagementDAOException; List getOperations(DeviceIdentifier deviceId) throws OperationManagementDAOException; 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/CommandOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java index 03b2a6aa67..ac248dea8f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java @@ -55,8 +55,46 @@ public class CommandOperationDAOImpl extends OperationDAOImpl { return operationId; } + public Operation getOperation(int id) throws OperationManagementDAOException { + + PreparedStatement stmt = null; + ResultSet rs = null; + Operation operation = null; + try { + Connection conn = OperationManagementDAOFactory.openConnection(); + String sql = "SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.STATUS, o.OPERATIONCODE," + + "co.ENABLED FROM DM_OPERATION o INNER JOIN DM_COMMAND_OPERATION co ON " + + "co.OPERATION_ID = o.ID WHERE o.ID=?"; + + stmt = conn.prepareStatement(sql); + stmt.setInt(1, id); + rs = stmt.executeQuery(); + + if (rs.next()) { + operation = new Operation(); + operation.setId(rs.getInt("ID")); + operation.setType(Operation.Type.valueOf(rs.getString("TYPE"))); + operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString()); + if (rs.getTimestamp("RECEIVED_TIMESTAMP") == null) { + operation.setReceivedTimeStamp(""); + } else { + operation.setReceivedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString()); + } + operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS"))); + operation.setCode(rs.getString("OPERATIONCODE")); + } + } catch (SQLException e) { + throw new OperationManagementDAOException("Error occurred while retrieving the operation object " + + "available for the id '" + id + "'", e); + } finally { + OperationManagementDAOUtil.cleanupResources(stmt, rs); + OperationManagementDAOFactory.closeConnection(); + } + return operation; + } + public List getOperations(DeviceIdentifier deviceId, - Operation.Status status) throws OperationManagementDAOException { + Operation.Status status) throws OperationManagementDAOException { PreparedStatement stmt = null; ResultSet rs = null; List operationList = new ArrayList(); @@ -64,8 +102,10 @@ public class CommandOperationDAOImpl extends OperationDAOImpl { try { Connection conn = OperationManagementDAOFactory.openConnection(); String sql = "SELECT po.OPERATION_ID, po.TYPE, po.CREATED_TIMESTAMP, po.RECEIVED_TIMESTAMP, po.STATUS, " + - "co.ENABLED,o.OPERATIONCODE FROM DM_COMMAND_OPERATION co INNER JOIN (SELECT o.ID AS OPERATION_ID, o.TYPE, " + - "o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.STATUS, o.OPERATIONCODE FROM DM_OPERATION o INNER JOIN (" + + "co.ENABLED,o.OPERATIONCODE FROM DM_COMMAND_OPERATION co INNER JOIN (SELECT o.ID AS OPERATION_ID, o.TYPE, " + + + "o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.STATUS, o.OPERATIONCODE FROM DM_OPERATION o INNER JOIN (" + + "SELECT dom.OPERATION_ID AS OP_ID FROM (SELECT d.ID FROM DM_DEVICE d INNER JOIN " + "DM_DEVICE_TYPE dm ON d.DEVICE_TYPE_ID = dm.ID AND dm.NAME = ? AND " + "d.DEVICE_IDENTIFICATION = ?) d1 INNER JOIN DM_DEVICE_OPERATION_MAPPING dom ON d1.ID = " + @@ -78,16 +118,21 @@ public class CommandOperationDAOImpl extends OperationDAOImpl { stmt.setString(3, status.toString()); rs = stmt.executeQuery(sql); - while(rs.next()){ - operation = new Operation(); - operation.setId(rs.getInt("OPERATION_ID")); - operation.setType(Operation.Type.valueOf(rs.getString("TYPE"))); - operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString()); - operation.setCreatedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString()); - operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS"))); - operation.setEnabled(rs.getBoolean("ENABLED")); - operation.setCode(rs.getString("OPERATIONCODE")); - operationList.add(operation); + while (rs.next()) { + operation = new Operation(); + operation.setId(rs.getInt("OPERATION_ID")); + operation.setType(Operation.Type.valueOf(rs.getString("TYPE"))); + operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString()); + + if (rs.getTimestamp("RECEIVED_TIMESTAMP") != null) { + operation.setCreatedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString()); + } else { + operation.setCreatedTimeStamp(null); + } + operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS"))); + operation.setEnabled(rs.getBoolean("ENABLED")); + operation.setCode(rs.getString("OPERATIONCODE")); + operationList.add(operation); } return operationList; } catch (SQLException e) { @@ -107,8 +152,10 @@ public class CommandOperationDAOImpl extends OperationDAOImpl { try { Connection conn = OperationManagementDAOFactory.openConnection(); String sql = "SELECT po.OPERATION_ID, po.TYPE, po.CREATED_TIMESTAMP, po.RECEIVED_TIMESTAMP, po.STATUS, " + - "co.ENABLED.o.OPERATIONCODE FROM DM_COMMAND_OPERATION co INNER JOIN (SELECT o.ID AS OPERATION_ID, o.TYPE, " + - "o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.STATUS, o.OPERATIONCODE FROM DM_OPERATION o INNER JOIN (" + + "co.ENABLED.o.OPERATIONCODE FROM DM_COMMAND_OPERATION co INNER JOIN (SELECT o.ID AS OPERATION_ID, o.TYPE, " + + + "o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.STATUS, o.OPERATIONCODE FROM DM_OPERATION o INNER JOIN (" + + "SELECT dom.OPERATION_ID AS OP_ID FROM (SELECT d.ID FROM DM_DEVICE d INNER JOIN " + "DM_DEVICE_TYPE dm ON d.DEVICE_TYPE_ID = dm.ID AND dm.NAME = ? AND " + "d.DEVICE_IDENTIFICATION = ?) d1 INNER JOIN DM_DEVICE_OPERATION_MAPPING dom ON d1.ID = " + @@ -117,7 +164,7 @@ public class CommandOperationDAOImpl extends OperationDAOImpl { stmt = conn.prepareStatement(sql); stmt.setString(1, deviceId.getType()); - stmt.setString(1, deviceId.getId()); + stmt.setString(2, deviceId.getId()); rs = stmt.executeQuery(); List operations = new ArrayList(); @@ -125,6 +172,13 @@ public class CommandOperationDAOImpl extends OperationDAOImpl { CommandOperation operation = new CommandOperation(); operation.setId(rs.getInt("ID")); operation.setType(Operation.Type.valueOf(rs.getString("TYPE"))); + operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString()); + + if (rs.getTimestamp("RECEIVED_TIMESTAMP") == null) { + operation.setReceivedTimeStamp(null); + } else { + operation.setReceivedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString()); + } operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS"))); operation.setEnabled(Boolean.parseBoolean(rs.getString("ENABLED"))); operation.setCode(rs.getString("OPERATIONCODE")); @@ -149,7 +203,7 @@ public class CommandOperationDAOImpl extends OperationDAOImpl { stmt = connection.prepareStatement( "UPDATE DM_COMMAND_OPERATION O SET O.ENABLED=? WHERE O.OPERATION_ID=?"); - stmt.setBoolean(1,operation.isEnabled()); + stmt.setBoolean(1, operation.isEnabled()); stmt.setInt(2, operation.getId()); stmt.executeUpdate(); @@ -168,7 +222,7 @@ public class CommandOperationDAOImpl extends OperationDAOImpl { PreparedStatement stmt = null; try { Connection connection = OperationManagementDAOFactory.openConnection(); - stmt = connection.prepareStatement("DELETE DM_COMMAND_OPERATION WHERE OPERATION_ID=?") ; + stmt = connection.prepareStatement("DELETE DM_COMMAND_OPERATION WHERE OPERATION_ID=?"); stmt.setInt(1, id); stmt.executeUpdate(); } catch (SQLException 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/OperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java index dcf336e20f..a8d1e32630 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java @@ -67,8 +67,8 @@ public class OperationDAOImpl implements OperationDAO { PreparedStatement stmt = null; try { Connection connection = OperationManagementDAOFactory.openConnection(); - stmt = connection.prepareStatement( - "UPDATE DM_OPERATION O SET O.RECEIVED_TIMESTAMP=?,O.STATUS=? WHERE O.ID=?"); + stmt = connection.prepareStatement("UPDATE DM_OPERATION O SET O.RECEIVED_TIMESTAMP=?,O.STATUS=? " + + "WHERE O.ID=?"); stmt.setTimestamp(1, new Timestamp(new Date().getTime())); stmt.setString(2, operation.getStatus().toString()); @@ -84,10 +84,11 @@ public class OperationDAOImpl implements OperationDAO { @Override public void deleteOperation(int id) throws OperationManagementDAOException { + PreparedStatement stmt = null; try { Connection connection = OperationManagementDAOFactory.openConnection(); - stmt = connection.prepareStatement("DELETE DM_OPERATION WHERE ID=?") ; + stmt = connection.prepareStatement("DELETE DM_OPERATION WHERE ID=?"); stmt.setInt(1, id); stmt.executeUpdate(); } catch (SQLException e) { @@ -98,13 +99,90 @@ public class OperationDAOImpl implements OperationDAO { } public Operation getOperation(int id) throws OperationManagementDAOException { - return null; + + PreparedStatement stmt = null; + ResultSet rs = null; + Operation operation = null; + try { + Connection conn = OperationManagementDAOFactory.openConnection(); + String sql = + "SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.STATUS, o.OPERATIONCODE FROM " + + "DM_OPERATION o WHERE o.ID=?"; + + stmt = conn.prepareStatement(sql); + stmt.setInt(1, id); + rs = stmt.executeQuery(); + + if (rs.next()) { + operation = new Operation(); + operation.setId(rs.getInt("ID")); + operation.setType(Operation.Type.valueOf(rs.getString("TYPE"))); + operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString()); + if (rs.getTimestamp("RECEIVED_TIMESTAMP") == null) { + operation.setReceivedTimeStamp(""); + } else { + operation.setReceivedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString()); + } + operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS"))); + operation.setCode(rs.getString("OPERATIONCODE")); + } + } catch (SQLException e) { + throw new OperationManagementDAOException("Error occurred while retrieving the operation object " + + "available for the id '" + id + "'", e); + } finally { + OperationManagementDAOUtil.cleanupResources(stmt, rs); + OperationManagementDAOFactory.closeConnection(); + } + return operation; } @Override - public Operation getOperation(DeviceIdentifier deviceId, int operationId) throws OperationManagementDAOException { + public Operation getOperation(DeviceIdentifier deviceIdentifier, int operationId) + throws OperationManagementDAOException { - return null; + PreparedStatement stmt = null; + ResultSet rs = null; + Operation operation = null; + + try { + Connection conn = OperationManagementDAOFactory.openConnection(); + String sql = + "SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.STATUS, o.OPERATIONCODE FROM " + + "DM_OPERATION o " + + "INNER JOIN (SELECT dom.OPERATION_ID AS OP_ID FROM " + + "(SELECT d.ID FROM DM_DEVICE d INNER " + + "JOIN " + + "DM_DEVICE_TYPE dm ON d.DEVICE_TYPE_ID = dm.ID AND dm.NAME = ? AND d" + + ".DEVICE_IDENTIFICATION = ?) d1 " + + "INNER JOIN DM_DEVICE_OPERATION_MAPPING dom ON d1.ID = dom.DEVICE_ID) ois " + + "ON o.ID = ois.OP_ID WHERE o.ID=?"; + stmt = conn.prepareStatement(sql); + stmt.setString(1, deviceIdentifier.getType()); + stmt.setString(2, deviceIdentifier.getId()); + stmt.setInt(3, operationId); + rs = stmt.executeQuery(); + + if (rs.next()) { + operation = new Operation(); + operation.setId(rs.getInt("ID")); + operation.setType(Operation.Type.valueOf(rs.getString("TYPE"))); + operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString()); + if (rs.getTimestamp("CREATED_TIMESTAMP") == null) { + operation.setReceivedTimeStamp(""); + } else { + operation.setReceivedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString()); + } + operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS"))); + operation.setCode(rs.getString("OPERATIONCODE")); + } + } catch (SQLException e) { + throw new OperationManagementDAOException("Error occurred while retrieving the operation list " + + "available for the '" + deviceIdentifier.getType() + "' with id '" + deviceIdentifier.getId() + "'", e); + } finally { + OperationManagementDAOUtil.cleanupResources(stmt, rs); + OperationManagementDAOFactory.closeConnection(); + } + return operation; } @Override @@ -115,8 +193,8 @@ public class OperationDAOImpl implements OperationDAO { @Override public List getOperations(DeviceIdentifier deviceId) throws OperationManagementDAOException { - List operations; + List operations; PreparedStatement stmt = null; ResultSet rs = null; try { @@ -141,9 +219,9 @@ public class OperationDAOImpl implements OperationDAO { operation.setId(rs.getInt("ID")); operation.setType(Operation.Type.valueOf(rs.getString("TYPE"))); operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString()); - if (rs.getTimestamp("CREATED_TIMESTAMP") == null){ + if (rs.getTimestamp("CREATED_TIMESTAMP") == null) { operation.setReceivedTimeStamp(""); - }else{ + } else { operation.setReceivedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString()); } operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS"))); @@ -196,10 +274,10 @@ public class OperationDAOImpl implements OperationDAO { operation.setStatus(this.getStatus(rs.getString("STATUS"))); operation.setId(rs.getInt("ID")); operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString()); - if (rs.getTimestamp("RECEIVED_TIMESTAMP") == null){ + if (rs.getTimestamp("RECEIVED_TIMESTAMP") == null) { operation.setReceivedTimeStamp(""); - }else{ - operation.setReceivedTimeStamp(rs.getString("RECEIVED_TIMESTAMP").toString()); + } else { + operation.setReceivedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString()); } operation.setCode(rs.getString("OPERATIONCODE")); } 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 0ebde86dd4..49871ca1de 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 @@ -157,11 +157,14 @@ public class ProfileOperationDAOImpl extends OperationDAOImpl { ois = new ObjectInputStream(bais); return (ProfileOperation) ois.readObject(); } catch (SQLException e) { + log.error("SQL error occurred while retrieving profile operation", e); throw new OperationManagementDAOException("Error occurred while adding operation metadata", e); } catch (ClassNotFoundException e) { + log.error("Class not found error occurred while retrieving profile operation", e); throw new OperationManagementDAOException("Error occurred while casting retrieved payload as a " + "ProfileOperation object", e); } catch (IOException e) { + log.error("IO error occurred while de serialize profile operation", e); throw new OperationManagementDAOException("Error occurred while serializing profile operation object", e); } finally { OperationManagementDAOUtil.cleanupResources(stmt, rs); @@ -178,8 +181,8 @@ public class ProfileOperationDAOImpl extends OperationDAOImpl { try { Connection connection = OperationManagementDAOFactory.openConnection(); - stmt = connection.prepareStatement( - "UPDATE DM_PROFILE_OPERATION O SET O.OPERATIONDETAILS=? WHERE O.OPERATION_ID=?"); + stmt = connection.prepareStatement("UPDATE DM_PROFILE_OPERATION O SET O.OPERATIONDETAILS=? " + + "WHERE O.OPERATION_ID=?"); bao = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bao); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java index cef57fffa6..f70c76bd11 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java @@ -116,7 +116,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @Override public boolean addOperation(Operation operation, - List devices) throws OperationManagementException { + List devices) throws OperationManagementException { return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().addOperation(operation, devices); } @@ -137,10 +137,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } @Override - public Operation updateOperation(int operationId, DeviceIdentifier deviceIdentifier, - String responsePayLoad) throws OperationManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider(). - updateOperation(operationId, deviceIdentifier, responsePayLoad); + public void updateOperation(int operationId, Operation.Status operationStatus) throws OperationManagementException { + DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().updateOperation(operationId, + operationStatus); } @Override @@ -150,5 +149,4 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { .sendEnrolmentInvitation(emailMessageProperties); } - }