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