1
2
3
4
5
6
7 package org.mule.module.cxf.support;
8
9 import org.mule.api.MuleEvent;
10 import org.mule.api.MuleMessage;
11 import org.mule.module.cxf.CxfConstants;
12 import org.mule.transport.http.HttpConstants;
13
14 import java.util.Collection;
15
16 import org.apache.cxf.interceptor.Fault;
17 import org.apache.cxf.message.Attachment;
18 import org.apache.cxf.message.Message;
19 import org.apache.cxf.phase.AbstractPhaseInterceptor;
20 import org.apache.cxf.phase.Phase;
21
22 public class CopyAttachmentInInterceptor extends AbstractPhaseInterceptor
23 {
24 public CopyAttachmentInInterceptor()
25 {
26 super(Phase.PRE_INVOKE);
27 }
28
29 public void handleMessage(Message message) throws Fault
30 {
31 MuleEvent event = (MuleEvent) message.getExchange().get(CxfConstants.MULE_EVENT);
32 MuleMessage muleMsg = event.getMessage();
33 Collection<Attachment> atts = message.getAttachments();
34
35 if (atts != null && !atts.isEmpty())
36 {
37 muleMsg.setInvocationProperty(CxfConstants.ATTACHMENTS, atts);
38 muleMsg.setOutboundProperty(HttpConstants.HEADER_CONTENT_TYPE, muleMsg.getInboundProperty(HttpConstants.HEADER_CONTENT_TYPE));
39 }
40 }
41
42 }
43
44