Search in sources :

Example 1 with MessageBuilderFactory

use of org.springframework.integration.support.MessageBuilderFactory in project spring-integration by spring-projects.

the class AbstractHttpRequestExecutingMessageHandler method getReply.

protected Object getReply(ResponseEntity<?> httpResponse) {
    if (this.expectReply) {
        HttpHeaders httpHeaders = httpResponse.getHeaders();
        Map<String, Object> headers = this.headerMapper.toHeaders(httpHeaders);
        if (this.transferCookies) {
            this.doConvertSetCookie(headers);
        }
        AbstractIntegrationMessageBuilder<?> replyBuilder = null;
        MessageBuilderFactory messageBuilderFactory = getMessageBuilderFactory();
        if (httpResponse.hasBody()) {
            Object responseBody = httpResponse.getBody();
            replyBuilder = (responseBody instanceof Message<?>) ? messageBuilderFactory.fromMessage((Message<?>) responseBody) : messageBuilderFactory.withPayload(responseBody);
        } else {
            replyBuilder = messageBuilderFactory.withPayload(httpResponse);
        }
        replyBuilder.setHeader(org.springframework.integration.http.HttpHeaders.STATUS_CODE, httpResponse.getStatusCode());
        return replyBuilder.copyHeaders(headers);
    }
    return null;
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) MessageBuilderFactory(org.springframework.integration.support.MessageBuilderFactory)

Aggregations

HttpHeaders (org.springframework.http.HttpHeaders)1 MessageBuilderFactory (org.springframework.integration.support.MessageBuilderFactory)1