Fetch enrollment Id if it is not already in the device

revert-70ac1926
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 {
EnrolmentInfo enrolmentInfo = device.getEnrolmentInfo();
if (enrolmentInfo == null || device.getEnrolmentInfo().getId() <= 0) {
pluginRepository.getOperationManager(device.getType(), this.getTenantId())
.updateOperation(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()),
operation);
} else {
pluginRepository.getOperationManager(device.getType(), this.getTenantId()) pluginRepository.getOperationManager(device.getType(), this.getTenantId())
.updateOperation(device.getEnrolmentInfo().getId(), operation, .updateOperation(device.getEnrolmentInfo().getId(), operation,
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); 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