Add the ability to set HTTP code status and rest entity when restbc received a fault message exchange

master
David BRASSELY 2013-04-09 14:06:26 +02:00
parent 79c198c516
commit 05c505e131
1 changed files with 25 additions and 9 deletions

View File

@ -50,6 +50,7 @@ import com.sun.jbi.restbc.jbiadapter.util.PathUtil;
import com.sun.jbi.restbc.jbiadapter.util.PropertiesUtil;
import com.sun.jbi.restbc.jbiadapter.wsdl.RestOperation;
import com.sun.jersey.api.uri.UriTemplate;
import javax.jbi.messaging.Fault;
/**
* InboundDelegator.java
@ -285,12 +286,27 @@ public class InboundDelegator {
} else if (msgEx instanceof InOut) {
InOut inout = (InOut) msgEx;
if (inout.getStatus() == ExchangeStatus.ACTIVE) {
ResponseBuilder responseBuilder = Response.ok();
ResponseBuilder responseBuilder;
NormalizedMessage replyMsg;
// https://openesb.atlassian.net/browse/ESBCOMP-24
// When we have a fault, set the response using the status code
// and use the fault message to set the payload of the response
if (inout.getOutMessage() != null) {
responseBuilder = Response.ok();
replyMsg = inout.getOutMessage();
} else {
// TODO: Be able to map fault with HTTP error code
// By default, set HTTP error code to 500
// Can be modified using status NM property
responseBuilder = Response.serverError();
replyMsg = inout.getFault();
}
NormalizedMessage replyMsg = inout.getOutMessage();
Object responsePayload = JbiMessageUtil.getPayloadFromWrappedMsg(replyMsg);
boolean isContentTypeSet = false;
if (responsePayload != null) { // NOI18N
if (responsePayload instanceof Source) {
Source xmlPayload = (Source) responsePayload;