| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kns.util; |
| 17 | |
|
| 18 | |
import java.util.HashMap; |
| 19 | |
import java.util.Map; |
| 20 | |
|
| 21 | |
import javax.servlet.http.HttpServletRequest; |
| 22 | |
|
| 23 | |
import org.apache.struts.Globals; |
| 24 | |
import org.kuali.rice.kim.api.identity.Person; |
| 25 | |
import org.kuali.rice.krad.UserSession; |
| 26 | |
import org.kuali.rice.krad.exception.KualiExceptionIncident; |
| 27 | |
import org.kuali.rice.krad.util.KRADConstants; |
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
public final class IncidentReportUtils { |
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
public static final String EXCEPTION_PROPERTIES="exceptionProperties"; |
| 44 | |
|
| 45 | 0 | private IncidentReportUtils() { |
| 46 | 0 | throw new UnsupportedOperationException("do not call"); |
| 47 | |
} |
| 48 | |
|
| 49 | |
public static Map<String, String> populateRequestForIncidentReport(Exception exception, |
| 50 | |
String documentId, String componentName, HttpServletRequest request) { |
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | 0 | Map<String, String> properties = new HashMap<String, String>(); |
| 55 | 0 | properties.put(KualiExceptionIncident.DOCUMENT_ID, documentId); |
| 56 | 0 | String userEmail = ""; |
| 57 | 0 | String userName = ""; |
| 58 | 0 | String uuid = ""; |
| 59 | |
|
| 60 | |
|
| 61 | 0 | UserSession userSession = (UserSession) request.getSession() |
| 62 | |
.getAttribute(KRADConstants.USER_SESSION_KEY); |
| 63 | 0 | Person sessionUser = null; |
| 64 | 0 | if (userSession != null) { |
| 65 | 0 | sessionUser = userSession.getPerson(); |
| 66 | |
} |
| 67 | 0 | if (sessionUser != null) { |
| 68 | 0 | userEmail = sessionUser.getEmailAddressUnmasked(); |
| 69 | 0 | userName = sessionUser.getName(); |
| 70 | 0 | uuid = sessionUser.getPrincipalName(); |
| 71 | |
} |
| 72 | 0 | properties.put(KualiExceptionIncident.USER_EMAIL, userEmail); |
| 73 | 0 | properties.put(KualiExceptionIncident.USER_NAME, userName); |
| 74 | 0 | properties.put(KualiExceptionIncident.UUID, uuid); |
| 75 | 0 | properties.put(KualiExceptionIncident.COMPONENT_NAME, componentName); |
| 76 | |
|
| 77 | |
|
| 78 | 0 | request.setAttribute(Globals.EXCEPTION_KEY, exception); |
| 79 | |
|
| 80 | 0 | request.setAttribute(EXCEPTION_PROPERTIES, properties); |
| 81 | |
|
| 82 | 0 | return properties; |
| 83 | |
|
| 84 | |
} |
| 85 | |
} |