Complete implementation of device type permanent delete

This service will do following modifications to achieve it's functionality,
 1. Dis-enroll and delete all devices of a device type
 2. Remove platform configuration of a device type
 3. Delete the device type
feature/appm-store/pbac
Yohan Avishke 5 years ago
parent 2e62acfafc
commit 3f9dba9356

@ -169,7 +169,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
DeviceManagementProviderService deviceManagementProviderService =
DeviceMgtAPIUtils.getDeviceManagementService();
try {
if (!deviceManagementProviderService.deleteDevices(deviceIdentifiers, false)) {
if (!deviceManagementProviderService.deleteDevices(deviceIdentifiers)) {
String msg = "Found un-deployed device type.";
log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(

@ -611,7 +611,7 @@ public interface DeviceManagementProviderService {
boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException;
boolean deleteDevices(List<String> deviceIdentifiers, boolean transactionAlreadyExists) throws DeviceManagementException, InvalidDeviceException;
boolean deleteDevices(List<String> deviceIdentifiers) throws DeviceManagementException, InvalidDeviceException;
boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException;
@ -773,11 +773,11 @@ public interface DeviceManagementProviderService {
DeviceManagementException;
/**
* Permanently delete a device type
* Permanently delete a device type with all it's devices
*
* @param deviceTypeName device type name
* @return True if device type successfully removed
* @throws DeviceManagementException
* @throws DeviceManagementException Will be thrown if any service level or DAO level error occurs
*/
boolean deleteDeviceType(String deviceTypeName) throws DeviceManagementException;

@ -3630,22 +3630,23 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
}
deviceIdentifiers.add(device.getDeviceIdentifier());
}
DeviceManagementDAOFactory.commitTransaction();
DeviceManagementDAOFactory.closeConnection();
// delete devices
deleteDevices(deviceIdentifiers, true);
deleteDevices(deviceIdentifiers);
DeviceManagementDAOFactory.beginTransaction();
}
// remove device type versions
deviceTypeVersions = deviceTypeDAO.getDeviceTypeVersions(
deviceTypeObj.getId(), deviceTypeName);
deviceTypeVersions = deviceTypeDAO.getDeviceTypeVersions(deviceTypeObj.getId(), deviceTypeName);
if (deviceTypeVersions.isEmpty()) {
if (log.isDebugEnabled()) {
log.debug("Device type: " + deviceTypeName + "doesn't have any type versions");
log.debug("Device of type: " + deviceTypeName + "doesn't have any type versions");
}
} else {
for (DeviceTypeVersion deviceTypeVersion : deviceTypeVersions) {
result = deviceTypeDAO.isDeviceTypeVersionModifiable(deviceTypeObj.getId()
, deviceTypeVersion.getVersionName(), tenantId);
if (!result) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Device type of: " + deviceTypeName + "is unauthorized to modify " +
"version";
log.error(msg);
@ -3653,7 +3654,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
}
result = deviceTypeDAO.updateDeviceTypeVersion(deviceTypeVersion);
if (!result) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Could not delete the version of device type: " +
deviceTypeName;
log.error(msg);

Loading…
Cancel
Save