mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fix device enrollment failure
This commit is contained in:
parent
294bf8ae90
commit
12c48540d8
@ -994,16 +994,19 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Group devices to the group: " + groupId);
|
log.debug("Group devices to the group: " + groupId);
|
||||||
}
|
}
|
||||||
Device device;
|
|
||||||
try {
|
try {
|
||||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
GroupManagementDAOFactory.beginTransaction();
|
List<String> deviceIdentifierList = deviceIdentifiers.stream()
|
||||||
for (DeviceIdentifier deviceIdentifier : deviceIdentifiers) {
|
.map(DeviceIdentifier::getId)
|
||||||
device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
getDevice(deviceIdentifier, false);
|
List<Device> devicesList = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider()
|
||||||
if (device == null) {
|
.getDeviceByIdList(deviceIdentifierList);
|
||||||
throw new DeviceNotFoundException("Device not found for id '" + deviceIdentifier.getId() + "'");
|
if (devicesList == null || devicesList.isEmpty()) {
|
||||||
|
throw new DeviceNotFoundException("Couldn't find any devices for the given deviceIdentifiers '" + deviceIdentifiers + "'");
|
||||||
}
|
}
|
||||||
|
GroupManagementDAOFactory.beginTransaction();
|
||||||
|
for (Device device : devicesList) {
|
||||||
if (!this.groupDAO.isDeviceMappedToGroup(groupId, device.getId(), tenantId)) {
|
if (!this.groupDAO.isDeviceMappedToGroup(groupId, device.getId(), tenantId)) {
|
||||||
this.groupDAO.addDevice(groupId, device.getId(), tenantId);
|
this.groupDAO.addDevice(groupId, device.getId(), tenantId);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user