cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6331] Wrapping exceptions in Fault
Date Mon, 06 Apr 2015 21:21:22 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 3309231e4 -> 534ce5c38


[CXF-6331] Wrapping exceptions in Fault


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/534ce5c3
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/534ce5c3
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/534ce5c3

Branch: refs/heads/master
Commit: 534ce5c38e1e7220a81cbee9dc5e9b720433b5b5
Parents: 3309231
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Mon Apr 6 22:21:03 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Mon Apr 6 22:21:03 2015 +0100

----------------------------------------------------------------------
 .../validation/JAXRSBeanValidationInvoker.java  | 44 +++++++++++---------
 1 file changed, 25 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/534ce5c3/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/JAXRSBeanValidationInvoker.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/JAXRSBeanValidationInvoker.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/JAXRSBeanValidationInvoker.java
index 22fe956..f526c53 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/JAXRSBeanValidationInvoker.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/JAXRSBeanValidationInvoker.java
@@ -23,6 +23,7 @@ import java.util.List;
 
 import javax.ws.rs.core.Response;
 
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxrs.JAXRSInvoker;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Exchange;
@@ -40,29 +41,34 @@ public class JAXRSBeanValidationInvoker extends JAXRSInvoker {
         Message message = JAXRSUtils.getCurrentMessage();
         
         BeanValidationProvider theProvider = getProvider(message);
-        
-        if (isValidateServiceObject()) {
-            theProvider.validateBean(serviceObject);
-        }
-        
-        theProvider.validateParameters(serviceObject, m, params.toArray());
-        
-        Object response = super.invoke(exchange, serviceObject, m, params);
-        
-        if (response instanceof MessageContentsList) {
-            MessageContentsList list = (MessageContentsList)response;
-            if (list.size() == 1) {
-                Object entity = ((MessageContentsList)list).get(0);
-                
-                if (entity instanceof Response) {
-                    theProvider.validateReturnValue(serviceObject, m, ((Response)entity).getEntity());
   
-                } else {                
-                    theProvider.validateReturnValue(serviceObject, m, entity);
+        try {
+            if (isValidateServiceObject()) {
+                theProvider.validateBean(serviceObject);
+            }
+            
+            theProvider.validateParameters(serviceObject, m, params.toArray());
+            
+            Object response = super.invoke(exchange, serviceObject, m, params);
+            
+            if (response instanceof MessageContentsList) {
+                MessageContentsList list = (MessageContentsList)response;
+                if (list.size() == 1) {
+                    Object entity = ((MessageContentsList)list).get(0);
+                    
+                    if (entity instanceof Response) {
+                        theProvider.validateReturnValue(serviceObject, m, ((Response)entity).getEntity());
   
+                    } else {                
+                        theProvider.validateReturnValue(serviceObject, m, entity);
+                    }
                 }
             }
+            return response;
+        } catch (Fault ex) {
+            throw ex;
+        } catch (Throwable ex) {
+            throw new Fault(ex);
         }
         
-        return response;
     }
     
     protected BeanValidationProvider getProvider(Message message) {


Mime
View raw message