{
src = msg.getPayloadAsBytes();
}
catch (final Exception e)
{
throw new TransformerException(this, e);
}
}
if (msg.getOutboundAttachmentNames() != null && msg.getOutboundAttachmentNames().size() > 0)
{
try
{
postMethod.setRequestEntity(createMultiPart(msg, postMethod));
return;
}
catch (final Exception e)
{
throw new TransformerException(this, e);
}
}
if (src instanceof String)
{
postMethod.setRequestEntity(new StringRequestEntity(src.toString(), outboundMimeType, encoding));
return;
}
if (src instanceof InputStream)
{
postMethod.setRequestEntity(new InputStreamRequestEntity((InputStream) src, outboundMimeType));
}
else if (src instanceof byte[])
{
postMethod.setRequestEntity(new ByteArrayRequestEntity((byte[]) src, outboundMimeType));
}
else if (src instanceof OutputHandler)
{
final MuleEvent event = RequestContext.getEvent();
postMethod.setRequestEntity(new StreamPayloadRequestEntity((OutputHandler) src, event));
}
else
{
final byte[] buffer = SerializationUtils.serialize((Serializable) src);
postMethod.setRequestEntity(new ByteArrayRequestEntity(buffer, outboundMimeType));
}
}
else if (msg.getOutboundAttachmentNames() != null && msg.getOutboundAttachmentNames().size() > 0)
{
try
{
postMethod.setRequestEntity(createMultiPart(msg, postMethod));
}
catch (Exception e)
{
throw new TransformerException(this, e);
}
}
}