Uploaded image for project: 'Webservices REST Module'
  1. Webservices REST Module
  2. RESTWS-422

Improve Validation handling of OpenMRS objects

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed
    • TBD
    • Resolution: Fixed
    • None
    • 2.5
    • None
    • None
    • Undetermined

    Description

      We'd like to make some changes in the webservices.rest module so that when you try to save something, and you get back Spring binding errors, the the client automatically sees a helpful field-by-field error result, with the correct 400 response status.

      Inconveniently, in openmrs-core, the ValidateUtil.validate(Object) method manually combines error messages into a single string. See https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/validator/ValidateUtil.java#L83 . The correct thing to do would be to also pass along the Errors object as part of the ValidationException.

      So, to make the change we need in webservices.rest, we need to either

      (a) change openmrs-core so a ValidationException holds a Spring errors object, backport this as far as 1.8.x, and have the next webservices.rest release depend on to-be-released versions of OpenMRS core.

      (b) duplicate the ValidationUtil.validate(Object) method in the webservices.rest module, with this small change; in the base DelegatingCrudResources class we will call this before calling save on an object (meaning that validation will happen twice for every create/update, once by webservices.rest, and again by core when we actually issue the service save call).

      We should do the change in (a) anyway, regardless of whether it is backported or not.

      Gliffy Diagrams

        Attachments

          Issue Links

            Activity

              People

                mogoodrich Mark Goodrich
                mogoodrich Mark Goodrich
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: