if (requestEncoding == null) {
requestEncoding = "ISO-8859-1";
}
// Are we sending a URL or an XML message?
String url = request.getParameter("url");
MultiChannelMessage message = null;
// Do we have an explicit charset encoding? Null values are allowed and
// should result in device default charset being used. N.B. the "null"
// string is sent by the form element when the user does not want to
// specify a character encoding
String characterSet = request.getParameter("charset");
if (characterSet.equalsIgnoreCase("null")) {
characterSet = null;
}
// do we need to generate and save the message to file
boolean genMessage = false;
if (request.getParameter("genMsg") != null &&
request.getParameter("genMsg").equalsIgnoreCase("on")) {
genMessage = true;
}
// get the subject
String subject = request.getParameter("subject");
if (characterSet != null) {
subject = ContentUtilities.convertEncoding(
subject,
requestEncoding,
characterSet
);
}
if (!(url.equals(""))) {
message = new MultiChannelMessageImpl(new URL(url), subject, characterSet);
} else {
String xml = request.getParameter("xml");
if (characterSet != null) {
// convert from request char set to specified charset
xml = ContentUtilities.convertEncoding(
xml,
requestEncoding,
characterSet
);
}
message = new MultiChannelMessageImpl(xml, subject, characterSet);
}
try {
message.addAttachments(getAttachments(request));
} catch (Exception ee) {
// log the fact that this failed and carry on.
// Probably not the best thing to do...
logger.error("Failed to attach attachments", ee);
}