Re: Using JAXRSBeanValidationOutInterceptor causes Fault when validation of an object fails

2016-10-18 Thread tomstark
Yeah, I was a little surprised that manipulating the MessageContentsList
directly didn't confuse the underlying layers.  Seemed like I might have
been potentially "pulling the rug out from underneath" the lower layers. 
Glad it worked.

As for the validation sequence, although it seems as though there is already
code to prevent an infinite loop of validation errors, perhaps it doesn't
make as much sense to validate again since there is the potential to lose
the original constraint violations.



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Using-JAXRSBeanValidationOutInterceptor-causes-Fault-when-validation-of-an-object-fails-tp5773878p5774018.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Using JAXRSBeanValidationOutInterceptor causes Fault when validation of an object fails

2016-10-18 Thread Sergey Beryozkin

Thanks.
By the way, I wonder if the fix in CXF will need to be different after 
all. See the JAXRS out interceptor validates the JAX-RS *method 
response*, and if the validation fails and the custom Response is 
created and the out chain is run again, the out validating interceptor 
now still attempts to validate (via the extension) the *method 
response*, which a custom entity which was created by your mapper does 
not represent, rather it is a custom representation of the violations data.
I think, by default, JAXRSBeanValidationOutInterceptor should ignore the 
data coming after the optional 2nd run, though the property will be 
there to do the 2nd validation


Cheers, Sergey

On 17/10/16 22:28, tomstark wrote:

Slight mod to what you have:

JAXRSUtils.getCurrentMessage().setContent(List.class, new
MessageContentsList(resp));

Using the "put" method did not work but the above code works just fine and I
was able to see the original outbound violations in an error response.

Thanks.



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Using-JAXRSBeanValidationOutInterceptor-causes-Fault-when-validation-of-an-object-fails-tp5773878p5773971.html
Sent from the cxf-user mailing list archive at Nabble.com.




--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/


Re: Using JAXRSBeanValidationOutInterceptor causes Fault when validation of an object fails

2016-10-17 Thread tomstark
Slight mod to what you have:

JAXRSUtils.getCurrentMessage().setContent(List.class, new
MessageContentsList(resp));

Using the "put" method did not work but the above code works just fine and I
was able to see the original outbound violations in an error response.

Thanks.



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Using-JAXRSBeanValidationOutInterceptor-causes-Fault-when-validation-of-an-object-fails-tp5773878p5773971.html
Sent from the cxf-user mailing list archive at Nabble.com.



Re: Using JAXRSBeanValidationOutInterceptor causes Fault when validation of an object fails

2016-10-17 Thread Sergey Beryozkin
Right, in that case please try JAXRSBeanvalidationInvoker, or, may be 
even better, try to add this line in your exception mapper:


JAXRSUtils.getCurrentMessage().put(List.class, new 
MessageContentsList(newResponse));


You will be able to remove this line once CXF-7091 gets resolved

Thanks, Sergey
On 17/10/16 15:07, tomstark wrote:

Tried the BeanValidationInInterceptor and BeanValidationOutInterceptor with
the the Out interceptor configured like this:

BeanValidationOutInterceptor bean = new BeanValidationOutInterceptor();
bean.setProvider(new BeanValidationProvider(new
HibernateBeanValidationProviderResolver()));
bean.setEnforceOnlyBeanConstraints(true);

Unfortunately, the Out interceptor tried to validate the "ResponseImpl", not
the entity contained within the response.  Anything I can to change that?

Thanks,

Tom



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Using-JAXRSBeanValidationOutInterceptor-causes-Fault-when-validation-of-an-object-fails-tp5773878p5773958.html
Sent from the cxf-user mailing list archive at Nabble.com.




--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/


Re: Using JAXRSBeanValidationOutInterceptor causes Fault when validation of an object fails

2016-10-17 Thread tomstark
Tried the BeanValidationInInterceptor and BeanValidationOutInterceptor with
the the Out interceptor configured like this:

BeanValidationOutInterceptor bean = new BeanValidationOutInterceptor();
bean.setProvider(new BeanValidationProvider(new
HibernateBeanValidationProviderResolver()));
bean.setEnforceOnlyBeanConstraints(true);

Unfortunately, the Out interceptor tried to validate the "ResponseImpl", not
the entity contained within the response.  Anything I can to change that?

Thanks,

Tom



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Using-JAXRSBeanValidationOutInterceptor-causes-Fault-when-validation-of-an-object-fails-tp5773878p5773958.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Using JAXRSBeanValidationOutInterceptor causes Fault when validation of an object fails

2016-10-14 Thread Sergey Beryozkin

Or try JAXRSBeanValidationInvoker (register it with jaxrs:invoker)

Sergey
On 14/10/16 22:17, Sergey Beryozkin wrote:

