diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java index d6c1e7c98b..321fa0222b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java @@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.mobile.impl.android; 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.configuration.mgt.TenantConfiguration; import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory; @@ -47,18 +48,33 @@ public class AndroidDeviceManager implements DeviceManager { return featureManager; } - @Override + @Override + public boolean saveConfiguration(TenantConfiguration tenantConfiguration) throws DeviceManagementException { + return false; + } + + @Override + public TenantConfiguration getConfiguration() throws DeviceManagementException { + return null; + } + + @Override public boolean enrollDevice(Device device) throws DeviceManagementException { - boolean status; + boolean status = false; MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); try { if (log.isDebugEnabled()) { log.debug("Enrolling a new Android device : " + device.getDeviceIdentifier()); } - AndroidDAOFactory.beginTransaction(); - status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice( - mobileDevice); - AndroidDAOFactory.commitTransaction(); + boolean isEnrolled = this.isEnrolled(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); + if (isEnrolled) { + this.modifyEnrollment(device); + } else { + AndroidDAOFactory.beginTransaction(); + status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice( + mobileDevice); + AndroidDAOFactory.commitTransaction(); + } } catch (MobileDeviceManagementDAOException e) { try { AndroidDAOFactory.rollbackTransaction(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java index b8f07199ed..af34ea52c5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java @@ -21,6 +21,7 @@ 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.configuration.mgt.TenantConfiguration; 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; @@ -43,7 +44,17 @@ public class WindowsDeviceManager implements DeviceManager { return null; } - @Override + @Override + public boolean saveConfiguration(TenantConfiguration tenantConfiguration) throws DeviceManagementException { + return false; + } + + @Override + public TenantConfiguration getConfiguration() throws DeviceManagementException { + return null; + } + + @Override public boolean modifyEnrollment(Device device) throws DeviceManagementException { return true; }