mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'device-delete-fix' into 'master'
Fix device delete ## Purpose > The purpose of this PR is to fix https://gitlab.com/entgra/product-iots/-/issues/510 ## Goals > Fix device permanent delete failing issue ## Approach > Add method to delete records of DM_DEVICE_OPERATION_RESPONSE_LARGE table ## Security checks - Followed secure coding standards? (Yes) - Ran FindSecurityBugs plugin and verified report? (No) - Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets? (Yes) ## Related MRs > N/A ## Test environment > Ubuntu 18.04 and MySql 5.7 ## Learning > N/A See merge request entgra/carbon-device-mgt!540
This commit is contained in:
commit
8414679608
@ -1912,12 +1912,14 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
||||
removeEnrollmentDeviceDetail(conn, enrollmentIds);
|
||||
removeEnrollmentDeviceLocation(conn, enrollmentIds);
|
||||
removeEnrollmentDeviceInfo(conn, enrollmentIds);
|
||||
removeDeviceLargeOperationResponse(conn, enrollmentIds);
|
||||
removeDeviceOperationResponse(conn, enrollmentIds);
|
||||
removeEnrollmentOperationMapping(conn, enrollmentIds);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Successfully removed enrollment device details, enrollment device location," +
|
||||
"enrollment device info, enrollment device application mapping, " +
|
||||
"enrollment device operation response, enrollment operation mapping data of " +
|
||||
"enrollment device operation large response, enrollment device " +
|
||||
"operation response, enrollment operation mapping data of " +
|
||||
"devices with identifiers: " + deviceIdentifiers);
|
||||
}
|
||||
removeDeviceEnrollment(conn, deviceIds);
|
||||
@ -2397,8 +2399,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
||||
*/
|
||||
private void removeDeviceOperationResponse(Connection conn, List<Integer> enrollmentIds)
|
||||
throws DeviceManagementDAOException {
|
||||
String sql = "DELETE FROM DM_DEVICE_OPERATION_RESPONSE WHERE ENROLMENT_ID = ?";
|
||||
try {
|
||||
String sql = "DELETE FROM DM_DEVICE_OPERATION_RESPONSE WHERE ENROLMENT_ID = ?";
|
||||
if (!executeBatchOperation(conn, sql, enrollmentIds)) {
|
||||
String msg = "Failed to remove device operation response of devices with enrollmentIds : "
|
||||
+ enrollmentIds + " while executing batch operation";
|
||||
@ -2413,6 +2415,29 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
||||
}
|
||||
}
|
||||
|
||||
private void removeDeviceLargeOperationResponse(Connection conn, List<Integer> enrollmentIds)
|
||||
throws DeviceManagementDAOException {
|
||||
String sql = "DELETE DM_DEVICE_OPERATION_RESPONSE_LARGE " +
|
||||
"FROM DM_DEVICE_OPERATION_RESPONSE_LARGE " +
|
||||
"INNER JOIN DM_DEVICE_OPERATION_RESPONSE ON DM_DEVICE_OPERATION_RESPONSE_LARGE.ID = " +
|
||||
"DM_DEVICE_OPERATION_RESPONSE.ID " +
|
||||
"WHERE ENROLMENT_ID = ?";
|
||||
try {
|
||||
if (!executeBatchOperation(conn, sql, enrollmentIds)) {
|
||||
String msg = "Failed to remove device large operation response 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 large device operation response 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_ENROLMENT_OP_MAPPING table
|
||||
* @param conn Connection object
|
||||
|
||||
Loading…
Reference in New Issue
Block a user