Fixes multiple device deleting issue

Fixes entgra/product-iots#656
corrective-policy
tcdlpds@gmail.com 4 years ago
parent e178cc081e
commit c88ec6077b

@ -150,6 +150,7 @@ import java.io.IOException;
import java.io.StringWriter;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
@ -613,7 +614,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
DeviceManagementDAOFactory.closeConnection();
}
try {
DeviceCacheKey deviceCacheKey;
for (Device device : existingDevices) {
if (!EnrolmentInfo.Status.REMOVED.equals(device.getEnrolmentInfo().getStatus())) {
@ -633,11 +633,12 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
if (deviceIdentifierMap.containsKey(device.getType())) {
deviceIdentifierMap.get(device.getType()).add(device.getDeviceIdentifier());
} else {
deviceIdentifierMap.put(device.getType(), Collections.singletonList(device.getDeviceIdentifier()));
deviceIdentifierMap.put(device.getType(),
new ArrayList<>(Collections.singletonList(device.getDeviceIdentifier())));
DeviceManager deviceManager = this.getDeviceManager(device.getType());
if (deviceManager == null) {
log.error("Device Manager associated with the device type '" + device.getType() +
"' is null. Therefore, not attempting method 'deleteDevice'");
log.error("Device Manager associated with the device type '" + device.getType()
+ "' is null. Therefore, not attempting method 'deleteDevice'");
return false;
}
deviceManagerMap.put(device.getType(), deviceManager);
@ -651,6 +652,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
if (log.isDebugEnabled()) {
log.debug("Permanently deleting the details of devices : " + validDeviceIdentifiers);
}
try {
DeviceManagementDAOFactory.beginTransaction();
//deleting device from the core
deviceDAO.deleteDevices(validDeviceIdentifiers, new ArrayList<>(deviceIds), enrollmentIds);

Loading…
Cancel
Save