|
|
|
@ -69,7 +69,7 @@ public class WindowsDeviceManager implements DeviceManager {
|
|
|
|
|
} catch (LicenseManagementException e) {
|
|
|
|
|
log.error("Error occurred while adding default license for Windows devices", e);
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
log.error("Error occurred while adding supported device features for Windows platform", e);
|
|
|
|
|
throw new IllegalStateException("Error occurred while adding windows features to the DB.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -79,8 +79,7 @@ public class WindowsDeviceManager implements DeviceManager {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean saveConfiguration(TenantConfiguration tenantConfiguration)
|
|
|
|
|
throws DeviceManagementException {
|
|
|
|
|
public boolean saveConfiguration(TenantConfiguration tenantConfiguration) throws DeviceManagementException {
|
|
|
|
|
boolean status;
|
|
|
|
|
Resource resource;
|
|
|
|
|
try {
|
|
|
|
@ -88,8 +87,7 @@ public class WindowsDeviceManager implements DeviceManager {
|
|
|
|
|
log.debug("Persisting windows configurations in Registry");
|
|
|
|
|
}
|
|
|
|
|
String resourcePath = MobileDeviceManagementUtil.getPlatformConfigPath(
|
|
|
|
|
DeviceManagementConstants.
|
|
|
|
|
MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
|
|
|
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
|
|
|
|
StringWriter writer = new StringWriter();
|
|
|
|
|
JAXBContext context = JAXBContext.newInstance(TenantConfiguration.class);
|
|
|
|
|
Marshaller marshaller = context.createMarshaller();
|
|
|
|
@ -143,14 +141,16 @@ public class WindowsDeviceManager implements DeviceManager {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
|
|
|
|
boolean status;
|
|
|
|
|
boolean status = false;
|
|
|
|
|
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
|
|
|
|
try {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Modifying the Windows device enrollment data");
|
|
|
|
|
}
|
|
|
|
|
WindowsDAOFactory.beginTransaction();
|
|
|
|
|
status = daoFactory.getMobileDeviceDAO().updateMobileDevice(mobileDevice);
|
|
|
|
|
if (daoFactory.getMobileDeviceDAO() != null) {
|
|
|
|
|
status = daoFactory.getMobileDeviceDAO().updateMobileDevice(mobileDevice);
|
|
|
|
|
}
|
|
|
|
|
WindowsDAOFactory.commitTransaction();
|
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
|
WindowsDAOFactory.rollbackTransaction();
|
|
|
|
@ -170,22 +170,21 @@ public class WindowsDeviceManager implements DeviceManager {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
|
boolean isEnrolled = false;
|
|
|
|
|
MobileDevice mobileDevice;
|
|
|
|
|
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;
|
|
|
|
|
if (daoFactory.getMobileDeviceDAO() != null) {
|
|
|
|
|
mobileDevice = daoFactory.getMobileDeviceDAO().getMobileDevice(deviceId.getId());
|
|
|
|
|
} else {
|
|
|
|
|
throw new DeviceManagementException("Error occurred while getting DAO object.");
|
|
|
|
|
}
|
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
|
String msg = "Error while checking the enrollment status of Windows device : " +
|
|
|
|
|
deviceId.getId();
|
|
|
|
|
String msg = "Error occurred while checking the enrollment status of Windows device : " + deviceId.getId();
|
|
|
|
|
throw new DeviceManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
return isEnrolled;
|
|
|
|
|
return (mobileDevice != null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -201,12 +200,15 @@ public class WindowsDeviceManager implements DeviceManager {
|
|
|
|
|
|
|
|
|
|
public List<Device> getAllDevices() throws DeviceManagementException {
|
|
|
|
|
List<Device> devices = null;
|
|
|
|
|
List<MobileDevice> mobileDevices = null;
|
|
|
|
|
try {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Fetching the details of all Windows devices");
|
|
|
|
|
}
|
|
|
|
|
WindowsDAOFactory.openConnection();
|
|
|
|
|
List<MobileDevice> mobileDevices = daoFactory.getMobileDeviceDAO().getAllMobileDevices();
|
|
|
|
|
if (daoFactory.getMobileDeviceDAO() != null) {
|
|
|
|
|
mobileDevices = daoFactory.getMobileDeviceDAO().getAllMobileDevices();
|
|
|
|
|
}
|
|
|
|
|
if (mobileDevices != null) {
|
|
|
|
|
devices = new ArrayList<>(mobileDevices.size());
|
|
|
|
|
for (MobileDevice mobileDevice : mobileDevices) {
|
|
|
|
@ -224,13 +226,15 @@ public class WindowsDeviceManager implements DeviceManager {
|
|
|
|
|
@Override
|
|
|
|
|
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
|
Device device = null;
|
|
|
|
|
MobileDevice mobileDevice = null;
|
|
|
|
|
try {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Getting the details of Windows device : '" + deviceId.getId() + "'");
|
|
|
|
|
}
|
|
|
|
|
WindowsDAOFactory.openConnection();
|
|
|
|
|
MobileDevice mobileDevice = daoFactory.getMobileDeviceDAO().
|
|
|
|
|
getMobileDevice(deviceId.getId());
|
|
|
|
|
if (daoFactory.getMobileDeviceDAO() != null) {
|
|
|
|
|
mobileDevice = daoFactory.getMobileDeviceDAO().getMobileDevice(deviceId.getId());
|
|
|
|
|
}
|
|
|
|
|
device = MobileDeviceManagementUtil.convertToDevice(mobileDevice);
|
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
@ -293,7 +297,9 @@ public class WindowsDeviceManager implements DeviceManager {
|
|
|
|
|
this.modifyEnrollment(device);
|
|
|
|
|
} else {
|
|
|
|
|
WindowsDAOFactory.beginTransaction();
|
|
|
|
|
status = daoFactory.getMobileDeviceDAO().addMobileDevice(mobileDevice);
|
|
|
|
|
if (daoFactory.getMobileDeviceDAO() != null) {
|
|
|
|
|
status = daoFactory.getMobileDeviceDAO().addMobileDevice(mobileDevice);
|
|
|
|
|
}
|
|
|
|
|
WindowsDAOFactory.commitTransaction();
|
|
|
|
|
}
|
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
|