HttpServletResponse response) throws Exception {
ReplacementForm rf = (ReplacementForm)form;
SessionInfo info = this.getSessionInfo(request);
if (null == rf.getReplacement().getMatchPattern() ||"".equals(rf.getReplacement().getMatchPattern())) {
ActionMessages mesgs = new ActionMessages();
mesgs.add(Globals.MESSAGE_KEY, new ActionMessage("createReplacement.error.noMatchPattern"));
saveErrors(request, mesgs);
return mapping.findForward("display");
}
if(rf.isEditing()) {
try {
WebForwardDatabaseFactory.getInstance().updateReplacement(rf.getReplacement());
CoreServlet.getServlet().fireCoreEvent(new CoreEvent(this, WebForwardEventConstants.UPDATE_REPLACEMENT, null, info, CoreEvent.STATE_SUCCESSFUL)
.addAttribute(WebForwardEventConstants.EVENT_ATTR_REPLACEMENT_TYPE, rf.getReplaceType())
.addAttribute(WebForwardEventConstants.EVENT_ATTR_REPLACEMENT_PATTERN, rf.getReplacement().getReplacePattern()));
} catch (Exception e) {
CoreServlet.getServlet().fireCoreEvent(new CoreEvent(this, WebForwardEventConstants.UPDATE_REPLACEMENT, null, info, CoreEvent.STATE_UNSUCCESSFUL)
.addAttribute(WebForwardEventConstants.EVENT_ATTR_REPLACEMENT_TYPE, rf.getReplaceType())
.addAttribute(WebForwardEventConstants.EVENT_ATTR_REPLACEMENT_PATTERN, rf.getReplacement().getReplacePattern()));
throw e;
}
}
else {
try {
WebForwardDatabaseFactory.getInstance().createReplacement(rf.getReplacement());
CoreServlet.getServlet().fireCoreEvent(new CoreEvent(this, WebForwardEventConstants.CREATE_REPLACEMENT, null, info, CoreEvent.STATE_SUCCESSFUL)
.addAttribute(WebForwardEventConstants.EVENT_ATTR_REPLACEMENT_TYPE, rf.getReplaceType())
.addAttribute(WebForwardEventConstants.EVENT_ATTR_REPLACEMENT_PATTERN, rf.getReplacement().getReplacePattern()));
} catch (Exception e) {
CoreServlet.getServlet().fireCoreEvent(new CoreEvent(this, WebForwardEventConstants.CREATE_REPLACEMENT, null, info, CoreEvent.STATE_UNSUCCESSFUL)
.addAttribute(WebForwardEventConstants.EVENT_ATTR_REPLACEMENT_TYPE, rf.getReplaceType())
.addAttribute(WebForwardEventConstants.EVENT_ATTR_REPLACEMENT_PATTERN, rf.getReplacement().getReplacePattern()));
throw e;
}
}
ActionMessages msgs = new ActionMessages();
msgs.add(Globals.MESSAGE_KEY, new ActionMessage("createReplacement.message.saved"));
saveMessages(request, msgs);
return mapping.findForward("success");
}