01: /*
02: * $Id: AxisCleanAndAddProperties.java 10489 2008-01-23 17:53:38Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
10:
11: package org.mule.transport.soap.axis.extras;
12:
13: import org.mule.api.MuleEventContext;
14: import org.mule.api.MuleMessage;
15: import org.mule.api.config.MuleProperties;
16: import org.mule.transport.http.HttpConnector;
17: import org.mule.transport.http.HttpConstants;
18: import org.mule.transport.soap.SoapConstants;
19: import org.mule.transport.soap.axis.AxisConnector;
20: import org.mule.util.StringUtils;
21:
22: import java.util.HashMap;
23: import java.util.Iterator;
24: import java.util.Map;
25:
26: public class AxisCleanAndAddProperties {
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(MuleEventContext muleEventContext) {
35:
36: Map props = new HashMap();
37: MuleMessage currentMessage = muleEventContext.getMessage();
38:
39: for (Iterator iterator = currentMessage.getPropertyNames()
40: .iterator(); iterator.hasNext();) {
41: String name = (String) iterator.next();
42: if (!StringUtils.equals(name, AxisConnector.SOAP_METHODS)
43: && !StringUtils.equals(name,
44: SoapConstants.SOAP_ACTION_PROPERTY)
45: && !StringUtils.equals(name,
46: MuleProperties.MULE_METHOD_PROPERTY)
47: && (!name
48: .startsWith(MuleProperties.PROPERTY_PREFIX) || StringUtils
49: .equals(name,
50: MuleProperties.MULE_USER_PROPERTY))
51: && !HttpConstants.ALL_HEADER_NAMES
52: .containsValue(name)
53: && !StringUtils.equals(name,
54: HttpConnector.HTTP_STATUS_PROPERTY)) {
55: props.put(name, currentMessage.getProperty(name));
56: }
57: }
58: return props;
59: }
60: }
|