cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r826053 - in /cxf/trunk: rt/core/src/main/java/org/apache/cxf/interceptor/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/ rt/frontend/jaxws/src/main/java/org/apache/cxf/ja...
Date Fri, 16 Oct 2009 19:54:08 GMT
Author: dkulp
Date: Fri Oct 16 19:54:08 2009
New Revision: 826053

URL: http://svn.apache.org/viewvc?rev=826053&view=rev
Log:
[CXF-1725] Some fault detail handling cleanup

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/FaultOutInterceptor.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/AbstractJAXWSMethodInvoker.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/DocLitBareCodeFirstServiceImpl.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/FaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/FaultOutInterceptor.java?rev=826053&r1=826052&r2=826053&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/FaultOutInterceptor.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/FaultOutInterceptor.java Fri
Oct 16 19:54:08 2009
@@ -74,14 +74,28 @@
             try {
                 if (isDOMSupported(db)) {
                     DataWriter<Node> writer = db.createWriter(Node.class);
-    
-                    writer.write(bean, part, f.getOrCreateDetail());
+
+                    if (f.hasDetails()) {
+                        writer.write(bean, part, f.getDetail());
+                    } else {
+                        writer.write(bean, part, f.getOrCreateDetail());
+                        if (!f.getDetail().hasChildNodes()) {
+                            f.setDetail(null);
+                        }
+                    }
                 } else {
-                    XMLStreamWriter xsw = new W3CDOMStreamWriter(f.getOrCreateDetail());
-    
-                    DataWriter<XMLStreamWriter> writer = db.createWriter(XMLStreamWriter.class);
-    
-                    writer.write(bean, part, xsw);
+                    if (f.hasDetails()) {
+                        XMLStreamWriter xsw = new W3CDOMStreamWriter(f.getDetail());
+                        DataWriter<XMLStreamWriter> writer = db.createWriter(XMLStreamWriter.class);
+                        writer.write(bean, part, xsw);
+                    } else {
+                        XMLStreamWriter xsw = new W3CDOMStreamWriter(f.getOrCreateDetail());
+                        DataWriter<XMLStreamWriter> writer = db.createWriter(XMLStreamWriter.class);
+                        writer.write(bean, part, xsw);
+                        if (!f.getDetail().hasChildNodes()) {
+                            f.setDetail(null);
+                        }
+                    }
                 }
     
                 f.setMessage(ex.getMessage());

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/AbstractJAXWSMethodInvoker.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/AbstractJAXWSMethodInvoker.java?rev=826053&r1=826052&r2=826053&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/AbstractJAXWSMethodInvoker.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/AbstractJAXWSMethodInvoker.java
Fri Oct 16 19:54:08 2009
@@ -76,7 +76,9 @@
                                             ex,
                                             sfe.getFault().getFaultCodeAsQName());
             fault.setRole(sfe.getFault().getFaultActor());
-            fault.setDetail(sfe.getFault().getDetail());
+            if (sfe.getFault().hasDetail()) {
+                fault.setDetail(sfe.getFault().getDetail());
+            }
             
             return fault;
         }

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java?rev=826053&r1=826052&r2=826053&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java Fri
Oct 16 19:54:08 2009
@@ -208,16 +208,17 @@
             soapFault.setFaultCode(((SoapFault)ex).getFaultCode());
             soapFault.setFaultActor(((SoapFault)ex).getRole());
 
-            Node nd = soapFault.getOwnerDocument().importNode(((SoapFault)ex).getOrCreateDetail(),
-                                                              true);
-            nd = nd.getFirstChild();
-            soapFault.addDetail();
-            while (nd != null) {
-                Node next = nd.getNextSibling();
-                soapFault.getDetail().appendChild(nd);
-                nd = next;
+            if (((SoapFault)ex).hasDetails()) {
+                Node nd = soapFault.getOwnerDocument().importNode(((SoapFault)ex).getDetail(),
+                                                                  true);
+                nd = nd.getFirstChild();
+                soapFault.addDetail();
+                while (nd != null) {
+                    Node next = nd.getNextSibling();
+                    soapFault.getDetail().appendChild(nd);
+                    nd = next;
+                }
             }
-
         } else {
             String msg = ex.getMessage();
             if (msg != null) {

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java?rev=826053&r1=826052&r2=826053&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
Fri Oct 16 19:54:08 2009
@@ -414,7 +414,9 @@
                                       sfe,
                                       sfe.getFault().getFaultCodeAsQName());
         sf.setRole(sfe.getFault().getFaultActor());
-        sf.setDetail(sfe.getFault().getDetail());
+        if (sfe.getFault().hasDetail()) {
+            sf.setDetail(sfe.getFault().getDetail());
+        }
         
         return sf;        
     }
