Coverage Report - org.mule.transport.soap.axis.AxisMuleMessageFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
AxisMuleMessageFactory
0%
0/30
0%
0/14
0
 
 1  
 /*
 2  
  * $Id: AxisMuleMessageFactory.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.transport.soap.axis;
 12  
 
 13  
 import org.mule.DefaultMuleMessage;
 14  
 import org.mule.api.MuleContext;
 15  
 import org.mule.module.cxf.MuleSoapHeaders;
 16  
 import org.mule.transport.AbstractMuleMessageFactory;
 17  
 import org.mule.util.StringUtils;
 18  
 
 19  
 import java.util.Iterator;
 20  
 
 21  
 import javax.xml.soap.SOAPMessage;
 22  
 
 23  
 import org.apache.axis.MessageContext;
 24  
 import org.apache.axis.attachments.AttachmentPart;
 25  
 import org.apache.commons.logging.Log;
 26  
 import org.apache.commons.logging.LogFactory;
 27  
 
 28  
 public class AxisMuleMessageFactory extends AbstractMuleMessageFactory
 29  
 {
 30  0
     private static Log log = LogFactory.getLog(AxisMuleMessageFactory.class);
 31  
     
 32  
     public AxisMuleMessageFactory(MuleContext context)
 33  
     {
 34  0
         super(context);
 35  0
     }
 36  
 
 37  
     @Override
 38  
     protected Class<?>[] getSupportedTransportMessageTypes()
 39  
     {
 40  0
         return new Class[] { Object.class };
 41  
     }
 42  
 
 43  
     @Override
 44  
     protected Object extractPayload(Object transportMessage, String encoding) throws Exception
 45  
     {
 46  0
         return transportMessage;
 47  
     }
 48  
 
 49  
     @Override
 50  
     protected void addProperties(DefaultMuleMessage message, Object transportMessage) throws Exception
 51  
     {
 52  0
         MessageContext ctx = MessageContext.getCurrentContext();
 53  0
         if (ctx != null)
 54  
         {
 55  0
             MuleSoapHeaders header = new MuleSoapHeaders(
 56  
                 ctx.getMessage().getSOAPPart().getEnvelope().getHeader());
 57  
 
 58  0
             if (StringUtils.isNotBlank(header.getReplyTo()))
 59  
             {
 60  0
                 message.setReplyTo(header.getReplyTo());
 61  
             }
 62  0
             if (StringUtils.isNotBlank(header.getCorrelationGroup()))
 63  
             {
 64  0
                 message.setCorrelationGroupSize(Integer.parseInt(header.getCorrelationGroup()));
 65  
             }
 66  0
             if (StringUtils.isNotBlank(header.getCorrelationSequence()))
 67  
             {
 68  0
                 message.setCorrelationSequence(Integer.parseInt(header.getCorrelationSequence()));
 69  
             }
 70  0
             if (StringUtils.isNotBlank(header.getCorrelationId()))
 71  
             {
 72  0
                 message.setCorrelationId(header.getCorrelationId());
 73  
             }
 74  
         }
 75  0
     }
 76  
 
 77  
     @Override
 78  
     protected void addAttachments(DefaultMuleMessage message, Object transportMessage) throws Exception
 79  
     {
 80  0
         MessageContext ctx = MessageContext.getCurrentContext();
 81  0
         if (ctx == null)
 82  
         {
 83  0
             return;
 84  
         }
 85  
         
 86  
         try
 87  
         {
 88  0
             SOAPMessage soapMessage = ctx.getMessage();
 89  0
             int x = 1;
 90  0
             for (Iterator<?> i = soapMessage.getAttachments(); i.hasNext(); x++)
 91  
             {
 92  0
                 String name = String.valueOf(x);
 93  0
                 AttachmentPart attachmentPart = (AttachmentPart)i.next();
 94  0
                 message.addAttachment(name, attachmentPart.getActivationDataHandler());
 95  
             }
 96  
         }
 97  0
         catch (Exception e)
 98  
         {
 99  
             // this will not happen
 100  0
             log.fatal("Failed to read attachments", e);
 101  0
         }
 102  0
     }
 103  
 }