From deeeb2ce48949cb529a0c83f1b6063086b9b4961 Mon Sep 17 00:00:00 2001 From: Ace Date: Wed, 10 Oct 2018 11:20:45 +0530 Subject: [PATCH] Persisting profile operations as string payloads and retriving same as strings, failing which as profile objects to support legacy functonality --- .../mgt/dao/impl/ProfileOperationDAOImpl.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 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/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 9223b3c030..86463ebca1 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 @@ -53,7 +53,7 @@ public class ProfileOperationDAOImpl extends GenericOperationDAOImpl { bao = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bao); - oos.writeObject(operation); + oos.writeObject(operation.getPayLoad()); stmt.setInt(1, operationId); stmt.setBytes(2, bao.toByteArray()); @@ -101,7 +101,13 @@ public class ProfileOperationDAOImpl extends GenericOperationDAOImpl { byte[] operationDetails = rs.getBytes("OPERATION_DETAILS"); bais = new ByteArrayInputStream(operationDetails); ois = new ObjectInputStream(bais); - profileOperation = (ProfileOperation) ois.readObject(); + Object obj = ois.readObject(); + if(obj instanceof String){ + profileOperation = new ProfileOperation(); + profileOperation.setPayLoad(obj); + } else { + profileOperation = (ProfileOperation) obj; + } } } catch (IOException e) { throw new OperationManagementDAOException("IO Error occurred while de serialize the profile " + @@ -147,9 +153,17 @@ public class ProfileOperationDAOImpl extends GenericOperationDAOImpl { byte[] operationDetails = rs.getBytes("OPERATION_DETAILS"); bais = new ByteArrayInputStream(operationDetails); ois = new ObjectInputStream(bais); - profileOperation = (ProfileOperation) ois.readObject(); - profileOperation.setStatus(status); - operationList.add(profileOperation); + Object obj = ois.readObject(); + if(obj instanceof String){ + profileOperation = new ProfileOperation(); + profileOperation.setPayLoad(obj); + profileOperation.setStatus(status); + operationList.add(profileOperation); + } else { + profileOperation = (ProfileOperation) obj; + profileOperation.setStatus(status); + operationList.add(profileOperation); + }; } } catch (IOException e) {