1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krad.web.form; |
17 | |
|
18 | |
import org.kuali.rice.krad.service.KRADServiceLocator; |
19 | |
|
20 | |
import java.io.PrintWriter; |
21 | |
import java.io.StringWriter; |
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
public class IncidentReportForm extends UifFormBase { |
29 | |
|
30 | |
private static final long serialVersionUID = -6677581167041430694L; |
31 | |
|
32 | 0 | protected String errorMessage = "The system has encountered an error and is unable to complete your request at this time. Please provide more information regarding this error by completing this Incident Report."; |
33 | |
|
34 | |
protected Exception exception; |
35 | |
protected String exceptionMessage; |
36 | |
protected String exceptionStackTrace; |
37 | |
|
38 | |
protected String userInput; |
39 | |
protected String incidentDocId; |
40 | |
protected String incidentViewId; |
41 | |
protected String controller; |
42 | |
protected String userName; |
43 | |
protected String userId; |
44 | |
protected String userEmail; |
45 | |
|
46 | |
protected boolean devMode; |
47 | |
|
48 | |
public IncidentReportForm() { |
49 | 0 | super(); |
50 | 0 | this.setRenderFullView(true); |
51 | 0 | setViewTypeName("INCIDENT"); |
52 | 0 | } |
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
public String createEmailMessage() { |
60 | 0 | String format = "Document Id: %s%n" + "View Id: %s%n" + "Handler: %s%n%n" + "User Email: %s%n" |
61 | |
+ "Person User Identifier: %s%n" + "Person Name: %s%n" + "User Input: %s%n%n" + "errorMessage: %n" |
62 | |
+ "%s"; |
63 | 0 | String message = String.format(format, (incidentDocId == null) ? "" : incidentDocId, (incidentViewId == null) ? "" : incidentViewId, |
64 | |
(controller == null) ? "" : controller, (userEmail == null) ? "" : userEmail, (userId == null) ? "" |
65 | |
: userId, (userName == null) ? "" : userName, (userInput == null) ? "" : userInput, |
66 | |
(exceptionStackTrace == null) ? "" : exceptionStackTrace); |
67 | |
|
68 | 0 | return message; |
69 | |
|
70 | |
} |
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
public String createEmailSubject() { |
78 | 0 | String env = KRADServiceLocator.getKualiConfigurationService().getPropertyValueAsString("environment"); |
79 | 0 | String format = "%s:%s:%s"; |
80 | 0 | String subject = String.format(format, env, (incidentViewId == null) ? "" : incidentViewId, |
81 | |
truncateString(exceptionMessage, 180)); |
82 | 0 | return subject; |
83 | |
} |
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
protected String truncateString(String str, int maxLength) { |
95 | 0 | if (str != null && str.length() > maxLength) |
96 | 0 | str = str.substring(0, maxLength); |
97 | 0 | return str; |
98 | |
} |
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
protected String getStackTrace(Throwable t) { |
108 | 0 | StringWriter sw = new StringWriter(); |
109 | 0 | PrintWriter pw = new PrintWriter(sw, true); |
110 | 0 | t.printStackTrace(pw); |
111 | 0 | pw.flush(); |
112 | 0 | sw.flush(); |
113 | 0 | return sw.toString(); |
114 | |
} |
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
public String getErrorMessage() { |
120 | 0 | return this.errorMessage; |
121 | |
} |
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
public void setErrorMessage(String errorMessage) { |
128 | 0 | this.errorMessage = errorMessage; |
129 | 0 | } |
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
public String getExceptionMessage() { |
135 | 0 | return this.exceptionMessage; |
136 | |
} |
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
public void setExceptionMessage(String exceptionMessage) { |
143 | 0 | this.exceptionMessage = exceptionMessage; |
144 | 0 | } |
145 | |
|
146 | |
|
147 | |
|
148 | |
|
149 | |
public String getExceptionStackTrace() { |
150 | 0 | return this.exceptionStackTrace; |
151 | |
} |
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
public void setExceptionStackTrace(String exceptionStackTrace) { |
158 | 0 | this.exceptionStackTrace = exceptionStackTrace; |
159 | 0 | } |
160 | |
|
161 | |
|
162 | |
|
163 | |
|
164 | |
public String getUserInput() { |
165 | 0 | return this.userInput; |
166 | |
} |
167 | |
|
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
public void setUserInput(String userInput) { |
173 | 0 | this.userInput = userInput; |
174 | 0 | } |
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
public boolean isDevMode() { |
180 | 0 | return this.devMode; |
181 | |
} |
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
|
187 | |
public void setDevMode(boolean devMode) { |
188 | 0 | this.devMode = devMode; |
189 | 0 | } |
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | |
|
195 | |
public void setIncidentDocId(String incidentDocId) { |
196 | 0 | this.incidentDocId = incidentDocId; |
197 | 0 | } |
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | |
public String getIncidentDocId() { |
203 | 0 | return incidentDocId; |
204 | |
} |
205 | |
|
206 | |
|
207 | |
|
208 | |
|
209 | |
|
210 | |
public void setIncidentViewId(String incidentViewId) { |
211 | 0 | this.incidentViewId = incidentViewId; |
212 | 0 | } |
213 | |
|
214 | |
|
215 | |
|
216 | |
|
217 | |
public String getIncidentViewId() { |
218 | 0 | return incidentViewId; |
219 | |
} |
220 | |
|
221 | |
|
222 | |
|
223 | |
|
224 | |
|
225 | |
public void setException(Exception exception) { |
226 | 0 | this.exception = exception; |
227 | 0 | setExceptionStackTrace(getStackTrace(exception)); |
228 | 0 | setExceptionMessage(exception.getMessage()); |
229 | 0 | } |
230 | |
|
231 | |
|
232 | |
|
233 | |
|
234 | |
public Exception getException() { |
235 | 0 | return exception; |
236 | |
} |
237 | |
|
238 | |
|
239 | |
|
240 | |
|
241 | |
|
242 | |
public void setUserName(String userName) { |
243 | 0 | this.userName = userName; |
244 | 0 | } |
245 | |
|
246 | |
|
247 | |
|
248 | |
|
249 | |
public String getUserName() { |
250 | 0 | return userName; |
251 | |
} |
252 | |
|
253 | |
|
254 | |
|
255 | |
|
256 | |
|
257 | |
public void setUserId(String userId) { |
258 | 0 | this.userId = userId; |
259 | 0 | } |
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | |
public String getUserId() { |
265 | 0 | return userId; |
266 | |
} |
267 | |
|
268 | |
|
269 | |
|
270 | |
|
271 | |
|
272 | |
public void setUserEmail(String userEmail) { |
273 | 0 | this.userEmail = userEmail; |
274 | 0 | } |
275 | |
|
276 | |
|
277 | |
|
278 | |
|
279 | |
public String getUserEmail() { |
280 | 0 | return userEmail; |
281 | |
} |
282 | |
|
283 | |
|
284 | |
|
285 | |
|
286 | |
|
287 | |
public void setController(String controller) { |
288 | 0 | this.controller = controller; |
289 | 0 | } |
290 | |
|
291 | |
|
292 | |
|
293 | |
|
294 | |
public String getController() { |
295 | 0 | return controller; |
296 | |
} |
297 | |
|
298 | |
} |