[
https://issues.apache.org/jira/browse/CXF-5401?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andriy Redko updated CXF-5401:
------------------------------
Attachment: patch-response-validation.txt
Hi Sergey,
I have been iterating over Response validation and would say that your idea
with Response.getEntity() is the best way to go at the moment. We should be
aware that we exploit an implementation, specific to Hibernate Validator: it
does not validate if method's return type and actual return value passed for
validation are compatible. And, because of that, all the validation constraints
declared for method are applicable to actual return value: that means we should
not do anything at all aside passing Response.getEntity(). That's why as part
of the patch I have removed some code.
More generic solution would be to add constraints to Response class
programmatically. Unfortunately, this is provider-specific (also highlighted in
JSR-349 spec) and I decided not to take this way right now.
Also, I have encountered one issue which patch addresses as well:
if both parameters validation (in) and return value validation (out) fail, it
causes two exceptions to be raised: ConstraintViolationException and then
ResponseConstraintViolationException. Because of that, initial
ConstraintViolationException is being lost and instead of 400 server always
return 500. I did a small modification to apply return value validation only
for successful responses.
Please review the patch when you have time.
Thanks,.
Andriy.
> Better support for validating the entities wrapped in JAX-RS Response
> ---------------------------------------------------------------------
>
> Key: CXF-5401
> URL: https://issues.apache.org/jira/browse/CXF-5401
> Project: CXF
> Issue Type: Improvement
> Reporter: Sergey Beryozkin
> Attachments: patch-response-validation.txt
>
>
> At the moment Response entities can only be validated against the rules
> attached to the entity properties. Method-level constraints (ex, NotNull) can
> not be applied yet.
> We need to either offer a support for few well-known constraints (NotNull,
> Null, etc) or come up with some generic code to get all the available
> constraints validated
--
This message was sent by Atlassian JIRA
(v6.1#6144)