Coverage Report - org.mule.module.cxf.support.CopyAttachmentInInterceptor
 
Classes in this File Line Coverage Branch Coverage Complexity
CopyAttachmentInInterceptor
0%
0/11
0%
0/4
0
 
 1  
 /*
 2  
  * $Id: CopyAttachmentInInterceptor.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 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