Hi

See
https://issues.apache.org/jira/browse/CXF-7091

We are voting for a 3.1.8 release right now, so I can only guess at this
stage that 3.1.9 will be out by the end of Dec or early January.

Please try CXF interceptors in meantime

Cheers, Sergey
On 14/10/16 21:59, tomstark wrote:

Hi Sergey,

Thanks for the info.  I'll try your suggestion.

Do you have a time frame for when 3.1.9 would be released?  Also, can you
reply with the bug number so I can track it?  Depending on timing, I may
have to wait to pick up the fix until our next release.

Thanks.



--
View this message in context:
http://cxf.547215.n5.nabble.com/Using-JAXRSBeanValidationOutInterceptor-causes-Fault-when-validation-of-an-object-fails-tp5773878p5773912.html

Sent from the cxf-user mailing list archive at Nabble.com.






--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/


Re: Using JAXRSBeanValidationOutInterceptor causes Fault when validation of an object fails

2016-10-14 Thread Sergey Beryozkin

Hi

See
https://issues.apache.org/jira/browse/CXF-7091

We are voting for a 3.1.8 release right now, so I can only guess at this 
stage that 3.1.9 will be out by the end of Dec or early January.


Please try CXF interceptors in meantime

Cheers, Sergey
On 14/10/16 21:59, tomstark wrote:

Hi Sergey,

Thanks for the info.  I'll try your suggestion.

Do you have a time frame for when 3.1.9 would be released?  Also, can you
reply with the bug number so I can track it?  Depending on timing, I may
have to wait to pick up the fix until our next release.

Thanks.



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Using-JAXRSBeanValidationOutInterceptor-causes-Fault-when-validation-of-an-object-fails-tp5773878p5773912.html
Sent from the cxf-user mailing list archive at Nabble.com.





Re: Using JAXRSBeanValidationOutInterceptor causes Fault when validation of an object fails

2016-10-14 Thread tomstark
Hi Sergey,

Thanks for the info.  I'll try your suggestion.

Do you have a time frame for when 3.1.9 would be released?  Also, can you
reply with the bug number so I can track it?  Depending on timing, I may
have to wait to pick up the fix until our next release.

Thanks.



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Using-JAXRSBeanValidationOutInterceptor-causes-Fault-when-validation-of-an-object-fails-tp5773878p5773912.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Using JAXRSBeanValidationOutInterceptor causes Fault when validation of an object fails

2016-10-14 Thread Sergey Beryozkin

Hi

Yes, the response filters are expected to be run again after an 
exception has been mapped. The fact that the abstract CXF filter sees 
the original value on the 2nd run is a bug, in most case the default 
mapper which only creates an HTTP error is sufficient. So I guess this 
is why this particular issue has only been detected now.


At this stage using non-JAX-RS CXF interceptors should do it, try setting

BeanValidationInInterceptor
(in jaxrs:inInterceptors)
BeanValidationOutInterceptor
(in jaxrs:outInterceptors)

ValidationExceptionMapper

I'll address the 2nd run issue for 3.1.9

Cheers, Sergey

On 14/10/16 17:58, tomstark wrote:

I'm trying to use the JAXRSBeanValidationOutInterceptor with a customized
ValidationExceptionMapper but it throws a Fault when processing instead of
returning a response with the violations.

Here is the scenario:
When a Response is built with an entity object that has violations, the
interceptor correctly runs and throws the
ResponseConstraintViolationException with the list of violations.  This is
then handled by the ValidationExceptionMapper which builds another Response
object with a different object for the entity object (our API error object).
That in turn is also sent through the same set of outbound interceptors
causing the validation to run again.  When the validation is run again, in
the AbstractValidationInterceptor.handleMessage method the code gets the
MessageContentsList to pass to the handleValidation method.

Problem:  The MessageContentsList contains the first entity from the initial
Response instead of the new entity from the new Response.  Since I don't
have direct access to the Message object, I don't think I can affect the
MessageContentsList.  What finally ends up happening is an internal CXF
Fault is thrown instead the response that contains the violations.

Other details:
I set BeanValidationOutInterceptor.enforceOnlyBeanConstraints to true
The order of the interceptors is:  (there are other mappers/filters but
after stepping through the code, I don't think they have any effect here)
JAXRSBeanValidationInInterceptor
JAXRSBeanValidationOutInterceptor
ValidationExceptionMapper

How do I affect the MessageContentsList to return the new entity so the
validation can run on the new object instead of the one that already failed?


Thanks,

Tom




--
View this message in context: 
http://cxf.547215.n5.nabble.com/Using-JAXRSBeanValidationOutInterceptor-causes-Fault-when-validation-of-an-object-fails-tp5773878.html
Sent from the cxf-user mailing list archive at Nabble.com.