@SuppressWarnings("unchecked")
@Override
public Object transformMessage(MuleMessage msg, String enc) throws TransformerException {
RestfulHttpRequest restMsg = new RestfulHttpRequest();
String url = (String) msg.getInboundProperty("http.request");
restMsg.setPath(url);
String httpMethod = (String) msg.getInboundProperty("http.method");
restMsg.setHttpMethod(httpMethod);
Map<String, Object> httpHeaders = (Map<String, Object>) msg.getInboundProperty("http.headers");
// set transaction uuid for outgoing http headers
httpHeaders.put(OPENHIM_TX_UUID, restMsg.getUuid());
restMsg.setHttpHeaders(httpHeaders);
try {
String body = msg.getPayloadAsString();
if (body != url) {
restMsg.setBody(body);
}
} catch (Exception e) {
throw new TransformerException(this, e);
}
String scheme = ((String)msg.getInboundProperty("http.context.uri")).split(":")[0];
if ("https".equals(scheme))
restMsg.setScheme(Scheme.HTTPS);
else if ("http".equals(scheme))
restMsg.setScheme(Scheme.HTTP);
return restMsg;
}