cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r538130 - in /incubator/cxf/branches/headerwork/rt: bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/ ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/ ...
Date Tue, 15 May 2007 10:50:48 GMT
Author: eglynn
Date: Tue May 15 03:50:47 2007
New Revision: 538130

URL: http://svn.apache.org/viewvc?view=rev&rev=538130
Log:
Some more header-related fixes from Ulhas.


Modified:
    incubator/cxf/branches/headerwork/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
    incubator/cxf/branches/headerwork/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
    incubator/cxf/branches/headerwork/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
    incubator/cxf/branches/headerwork/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
    incubator/cxf/branches/headerwork/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java

Modified: incubator/cxf/branches/headerwork/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/headerwork/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java?view=diff&rev=538130&r1=538129&r2=538130
==============================================================================
--- incubator/cxf/branches/headerwork/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
(original)
+++ incubator/cxf/branches/headerwork/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
Tue May 15 03:50:47 2007
@@ -31,6 +31,7 @@
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
@@ -108,30 +109,28 @@
                     Node currentHead  = headerEls.item(i);
                     Node node = currentHead;
                     NodeList heads = node.getChildNodes();
-                    for (int x = 0; x < heads.getLength(); x++) {
+                    int len = heads.getLength();
+                    for (int x = 0; x < len; x++) {
                         node = (Node)heads.item(x);
                         if (node.getNodeType() == Node.ELEMENT_NODE) {
                             Element hel = (Element)node;
                             // Need to add any attributes that are present on the parent
element
                             // which otherwise would be lost.
                             if (currentHead.hasAttributes()) {
-                                boolean found = false;
-                                for (int ct = 0; ct < currentHead.getAttributes().getLength();
ct++) {
-                                    Node attr = currentHead.getAttributes().item(ct);
-                                    for (int subct = 0; 
-                                        node.hasAttributes() && subct < node.getAttributes().getLength();

-                                        subct++) {
-                                        if (node.getAttributes().item(subct).equals(attr.getNodeName()))
{
-                                            found = true;
-                                            break;
-                                        }
-                                    }
-                                    if (!found && node instanceof Element) {
-                                        Attr attribute = node.getOwnerDocument().createAttributeNS(
+                                NamedNodeMap nnp = currentHead.getAttributes();
+                                for (int ct = 0; ct < nnp.getLength(); ct++) {
+                                    Node attr = nnp.item(ct);
+                                    Node headerAttrNode = hel.hasAttributes() 
+                                            ?  hel.getAttributes().getNamedItemNS(
+                                                            attr.getNamespaceURI(), attr.getLocalName())

+                                            : null;
+                                    
+                                    if (headerAttrNode == null) {
+                                        Attr attribute = hel.getOwnerDocument().createAttributeNS(
                                                 attr.getNamespaceURI(), 
                                                 attr.getNodeName());
                                         attribute.setNodeValue(attr.getNodeValue());
-                                        ((Element) node).setAttributeNodeNS(attribute);
+                                        hel.setAttributeNodeNS(attribute);
                                     }
                                 }
                             }

Modified: incubator/cxf/branches/headerwork/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/headerwork/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java?view=diff&rev=538130&r1=538129&r2=538130
==============================================================================
--- incubator/cxf/branches/headerwork/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
(original)
+++ incubator/cxf/branches/headerwork/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
Tue May 15 03:50:47 2007
@@ -76,8 +76,9 @@
             if (preexistingHeaders) {
                 xtw.writeStartElement(soapVersion.getPrefix(), 
                                       soapVersion.getHeader().getLocalPart(),
-                                      soapVersion.getNamespace());                    
-                for (Header header : message.getHeaders()) {
+                                      soapVersion.getNamespace());   
+                List<Header> hdrList = message.getHeaders();
+                for (Header header : hdrList) {
                     DataBinding b = header.getDataBinding();
                     if (b == null) {
                         HeaderProcessor hp = bus.getExtension(HeaderManager.class)
@@ -91,8 +92,6 @@
                             .write(header.getObject(), xtw);
                     } else {
                         Element node = (Element)header.getObject();
-//                        System.out.println("SOAPOUTINTERCEPTOR : node name : " 
-//                        + node.getLocalName() +  " namespace URI" + node.getNamespaceURI());
                         StaxUtils.copy(node, xtw);
                     }
                 }

Modified: incubator/cxf/branches/headerwork/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/headerwork/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java?view=diff&rev=538130&r1=538129&r2=538130
==============================================================================
--- incubator/cxf/branches/headerwork/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
(original)
+++ incubator/cxf/branches/headerwork/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
Tue May 15 03:50:47 2007
@@ -96,7 +96,8 @@
             //replace header element if necessary
             if (message.hasHeaders()) {
                 NodeList headerEls = soapMessage.getSOAPHeader().getChildNodes();
-                for (int i = 0; i < headerEls.getLength(); i++) {
+                int len = headerEls.getLength();
+                for (int i = 0; i < len; i++) {
                     Node nd = headerEls.item(i);
                     if (Node.ELEMENT_NODE == nd.getNodeType()) {
                         Element hel = (Element)nd;

Modified: incubator/cxf/branches/headerwork/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/headerwork/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java?view=diff&rev=538130&r1=538129&r2=538130
==============================================================================
--- incubator/cxf/branches/headerwork/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
(original)
+++ incubator/cxf/branches/headerwork/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
Tue May 15 03:50:47 2007
@@ -42,7 +42,6 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.binding.soap.SoapFault;
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.SoapVersion;
@@ -150,7 +149,7 @@
                 List<Header> header = message.getHeaders();
                 discardMAPs(header, maps);
 
-                Element hdr = getHeaderFactory().getHeader();                
+                Element hdr = getHeaderFactory().getHeader(message.getVersion());       
        
                 JAXBContext jaxbContext = 
                     VersionTransformer.getExposedJAXBContext(
                                                      maps.getNamespaceURI());
@@ -195,7 +194,8 @@
                 encodeReferenceParameters(maps, hdr, marshaller);
                 
                 NodeList children = hdr.getChildNodes();
-                for (int i = 0; i < children.getLength(); i++) {
+                int len = children.getLength();
+                for (int i = 0; i < len; i++) {
                     Node node = children.item(i);
                     
                     if (node instanceof Element) {
@@ -636,11 +636,10 @@
     protected HeaderFactory getHeaderFactory() {
         if (headerFactory == null) {
             headerFactory = new HeaderFactory() {
-                public Element getHeader() {
+                public Element getHeader(SoapVersion soapversion) {
                     Document doc = DOMUtils.createDocument();
-                    SoapVersion version = Soap11.getInstance();
-                    return doc.createElementNS(version.getHeader().getNamespaceURI(),
-                                               version.getHeader().getLocalPart());
+                    return doc.createElementNS(soapversion.getHeader().getNamespaceURI(),
+                            soapversion.getHeader().getLocalPart());
                 }
             };
         }
@@ -652,7 +651,7 @@
     }
 
     public interface HeaderFactory {
-        Element getHeader();
+        Element getHeader(SoapVersion soapversion);
     }
 }
 

Modified: incubator/cxf/branches/headerwork/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/headerwork/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java?view=diff&rev=538130&r1=538129&r2=538130
==============================================================================
--- incubator/cxf/branches/headerwork/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java
(original)
+++ incubator/cxf/branches/headerwork/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java
Tue May 15 03:50:47 2007
@@ -39,6 +39,7 @@
 
 import org.apache.cxf.binding.soap.SoapFault;
 import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.SoapVersion;
 import org.apache.cxf.headers.Header;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
@@ -245,7 +246,7 @@
         AddressingPropertiesImpl maps = getMAPs(requestor, outbound, exposeAs);
         final Element header = control.createMock(Element.class);
         codec.setHeaderFactory(new MAPCodec.HeaderFactory() {
-            public Element getHeader() {
+            public Element getHeader(SoapVersion version) {
                 return header;
             }
         });



Mime
View raw message