We need to add unique code validation for adding supervisory nodes.
Now when user tries to create a new supervisory node using API (there is no edit/add page for Supervisory Nodes) and enters duplicated code he/she gets sql exception. Instead we need to introduce validation for code uniqueness and return human-readable validation error message.
The following response body is now returned in lieu of an exception:
Although this is much better, I'm under the impression that the message property should be more descriptive.
and : Although I'm not sure how you'd prioritize the above improvement, I failed the test run of OLMIS-3552.
, Please change the error message to say: "This Supervisory Node code already exists." Then the user should be directed back to the Create Supervisory Node page, so they can edit the supervisory node code.
I tested the ticket, and now everything works correctly. Please only add the changelog.
The changelog was added, so I will close the ticket.
I double/triple checked this ticket and agree that it can be considered done.
However the implementation of this ticket is not fully correct:
I pushed a small bit of code that covers the actual handling of the database exception - which this ticket /should/ have done.
I created a new issue, OLMIS-3570, to migrate away from the current inadequate Validation technique being used throughout this Service
Functionally, the normal user paths were fixed. However the root cause, handling the exception that arises from a DB constraint was not, even though that was pointed out in the comments here. As I wrote in OLMIS-3570, using Validation java code, for what is inherently a DB constraint logic, isn't appropriate (violates DRY) nor accurate (Validation Java code relies on transaction isolation level).