|
|
@ -156,9 +156,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
device.getDeviceIdentifier() + "', which belongs to " + "platform '" +
|
|
|
|
device.getDeviceIdentifier() + "', which belongs to " + "platform '" +
|
|
|
|
device.getType() + " upon the user '" + device.getEnrolmentInfo().getOwner() + "'");
|
|
|
|
device.getType() + " upon the user '" + device.getEnrolmentInfo().getOwner() + "'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (TransactionManagementException | DeviceManagementDAOException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
DeviceManagementDAOFactory.rollbackTransaction();
|
|
|
|
DeviceManagementDAOFactory.rollbackTransaction();
|
|
|
|
log.error("Error occurred while adding enrolment related metadata", e);
|
|
|
|
throw new DeviceManagementException("Error occurred while adding enrolment related metadata", e);
|
|
|
|
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred while initiating transaction", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -173,10 +175,12 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
int deviceId = deviceDAO.addDevice(type.getId(), device, tenantId);
|
|
|
|
int deviceId = deviceDAO.addDevice(type.getId(), device, tenantId);
|
|
|
|
enrolmentId = enrolmentDAO.addEnrollment(deviceId, device.getEnrolmentInfo(), tenantId);
|
|
|
|
enrolmentId = enrolmentDAO.addEnrollment(deviceId, device.getEnrolmentInfo(), tenantId);
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
} catch (DeviceManagementDAOException | TransactionManagementException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
DeviceManagementDAOFactory.rollbackTransaction();
|
|
|
|
DeviceManagementDAOFactory.rollbackTransaction();
|
|
|
|
log.error("Error occurred while adding metadata of '" + device.getType() + "' device carrying " +
|
|
|
|
throw new DeviceManagementException("Error occurred while adding metadata of '" + device.getType() +
|
|
|
|
"the identifier '" + device.getDeviceIdentifier() + "'", e);
|
|
|
|
"' device carrying the identifier '" + device.getDeviceIdentifier() + "'", e);
|
|
|
|
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred while initiating transaction", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -214,10 +218,12 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
enrolmentDAO.updateEnrollment(deviceId, device.getEnrolmentInfo(), tenantId);
|
|
|
|
enrolmentDAO.updateEnrollment(deviceId, device.getEnrolmentInfo(), tenantId);
|
|
|
|
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
} catch (DeviceManagementDAOException | TransactionManagementException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
DeviceManagementDAOFactory.rollbackTransaction();
|
|
|
|
DeviceManagementDAOFactory.rollbackTransaction();
|
|
|
|
throw new DeviceManagementException("Error occurred while modifying the device " +
|
|
|
|
throw new DeviceManagementException("Error occurred while modifying the device " +
|
|
|
|
"'" + device.getId() + "'", e);
|
|
|
|
"'" + device.getId() + "'", e);
|
|
|
|
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred while initiating transaction", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -247,10 +253,12 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
deviceDAO.updateDevice(deviceType.getId(), device, tenantId);
|
|
|
|
deviceDAO.updateDevice(deviceType.getId(), device, tenantId);
|
|
|
|
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
} catch (DeviceManagementDAOException | TransactionManagementException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
DeviceManagementDAOFactory.rollbackTransaction();
|
|
|
|
DeviceManagementDAOFactory.rollbackTransaction();
|
|
|
|
throw new DeviceManagementException("Error occurred while dis-enrolling '" + deviceId.getType() +
|
|
|
|
throw new DeviceManagementException("Error occurred while dis-enrolling '" + deviceId.getType() +
|
|
|
|
"' device with the identifier '" + deviceId.getId() + "'", e);
|
|
|
|
"' device with the identifier '" + deviceId.getId() + "'", e);
|
|
|
|
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred while initiating transaction", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -302,14 +310,16 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
List<Device> allDevices;
|
|
|
|
List<Device> allDevices;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
|
|
|
|
|
|
|
|
allDevices = deviceDAO.getDevices(this.getTenantId());
|
|
|
|
allDevices = deviceDAO.getDevices(this.getTenantId());
|
|
|
|
} catch (DeviceManagementDAOException | SQLException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
throw new DeviceManagementException("Error occurred while retrieving device list pertaining to " +
|
|
|
|
throw new DeviceManagementException("Error occurred while retrieving device list pertaining to " +
|
|
|
|
"the current tenant", e);
|
|
|
|
"the current tenant", e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (Device device : allDevices) {
|
|
|
|
for (Device device : allDevices) {
|
|
|
|
DeviceManager deviceManager = this.getDeviceManager(device.getType());
|
|
|
|
DeviceManager deviceManager = this.getDeviceManager(device.getType());
|
|
|
|
if (deviceManager == null) {
|
|
|
|
if (deviceManager == null) {
|
|
|
@ -338,9 +348,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
allDevices = deviceDAO.getDevices(deviceType, this.getTenantId());
|
|
|
|
allDevices = deviceDAO.getDevices(deviceType, this.getTenantId());
|
|
|
|
} catch (DeviceManagementDAOException | SQLException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
throw new DeviceManagementException("Error occurred while retrieving all devices of type '" +
|
|
|
|
throw new DeviceManagementException("Error occurred while retrieving all devices of type '" +
|
|
|
|
deviceType + "' that are being managed within the scope of current tenant", e);
|
|
|
|
deviceType + "' that are being managed within the scope of current tenant", e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -415,7 +427,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
.getProperty("line.separator")).append(messageFooter3.trim());
|
|
|
|
.getProperty("line.separator")).append(messageFooter3.trim());
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
log.error("IO error in processing enrol email message " + emailMessageProperties);
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error replacing tags in email template '" +
|
|
|
|
throw new DeviceManagementException("Error replacing tags in email template '" +
|
|
|
|
emailMessageProperties.getSubject() + "'", e);
|
|
|
|
emailMessageProperties.getSubject() + "'", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -479,7 +490,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
messageBuilder.append(System.getProperty("line.separator")).append(messageFooter3.trim());
|
|
|
|
messageBuilder.append(System.getProperty("line.separator")).append(messageFooter3.trim());
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
log.error("IO error in processing enrol email message " + emailMessageProperties);
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error replacing tags in email template '" +
|
|
|
|
throw new DeviceManagementException("Error replacing tags in email template '" +
|
|
|
|
emailMessageProperties.getSubject() + "'", e);
|
|
|
|
emailMessageProperties.getSubject() + "'", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -494,9 +504,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
device = deviceDAO.getDevice(deviceId, this.getTenantId());
|
|
|
|
device = deviceDAO.getDevice(deviceId, this.getTenantId());
|
|
|
|
} catch (DeviceManagementDAOException | SQLException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
throw new DeviceManagementException("Error occurred while obtaining the device for id " +
|
|
|
|
throw new DeviceManagementException("Error occurred while obtaining the device for id " +
|
|
|
|
"'" + deviceId.getId() + "'", e);
|
|
|
|
"'" + deviceId.getId() + "'", e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -571,9 +583,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
return success;
|
|
|
|
return success;
|
|
|
|
} catch (DeviceManagementDAOException | TransactionManagementException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
DeviceManagementDAOFactory.rollbackTransaction();
|
|
|
|
DeviceManagementDAOFactory.rollbackTransaction();
|
|
|
|
throw new DeviceManagementException("Error occurred while setting enrollment status", e);
|
|
|
|
throw new DeviceManagementException("Error occurred while setting enrollment status", e);
|
|
|
|
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred while initiating transaction", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -620,8 +634,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int addOperation(Operation operation, List<DeviceIdentifier> devices) throws
|
|
|
|
public int addOperation(Operation operation,
|
|
|
|
OperationManagementException {
|
|
|
|
List<DeviceIdentifier> devices) throws OperationManagementException {
|
|
|
|
return DeviceManagementDataHolder.getInstance().getOperationManager().addOperation(operation, devices);
|
|
|
|
return DeviceManagementDataHolder.getInstance().getOperationManager().addOperation(operation, devices);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -652,8 +666,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceId, int operationId)
|
|
|
|
public Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceId,
|
|
|
|
throws OperationManagementException {
|
|
|
|
int operationId) throws OperationManagementException {
|
|
|
|
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperationByDeviceAndOperationId(
|
|
|
|
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperationByDeviceAndOperationId(
|
|
|
|
deviceId, operationId);
|
|
|
|
deviceId, operationId);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -678,9 +692,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
userDevices = deviceDAO.getDevicesOfUser(username, this.getTenantId());
|
|
|
|
userDevices = deviceDAO.getDevicesOfUser(username, this.getTenantId());
|
|
|
|
} catch (DeviceManagementDAOException | SQLException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
throw new DeviceManagementException("Error occurred while retrieving the list of devices that " +
|
|
|
|
throw new DeviceManagementException("Error occurred while retrieving the list of devices that " +
|
|
|
|
"belong to the user '" + username + "'", e);
|
|
|
|
"belong to the user '" + username + "'", e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -749,8 +765,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
return deviceDAO.getDeviceCount(this.getTenantId());
|
|
|
|
return deviceDAO.getDeviceCount(this.getTenantId());
|
|
|
|
} catch (DeviceManagementDAOException | SQLException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
throw new DeviceManagementException("Error occurred while retrieving the device count", e);
|
|
|
|
throw new DeviceManagementException("Error occurred while retrieving the device count", e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -763,9 +781,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
allDevices = deviceDAO.getDevicesByName(deviceName, this.getTenantId());
|
|
|
|
allDevices = deviceDAO.getDevicesByName(deviceName, this.getTenantId());
|
|
|
|
} catch (DeviceManagementDAOException | SQLException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
throw new DeviceManagementException("Error occurred while fetching the list of devices that matches to '"
|
|
|
|
throw new DeviceManagementException("Error occurred while fetching the list of devices that matches to '"
|
|
|
|
+ deviceName + "'", e);
|
|
|
|
+ deviceName + "'", e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -785,14 +805,22 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void updateDeviceEnrolmentInfo(Device device, EnrolmentInfo.Status status) throws DeviceManagementException {
|
|
|
|
public void updateDeviceEnrolmentInfo(Device device, EnrolmentInfo.Status status) throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
|
|
|
|
DeviceType deviceType = deviceTypeDAO.getDeviceType(device.getType());
|
|
|
|
DeviceType deviceType = deviceTypeDAO.getDeviceType(device.getType());
|
|
|
|
device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime());
|
|
|
|
device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime());
|
|
|
|
device.getEnrolmentInfo().setStatus(status);
|
|
|
|
device.getEnrolmentInfo().setStatus(status);
|
|
|
|
deviceDAO.updateDevice(deviceType.getId(), device, this.getTenantId());
|
|
|
|
deviceDAO.updateDevice(deviceType.getId(), device, this.getTenantId());
|
|
|
|
} catch (DeviceManagementDAOException deviceDaoEx) {
|
|
|
|
|
|
|
|
String errorMsg = "Error occured update device enrolment status : " + device.getId();
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
log.error(errorMsg, deviceDaoEx);
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
throw new DeviceManagementException(errorMsg, deviceDaoEx);
|
|
|
|
DeviceManagementDAOFactory.rollbackTransaction();
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred update device enrolment status : '" +
|
|
|
|
|
|
|
|
device.getId() + "'", e);
|
|
|
|
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred while initiating transaction", e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -823,12 +851,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
allDevices = deviceDAO.getDevicesByStatus(status, this.getTenantId());
|
|
|
|
allDevices = deviceDAO.getDevicesByStatus(status, this.getTenantId());
|
|
|
|
} catch (DeviceManagementDAOException | SQLException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
"Error occurred while fetching the list of devices that matches to status: '" + status + "'", e);
|
|
|
|
"Error occurred while fetching the list of devices that matches to status: '" + status + "'", e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (Device device : allDevices) {
|
|
|
|
for (Device device : allDevices) {
|
|
|
|