|
|
|
@ -20,12 +20,12 @@ 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.spi.DeviceManager;
|
|
|
|
|
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 org.wso2.carbon.device.mgt.common.*;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -36,6 +36,12 @@ import java.util.List;
|
|
|
|
|
public class AndroidDeviceManagerService implements DeviceManager {
|
|
|
|
|
|
|
|
|
|
private static final Log log = LogFactory.getLog(AndroidDeviceManagerService.class);
|
|
|
|
|
private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory;
|
|
|
|
|
|
|
|
|
|
public AndroidDeviceManagerService() {
|
|
|
|
|
mobileDeviceManagementDAOFactory = new MobileDeviceManagementDAOFactory(
|
|
|
|
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getProviderType() {
|
|
|
|
@ -55,7 +61,7 @@ public class AndroidDeviceManagerService implements DeviceManager {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Enrolling a new Android device : " + device.getDeviceIdentifier());
|
|
|
|
|
}
|
|
|
|
|
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice(
|
|
|
|
|
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice(
|
|
|
|
|
mobileDevice);
|
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
|
String msg = "Error while enrolling the Android device : " +
|
|
|
|
@ -74,7 +80,7 @@ public class AndroidDeviceManagerService implements DeviceManager {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Modifying the Android device enrollment data");
|
|
|
|
|
}
|
|
|
|
|
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
|
|
|
|
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
|
|
|
|
.updateMobileDevice(mobileDevice);
|
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
|
String msg = "Error while updating the enrollment of the Android device : " +
|
|
|
|
@ -92,7 +98,7 @@ public class AndroidDeviceManagerService implements DeviceManager {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Dis-enrolling Android device : " + deviceId);
|
|
|
|
|
}
|
|
|
|
|
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
|
|
|
|
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
|
|
|
|
.deleteMobileDevice(deviceId.getId());
|
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
|
String msg = "Error while removing the Android device : " + deviceId.getId();
|
|
|
|
@ -110,7 +116,7 @@ public class AndroidDeviceManagerService implements DeviceManager {
|
|
|
|
|
log.debug("Checking the enrollment of Android device : " + deviceId.getId());
|
|
|
|
|
}
|
|
|
|
|
MobileDevice mobileDevice =
|
|
|
|
|
MobileDeviceManagementDAOFactory.getMobileDeviceDAO().getMobileDevice(
|
|
|
|
|
mobileDeviceManagementDAOFactory.getMobileDeviceDAO().getMobileDevice(
|
|
|
|
|
deviceId.getId());
|
|
|
|
|
if (mobileDevice != null) {
|
|
|
|
|
isEnrolled = true;
|
|
|
|
@ -142,7 +148,7 @@ public class AndroidDeviceManagerService implements DeviceManager {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Getting the details of Android device : " + deviceId.getId());
|
|
|
|
|
}
|
|
|
|
|
MobileDevice mobileDevice = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().
|
|
|
|
|
MobileDevice mobileDevice = mobileDeviceManagementDAOFactory.getMobileDeviceDAO().
|
|
|
|
|
getMobileDevice(deviceId.getId());
|
|
|
|
|
device = MobileDeviceManagementUtil.convertToDevice(mobileDevice);
|
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
@ -167,7 +173,7 @@ public class AndroidDeviceManagerService implements DeviceManager {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("updating the details of Android device : " + device.getDeviceIdentifier());
|
|
|
|
|
}
|
|
|
|
|
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
|
|
|
|
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
|
|
|
|
.updateMobileDevice(mobileDevice);
|
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
|
String msg = "Error while updating the Android device : " + device.getDeviceIdentifier();
|
|
|
|
@ -185,7 +191,7 @@ public class AndroidDeviceManagerService implements DeviceManager {
|
|
|
|
|
log.debug("Fetching the details of all Android devices");
|
|
|
|
|
}
|
|
|
|
|
List<MobileDevice> mobileDevices =
|
|
|
|
|
MobileDeviceManagementDAOFactory.getMobileDeviceDAO().
|
|
|
|
|
mobileDeviceManagementDAOFactory.getMobileDeviceDAO().
|
|
|
|
|
getAllMobileDevices();
|
|
|
|
|
if (mobileDevices != null) {
|
|
|
|
|
devices = new ArrayList<Device>();
|
|
|
|
|