@@ -447,15 +449,29 @@
                 soapFault.setFaultString(sf.getFault().getFaultString());
                 soapFault.setFaultCode(sf.getFault().getFaultCode());
                 soapFault.setFaultActor(sf.getFault().getFaultActor());
-                Node nd = soapMessage.getSOAPPart().importNode(sf.getFault().getDetail().getFirstChild(),
-                                                               true);
-                soapFault.addDetail().appendChild(nd);
+                if (sf.getFault().hasDetail()) {
+                    Node nd = soapMessage.getSOAPPart().importNode(sf.getFault().getDetail(),
+                                                                   true);
+                    nd = nd.getFirstChild();
+                    soapFault.addDetail();
+                    while (nd != null) {
+                        soapFault.getDetail().appendChild(nd);
+                        nd = nd.getNextSibling();
+                    }
+                }
             } else if (exception instanceof Fault) {
                 SoapFault sf = SoapFault.createFault((Fault)exception, ((SoapMessage)msg).getVersion());
                 soapFault.setFaultString(sf.getReason());
                 soapFault.setFaultCode(sf.getFaultCode());
-                Node nd = soapMessage.getSOAPPart().importNode(sf.getOrCreateDetail(), true);
-                soapFault.addDetail().appendChild(nd);
+                if (sf.hasDetails()) {
+                    soapFault.addDetail();
+                    Node nd = soapMessage.getSOAPPart().importNode(sf.getDetail(), true);
+                    nd = nd.getFirstChild();
+                    while (nd != null) {
+                        soapFault.getDetail().appendChild(nd);
+                        nd = nd.getNextSibling();
+                    }
+                }
             } else {
                 soapFault.setFaultCode(new QName("http://cxf.apache.org/faultcode", "HandlerFault"));
                 soapFault.setFaultString(exception.getMessage());

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java?rev=826053&r1=826052&r2=826053&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java
Fri Oct 16 19:54:08 2009
@@ -142,8 +142,15 @@
                         .getVersion());
                     soapFault.setFaultString(sf.getReason());
                     soapFault.setFaultCode(sf.getFaultCode());
-                    Node nd = originalMsg.getSOAPPart().importNode(sf.getOrCreateDetail(),
true);
-                    soapFault.addDetail().appendChild(nd);
+                    if (sf.hasDetails()) {
+                        soapFault.addDetail();
+                        Node nd = originalMsg.getSOAPPart().importNode(sf.getDetail(), true);
+                        nd = nd.getFirstChild();
+                        while (nd != null) {
+                            soapFault.getDetail().appendChild(nd);
+                            nd = nd.getNextSibling();
+                        }
+                    }
                 } else {
                     soapFault.setFaultString(exception.getMessage());
                     soapFault.setFaultCode(new QName("http://cxf.apache.org/faultcode", "HandleFault"));

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java?rev=826053&r1=826052&r2=826053&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
Fri Oct 16 19:54:08 2009
@@ -109,7 +109,14 @@
                 OperationInfo op = message.getExchange().get(BindingOperationInfo.class).getOperationInfo();
                 QName faultName = getFaultName(fault, cause.getClass(), op);
                 MessagePartInfo part = getFaultMessagePart(faultName, op);
-                writer.write(faultInfo, part, f.getOrCreateDetail());
+                if (f.hasDetails()) {
+                    writer.write(faultInfo, part, f.getDetail());
+                } else {
+                    writer.write(faultInfo, part, f.getOrCreateDetail());
+                    if (!f.getDetail().hasChildNodes()) {
+                        f.setDetail(null);
+                    }
+                }
     
                 f.setMessage(ex.getMessage());
             } catch (Exception nex) {

Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java?rev=826053&r1=826052&r2=826053&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
(original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
Fri Oct 16 19:54:08 2009
@@ -201,6 +201,13 @@
             assertEquals("mr.actor", ex.getFault().getFaultActor());
             assertEquals("test", ex.getFault().getDetail().getFirstChild().getLocalName());
         }
+        req.setName("emptyfault");
+        try {
+            resp = port.greetMe(req);
+            fail("did not get fault back");
+        } catch (SOAPFaultException ex) {
+            assertFalse(ex.getFault().hasDetail());
+        }
     } 
     
 

Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/DocLitBareCodeFirstServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/DocLitBareCodeFirstServiceImpl.java?rev=826053&r1=826052&r2=826053&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/DocLitBareCodeFirstServiceImpl.java
(original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/DocLitBareCodeFirstServiceImpl.java
Fri Oct 16 19:54:08 2009
@@ -45,6 +45,8 @@
             } catch (SOAPException ex) {
                 throw new WebServiceException(ex);
             }
+        } else if ("emptyfault".equals(gmr.getName())) {
+            throw new RuntimeException("Empty!");
         }
         
         GreetMeResponse resp = new GreetMeResponse();



Mime
View raw message