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