* @param context the context associated with the active request
* @throws Exception if an exception occurs
*/
private void executeSendFeedback(ActionEvent event, RequestContext context)
throws Exception {
MessageBroker msgBroker = extractMessageBroker();
ApplicationConfiguration appConfig = context.getApplicationConfiguration();
FeedbackMessage msg = getFeedbackMessage();
// validate parameters
boolean bOk = true;
String sName = msg.getFromName();
String sEmail = msg.getFromAddress();
String sBody = msg.getBody();
String sSender = sEmail;
if (!Val.chkEmail(sEmail)) {
bOk = false;
msgBroker.addErrorMessage("identity.feedback.err.email");
} else if (sBody.length() == 0) {
bOk = false;
msgBroker.addErrorMessage("identity.feedback.err.body");
} else if (sName.length() > 0) {
sSender = sName;
}
// send mail if ok
if (bOk) {
// try to filter out mischievous content
sSender = sSender.replaceAll("<", "<");
sBody = sBody.replaceAll("<", "<");
// build the message subject and body
String[] args = new String[3];
args[0] = sSender;
args[1] = sBody;
args[2] = RequestContext.resolveBaseContextPath((HttpServletRequest) context.getServletRequest());
String sSubject = msgBroker.retrieveMessage("identity.feedback.email.subject");
sBody = msgBroker.retrieveMessage("identity.feedback.email.body",args);
// send the message to the site
MailRequest mailReq = appConfig.getMailConfiguration().newInboundRequest();
mailReq.setFromAddress(sEmail);
mailReq.setSubject(sSubject);
mailReq.setBody(sBody);
mailReq.send();
// send a copy of the message to the user
MailRequest mailReqCopy = appConfig.getMailConfiguration().newOutboundRequest();
mailReqCopy.setToAddress(sEmail);
mailReqCopy.setSubject(sSubject);
mailReqCopy.setBody(sBody);
mailReqCopy.send();
// add the success message, set the navigation outcome
msgBroker.addSuccessMessage("identity.feedback.success");
setNavigationOutcome(ResourceKeys.NAVIGATIONOUTCOME_HOME_DIRECT);
}
}