cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r692162 - in /cxf/branches/2.1.x-fixes: ./ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ systests/src/test/java/org/apache/cxf/systest/outofband/header/
Date Thu, 04 Sep 2008 16:59:18 GMT
Author: dkulp
Date: Thu Sep  4 09:59:16 2008
New Revision: 692162

URL: http://svn.apache.org/viewvc?rev=692162&view=rev
Log:
Merged revisions 692116 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r692116 | dkulp | 2008-09-04 11:46:34 -0400 (Thu, 04 Sep 2008) | 3 lines
  
  Don't hold onto the header objects (allow them to be gc'd sooner)
  Update error message to be a bit more descriptive
........

Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties
    cxf/branches/2.1.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/MustUnderstandInterceptor.java
    cxf/branches/2.1.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/MustUnderstandInterceptorTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHeaderTest.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep  4 09:59:16 2008
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691355,691488,691602,691646,691706,691728
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691355,691488,691602,691646,691706,691728,692116

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.1.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties?rev=692162&r1=692161&r2=692162&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties
(original)
+++ cxf/branches/2.1.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties
Thu Sep  4 09:59:16 2008
@@ -21,7 +21,7 @@
 
 XML_STREAM_EXC=Error reading XMLStreamReader.
 XML_WRITE_EXC=Error writing to XMLStreamWriter.
-MUST_UNDERSTAND=Can not understand QNames: {0}
+MUST_UNDERSTAND=MustUnderstand headers: {0} are not understood.
 PARSER_EXC=Could not create DOM DocumentBuilder.
 NO_OPERATION=No such operation: {0}
 ATTACHMENT_IO=Attachment IO Exception: {0}

Modified: cxf/branches/2.1.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/MustUnderstandInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/MustUnderstandInterceptor.java?rev=692162&r1=692161&r2=692162&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/MustUnderstandInterceptor.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/MustUnderstandInterceptor.java
Thu Sep  4 09:59:16 2008
@@ -59,7 +59,7 @@
         SoapVersion soapVersion = soapMessage.getVersion();              
         Set<Header> mustUnderstandHeaders = new HashSet<Header>();
         Set<URI> serviceRoles = new HashSet<URI>();
-        Set<Header> notUnderstandHeaders = new HashSet<Header>();
+        Set<QName> notUnderstandHeaders = new HashSet<QName>();
         Set<Header> ultimateReceiverHeaders = new HashSet<Header>();
         Set<QName> mustUnderstandQNames = new HashSet<QName>();
 
@@ -67,27 +67,15 @@
                                    serviceRoles, ultimateReceiverHeaders);
         initServiceSideInfo(mustUnderstandQNames, soapMessage, serviceRoles);
         
-        if (!checkUnderstand(mustUnderstandHeaders, mustUnderstandQNames,
-                             notUnderstandHeaders)) {
-            StringBuffer sb = new StringBuffer(300);
-            boolean first = true;
-            for (Header head : notUnderstandHeaders) {
-                if (first) {
-                    first = false;
-                } else {
-                    sb.append(", ");
-                }
-                sb.append(head.getName().toString());
-            }
-            if (sb.length() > 0) {
-                throw new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE, sb.toString()),
-                                soapVersion.getMustUnderstand());
-            }
+        checkUnderstand(mustUnderstandHeaders, mustUnderstandQNames,
+                             notUnderstandHeaders);
+        if (!notUnderstandHeaders.isEmpty()) {
+            throw new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE, notUnderstandHeaders),
+                            soapVersion.getMustUnderstand());
         }
         if (!ultimateReceiverHeaders.isEmpty()) {
             soapMessage.getInterceptorChain()
-                .add(new UltimateReceiverMustUnderstandInterceptor(ultimateReceiverHeaders,
-                                                                   mustUnderstandQNames));
+                .add(new UltimateReceiverMustUnderstandInterceptor(mustUnderstandQNames));
         }
     }
 
@@ -143,20 +131,16 @@
         }
     }
 
