cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andreasm...@apache.org
Subject svn commit: r525943 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/message/ rt/core/src/main/java/org/apache/cxf/interceptor/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/ rt/ws/addr/src/main/java/org/apache/cxf/ws/addres...
Date Thu, 05 Apr 2007 19:34:12 GMT
Author: andreasmyth
Date: Thu Apr  5 12:34:10 2007
New Revision: 525943

URL: http://svn.apache.org/viewvc?view=rev&rev=525943
Log:
Fixes to fault processing to ensure that:
* interceptors on the fault chain can safely use MessageUtils.isRequestor()
* addressing headers decoded by a MAPCodec on the in chain are available to interceptors on
the in fault chain after switching over to the latter
* the headers element is available to (soap) interceptors on the in fault chain

Added:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java
      - copied, changed from r525554, incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java
Removed:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/ExchangeImpl.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientOutFaultObserver.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptorTest.java
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java
    incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptorTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/wsa_interceptors.xml

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/ExchangeImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/ExchangeImpl.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/ExchangeImpl.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/ExchangeImpl.java Thu Apr
 5 12:34:10 2007
@@ -76,7 +76,9 @@
 
     public void setInMessage(Message m) {
         inMessage = m;
-        m.setExchange(this);
+        if (null != m) {
+            m.setExchange(this);
+        }
     }
 
     public void setConduit(Conduit c) {

Copied: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java
(from r525554, incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java?view=diff&rev=525943&p1=incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java&r1=525554&p2=incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java
Thu Apr  5 12:34:10 2007
@@ -28,32 +28,47 @@
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
-import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.phase.PhaseInterceptorChain;
 import org.apache.cxf.transport.MessageObserver;
 
-public abstract class AbstractFaultChainIntiatorObserver implements MessageObserver {
+public abstract class AbstractFaultChainInitiatorObserver implements MessageObserver {
     
-    private static final Logger LOG = Logger.getLogger(AbstractFaultChainIntiatorObserver.class.getName());
+    private static final Logger LOG = Logger.getLogger(AbstractFaultChainInitiatorObserver.class.getName());
     
     private Bus bus;
 
-    public AbstractFaultChainIntiatorObserver(Bus bus) {
+    public AbstractFaultChainInitiatorObserver(Bus bus) {
         this.bus = bus;
     }
 
-    public void onMessage(Message m) {
-        Message faultMessage = getFaultMessage(m);
-        Exchange ex = m.getExchange();
-        if (faultMessage == null) {
-            Endpoint ep = ex.get(Endpoint.class);
-            faultMessage = ep.getBinding().createMessage();
-        }
-        
-        setFaultMessage(m, faultMessage);
-        MessageImpl.copyContent(m, faultMessage);
+    public void onMessage(Message message) {
+      
+        assert  null != message;
+        Exchange exchange = message.getExchange();
+
+        Message faultMessage = null;
 
+        // now that we have switched over to the fault chain,
+        // prevent any further operations on the in/out message 
+
+        if (isOutboundObserver()) {
+            Exception ex = message.getContent(Exception.class);
+            faultMessage = exchange.getOutMessage();
+            if (null == faultMessage) {
+                faultMessage = exchange.get(Endpoint.class).getBinding().createMessage();
+            }
+            faultMessage.setContent(Exception.class, ex);
+            assert exchange.get(Exception.class) == ex;
+            exchange.setOutMessage(null);
+            exchange.setOutFaultMessage(faultMessage);
+        } else {
+            faultMessage = message;
+            exchange.setInMessage(null);
+            exchange.setInFaultMessage(faultMessage);
+        }          
+         
+       
         // setup chain
         PhaseInterceptorChain chain = new PhaseInterceptorChain(getPhases());
         initializeInterceptors(faultMessage.getExchange(), chain);
@@ -62,7 +77,7 @@
         try {
             chain.doIntercept(faultMessage);
         } catch (Exception exc) {
-            LogUtils.log(LOG, Level.INFO, "Error occured during error handling, give up!",
ex);
+            LogUtils.log(LOG, Level.INFO, "Error occured during error handling, give up!",
exc);
         }
     }
 
@@ -78,17 +93,4 @@
         return bus;
     }
 
-    private Message getFaultMessage(Message original) {
-        return isOutboundObserver()
-               ? original.getExchange().getOutFaultMessage()
-               : original.getExchange().getInFaultMessage();
-    }
-
-    private void setFaultMessage(Message original, Message fault) {
-        if (isOutboundObserver()) {
-            original.getExchange().setOutFaultMessage(fault);
-        } else {
-            original.getExchange().setInFaultMessage(fault);
-        }
-    }
 }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientOutFaultObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientOutFaultObserver.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientOutFaultObserver.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientOutFaultObserver.java
Thu Apr  5 12:34:10 2007
@@ -26,7 +26,7 @@
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.phase.PhaseManager;
 
-public class ClientOutFaultObserver extends AbstractFaultChainIntiatorObserver {
+public class ClientOutFaultObserver extends AbstractFaultChainInitiatorObserver {
 
     
     public ClientOutFaultObserver(Bus bus) {

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java
Thu Apr  5 12:34:10 2007
@@ -27,7 +27,7 @@
 import org.apache.cxf.phase.PhaseInterceptorChain;
 import org.apache.cxf.phase.PhaseManager;
 
-public class InFaultChainInitiatorObserver extends AbstractFaultChainIntiatorObserver {
+public class InFaultChainInitiatorObserver extends AbstractFaultChainInitiatorObserver {
 
     public InFaultChainInitiatorObserver(Bus bus) {
         super(bus);

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java
Thu Apr  5 12:34:10 2007
@@ -27,7 +27,7 @@
 import org.apache.cxf.phase.PhaseInterceptorChain;
 import org.apache.cxf.phase.PhaseManager;
 
-public class OutFaultChainInitiatorObserver extends AbstractFaultChainIntiatorObserver {
+public class OutFaultChainInitiatorObserver extends AbstractFaultChainInitiatorObserver {
 
     public OutFaultChainInitiatorObserver(Bus bus) {
         super(bus);

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Thu Apr  5 12:34:10 2007
@@ -62,6 +62,7 @@
     
     public static final String HTTP_REQUEST = "HTTP.REQUEST";
     public static final String HTTP_RESPONSE = "HTTP.RESPONSE";
+    public static final String PROTOCOL_HEADERS_CONTENT_TYPE = Message.CONTENT_TYPE.toLowerCase();
     
     private static final Logger LOG = LogUtils.getL7dLogger(AbstractHTTPDestination.class);
     
@@ -295,7 +296,14 @@
 
             Integer i = (Integer)outMessage.get(Message.RESPONSE_CODE);
             if (i != null) {
-                int status = i.intValue();               
+                int status = i.intValue();  
+                if (HttpURLConnection.HTTP_INTERNAL_ERROR == i) {
+                    Map<Object, Object> pHeaders = 
+                        CastUtils.cast((Map)outMessage.get(Message.PROTOCOL_HEADERS));
+                    if (null != pHeaders && pHeaders.containsKey(PROTOCOL_HEADERS_CONTENT_TYPE))
{
+                        pHeaders.remove(PROTOCOL_HEADERS_CONTENT_TYPE);
+                    }
+                }
                 response.setStatus(status);
             } else {
                 response.setStatus(HttpURLConnection.HTTP_OK);

Modified: incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
(original)
+++ incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
Thu Apr  5 12:34:10 2007
@@ -326,8 +326,7 @@
             storePartialResponseSent(inMessage);
             Exchange exchange = inMessage.getExchange();
             Message fullResponse = exchange.getOutMessage();
-            Endpoint endpoint = exchange.get(Endpoint.class);
-            Message partialResponse = endpoint.getBinding().createMessage();
+            Message partialResponse = createMessage(exchange);
             ensurePartialResponseMAPs(partialResponse, namespaceURI);
             
             // ensure the inbound MAPs are available in the partial response
@@ -364,7 +363,7 @@
                     if (fullResponse != null) {
                         exchange.setOutMessage(fullResponse);
                     } else {
-                        fullResponse = endpoint.getBinding().createMessage();
+                        fullResponse = createMessage(exchange);
                         exchange.setOutMessage(fullResponse);
                     }
                     

Modified: incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
(original)
+++ incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
Thu Apr  5 12:34:10 2007
@@ -60,7 +60,7 @@
 import org.apache.cxf.ws.addressing.Names;
 import org.apache.cxf.ws.addressing.RelatesToType;
 
-import static org.apache.cxf.message.Message.MIME_HEADERS;
+
 
 
 /**
@@ -123,8 +123,11 @@
     private void mediate(SoapMessage message) {
         if (ContextUtils.isOutbound(message)) {
             encode(message, ContextUtils.retrieveMAPs(message, false, true));
-        } else {
-            ContextUtils.storeMAPs(decode(message), message, false);
+        } else if (null == ContextUtils.retrieveMAPs(message, false, false)) {          
 
+            AddressingProperties maps = decode(message);
+            ContextUtils.storeMAPs(maps, message, false);
+            markPartialResponse(message, maps);
+            restoreExchange(message, maps);     
         }
     }
 
@@ -138,7 +141,7 @@
                         AddressingProperties maps) {
         if (maps != null) { 
             cacheExchange(message, maps);
-            LOG.log(Level.INFO, "\nOutbound WS-Addressing headers");
+            LOG.log(Level.INFO, "Outbound WS-Addressing headers");
             try {
                 Element header = message.getHeaders(Element.class);
                 discardMAPs(header, maps);
@@ -241,7 +244,7 @@
         try {
             Element header = message.getHeaders(Element.class);
             if (header != null) {
-                LOG.log(Level.INFO, "\nInbound WS-Addressing headers");
+                LOG.log(Level.INFO, "Inbound WS-Addressing headers");
                 Unmarshaller unmarshaller = null;
                 NodeList headerElements = header.getChildNodes();
                 int headerCount = headerElements.getLength();
@@ -304,9 +307,7 @@
                                     headerURI);
                         }
                     }
-                }
-                restoreExchange(message, maps);
-                markPartialResponse(message, maps);
+                }                
             }
         } catch (JAXBException je) {
             LOG.log(Level.WARNING, "SOAP_HEADER_DECODE_FAILURE_MSG", je); 
@@ -419,7 +420,7 @@
      */
     private void discardMAPs(Element header, AddressingProperties maps) throws SOAPException
{
         NodeList headerElements =
-            header.getElementsByTagNameNS(maps.getNamespaceURI(), "*");
+            header.getElementsByTagNameNS(maps.getNamespaceURI(), "*");        
         for (int i = 0; i < headerElements.getLength(); i++) {
             Node headerElement = headerElements.item(i);
             if (Names.WSA_NAMESPACE_NAME.equals(headerElement.getNamespaceURI())) {
@@ -438,7 +439,7 @@
                                  SoapMessage message) {
         if (!(action == null || "".equals(action.getValue()))) {
             Map<String, List<String>> mimeHeaders = CastUtils.cast((Map<?,
?>)
-                message.get(MIME_HEADERS));
+                message.get(Message.MIME_HEADERS));
             if (mimeHeaders != null) {
                 List<String> soapActionHeaders =
                     mimeHeaders.get(Names.SOAP_ACTION_HEADER);
@@ -539,7 +540,7 @@
                         && endpoint != null) {
                         message.getInterceptorChain().abort();
                         if (endpoint.getInFaultObserver() != null) {
-                            endpoint.getInFaultObserver().onMessage(message);
+                            endpoint.getInFaultObserver().onMessage(message);           
                
                         }
                     }
                 }

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java
Thu Apr  5 12:34:10 2007
@@ -22,6 +22,8 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.service.model.BindingFaultInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
 
 /**
  * 
@@ -36,5 +38,34 @@
     
     public Bus getBus() {
         return bus;
+    }
+    
+    protected BindingFaultInfo getBindingFaultInfo(Message msg, Exception ex, BindingOperationInfo
boi) {
+        BindingFaultInfo bfi = msg.get(BindingFaultInfo.class);        
+        if (null == bfi) {
+            Throwable cause = ex.getCause();
+            if (null == cause) {
+                return null;
+            }
+            for (BindingFaultInfo b : boi.getFaults()) {
+                Class<?> faultClass = b.getFaultInfo().getProperty(Class.class.getName(),
Class.class);
+                if (faultClass.isAssignableFrom(cause.getClass())) {
+                    bfi = b;
+                    msg.put(BindingFaultInfo.class, bfi);
+                    break;
+                }
+            }  
+            if (null == bfi && null != boi.getWrappedOperation()) {
+                for (BindingFaultInfo b : boi.getWrappedOperation().getFaults()) {
+                    Class<?> faultClass = b.getFaultInfo().getProperty(Class.class.getName(),
Class.class);
+                    if (faultClass.isAssignableFrom(cause.getClass())) {
+                        bfi = b;
+                        msg.put(BindingFaultInfo.class, bfi);
+                        break;
+                    }
+                }  
+            }
+        }
+        return bfi;
     }
 }

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java
(original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java
Thu Apr  5 12:34:10 2007
@@ -78,11 +78,11 @@
     }
     
     
-    void initialise(EndpointInfo ei, boolean isServer, PolicyEngineImpl engine, Assertor
assertor) {
+    void initialise(EndpointInfo ei, boolean isRequestor, PolicyEngineImpl engine, Assertor
assertor) {
         initialisePolicy(ei, engine);
         chooseAlternative(engine, assertor);
-        initialiseVocabulary(ei, isServer, engine);
-        initialiseInterceptors(ei, isServer, engine); 
+        initialiseVocabulary(ei, isRequestor, engine);
+        initialiseInterceptors(ei, isRequestor, engine); 
     }
    
     void initialisePolicy(EndpointInfo ei, PolicyEngineImpl engine) {

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
(original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
Thu Apr  5 12:34:10 2007
@@ -192,7 +192,7 @@
             return endpointPolicy;
         }
         Assertor assertor = conduit instanceof Assertor ? (Assertor)conduit : null;
-        return createEndpointPolicyInfo(ei, false, assertor);
+        return createEndpointPolicyInfo(ei, true, assertor);
     }
    
     public EndpointPolicy getServerEndpointPolicy(EndpointInfo ei, Destination destination)
{
@@ -201,7 +201,7 @@
             return endpointPolicy;
         }
         Assertor assertor = destination instanceof Assertor ? (Assertor)destination : null;
-        return createEndpointPolicyInfo(ei, true, assertor);
+        return createEndpointPolicyInfo(ei, false, assertor);
     }
     
     public void setEndpointPolicy(EndpointInfo ei, EndpointPolicy ep) {
@@ -459,9 +459,9 @@
    
     
     
-    EndpointPolicyImpl createEndpointPolicyInfo(EndpointInfo ei, boolean isServer, Assertor
assertor) {
+    EndpointPolicyImpl createEndpointPolicyInfo(EndpointInfo ei, boolean isRequestor, Assertor
assertor) {
         EndpointPolicyImpl epi = createEndpointPolicyInfo();
-        epi.initialise(ei, isServer, this, assertor);
+        epi.initialise(ei, isRequestor, this, assertor);
         endpointInfo.put(ei, epi);
 
         return epi;

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java
Thu Apr  5 12:34:10 2007
@@ -29,6 +29,7 @@
 import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.service.model.BindingFaultInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.EndpointInfo;
 
 /**
@@ -58,11 +59,11 @@
         Exchange exchange = message.getExchange();
         assert null != exchange;
         
-        BindingFaultInfo bfi = message.get(BindingFaultInfo.class);
-        if (null == bfi) {
-            LOG.fine("No binding fault info.");
+        BindingOperationInfo boi = exchange.get(BindingOperationInfo.class);
+        if (null == boi) {
+            LOG.fine("No binding operation info.");
             return;
-        }
+        }        
         
         Endpoint e = exchange.get(Endpoint.class);
         if (null == e) {
@@ -78,6 +79,18 @@
         
         AssertionInfoMap aim = message.get(AssertionInfoMap.class);
         if (null == aim) {
+            return;
+        }
+        
+        Exception ex = message.getContent(Exception.class);
+        if (null == ex) {
+            ex = exchange.get(Exception.class);
+        }
+        assert null != ex;
+        
+        BindingFaultInfo bfi = getBindingFaultInfo(message, ex, boi);
+        if (null == bfi) {
+            LOG.fine("No binding fault info.");
             return;
         }
         

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java
Thu Apr  5 12:34:10 2007
@@ -102,33 +102,4 @@
             msg.put(AssertionInfoMap.class, new AssertionInfoMap(assertions));
         }
     }
-    
-    BindingFaultInfo getBindingFaultInfo(Message msg, Exception ex, BindingOperationInfo
boi) {
-        BindingFaultInfo bfi = msg.get(BindingFaultInfo.class);        
-        if (null == bfi) {
-            Throwable cause = ex.getCause();
-            if (null == cause) {
-                return null;
-            }
-            for (BindingFaultInfo b : boi.getFaults()) {
-                Class<?> faultClass = b.getFaultInfo().getProperty(Class.class.getName(),
Class.class);
-                if (faultClass.isAssignableFrom(cause.getClass())) {
-                    bfi = b;
-                    msg.put(BindingFaultInfo.class, bfi);
-                    break;
-                }
-            }  
-            if (null == bfi && null != boi.getWrappedOperation()) {
-                for (BindingFaultInfo b : boi.getWrappedOperation().getFaults()) {
-                    Class<?> faultClass = b.getFaultInfo().getProperty(Class.class.getName(),
Class.class);
-                    if (faultClass.isAssignableFrom(cause.getClass())) {
-                        bfi = b;
-                        msg.put(BindingFaultInfo.class, bfi);
-                        break;
-                    }
-                }  
-            }
-        }
-        return bfi;
-    }
 }

Modified: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java
(original)
+++ incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java
Thu Apr  5 12:34:10 2007
@@ -103,7 +103,7 @@
         EndpointPolicyImpl epi = control.createMock(EndpointPolicyImpl.class, 
                                                     new Method[] {m1, m2, m3, m4});
         EndpointInfo ei = control.createMock(EndpointInfo.class);
-        boolean isServer = true;
+        boolean isRequestor = false;
         PolicyEngineImpl pe = control.createMock(PolicyEngineImpl.class);
         Assertor a = control.createMock(Assertor.class);
          
@@ -111,11 +111,11 @@
         EasyMock.expectLastCall();
         epi.chooseAlternative(pe, a);
         EasyMock.expectLastCall();
-        epi.initialiseInterceptors(ei, isServer, pe); 
+        epi.initialiseInterceptors(ei, isRequestor, pe); 
         EasyMock.expectLastCall();
         
         control.replay();
-        epi.initialise(ei, isServer, pe, a);
+        epi.initialise(ei, isRequestor, pe, a);
         control.verify();        
     }
     

Modified: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
(original)
+++ incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
Thu Apr  5 12:34:10 2007
@@ -265,7 +265,7 @@
         EndpointInfo ei = control.createMock(EndpointInfo.class);
         AssertingConduit conduit = control.createMock(AssertingConduit.class);
         EndpointPolicyImpl epi = control.createMock(EndpointPolicyImpl.class);
-        EasyMock.expect(engine.createEndpointPolicyInfo(ei, false, conduit)).andReturn(epi);
+        EasyMock.expect(engine.createEndpointPolicyInfo(ei, true, conduit)).andReturn(epi);
         control.replay();
         assertSame(epi, engine.getClientEndpointPolicy(ei, conduit));
         control.verify();        
@@ -280,7 +280,7 @@
         EndpointInfo ei = control.createMock(EndpointInfo.class);
         AssertingDestination destination = control.createMock(AssertingDestination.class);
         EndpointPolicyImpl epi = control.createMock(EndpointPolicyImpl.class);
-        EasyMock.expect(engine.createEndpointPolicyInfo(ei, true, destination)).andReturn(epi);
+        EasyMock.expect(engine.createEndpointPolicyInfo(ei, false, destination)).andReturn(epi);
         control.replay();
         assertSame(epi, engine.getServerEndpointPolicy(ei, destination));
         control.verify();        

Modified: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java
(original)
+++ incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java
Thu Apr  5 12:34:10 2007
@@ -212,7 +212,7 @@
     
     @Test
     public void testServerPolicyOutFaultInterceptor() throws NoSuchMethodException {
-        Method m = ServerPolicyOutFaultInterceptor.class.getDeclaredMethod("getBindingFaultInfo",
+        Method m = AbstractPolicyInterceptor.class.getDeclaredMethod("getBindingFaultInfo",
             new Class[] {Message.class, Exception.class, BindingOperationInfo.class});
         
         ServerPolicyOutFaultInterceptor interceptor = 

Modified: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptorTest.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptorTest.java
(original)
+++ incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptorTest.java
Thu Apr  5 12:34:10 2007
@@ -24,6 +24,7 @@
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.service.model.BindingFaultInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.neethi.Policy;
 import org.easymock.classextension.EasyMock;
@@ -41,11 +42,13 @@
     private Bus bus;
     private Message message;
     private Exchange exchange;
+    private BindingOperationInfo boi;
     private BindingFaultInfo bfi;
     private Endpoint endpoint;
     private EndpointInfo ei;
     private PolicyEngine engine;
     private AssertionInfoMap aim;
+    private Exception ex;
     
     @Before
     public void setUp() {
@@ -59,37 +62,43 @@
             new PolicyVerificationInFaultInterceptor();
         interceptor.setBus(bus);
         
-        setupMessage(false, false, false, false, false);
+        setupMessage(false, false, false, false, false, false);
         control.replay();
         interceptor.handleMessage(message);
         control.verify();
         
         control.reset();
-        setupMessage(true, false, false, false, false);
+        setupMessage(true, false, false, false, false, false);
         control.replay();
         interceptor.handleMessage(message);
         control.verify();
         
         control.reset();
-        setupMessage(true, true, false, false, false);
+        setupMessage(true, true, false, false, false, false);
         control.replay();
         interceptor.handleMessage(message);
         control.verify();
         
         control.reset();
-        setupMessage(true, true, true, false, false);
+        setupMessage(true, true, true, false, false, false);
         control.replay();
         interceptor.handleMessage(message);
         control.verify();
         
         control.reset();
-        setupMessage(true, true, true, true, false);
+        setupMessage(true, true, true, true, false, false);
         control.replay();
         interceptor.handleMessage(message);
         control.verify();
         
         control.reset();
-        setupMessage(true, true, true, true, true);
+        setupMessage(true, true, true, true, true, false);
+        control.replay();
+        interceptor.handleMessage(message);
+        control.verify();
+        
+        control.reset();
+        setupMessage(true, true, true, true, true, true);
         EffectivePolicyImpl effectivePolicy = control.createMock(EffectivePolicyImpl.class);
       
         EasyMock.expect(engine.getEffectiveClientFaultPolicy(ei, bfi)).andReturn(effectivePolicy);
         Policy policy = control.createMock(Policy.class);
@@ -102,10 +111,11 @@
     }
     
     void setupMessage(boolean requestor,
-                      boolean setupBindingFaultInfo,
+                      boolean setupOperationInfo,
                       boolean setupEndpoint,
                       boolean setupPolicyEngine,
-                      boolean setupAssertionInfoMap) {
+                      boolean setupAssertionInfoMap,
+                      boolean setupBindingFaultInfo) {
         if (null == message) {
             message = control.createMock(Message.class); 
         }
@@ -119,11 +129,11 @@
         }
         
         EasyMock.expect(message.getExchange()).andReturn(exchange);
-        if (setupBindingFaultInfo && null == bfi) {
-            bfi = control.createMock(BindingFaultInfo.class);
+        if (setupOperationInfo && null == boi) {
+            boi = control.createMock(BindingOperationInfo.class);
         }
-        EasyMock.expect(message.get(BindingFaultInfo.class)).andReturn(bfi);
-        if (!setupBindingFaultInfo) {
+        EasyMock.expect(exchange.get(BindingOperationInfo.class)).andReturn(boi);
+        if (!setupOperationInfo) {
             return;
         }
         if (setupEndpoint && null == endpoint) {
@@ -149,6 +159,19 @@
             aim = control.createMock(AssertionInfoMap.class);
         }
         EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim);
+        if (!setupAssertionInfoMap) {
+            return;           
+        }
+        if (null == ex) {
+            ex = control.createMock(Exception.class);
+        }
+        EasyMock.expect(message.getContent(Exception.class)).andReturn(null);
+        EasyMock.expect(exchange.get(Exception.class)).andReturn(ex);
+        
+        if (setupBindingFaultInfo && null == bfi) {
+            bfi = control.createMock(BindingFaultInfo.class);            
+        }
+        EasyMock.expect(message.get(BindingFaultInfo.class)).andReturn(bfi);
     }
 
 }

Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java
Thu Apr  5 12:34:10 2007
@@ -36,7 +36,6 @@
 import javax.xml.namespace.QName;
 import javax.xml.soap.SOAPException;
 
-
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -127,13 +126,6 @@
     // Interceptor interface
 
     /* (non-Javadoc)
-     * @see org.apache.cxf.interceptor.Interceptor#handleFault(org.apache.cxf.message.Message)
-     */
-    public void handleFault(SoapMessage message) {
-        mediate(message);        
-    }
-
-    /* (non-Javadoc)
      * @see org.apache.cxf.interceptor.Interceptor#handleMessage(org.apache.cxf.message.Message)
      */
 
@@ -366,23 +358,11 @@
     private static void discardRMHeaders(Element header) throws SOAPException {
         NodeList headerElements =
             header.getElementsByTagNameNS(RMConstants.getNamespace(), "*");
-        
         for (int i = 0; i < headerElements.getLength(); i++) {
             Node headerElement = headerElements.item(i);
             if (RMConstants.getNamespace().equals(headerElement.getNamespaceURI())) {
                 header.removeChild(headerElement);
             }
-
-            
-            // REVISIT should detach wsa:Action on resend
-            /*
-            if (org.apache.cxf.ws.addressing.Names.WSA_NAMESPACE_NAME
-                .equals(headerName.getURI())
-                && org.apache.cxf.ws.addressing.Names.WSA_ACTION_NAME
-                .equals(headerName.getLocalName())) {
-                headerElement.detachNode();
-            }
-            */
         }
     }
     

Modified: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptorTest.java?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptorTest.java
(original)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptorTest.java
Thu Apr  5 12:34:10 2007
@@ -100,20 +100,6 @@
     }
     
     @Test
-    public void testHandleFault() throws NoSuchMethodException {
-        Method m = RMSoapInterceptor.class.getDeclaredMethod("mediate", 
-            new Class[] {SoapMessage.class});
-        RMSoapInterceptor codec = control.createMock(RMSoapInterceptor.class, new Method[]
{m});
-        SoapMessage msg = control.createMock(SoapMessage.class);
-        codec.mediate(msg);
-        EasyMock.expectLastCall();
-        
-        control.replay();
-        codec.handleFault(msg);
-        control.verify();
-    }
-    
-    @Test
     public void testMediate() throws NoSuchMethodException {
         Method m1 = RMSoapInterceptor.class.getDeclaredMethod("encode", 
                                                              new Class[] {SoapMessage.class});

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/wsa_interceptors.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/wsa_interceptors.xml?view=diff&rev=525943&r1=525942&r2=525943
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/wsa_interceptors.xml
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/wsa_interceptors.xml
Thu Apr  5 12:34:10 2007
@@ -25,11 +25,19 @@
   
     <bean id="mapAggregator" class="org.apache.cxf.ws.addressing.MAPAggregator"/>
     <bean id="mapCodec" class="org.apache.cxf.ws.addressing.soap.MAPCodec"/>
+    <bean id="loggingIn" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
 
     <!-- We are adding the interceptors to the bus as we will have only one endpoint/service/bus.
-->
 
     <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl">
         <property name="inInterceptors">
+            <list>
+                <ref bean="mapAggregator"/>
+                <ref bean="mapCodec"/>
+                <ref bean="loggingIn"/>
+            </list>
+        </property>
+        <property name="inFaultInterceptors">
             <list>
                 <ref bean="mapAggregator"/>
                 <ref bean="mapCodec"/>



Mime
View raw message