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