camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amit <ap1...@att.com>
Subject Re: CFX-Bean:headers access Issue
Date Wed, 16 Oct 2013 17:51:37 GMT
After removing conent-type from header filter. I found the issue in
CxfHeaderHelper below method. It puts the content Type in message not in
header and org.apache.cxf.jaxrs.impl.HttpHeadersImpl class get  content Type
from header. I did comment out "if
(Exchange.CONTENT_TYPE.equals(entry.getKey()))"  block and it works as
expected.



public static void propagateCamelToCxf(HeaderFilterStrategy strategy,
            Map<String, Object> headers, Message message, Exchange exchange)
{

        Map<String, List&lt;String>> cxfHeaders =
            CastUtils.cast((Map<?,
?>)message.get(Message.PROTOCOL_HEADERS));

        if (cxfHeaders == null) {
            // use a treemap to keep ordering and ignore key case
            cxfHeaders = new TreeMap<String,
List&lt;String>>(String.CASE_INSENSITIVE_ORDER);
            message.put(Message.PROTOCOL_HEADERS, cxfHeaders);
        }

        for (Map.Entry<String, Object> entry : headers.entrySet()) {
            if (strategy != null
                    && !strategy.applyFilterToCamelHeaders(entry.getKey(),
entry.getValue(), exchange)) {

                if (Exchange.CONTENT_TYPE.equals(entry.getKey())) {             
//commented out this block
                    message.put(Message.CONTENT_TYPE, entry.getValue());
                } else
                	
                if (Client.REQUEST_CONTEXT.equals(entry.getKey())
                            ||
Client.RESPONSE_CONTEXT.equals(entry.getKey())
                            || Message.RESPONSE_CODE.equals(entry.getKey()))
{
                    message.put(entry.getKey(), entry.getValue());
                } else {
                    Object values = entry.getValue();
                    if (values instanceof List<?>) {
                        cxfHeaders.put(entry.getKey(),
CastUtils.cast((List<?>)values, String.class));
                    } else {
                        List<String> listValue = new ArrayList<String>();
                        listValue.add(entry.getValue().toString());
                        cxfHeaders.put(entry.getKey(), listValue);
                    }
                }
            }
        }
    }

Thanks,
Amit 



--
View this message in context: http://camel.465427.n5.nabble.com/CFX-Bean-headers-access-Issue-tp5741312p5741691.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message