From 2f18f03fb3d3b7417092d34a2d6bb12124fe5696 Mon Sep 17 00:00:00 2001 From: asok Date: Tue, 17 Feb 2015 18:32:52 +0530 Subject: [PATCH 1/3] adding windows enrolment --- .../windows/WindowsDeviceManagerService.java | 139 ++++++++++-------- 1 file changed, 79 insertions(+), 60 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagerService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagerService.java index ecbfb6dafc..16d93c09be 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagerService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagerService.java @@ -18,8 +18,14 @@ package org.wso2.carbon.device.mgt.mobile.impl.windows; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService; +import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory; +import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; +import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; import java.util.List; @@ -28,65 +34,78 @@ import java.util.List; */ public class WindowsDeviceManagerService implements DeviceManagerService { - @Override - public String getProviderType() { - return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS; - } - - @Override - public boolean enrollDevice(Device device) throws DeviceManagementException { - return true; - } - - @Override - public boolean modifyEnrollment(Device device) throws DeviceManagementException { - return true; - } - - @Override - public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - return true; - } - - @Override - public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { - return true; - } - - @Override - public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { - return true; - } - - @Override - public boolean setActive(DeviceIdentifier deviceId, boolean status) - throws DeviceManagementException { - return true; - } - - public List getAllDevices() throws DeviceManagementException { - return null; - } - - @Override - public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - return null; - } - - @Override - public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) - throws DeviceManagementException { - return true; - } - - @Override - public OperationManager getOperationManager() throws DeviceManagementException { - return null; - } - - @Override - public boolean updateDeviceInfo(Device device) throws DeviceManagementException { - return true; - } + private static final Log log = LogFactory.getLog(WindowsDeviceManagerService.class); + + @Override + public String getProviderType() { + return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS; + } + + @Override + public boolean enrollDevice(Device device) throws DeviceManagementException { + boolean status; + MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); + try { + status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice( + mobileDevice); + } catch (MobileDeviceManagementDAOException e) { + String msg = "Error while enrolling the Android device : " + + device.getDeviceIdentifier(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } + return status; + } + + @Override + public boolean modifyEnrollment(Device device) throws DeviceManagementException { + return true; + } + + @Override + public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { + return true; + } + + @Override + public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { + return true; + } + + @Override + public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { + return true; + } + + @Override + public boolean setActive(DeviceIdentifier deviceId, boolean status) + throws DeviceManagementException { + return true; + } + + public List getAllDevices() throws DeviceManagementException { + return null; + } + + @Override + public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { + return null; + } + + @Override + public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) + throws DeviceManagementException { + return true; + } + + @Override + public OperationManager getOperationManager() throws DeviceManagementException { + return null; + } + + @Override + public boolean updateDeviceInfo(Device device) throws DeviceManagementException { + return true; + } } From 02c57a93230da4e6bc0f5e29f66a944e0baabfb6 Mon Sep 17 00:00:00 2001 From: asok Date: Tue, 17 Feb 2015 18:40:02 +0530 Subject: [PATCH 2/3] change error info --- .../mgt/mobile/impl/windows/WindowsDeviceManagerService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagerService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagerService.java index 16d93c09be..a6582e2ff1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagerService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagerService.java @@ -49,7 +49,7 @@ public class WindowsDeviceManagerService implements DeviceManagerService { status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice( mobileDevice); } catch (MobileDeviceManagementDAOException e) { - String msg = "Error while enrolling the Android device : " + + String msg = "Error while enrolling the Windows device : " + device.getDeviceIdentifier(); log.error(msg, e); throw new DeviceManagementException(msg, e); From 78d6e27e15e8a746e2d4c692ca2ec1430d9e83eb Mon Sep 17 00:00:00 2001 From: asok Date: Thu, 19 Feb 2015 13:01:37 +0530 Subject: [PATCH 3/3] unimplemented methods returns false --- .../impl/windows/WindowsDeviceManagerService.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagerService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagerService.java index a6582e2ff1..e2aa680ec6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagerService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagerService.java @@ -59,28 +59,28 @@ public class WindowsDeviceManagerService implements DeviceManagerService { @Override public boolean modifyEnrollment(Device device) throws DeviceManagementException { - return true; + return false; } @Override public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - return true; + return false; } @Override public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { - return true; + return false; } @Override public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { - return true; + return false; } @Override public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException { - return true; + return false; } public List getAllDevices() throws DeviceManagementException { @@ -95,7 +95,7 @@ public class WindowsDeviceManagerService implements DeviceManagerService { @Override public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException { - return true; + return false; } @Override @@ -105,7 +105,7 @@ public class WindowsDeviceManagerService implements DeviceManagerService { @Override public boolean updateDeviceInfo(Device device) throws DeviceManagementException { - return true; + return false; } }