Fetch enrollment Id if it is not already in the device

merge-requests/713/head
Charitha Goonetilleke 4 years ago
parent 55c3f93deb
commit 4943635a61

@ -1973,16 +1973,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
@Override @Override
public void updateOperation(Device device, Operation operation) throws OperationManagementException { public void updateOperation(Device device, Operation operation) throws OperationManagementException {
EnrolmentInfo enrolmentInfo = device.getEnrolmentInfo();
if (enrolmentInfo == null) {
throw new OperationManagementException(
"Device not found for device id:" + device.getDeviceIdentifier() + " " + "type:" +
device.getType());
}
try { try {
pluginRepository.getOperationManager(device.getType(), this.getTenantId()) EnrolmentInfo enrolmentInfo = device.getEnrolmentInfo();
.updateOperation(device.getEnrolmentInfo().getId(), operation, if (enrolmentInfo == null || device.getEnrolmentInfo().getId() <= 0) {
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); pluginRepository.getOperationManager(device.getType(), this.getTenantId())
.updateOperation(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()),
operation);
} else {
pluginRepository.getOperationManager(device.getType(), this.getTenantId())
.updateOperation(device.getEnrolmentInfo().getId(), operation,
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
}
if (DeviceManagerUtil.isPublishOperationResponseEnabled()) { if (DeviceManagerUtil.isPublishOperationResponseEnabled()) {
List<String> permittedOperations = DeviceManagerUtil.getEnabledOperationsForResponsePublish(); List<String> permittedOperations = DeviceManagerUtil.getEnabledOperationsForResponsePublish();
if (permittedOperations.contains(operation.getCode()) if (permittedOperations.contains(operation.getCode())

Loading…
Cancel
Save