<commit_before>package se.vgregion.routes;

import com.liferay.portal.kernel.messaging.DestinationNames;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.spring.SpringRouteBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.core.Response;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * User: pabe
 * Date: 2011-05-10
 * Time: 15:56
 */
public class MessagebusRestRouteBuilder extends SpringRouteBuilder {

    private String messageBusDestination;
    private String restDestination;
    private String restMethod;
    private String restContentType;

    public MessagebusRestRouteBuilder(String messageBusDestination, String restDestination, String restMethod,
            String restContentType) {
        this.messageBusDestination = messageBusDestination;
        this.restDestination = restDestination;
        this.restMethod = restMethod;
        this.restContentType = restContentType;

        log.info("MB: {} ReST: {}", messageBusDestination, restDestination);
    }

    public MessagebusRestRouteBuilder(String messageBusDestination, String restDestination) {
        this(messageBusDestination, restDestination, "POST", "*/*");
    }

    @Override
    public void configure() throws Exception {
        from("liferay:" + messageBusDestination)
                .errorHandler(deadLetterChannel("direct:error_" + messageBusDestination))
                .setHeader(Exchange.HTTP_METHOD, simple(restMethod))
                .setProperty("correlationId", header("responseId"))
                .inOut("cxfrs://" + restDestination)
                .process(new Processor() {
                    @Override
                    public void process(Exchange exchange) throws Exception {
                        String result = extractResponseBody(exchange);
                        exchange.getOut().setBody(result);
                    }<commit_msg>- And set AcceptType in header<commit_after>package se.vgregion.routes;

import com.liferay.portal.kernel.messaging.DestinationNames;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.spring.SpringRouteBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.core.Response;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * User: pabe
 * Date: 2011-05-10
 * Time: 15:56
 */
public class MessagebusRestRouteBuilder extends SpringRouteBuilder {

    private String messageBusDestination;
    private String restDestination;
    private String restMethod;
    private String restContentType;

    public MessagebusRestRouteBuilder(String messageBusDestination, String restDestination, String restMethod,
            String restContentType) {
        this.messageBusDestination = messageBusDestination;
        this.restDestination = restDestination;
        this.restMethod = restMethod;
        this.restContentType = restContentType;

        log.info("MB: {} ReST: {}", messageBusDestination, restDestination);
    }

    public MessagebusRestRouteBuilder(String messageBusDestination, String restDestination) {
        this(messageBusDestination, restDestination, "POST", "*/*");
    }

    @Override
    public void configure() throws Exception {
        from("liferay:" + messageBusDestination)
                .errorHandler(deadLetterChannel("direct:error_" + messageBusDestination))
                .setHeader(Exchange.HTTP_METHOD, simple(restMethod))
                .setHeader(Exchange.ACCEPT_CONTENT_TYPE, simple(restContentType))
                .setProperty("correlationId", header("responseId"))
                .inOut("cxfrs://" + restDestination)
                .process(new Processor() {
                    @Override
                    public void process(Exchange exchange) throws Exception {
                        String result = extractResponseBody(exchange);
                        exchange.getOut().setBody(result);
                    }
{'fraction_non_alphanumeric': 0.09093143278446793, 'fraction_numerical': 0.006881297616121897, 'mean_word_length': 3.074074074074074, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4268985', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1036, 'n_words': 213}