try
{
message.addOutboundAttachment(expression, (DataHandler) object);
} catch (Exception e)
{
throw new MuleRuntimeException(e);
}
}
else
{
String[] split = expression.split(ExpressionConstants.DELIM);
if (split.length < 2)
{
throw new MuleRuntimeException(CoreMessages.createStaticMessage(MessageFormat.format("attachment enrichment expression {0} does not declare a content type",expression)));
}
String attachmentName = split[0];
String contentType = split[1];
try
{
message.addOutboundAttachment(attachmentName,object,contentType);
}
catch (Exception e)
{
throw new MuleRuntimeException(CoreMessages.createStaticMessage("failed to set attachment"));
}
}
}