Package org.apache.camel.spi

Examples of org.apache.camel.spi.HeaderFilterStrategy


        String httpProtocolVersion = in.getHeader(Exchange.HTTP_PROTOCOL_VERSION, String.class);
        if (httpProtocolVersion != null) {
            // set the HTTP protocol version
            httpRequest.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpHelper.parserHttpVersion(httpProtocolVersion));
        }
        HeaderFilterStrategy strategy = getEndpoint().getHeaderFilterStrategy();

        // propagate headers as HTTP headers
        for (Map.Entry<String, Object> entry : in.getHeaders().entrySet()) {
            String key = entry.getKey();
            Object headerValue = in.getHeader(key);

            if (headerValue != null) {
                // use an iterator as there can be multiple values. (must not use a delimiter)
                final Iterator it = ObjectHelper.createIterator(headerValue, null);

                // the value to add as request header
                final List<String> values = new ArrayList<String>();

                // if its a multi value then check each value if we can add it and for multi values they
                // should be combined into a single value
                while (it.hasNext()) {
                    String value = exchange.getContext().getTypeConverter().convertTo(String.class, it.next());

                    // we should not add headers for the parameters in the uri if we bridge the endpoint
                    // as then we would duplicate headers on both the endpoint uri, and in HTTP headers as well
                    if (skipRequestHeaders != null && skipRequestHeaders.containsKey(key)) {
                        Object skipValue = skipRequestHeaders.get(key);
                        if (ObjectHelper.equal(skipValue, value)) {
                            continue;
                        }
                    }
                    if (value != null && strategy != null && !strategy.applyFilterToCamelHeaders(key, value, exchange)) {
                        values.add(value);
                    }
                }

                // add the value(s) as a http request header
View Full Code Here


    }

    public void process(Exchange exchange) throws Exception {
        HttpMethod method = createMethod(exchange);
        Message in = exchange.getIn();
        HeaderFilterStrategy strategy = ((HttpEndpoint)getEndpoint()).getHeaderFilterStrategy();

        // propagate headers as HTTP headers
        for (String headerName : in.getHeaders().keySet()) {
            String headerValue = in.getHeader(headerName, String.class);
            if (strategy != null && !strategy.applyFilterToCamelHeaders(headerName, headerValue, exchange)) {
                method.addRequestHeader(headerName, headerValue);
            }
        }

        // lets store the result in the output message.
View Full Code Here

            }
        }

        // propagate headers as HTTP headers
        Message in = exchange.getIn();
        HeaderFilterStrategy strategy = getEndpoint().getHeaderFilterStrategy();
        for (Map.Entry<String, Object> entry : in.getHeaders().entrySet()) {
            String key = entry.getKey();
            Object headerValue = in.getHeader(key);

            if (headerValue != null) {
                // use an iterator as there can be multiple values. (must not use a delimiter, and allow empty values)
                final Iterator<?> it = ObjectHelper.createIterator(headerValue, null, true);

                // the values to add as a request header
                final List<String> values = new ArrayList<String>();

                // if its a multi value then check each value if we can add it and for multi values they
                // should be combined into a single value
                while (it.hasNext()) {
                    String value = exchange.getContext().getTypeConverter().convertTo(String.class, it.next());

                    // we should not add headers for the parameters in the uri if we bridge the endpoint
                    // as then we would duplicate headers on both the endpoint uri, and in HTTP headers as well
                    if (skipRequestHeaders != null && skipRequestHeaders.containsKey(key)) {
                        Object skipValue = skipRequestHeaders.get(key);
                        if (ObjectHelper.equal(skipValue, value)) {
                            continue;
                        }
                    }
                    if (value != null && strategy != null && !strategy.applyFilterToCamelHeaders(key, value, exchange)) {
                        values.add(value);
                    }
                }

                // add the value(s) as a http request header
View Full Code Here

            }
        }

        // and copy headers from IN message
        Message in = exchange.getIn();
        HeaderFilterStrategy strategy = getEndpoint().getHeaderFilterStrategy();

        // propagate headers as HTTP headers
        for (String headerName : in.getHeaders().keySet()) {
            String headerValue = in.getHeader(headerName, String.class);
            if (strategy != null && !strategy.applyFilterToCamelHeaders(headerName, headerValue, exchange)) {
                httpExchange.addRequestHeader(headerName, headerValue);
            }
        }

        return httpExchange;
View Full Code Here

    // ----------------------------------------------------------------
    //  Customization points
    // ----------------------------------------------------------------
   
    protected void writeRequestHeaders(GTaskEndpoint endpoint, Exchange exchange, TaskOptions request) {
        HeaderFilterStrategy strategy = endpoint.getHeaderFilterStrategy();
        for (String headerName : exchange.getIn().getHeaders().keySet()) {
            String headerValue = exchange.getIn().getHeader(headerName, String.class);
            if (strategy != null && !strategy.applyFilterToCamelHeaders(headerName, headerValue, exchange)) {
                request.header(headerName, headerValue);
            }
        }
    }
View Full Code Here

    public void testHeaderFilterStrategyComponent() {
        MyComponent comp = new MyComponent();
        assertNull(comp.getHeaderFilterStrategy());

        HeaderFilterStrategy strategy = new DefaultHeaderFilterStrategy();
        comp.setHeaderFilterStrategy(strategy);

        assertSame(strategy, comp.getHeaderFilterStrategy());
    }
View Full Code Here

    public void testHeaderFilterStrategyAware() {
        MyComponent comp = new MyComponent();
        assertNull(comp.getHeaderFilterStrategy());

        HeaderFilterStrategy strategy = new DefaultHeaderFilterStrategy();
        comp.setHeaderFilterStrategy(strategy);

        MyEndpoint my = new MyEndpoint();
        comp.setEndpointHeaderFilterStrategy(my);
View Full Code Here

    public void testHeaderFilterStrategyComponent() {
        MyComponent comp = new MyComponent();
        assertNull(comp.getHeaderFilterStrategy());

        HeaderFilterStrategy strategy = new DefaultHeaderFilterStrategy();
        comp.setHeaderFilterStrategy(strategy);

        assertSame(strategy, comp.getHeaderFilterStrategy());
    }
View Full Code Here

    public void testHeaderFilterStrategyAware() {
        MyComponent comp = new MyComponent();
        assertNull(comp.getHeaderFilterStrategy());

        HeaderFilterStrategy strategy = new DefaultHeaderFilterStrategy();
        comp.setHeaderFilterStrategy(strategy);

        MyEndpoint my = new MyEndpoint();
        comp.setEndpointHeaderFilterStrategy(my);
View Full Code Here

    // ----------------------------------------------------------------
    //  Customization points
    // ----------------------------------------------------------------
   
    protected void readResponseHeaders(GHttpEndpoint endpoint, Exchange exchange, HTTPResponse response) {
        HeaderFilterStrategy strategy = endpoint.getHeaderFilterStrategy();
       
        Message in = exchange.getIn();
        Message out = exchange.getOut();
       
        out.setHeaders(in.getHeaders());
        out.setHeader(Exchange.HTTP_RESPONSE_CODE, response.getResponseCode());
       
        String contentType = getResponseHeader("Content-Type", response);
        if (contentType != null) {
            out.setHeader(Exchange.CONTENT_TYPE, contentType);
        }
       
        for (HTTPHeader header : response.getHeaders()) {
            String name = header.getName();
            String value = header.getValue();
            if (strategy != null && !strategy.applyFilterToExternalHeaders(name, value, exchange)) {
                out.setHeader(name, value);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.camel.spi.HeaderFilterStrategy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.