01 package com.bea.medrec.actions;
02
03 import com.bea.medrec.beans.ErrorBean;
04 import com.bea.medrec.utils.ClientException;
05 import com.bea.medrec.utils.MedRecLog4jFactory;
06 import com.bea.medrec.utils.MedRecWebAppUtils;
07 import javax.servlet.http.HttpServletRequest;
08 import javax.servlet.http.HttpServletResponse;
09 import org.apache.log4j.Logger;
10 import org.apache.struts.action.ActionForm;
11 import org.apache.struts.action.ActionForward;
12 import org.apache.struts.action.ActionMapping;
13
14 /**
15 * <p>Handles error presentation.</p>
16 *
17 * @author Copyright (c) 2006 by BEA Systems. All Rights Reserved.
18 */
19 public class ErrorAction extends BaseAction {
20 private static Logger logger =
21 MedRecLog4jFactory.getLogger(ErrorAction.class.getName());
22
23 /**
24 * <p>Process the specified HTTP request, and create the corresponding HTTP
25 * response (or forward to another web component that will create it).
26 * Return an <code>ActionForward</code> instance describing where and how
27 * control should be forwarded.
28 * <br>
29 * Handles presentation of error messages.
30 * </p>
31 *
32 * @param mapping The ActionMapping used to select this instance
33 * @param form The optional ActionForm bean for this request (if any)
34 * @param request The HTTP request we are processing
35 * @param response The HTTP response we are creating
36 */
37 public ActionForward executeAction(ActionMapping mapping,
38 ActionForm form,
39 HttpServletRequest request,
40 HttpServletResponse response)
41 throws ClientException {
42 logger.info("Error action excution");
43 ErrorBean error = (ErrorBean) request.getAttribute("errorBean");
44 error = (error == null ? new ErrorBean() : error);
45
46 if (MedRecWebAppUtils.isEmpty(error.getErrMessage())) {
47 error.setErrMessage("Error unknown. Please contact system admin.");
48 error.setLink("home");
49 }
50
51 request.setAttribute("errorBean", error);
52 return mapping.findForward("error.page");
53 }
54 }
|