Merge branch 'delete' into 'master'

Fix permanent device deletion issue

Closes product-iots#337

See merge request entgra/carbon-device-mgt!461
feature/appm-store/pbac
Dharmakeerthi Lasantha 5 years ago
commit 1201ae0e1e

@ -1867,11 +1867,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Successfully removed device notification data of devices: " + deviceIdentifiers); log.debug("Successfully removed device notification data of devices: " + deviceIdentifiers);
} }
removeDeviceApplicationMapping(conn, deviceIds);
if (log.isDebugEnabled()) {
log.debug("Successfully removed device application mapping data of devices: "
+ deviceIdentifiers);
}
removeDevicePolicyApplied(conn, deviceIds); removeDevicePolicyApplied(conn, deviceIds);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Successfully removed device applied policy data of devices: " + deviceIdentifiers); log.debug("Successfully removed device applied policy data of devices: " + deviceIdentifiers);
@ -1887,7 +1882,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
removeEnrollmentDeviceDetail(conn, enrollmentIds); removeEnrollmentDeviceDetail(conn, enrollmentIds);
removeEnrollmentDeviceLocation(conn, enrollmentIds); removeEnrollmentDeviceLocation(conn, enrollmentIds);
removeEnrollmentDeviceInfo(conn, enrollmentIds); removeEnrollmentDeviceInfo(conn, enrollmentIds);
removeEnrollmentDeviceApplicationMapping(conn, enrollmentIds);
removeDeviceOperationResponse(conn, enrollmentIds); removeDeviceOperationResponse(conn, enrollmentIds);
removeEnrollmentOperationMapping(conn, enrollmentIds); removeEnrollmentOperationMapping(conn, enrollmentIds);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -2224,29 +2218,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} }
/***
* This method removes records of a given list of devices from the DM_DEVICE_APPLICATION_MAPPING table
* @param conn Connection object
* @param deviceIds list of device ids (primary keys)
* @throws DeviceManagementDAOException if deletion fails
*/
private void removeDeviceApplicationMapping(Connection conn, List<Integer> deviceIds)
throws DeviceManagementDAOException {
String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ?";
try {
if (!executeBatchOperation(conn, sql, deviceIds)) {
String msg = "Failed to remove device application mapping of of devices with deviceIds : " + deviceIds +
" while executing batch operation";
log.error(msg);
throw new DeviceManagementDAOException(msg);
}
} catch (SQLException e) {
String msg = "SQL error occurred while removing device application mapping of devices with deviceIds : "
+ deviceIds;
log.error(msg, e);
throw new DeviceManagementDAOException(msg, e);
}
}
/*** /***
* This method removes records of a given list of devices from the DM_DEVICE_POLICY_APPLIED table * This method removes records of a given list of devices from the DM_DEVICE_POLICY_APPLIED table
@ -2365,29 +2336,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} }
} }
/***
* This method removes records of a given list of enrollments from the DM_DEVICE_APPLICATION_MAPPING table
* @param conn Connection object
* @param enrollmentIds list of enrollment ids (primary keys)
* @throws DeviceManagementDAOException if deletion fails
*/
private void removeEnrollmentDeviceApplicationMapping(Connection conn, List<Integer> enrollmentIds)
throws DeviceManagementDAOException {
String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE ENROLMENT_ID = ?";
try {
if (!executeBatchOperation(conn, sql, enrollmentIds)) {
String msg = "Failed to remove enrollment device application mapping of devices with enrollmentIds : "
+ enrollmentIds + " while executing batch operation";
log.error(msg);
throw new DeviceManagementDAOException(msg);
}
} catch (SQLException e) {
String msg = "SQL error occurred while removing enrollment device application mapping of devices with " +
"enrollmentIds : " + enrollmentIds;
log.error(msg, e);
throw new DeviceManagementDAOException(msg, e);
}
}
/*** /***
* This method removes records of a given list of enrollments from the DM_DEVICE_OPERATION_RESPONSE table * This method removes records of a given list of enrollments from the DM_DEVICE_OPERATION_RESPONSE table

Loading…
Cancel
Save