Fix #742 by extracting validation and business logic from the PushDeviceController.
There are two new service classes. PushDeviceService is called right away by controller, it handles validation or fetching credential entity if needed. This service class uses DeviceRegistrationService which finally communicates with the devices repository. The intention of this split is to reduce the complexity and to benefit from @Retryable annotation.
Except for the DeviceRegistrationService#updateStatus no significant changes were applied (just moved). The updateStatus were modified to increase readability of the code. All the refactored code is now covered with tests.
The default value for retry attempts was decreased from 3 to 2, as that number is sufficient by default.
There was also a bug regarding /push/device/create/multi endpoint - when an activationId was repeated in single request, the server returned a constraint violation error. This is now fixed by distinct filter in DeviceRegistrationService#createOrUpdateDevices.
Fix #742 by extracting validation and business logic from the
PushDeviceController
.There are two new service classes.
PushDeviceService
is called right away by controller, it handles validation or fetching credential entity if needed. This service class usesDeviceRegistrationService
which finally communicates with the devices repository. The intention of this split is to reduce the complexity and to benefit from@Retryable
annotation.Except for the
DeviceRegistrationService#updateStatus
no significant changes were applied (just moved). TheupdateStatus
were modified to increase readability of the code. All the refactored code is now covered with tests.The default value for retry attempts was decreased from 3 to 2, as that number is sufficient by default.
There was also a bug regarding
/push/device/create/multi
endpoint - when an activationId was repeated in single request, the server returned a constraint violation error. This is now fixed by distinct filter inDeviceRegistrationService#createOrUpdateDevices
.