|
|
@ -170,7 +170,22 @@ public class WindowsDeviceManager implements DeviceManager {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
return true;
|
|
|
|
boolean isEnrolled = false;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
log.debug("Checking the enrollment of Windows device : " + deviceId.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
MobileDevice mobileDevice =
|
|
|
|
|
|
|
|
daoFactory.getMobileDeviceDAO().getMobileDevice(deviceId.getId());
|
|
|
|
|
|
|
|
if (mobileDevice != null) {
|
|
|
|
|
|
|
|
isEnrolled = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
String msg = "Error while checking the enrollment status of Windows device : " +
|
|
|
|
|
|
|
|
deviceId.getId();
|
|
|
|
|
|
|
|
throw new DeviceManagementException(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return isEnrolled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -266,18 +281,26 @@ public class WindowsDeviceManager implements DeviceManager {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
|
|
|
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
|
|
|
boolean status;
|
|
|
|
boolean status = false;
|
|
|
|
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
|
|
|
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
WindowsDAOFactory.beginTransaction();
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
status = daoFactory.getMobileDeviceDAO().addMobileDevice(mobileDevice);
|
|
|
|
log.debug("Enrolling a new windows device : " + device.getDeviceIdentifier());
|
|
|
|
WindowsDAOFactory.commitTransaction();
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean isEnrolled = this.isEnrolled(
|
|
|
|
|
|
|
|
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
|
|
|
|
|
|
|
if (isEnrolled) {
|
|
|
|
|
|
|
|
this.modifyEnrollment(device);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
WindowsDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
status = daoFactory.getMobileDeviceDAO().addMobileDevice(mobileDevice);
|
|
|
|
|
|
|
|
WindowsDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
WindowsDAOFactory.rollbackTransaction();
|
|
|
|
WindowsDAOFactory.rollbackTransaction();
|
|
|
|
throw new DeviceManagementException("Error while enrolling the Windows device '" +
|
|
|
|
String msg =
|
|
|
|
device.getDeviceIdentifier() + "'", e);
|
|
|
|
"Error while enrolling the windows device : " + device.getDeviceIdentifier();
|
|
|
|
} finally {
|
|
|
|
throw new DeviceManagementException(msg, e);
|
|
|
|
WindowsDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|