-    private boolean checkUnderstand(Set<Header> mustUnderstandHeaders,
+    private void checkUnderstand(Set<Header> mustUnderstandHeaders,
                                     Set<QName> mustUnderstandQNames,
-                                    Set<Header> notUnderstandHeaders) {
+                                    Set<QName> notUnderstandHeaders) {
 
         for (Header header : mustUnderstandHeaders) {
             QName qname = header.getName();
             if (!mustUnderstandQNames.contains(qname)) {
-                notUnderstandHeaders.add(header);
+                notUnderstandHeaders.add(header.getName());
             }
         }
-        if (notUnderstandHeaders.size() > 0) {
-            return false;
-        }
-        return true;
     }
     
     
@@ -165,42 +149,33 @@
      * 
      */
     private class UltimateReceiverMustUnderstandInterceptor extends AbstractSoapInterceptor
{
-        Set<Header> ultimateReceiverHeaders;
         Set<QName> knownHeaders;
-        public UltimateReceiverMustUnderstandInterceptor(Set<Header> ult,
-                                                         Set<QName> knownHeaders) {
+        public UltimateReceiverMustUnderstandInterceptor(Set<QName> knownHeaders) {
             super(Phase.INVOKE);
             this.knownHeaders = knownHeaders;
-            ultimateReceiverHeaders = ult;
         }
         public void handleMessage(SoapMessage soapMessage) throws Fault {
             SoapVersion soapVersion = soapMessage.getVersion();
-            Set<Header> notFound = new HashSet<Header>();
+            Set<QName> notFound = new HashSet<QName>();
             List<Header> heads = soapMessage.getHeaders();
-            for (Header header : ultimateReceiverHeaders) {
-                if (heads.contains(header)
+            
+            for (Header header : heads) {
+                if (header instanceof SoapHeader
+                    && ((SoapHeader)header).isMustUnderstand()
                     && header.getDirection() == Header.Direction.DIRECTION_IN
-                    && !knownHeaders.contains(header.getName())) {
-                    notFound.add(header);
+                    && !knownHeaders.contains(header.getName())
+                    && (StringUtils.isEmpty(((SoapHeader)header).getActor())
+                        || soapVersion.getUltimateReceiverRole()
+                            .equals(((SoapHeader)header).getActor()))) {
+                    
+                    notFound.add(header.getName());
                 }
             }
             
             
             if (!notFound.isEmpty()) {
-                StringBuffer sb = new StringBuffer(300);
-                boolean first = true;
-                for (Header head : notFound) {
-                    if (first) {
-                        first = false;
-                    } else {
-                        sb.append(", ");
-                    }
-                    sb.append(head.getName().toString());
-                }
-                if (sb.length() > 0) {
-                    throw new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE, sb.toString()),
-                                    soapVersion.getMustUnderstand());
-                }
+                throw new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE, notFound),
+                                soapVersion.getMustUnderstand());
             }            
         }
 

Modified: cxf/branches/2.1.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/MustUnderstandInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/MustUnderstandInterceptorTest.java?rev=692162&r1=692161&r2=692162&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/MustUnderstandInterceptorTest.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/MustUnderstandInterceptorTest.java
Thu Sep  4 09:59:16 2008
@@ -99,7 +99,7 @@
             fail("InBound Exception Missing! Exception should be Can't understands QNames:
" + PASSENGER);
         } else {
             assertEquals(soapMessage.getVersion().getMustUnderstand(), ie.getFaultCode());
-            assertEquals("Can not understand QNames: " + PASSENGER, ie.getMessage().toString());
+            assertTrue(ie.getMessage().toString().contains(PASSENGER.toString()));
         }
     }
 

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHeaderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHeaderTest.java?rev=692162&r1=692161&r2=692162&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHeaderTest.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHeaderTest.java
Thu Sep  4 09:59:16 2008
@@ -191,7 +191,7 @@
             putLastTradedPrice.sayHi(holder);
             fail("mustUnderstand header should not have been processed");
         } catch (Exception ex) {
-            assertTrue(ex.getMessage().contains("Can not understand"));
+            assertTrue(ex.getMessage(), ex.getMessage().contains("MustUnderstand"));
         }
     }
 }



Mime
View raw message