Merge pull request #102 from hasuniea/master

fixed device enrollment modification
revert-dabc3590
Prabath Abeysekara 9 years ago
commit 820bd75223

@ -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 {
if (log.isDebugEnabled()) {
log.debug("Enrolling a new windows device : " + device.getDeviceIdentifier());
}
boolean isEnrolled = this.isEnrolled(
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
if (isEnrolled) {
this.modifyEnrollment(device);
} else {
WindowsDAOFactory.beginTransaction(); WindowsDAOFactory.beginTransaction();
status = daoFactory.getMobileDeviceDAO().addMobileDevice(mobileDevice); status = daoFactory.getMobileDeviceDAO().addMobileDevice(mobileDevice);
WindowsDAOFactory.commitTransaction(); 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;
} }

Loading…
Cancel
Save