Ori Liel has submitted this change and it was merged. Change subject: restapi: Return Additional Info For 400 Messages (#867794) ......................................................................
restapi: Return Additional Info For 400 Messages (#867794) When user issues a POST or PUT request, and the body is malformed, the application will identify, according to the context, what the user was trying to do, and return the correct usage from RSDL. This patch includes work to make RsdlBuilder a stand-alone tool which does not require the application server. The solution does not require this direcly, but it is better structured this way. Right now the solution does not apply for YAML format, because of other issues we have with Yaml format, but it can very easily be used also for Yaml in the future. Example of output: POST .../api/tags asdfas dlkh (some malformed request body) <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <usage_message> <message>Request syntactically incorrect. See the link description below for the correct usage:</message> <detailedLink href="/ovirt-engine/api/tags" rel="add"> <description>add a new tag to the system</description> <request> <http_method>POST</http_method> <headers> <header required="true"> <name>Content-Type</name> <value>application/xml|json</value> </header> <header required="false"> <name>Correlation-Id</name> <value>any string</value> </header> </headers> <body> <type>Tag</type> <parameters_set> <parameter required="true" type="xs:string"> <name>tag.name</name> </parameter> <parameter required="false" type="xs:string"> <name>tag.description</name> </parameter> <parameter required="false" type="xs:string"> <name>tag.parent.tag.id|name</name> </parameter> </parameters_set> </body> </request> <response> <type>Tag</type> </response> </detailedLink> </usage_message> Bug-Url: http://bugzilla.redhat.com/867794 Change-Id: Ic7a6da4fbb00ea5f1e6919ddfe21dd7b3dd126fd Signed-off-by: Ori Liel <ol...@redhat.com> --- M backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/BackendApplication.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendApiResource.java A backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/JaxbExceptionMapper.java A backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/JsonExceptionMapper.java A backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/UsageFinder.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/rsdl/RsdlBuilder.java A backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/util/ApiRootLinksCreator.java 8 files changed, 301 insertions(+), 101 deletions(-) Approvals: Ori Liel: Verified; Looks good to me, approved -- To view, visit http://gerrit.ovirt.org/23017 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic7a6da4fbb00ea5f1e6919ddfe21dd7b3dd126fd Gerrit-PatchSet: 4 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Ori Liel <ol...@redhat.com> Gerrit-Reviewer: Juan Hernandez <juan.hernan...@redhat.com> Gerrit-Reviewer: Michael Pasternak <mpast...@redhat.com> Gerrit-Reviewer: Ori Liel <ol...@redhat.com> Gerrit-Reviewer: oVirt Jenkins CI Server _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches