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 | 0 | public class KualiExceptionIncidentForm extends KualiForm { |
35 | |
private static final long serialVersionUID = 831951332440283401L; |
36 | 0 | private static Logger LOG=Logger.getLogger(KualiExceptionIncidentForm.class); |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | 0 | private static final Set<String> PROPS_NEEDED_FOR_MAP = new HashSet<String>(); |
42 | |
static { |
43 | 0 | PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.DOCUMENT_ID); |
44 | 0 | PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.USER_EMAIL); |
45 | 0 | PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.USER_NAME); |
46 | 0 | PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.UUID); |
47 | 0 | PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.COMPONENT_NAME); |
48 | 0 | PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.DESCRIPTION); |
49 | 0 | PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.EXCEPTION_REPORT_SUBJECT); |
50 | 0 | PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.EXCEPTION_MESSAGE); |
51 | 0 | PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.DISPLAY_MESSAGE); |
52 | 0 | PROPS_NEEDED_FOR_MAP.add(ExceptionIncident.STACK_TRACE); |
53 | 0 | } |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | 0 | 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 | 0 | private String documentId=""; |
83 | |
|
84 | |
|
85 | |
|
86 | 0 | private String userEmail=""; |
87 | |
|
88 | |
|
89 | |
|
90 | 0 | private String principalName=""; |
91 | |
|
92 | |
|
93 | |
|
94 | 0 | 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 | 0 | super.populate(request); |
110 | |
|
111 | |
|
112 | 0 | if(notNull(request.getParameter(KRADConstants.CANCEL_METHOD + ".x")) && notNull(request.getParameter( |
113 | |
KRADConstants.CANCEL_METHOD + ".y"))){ |
114 | 0 | this.setCancel(true); |
115 | |
} |
116 | 0 | } |
117 | |
|
118 | |
private boolean notNull(String s){ |
119 | 0 | if(s != null && !"".equals(s)){ |
120 | 0 | return true; |
121 | |
}else |
122 | 0 | return false; |
123 | |
} |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
public void reset(ActionMapping mapping, HttpServletRequest request) { |
132 | |
|
133 | 0 | this.setMethodToCall(null); |
134 | 0 | this.setRefreshCaller(null); |
135 | 0 | this.setAnchor(null); |
136 | 0 | this.setCurrentTabIndex(0); |
137 | |
|
138 | 0 | this.cancel=false; |
139 | 0 | this.documentId=null; |
140 | 0 | this.componentName=null; |
141 | 0 | this.description=null; |
142 | 0 | this.displayMessage=null; |
143 | 0 | this.exceptionMessage=null; |
144 | 0 | this.stackTrace=null; |
145 | 0 | this.userEmail=null; |
146 | 0 | this.userName=null; |
147 | 0 | this.principalName=null; |
148 | |
|
149 | 0 | } |
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 | 0 | if (LOG.isTraceEnabled()) { |
170 | 0 | String message=String.format("ENTRY"); |
171 | 0 | LOG.trace(message); |
172 | |
} |
173 | |
|
174 | 0 | Map<String, String> map=new HashMap<String, String>(); |
175 | 0 | map.put(ExceptionIncident.DOCUMENT_ID, this.documentId); |
176 | 0 | map.put(ExceptionIncident.USER_EMAIL, this.userEmail); |
177 | 0 | map.put(ExceptionIncident.USER_NAME, this.userName); |
178 | 0 | map.put(ExceptionIncident.UUID, this.principalName); |
179 | 0 | map.put(ExceptionIncident.COMPONENT_NAME, this.componentName); |
180 | 0 | map.put(ExceptionIncident.DESCRIPTION, this.description); |
181 | 0 | map.put(ExceptionIncident.EXCEPTION_REPORT_SUBJECT, this.exceptionReportSubject); |
182 | 0 | map.put(ExceptionIncident.EXCEPTION_MESSAGE, this.exceptionMessage); |
183 | 0 | map.put(ExceptionIncident.DISPLAY_MESSAGE, this.displayMessage); |
184 | 0 | map.put(ExceptionIncident.STACK_TRACE, this.stackTrace); |
185 | |
|
186 | 0 | if (LOG.isTraceEnabled()) { |
187 | 0 | String message=String.format("ENTRY %s", map.toString()); |
188 | 0 | LOG.trace(message); |
189 | |
} |
190 | |
|
191 | 0 | return map; |
192 | |
} |
193 | |
|
194 | |
|
195 | |
|
196 | |
|
197 | |
public final boolean isCancel() { |
198 | 0 | return this.cancel; |
199 | |
} |
200 | |
|
201 | |
|
202 | |
|
203 | |
|
204 | |
public final void setCancel(boolean cancel) { |
205 | 0 | this.cancel = cancel; |
206 | 0 | } |
207 | |
|
208 | |
|
209 | |
|
210 | |
|
211 | |
|
212 | |
|
213 | |
|
214 | |
|
215 | |
|
216 | |
|
217 | |
|
218 | |
public final String getDescription() { |
219 | 0 | return this.description; |
220 | |
} |
221 | |
|
222 | |
|
223 | |
|
224 | |
|
225 | |
public final void setDescription(String description) { |
226 | 0 | this.description = description; |
227 | 0 | } |
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | |
public final String getExceptionMessage() { |
233 | 0 | return this.exceptionMessage; |
234 | |
} |
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | |
public final void setExceptionMessage(String exceptionMessage) { |
240 | 0 | this.exceptionMessage = exceptionMessage; |
241 | 0 | } |
242 | |
|
243 | |
|
244 | |
|
245 | |
|
246 | |
public final String getDisplayMessage() { |
247 | 0 | return this.displayMessage; |
248 | |
} |
249 | |
|
250 | |
|
251 | |
|
252 | |
|
253 | |
public final void setDisplayMessage(String displayMessage) { |
254 | 0 | this.displayMessage = displayMessage; |
255 | 0 | } |
256 | |
|
257 | |
|
258 | |
|
259 | |
|
260 | |
public final String getDocumentId() { |
261 | 0 | return this.documentId; |
262 | |
} |
263 | |
|
264 | |
|
265 | |
|
266 | |
|
267 | |
public final void setDocumentId(String documentId) { |
268 | 0 | this.documentId = documentId; |
269 | 0 | } |
270 | |
|
271 | |
|
272 | |
|
273 | |
|
274 | |
public final String getUserEmail() { |
275 | 0 | return this.userEmail; |
276 | |
} |
277 | |
|
278 | |
|
279 | |
|
280 | |
|
281 | |
public final void setUserEmail(String userEmail) { |
282 | 0 | this.userEmail = userEmail; |
283 | 0 | } |
284 | |
|
285 | |
|
286 | |
|
287 | |
|
288 | |
public String getPrincipalName() { |
289 | 0 | return this.principalName; |
290 | |
} |
291 | |
|
292 | |
|
293 | |
|
294 | |
|
295 | |
public void setPrincipalName(String principalName) { |
296 | 0 | this.principalName = principalName; |
297 | 0 | } |
298 | |
|
299 | |
|
300 | |
|
301 | |
|
302 | |
public final String getUserName() { |
303 | 0 | return this.userName; |
304 | |
} |
305 | |
|
306 | |
|
307 | |
|
308 | |
|
309 | |
public final void setUserName(String userName) { |
310 | 0 | this.userName = userName; |
311 | 0 | } |
312 | |
|
313 | |
|
314 | |
|
315 | |
|
316 | |
public final void setStackTrace(String stackTrace) { |
317 | 0 | this.stackTrace = stackTrace; |
318 | 0 | } |
319 | |
|
320 | |
|
321 | |
|
322 | |
|
323 | |
public final String getStackTrace() { |
324 | 0 | return this.stackTrace; |
325 | |
} |
326 | |
|
327 | |
|
328 | |
|
329 | |
|
330 | |
public final String getExceptionReportSubject() { |
331 | 0 | return this.exceptionReportSubject; |
332 | |
} |
333 | |
|
334 | |
|
335 | |
|
336 | |
|
337 | |
public final void setExceptionReportSubject(String exceptionReportSubject) { |
338 | 0 | this.exceptionReportSubject = exceptionReportSubject; |
339 | 0 | } |
340 | |
|
341 | |
|
342 | |
|
343 | |
|
344 | |
public final String getComponentName() { |
345 | 0 | return this.componentName; |
346 | |
} |
347 | |
|
348 | |
|
349 | |
|
350 | |
|
351 | |
public final void setComponentName(String componentName) { |
352 | 0 | this.componentName = componentName; |
353 | 0 | } |
354 | |
|
355 | |
|
356 | |
|
357 | |
|
358 | |
|
359 | |
|
360 | |
@Override |
361 | |
public boolean shouldMethodToCallParameterBeUsed( |
362 | |
String methodToCallParameterName, |
363 | |
String methodToCallParameterValue, HttpServletRequest request) { |
364 | |
|
365 | 0 | return true; |
366 | |
} |
367 | |
|
368 | |
|
369 | |
|
370 | |
|
371 | |
@Override |
372 | |
public boolean shouldPropertyBePopulatedInForm( |
373 | |
String requestParameterName, HttpServletRequest request) { |
374 | 0 | if (PROPS_NEEDED_FOR_MAP.contains(requestParameterName)) { |
375 | 0 | return true; |
376 | |
} |
377 | 0 | else if (KRADConstants.CANCEL_METHOD.equals(requestParameterName)) { |
378 | 0 | return true; |
379 | |
} |
380 | 0 | return super.shouldPropertyBePopulatedInForm(requestParameterName, request); |
381 | |
} |
382 | |
} |
383 | |
|