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