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