View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.cxf.support;
8   
9   import org.mule.api.MuleEvent;
10  import org.mule.module.cxf.CxfConstants;
11  
12  import java.util.Collection;
13  
14  import org.apache.cxf.interceptor.Fault;
15  import org.apache.cxf.message.Attachment;
16  import org.apache.cxf.message.Message;
17  import org.apache.cxf.phase.AbstractPhaseInterceptor;
18  import org.apache.cxf.phase.Phase;
19  
20  /**
21   * Copies any attachments which were stored by the proxy to the outbound CXF message.
22   */
23  public class CopyAttachmentOutInterceptor extends AbstractPhaseInterceptor
24  {
25      public CopyAttachmentOutInterceptor()
26      {
27          super(Phase.SETUP);
28      }
29  
30      public void handleMessage(Message message) throws Fault
31      {
32          MuleEvent event = (MuleEvent) message.getExchange().get(CxfConstants.MULE_EVENT);
33          Collection<Attachment> a = event.getMessage().getInvocationProperty(CxfConstants.ATTACHMENTS);
34          
35          if (a != null) 
36          {
37              message.setAttachments(a);
38          }
39      }
40  }
41  
42