KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > soap > axis > extras > AxisCleanAndAddProperties


1 /*
2  * $Id$
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 MuleSource MPL
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 java.util.HashMap JavaDoc;
14 import java.util.Iterator JavaDoc;
15 import java.util.Map JavaDoc;
16
17 import org.apache.commons.lang.StringUtils;
18 import org.mule.config.MuleProperties;
19 import org.mule.providers.http.HttpConnector;
20 import org.mule.providers.http.HttpConstants;
21 import org.mule.providers.soap.SoapConstants;
22 import org.mule.umo.UMOEventContext;
23 import org.mule.umo.UMOMessage;
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 JavaDoc cleanAndAdd(UMOEventContext muleEventContext){
35         
36         Map JavaDoc props = new HashMap JavaDoc();
37         UMOMessage currentMessage = muleEventContext.getMessage();
38         final String JavaDoc SOAP_METHODS = "soapMethods";
39
40         for (Iterator JavaDoc iterator = currentMessage.getPropertyNames().iterator(); iterator.hasNext();)
41         {
42             String JavaDoc name = (String JavaDoc)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 }
Popular Tags