From fe1e3dd43acb845c017fc7593f9f7780dc5776a8 Mon Sep 17 00:00:00 2001 From: mharindu Date: Mon, 11 May 2015 12:29:58 +0530 Subject: [PATCH 1/8] Fixed profile operation update bug --- .../mgt/core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java | 1 + 1 file changed, 1 insertion(+) 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 efd42803b2..f59fe6452d 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 @@ -127,6 +127,7 @@ public class ProfileOperationDAOImpl extends OperationDAOImpl { PreparedStatement stmt = null; ByteArrayOutputStream bao = null; ObjectOutputStream oos = null; + super.updateOperation(operation); try { Connection connection = OperationManagementDAOFactory.getConnection(); From f83897708caefaea226ea23cafdefd94eb1ba19e Mon Sep 17 00:00:00 2001 From: mharindu Date: Thu, 14 May 2015 22:13:57 +0530 Subject: [PATCH 2/8] Merged --- .../device/mgt/core/operation/mgt/OperationManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 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/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 5000bd56a6..e2a56958e3 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 @@ -169,7 +169,7 @@ public class OperationManagerImpl implements OperationManager { if (device == null) { throw new OperationManagementException("Device not found for given device " + - "Identifier:" + deviceIdentifier.getId() + " and given type" + deviceIdentifier.getType()); + "Identifier:" + deviceIdentifier.getId() + " and given type:" + deviceIdentifier.getType()); } operations = new ArrayList(); dtoOperationList = operationDAO.getOperationsByDeviceAndStatus(device.getId(), From 6b84d65e29f7176cfbbb233fad42036a0ef70c85 Mon Sep 17 00:00:00 2001 From: mharindu Date: Mon, 18 May 2015 15:14:14 +0530 Subject: [PATCH 3/8] Refactored updateDeviceInfo function --- .../org/wso2/carbon/device/mgt/common/spi/DeviceManager.java | 2 +- .../wso2/carbon/device/mgt/common/spi/DeviceMgtService.java | 2 +- .../device/mgt/core/DeviceManagementServiceProviderImpl.java | 4 ++-- .../device/mgt/core/service/DeviceManagementServiceImpl.java | 4 ++-- .../org/wso2/carbon/device/mgt/core/TestDeviceManager.java | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java index aeb84c669e..72ed8ecbb7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java @@ -121,7 +121,7 @@ public interface DeviceManager { * @param device Updated device information related data * @throws DeviceManagementException If some unusual behaviour is observed while updating the device info */ - boolean updateDeviceInfo(Device device, List applicationList) throws DeviceManagementException; + boolean updateDeviceInfo(Device device) throws DeviceManagementException; /** * Method to set the ownership type of a particular device. i.e. BYOD, COPE. diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceMgtService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceMgtService.java index 82b21e9630..8c247ffe44 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceMgtService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceMgtService.java @@ -19,6 +19,6 @@ package org.wso2.carbon.device.mgt.common.spi; -public interface DeviceMgtService extends DeviceManager,AppManager { +public interface DeviceMgtService extends DeviceManager, AppManager { } 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 0463c16d53..88c35a15b2 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 @@ -378,10 +378,10 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ } @Override - public boolean updateDeviceInfo(Device device, List applicationList) throws DeviceManagementException { + public boolean updateDeviceInfo(Device device) throws DeviceManagementException { DeviceManager dms = this.getPluginRepository().getDeviceManagementProvider(device.getType()); - return dms.updateDeviceInfo(device,applicationList); + return dms.updateDeviceInfo(device); } @Override 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 621cea3669..e4eb06186b 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 @@ -98,9 +98,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } @Override - public boolean updateDeviceInfo(Device device, List applicationList) throws DeviceManagementException { + public boolean updateDeviceInfo(Device device) throws DeviceManagementException { return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider(). - updateDeviceInfo(device, applicationList); + updateDeviceInfo(device); } @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java index ea8ad2e2f9..f0d64f389a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java @@ -79,7 +79,7 @@ public class TestDeviceManager implements DeviceMgtService { } @Override - public boolean updateDeviceInfo(Device device, List applicationList) throws DeviceManagementException { + public boolean updateDeviceInfo(Device device) throws DeviceManagementException { return false; } From ead4d3be69344861b0f4552fa736d759abdbd991 Mon Sep 17 00:00:00 2001 From: mharindu Date: Tue, 19 May 2015 11:19:41 +0530 Subject: [PATCH 4/8] Refactored device info --- .../device/mgt/common/spi/DeviceManager.java | 3 ++- .../core/DeviceManagementServiceProviderImpl.java | 15 ++++++++++++--- .../core/service/DeviceManagementServiceImpl.java | 8 ++++---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java index 72ed8ecbb7..0eb13dee00 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java @@ -118,10 +118,11 @@ public interface DeviceManager { /** * Method to update device information. * + * @param deviceIdentifier identifier to identify the device * @param device Updated device information related data * @throws DeviceManagementException If some unusual behaviour is observed while updating the device info */ - boolean updateDeviceInfo(Device device) throws DeviceManagementException; + boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException; /** * Method to set the ownership type of a particular device. i.e. BYOD, COPE. 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 88c35a15b2..80744ec6a8 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 @@ -136,7 +136,16 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { DeviceManager dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); - return dms.disenrollDevice(deviceId); + boolean status = dms.disenrollDevice(deviceId); + try { + org.wso2.carbon.device.mgt.core.dto.Device device = this.getDeviceDAO().getDevice(deviceId); + device.setStatus(Status.INACTIVE); + this.getDeviceDAO().updateDevice(device); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementException("Error occurred while modifying the device " + + "'" + deviceId.getId() + "'", e); + } + return status; } @Override @@ -378,10 +387,10 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ } @Override - public boolean updateDeviceInfo(Device device) throws DeviceManagementException { + public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException { DeviceManager dms = this.getPluginRepository().getDeviceManagementProvider(device.getType()); - return dms.updateDeviceInfo(device); + return dms.updateDeviceInfo(deviceIdentifier, device); } @Override 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 e4eb06186b..8cfd9ad0b5 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 @@ -98,21 +98,21 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } @Override - public boolean updateDeviceInfo(Device device) throws DeviceManagementException { + public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException { return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider(). - updateDeviceInfo(device); + updateDeviceInfo(deviceIdentifier, device); } @Override public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException { return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().setOwnership(deviceId, - ownershipType); + ownershipType); } @Override public License getLicense(String deviceType, String languageCode) throws LicenseManagementException { return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getLicense(deviceType, - languageCode); + languageCode); } @Override From 40feabb9df335eb2f6a2b47a8fb169d855678d01 Mon Sep 17 00:00:00 2001 From: mharindu Date: Tue, 19 May 2015 17:13:36 +0530 Subject: [PATCH 5/8] Fixed bug in device disenrollment --- .../mgt/core/DeviceManagementServiceProviderImpl.java | 7 ------- 1 file changed, 7 deletions(-) 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 22265bf0e9..0f8032899d 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 @@ -137,13 +137,6 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ DeviceManager dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); boolean status = dms.disenrollDevice(deviceId); - try { - int deviceID = Integer.parseInt(deviceId.getId()); - this.getDeviceDAO().updateDeviceStatus(deviceID, Status.INACTIVE); - } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while modifying the device " + - "'" + deviceId.getId() + "'", e); - } return status; } From 8f00128ab1021063b16182a46a973e0d2328e8ee Mon Sep 17 00:00:00 2001 From: Milan Perera Date: Tue, 19 May 2015 17:22:36 +0530 Subject: [PATCH 6/8] Update DeviceManager.java --- .../org/wso2/carbon/device/mgt/common/spi/DeviceManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java index 29cc25bf57..0eb13dee00 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java @@ -122,7 +122,6 @@ public interface DeviceManager { * @param device Updated device information related data * @throws DeviceManagementException If some unusual behaviour is observed while updating the device info */ - boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException; /** From 7d3bf84d9f38aa1b061405a252c3c09e582eb773 Mon Sep 17 00:00:00 2001 From: Milan Perera Date: Tue, 19 May 2015 17:26:24 +0530 Subject: [PATCH 7/8] Update DeviceManagementServiceProviderImpl.java --- .../device/mgt/core/DeviceManagementServiceProviderImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 0f8032899d..7eb690c10e 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 @@ -136,8 +136,7 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { DeviceManager dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); - boolean status = dms.disenrollDevice(deviceId); - return status; + return dms.disenrollDevice(deviceId); } @Override From c068ac88dee8f9cec8311911f393ad217082cb67 Mon Sep 17 00:00:00 2001 From: Milan Perera Date: Tue, 19 May 2015 17:30:20 +0530 Subject: [PATCH 8/8] Update DeviceManagementServiceImpl.java --- .../mgt/core/service/DeviceManagementServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 e14e30eb98..cb2d363fb6 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 @@ -107,13 +107,13 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @Override public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException { return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().setOwnership(deviceId, - ownershipType); + ownershipType); } @Override public License getLicense(String deviceType, String languageCode) throws LicenseManagementException { return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getLicense(deviceType, - languageCode); + languageCode); } @Override @@ -205,4 +205,4 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider() .getAllDevicesOfRole(roleName); } -} \ No newline at end of file +}