cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r748306 - in /cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src: main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java test/java/org/apache/cxf/jaxws/support/ContextPropertiesMappingTest.java
Date Thu, 26 Feb 2009 21:14:41 GMT
Author: dkulp
Date: Thu Feb 26 21:14:40 2009
New Revision: 748306

URL: http://svn.apache.org/viewvc?rev=748306&view=rev
Log:
[CXF-2067] Patch from Colm OhEigeartaigh applied

Modified:
    cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java
    cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ContextPropertiesMappingTest.java

Modified: cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java?rev=748306&r1=748305&r2=748306&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java
Thu Feb 26 21:14:40 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.jaxws.support;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -31,6 +32,7 @@
 import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.handler.MessageContext.Scope;
 
+import org.apache.cxf.attachment.AttachmentImpl;
 import org.apache.cxf.binding.soap.SoapConstants;
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.configuration.security.AuthorizationPolicy;
@@ -278,6 +280,25 @@
                 sm.getHeaders().add((Header) iter.next());
             }
         }
+
+        if (exchange.getOutMessage() != null) {
+            Message out = exchange.getOutMessage();
+            Map<String, DataHandler> dataHandlers =
+                CastUtils.cast((Map<?, ?>)out.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS));
+            if (dataHandlers != null && !dataHandlers.isEmpty()) {
+                Collection<Attachment> attachments = out.getAttachments();
+                if (attachments == null) {
+                    attachments = new ArrayList<Attachment>();
+                    out.setAttachments(attachments);
+                }
+                for (Map.Entry<String, DataHandler> entry : dataHandlers.entrySet())
{
+                    Attachment att = new AttachmentImpl(entry.getKey(), entry.getValue());
+                    attachments.add(att);
+                }
+            }
+            out.remove(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
+        }
+
         if (ctx.containsKey(MessageContext.HTTP_RESPONSE_HEADERS)) {
             Map<String, List<String>> other = CastUtils
                 .cast((Map<?, ?>)ctx.get(MessageContext.HTTP_RESPONSE_HEADERS));

Modified: cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ContextPropertiesMappingTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ContextPropertiesMappingTest.java?rev=748306&r1=748305&r2=748306&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ContextPropertiesMappingTest.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ContextPropertiesMappingTest.java
Thu Feb 26 21:14:40 2009
@@ -132,13 +132,13 @@
         xchng.setOutMessage(outMsg);
         
         responseContext.put(MessageContext.HTTP_RESPONSE_CODE, RESPONSE_CODE);
-        
+
         MessageContext ctx = EasyMock.createMock(MessageContext.class);
         ctx.containsKey(MessageContext.HTTP_RESPONSE_CODE);
         EasyMock.expectLastCall().andReturn(true);
         ctx.get(MessageContext.HTTP_RESPONSE_CODE);
         EasyMock.expectLastCall().andReturn(RESPONSE_CODE);
-        
+
         ctx.containsKey(Header.HEADER_LIST);
         EasyMock.expectLastCall().andReturn(true);
         ctx.get(Header.HEADER_LIST);
@@ -150,11 +150,18 @@
         EasyMock.expectLastCall().andReturn(false);
 
         EasyMock.replay(ctx);
+
+        final Map<String, DataHandler> dataHandlers = new HashMap<String, DataHandler>();
+        dataHandlers.put("1", new DataHandler("one", "text/plain"));
+        outMsg.put(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS, dataHandlers);
         
         ContextPropertiesMapping.updateWebServiceContext(xchng, ctx);
         Integer respCode = (Integer)outMsg.get(Message.RESPONSE_CODE);
         assertNotNull("no response code set on out message", respCode);
         assertEquals("incorrect response code returned", RESPONSE_CODE, respCode);
+
+        assertNull(outMsg.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS));
+        assertNotNull(outMsg.getAttachments());
     }
 
     @Test



Mime
View raw message