View Javadoc

1   /*
2    * $Id: AxisCleanAndAddProperties.java 7976 2007-08-21 14:26:13Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.providers.soap.axis.extras;
12  
13  import org.mule.config.MuleProperties;
14  import org.mule.providers.http.HttpConnector;
15  import org.mule.providers.http.HttpConstants;
16  import org.mule.providers.soap.SoapConstants;
17  import org.mule.umo.UMOEventContext;
18  import org.mule.umo.UMOMessage;
19  import org.mule.util.StringUtils;
20  
21  import java.util.HashMap;
22  import java.util.Iterator;
23  import java.util.Map;
24  
25  public class AxisCleanAndAddProperties
26  {
27      
28      // add all custom headers, filter out all mule headers (such as
29      // MULE_SESSION) except
30      // for MULE_USER header. Filter out other headers like "soapMethods" and
31      // MuleProperties.MULE_METHOD_PROPERTY and "soapAction"
32      // and also filter out any http related header
33      
34      public static Map cleanAndAdd(UMOEventContext muleEventContext){
35          
36          Map props = new HashMap();
37          UMOMessage currentMessage = muleEventContext.getMessage();
38          final String SOAP_METHODS = "soapMethods";
39  
40          for (Iterator iterator = currentMessage.getPropertyNames().iterator(); iterator.hasNext();)
41          {
42              String name = (String)iterator.next();
43              if (!StringUtils.equals(name, SOAP_METHODS)
44                  && !StringUtils.equals(name, SoapConstants.SOAP_ACTION_PROPERTY)
45                  && !StringUtils.equals(name, MuleProperties.MULE_METHOD_PROPERTY)
46                  && (!name.startsWith(MuleProperties.PROPERTY_PREFIX) || StringUtils.equals(name,
47                      MuleProperties.MULE_USER_PROPERTY))
48                  && !HttpConstants.ALL_HEADER_NAMES.containsValue(name)
49                  && !StringUtils.equals(name, HttpConnector.HTTP_STATUS_PROPERTY))
50              {
51                  props.put(name, currentMessage.getProperty(name));
52              }
53          }
54          return props;
55      }
56  }