1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.web.struts.form;
17
18 import org.apache.log4j.Logger;
19 import org.apache.struts.action.ActionMapping;
20 import org.kuali.rice.krad.exception.ExceptionIncident;
21 import org.kuali.rice.krad.util.KRADConstants;
22
23 import javax.servlet.http.HttpServletRequest;
24 import java.util.HashMap;
25 import java.util.HashSet;
26 import java.util.Map;
27 import java.util.Set;
28
29
30
31
32
33
34 public class KualiExceptionIncidentForm extends KualiForm {
35 private static final long serialVersionUID = 831951332440283401L;
36 private static Logger LOG=Logger.getLogger(KualiExceptionIncidentForm.class);
37
38
39
40
41 private static final Set<String> PROPS_NEEDED_FOR_MAP = new HashSet<String>();
42 static {
43 PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.DOCUMENT_ID);
44 PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.USER_EMAIL);
45 PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.USER_NAME);
46 PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.UUID);
47 PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.COMPONENT_NAME);
48 PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.DESCRIPTION);
49 PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.EXCEPTION_REPORT_SUBJECT);
50 PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.EXCEPTION_MESSAGE);
51 PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.DISPLAY_MESSAGE);
52 PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.STACK_TRACE);
53 }
54
55
56
57
58 private boolean cancel=false;
59
60
61
62
63
64
65
66 private String exceptionReportSubject;
67
68
69
70 private String exceptionMessage;
71
72
73
74 private String displayMessage;
75
76
77
78 private String description;
79
80
81
82 private String documentId="";
83
84
85
86 private String userEmail="";
87
88
89
90 private String principalName="";
91
92
93
94 private String userName="";
95
96
97
98 private String stackTrace;
99
100
101
102 private String componentName;
103
104
105
106
107 public void populate(HttpServletRequest request) {
108
109 super.populate(request);
110
111
112 if(notNull(request.getParameter(KRADConstants.CANCEL_METHOD + ".x")) && notNull(request.getParameter(
113 KRADConstants.CANCEL_METHOD + ".y"))){
114 this.setCancel(true);
115 }
116 }
117
118 private boolean notNull(String s){
119 if(s != null && !"".equals(s)){
120 return true;
121 }else
122 return false;
123 }
124
125
126
127
128
129
130
131 public void reset(ActionMapping mapping, HttpServletRequest request) {
132
133 this.setMethodToCall(null);
134 this.setRefreshCaller(null);
135 this.setAnchor(null);
136 this.setCurrentTabIndex(0);
137
138 this.cancel=false;
139 this.documentId=null;
140 this.componentName=null;
141 this.description=null;
142 this.displayMessage=null;
143 this.exceptionMessage=null;
144 this.stackTrace=null;
145 this.userEmail=null;
146 this.userName=null;
147 this.principalName=null;
148
149 }
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168 public Map<String, String> toMap() {
169 if (LOG.isTraceEnabled()) {
170 String message=String.format("ENTRY");
171 LOG.trace(message);
172 }
173
174 Map<String, String> map=new HashMap<String, String>();
175 map.put(ExceptionIncident.DOCUMENT_ID, this.documentId);
176 map.put(ExceptionIncident.USER_EMAIL, this.userEmail);
177 map.put(ExceptionIncident.USER_NAME, this.userName);
178 map.put(ExceptionIncident.UUID, this.principalName);
179 map.put(ExceptionIncident.COMPONENT_NAME, this.componentName);
180 map.put(ExceptionIncident.DESCRIPTION, this.description);
181 map.put(ExceptionIncident.EXCEPTION_REPORT_SUBJECT, this.exceptionReportSubject);
182 map.put(ExceptionIncident.EXCEPTION_MESSAGE, this.exceptionMessage);
183 map.put(ExceptionIncident.DISPLAY_MESSAGE, this.displayMessage);
184 map.put(ExceptionIncident.STACK_TRACE, this.stackTrace);
185
186 if (LOG.isTraceEnabled()) {
187 String message=String.format("ENTRY %s", map.toString());
188 LOG.trace(message);
189 }
190
191 return map;
192 }
193
194
195
196
197 public final boolean isCancel() {
198 return this.cancel;
199 }
200
201
202
203
204 public final void setCancel(boolean cancel) {
205 this.cancel = cancel;
206 }
207
208
209
210
211
212
213
214
215
216
217
218 public final String getDescription() {
219 return this.description;
220 }
221
222
223
224
225 public final void setDescription(String description) {
226 this.description = description;
227 }
228
229
230
231
232 public final String getExceptionMessage() {
233 return this.exceptionMessage;
234 }
235
236
237
238
239 public final void setExceptionMessage(String exceptionMessage) {
240 this.exceptionMessage = exceptionMessage;
241 }
242
243
244
245
246 public final String getDisplayMessage() {
247 return this.displayMessage;
248 }
249
250
251
252
253 public final void setDisplayMessage(String displayMessage) {
254 this.displayMessage = displayMessage;
255 }
256
257
258
259
260 public final String getDocumentId() {
261 return this.documentId;
262 }
263
264
265
266
267 public final void setDocumentId(String documentId) {
268 this.documentId = documentId;
269 }
270
271
272
273
274 public final String getUserEmail() {
275 return this.userEmail;
276 }
277
278
279
280
281 public final void setUserEmail(String userEmail) {
282 this.userEmail = userEmail;
283 }
284
285
286
287
288 public String getPrincipalName() {
289 return this.principalName;
290 }
291
292
293
294
295 public void setPrincipalName(String principalName) {
296 this.principalName = principalName;
297 }
298
299
300
301
302 public final String getUserName() {
303 return this.userName;
304 }
305
306
307
308
309 public final void setUserName(String userName) {
310 this.userName = userName;
311 }
312
313
314
315
316 public final void setStackTrace(String stackTrace) {
317 this.stackTrace = stackTrace;
318 }
319
320
321
322
323 public final String getStackTrace() {
324 return this.stackTrace;
325 }
326
327
328
329
330 public final String getExceptionReportSubject() {
331 return this.exceptionReportSubject;
332 }
333
334
335
336
337 public final void setExceptionReportSubject(String exceptionReportSubject) {
338 this.exceptionReportSubject = exceptionReportSubject;
339 }
340
341
342
343
344 public final String getComponentName() {
345 return this.componentName;
346 }
347
348
349
350
351 public final void setComponentName(String componentName) {
352 this.componentName = componentName;
353 }
354
355
356
357
358
359
360 @Override
361 public boolean shouldMethodToCallParameterBeUsed(
362 String methodToCallParameterName,
363 String methodToCallParameterValue, HttpServletRequest request) {
364
365 return true;
366 }
367
368
369
370
371 @Override
372 public boolean shouldPropertyBePopulatedInForm(
373 String requestParameterName, HttpServletRequest request) {
374 if (PROPS_NEEDED_FOR_MAP.contains(requestParameterName)) {
375 return true;
376 }
377 else if (KRADConstants.CANCEL_METHOD.equals(requestParameterName)) {
378 return true;
379 }
380 return super.shouldPropertyBePopulatedInForm(requestParameterName, request);
381 }
382 }
383