Coverage Report - org.mule.endpoint.outbound.OutboundResponsePropertiesMessageProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
OutboundResponsePropertiesMessageProcessor
0%
0/12
0%
0/6
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.endpoint.outbound;
 8  
 
 9  
 import org.mule.api.MuleEvent;
 10  
 import org.mule.api.MuleException;
 11  
 import org.mule.api.endpoint.OutboundEndpoint;
 12  
 import org.mule.processor.AbstractInterceptingMessageProcessor;
 13  
 
 14  
 import java.util.List;
 15  
 
 16  
 /**
 17  
  * Propagates properties from request message to response message as defined by
 18  
  * {@link OutboundEndpoint#getResponseProperties()}.
 19  
  * <p>
 20  
  * //TODO This can became a standard MessageProcessor in the response chain if/when
 21  
  * event has a (immutable) reference to request message.
 22  
  */
 23  
 public class OutboundResponsePropertiesMessageProcessor extends AbstractInterceptingMessageProcessor
 24  
 {
 25  
 
 26  
     private OutboundEndpoint endpoint;
 27  
 
 28  
     public OutboundResponsePropertiesMessageProcessor(OutboundEndpoint endpoint)
 29  0
     {
 30  0
         this.endpoint = endpoint;
 31  0
     }
 32  
 
 33  
     public MuleEvent process(MuleEvent event) throws MuleException
 34  
     {
 35  0
         MuleEvent responseEvent = processNext(event);
 36  
 
 37  0
         if (responseEvent != null)
 38  
         {
 39  
             // Properties which should be carried over from the request message
 40  
             // to the response message
 41  0
             List<String> responseProperties = endpoint.getResponseProperties();
 42  0
             for (String propertyName : responseProperties)
 43  
             {
 44  0
                 Object propertyValue = event.getMessage().getOutboundProperty(propertyName);
 45  0
                 if (propertyValue != null)
 46  
                 {
 47  0
                     responseEvent.getMessage().setOutboundProperty(propertyName, propertyValue);
 48  
                 }
 49  0
             }
 50  
         }
 51  0
         return responseEvent;
 52  
     }
 53  
 }