1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.web.struts.form.pojo;
17
18 import org.apache.log4j.Logger;
19 import org.apache.struts.action.ActionForm;
20 import org.apache.struts.action.ActionForward;
21 import org.apache.struts.action.ActionMapping;
22 import org.apache.struts.action.ExceptionHandler;
23 import org.apache.struts.config.ExceptionConfig;
24 import org.kuali.rice.kns.web.struts.form.KualiDocumentFormBase;
25 import org.kuali.rice.kns.util.IncidentReportUtils;
26
27 import javax.servlet.http.HttpServletRequest;
28 import javax.servlet.http.HttpServletResponse;
29 import java.util.Map;
30
31
32
33
34
35
36
37
38 public class StrutsExceptionIncidentHandler extends ExceptionHandler {
39 private static final Logger LOG=
40 Logger.getLogger(StrutsExceptionIncidentHandler.class);
41
42
43
44
45
46
47 public static final String EXCEPTION_INCIDENT_HANDLER="exceptionIncidentHandler";
48
49
50
51
52
53
54
55
56
57
58
59
60
61 public ActionForward execute(Exception exception,
62 ExceptionConfig exceptionConfig,
63 ActionMapping mapping,
64 ActionForm form,
65 HttpServletRequest request,
66 HttpServletResponse response) {
67
68 if (LOG.isTraceEnabled()) {
69 String message=String.format("ENTRY %s", exception.getMessage());
70 LOG.trace(message);
71 }
72
73 LOG.error("Exception being handled by Exception Handler", exception);
74
75 String documentId="";
76 if (form instanceof KualiDocumentFormBase) {
77 KualiDocumentFormBase docForm=(KualiDocumentFormBase)form;
78 if (docForm.getDocument() != null) {
79 documentId=docForm.getDocument().getDocumentNumber();
80 }
81 }
82
83 Map<String, String> properties = IncidentReportUtils.populateRequestForIncidentReport(exception, documentId, form.getClass().getSimpleName(), request);
84
85 ActionForward forward=mapping.findForward(EXCEPTION_INCIDENT_HANDLER);
86
87 if (LOG.isTraceEnabled()) {
88 String message=String.format("ENTRY %s%n%s%n%s",
89 exception.getMessage(),
90 properties.toString(),
91 (forward==null)?"null":forward.getPath());
92 LOG.trace(message);
93 }
94
95 return forward;
96 }
97
98 }
99