1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.web.struts.action;
17
18 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20 import org.apache.struts.Globals;
21 import org.apache.struts.action.Action;
22 import org.apache.struts.action.ActionForm;
23 import org.apache.struts.action.ActionForward;
24 import org.apache.struts.action.ActionMapping;
25 import org.kuali.rice.core.api.util.RiceConstants;
26 import org.kuali.rice.krad.util.KRADConstants;
27
28 import javax.servlet.http.HttpServletRequest;
29 import javax.servlet.http.HttpServletResponse;
30 import java.util.HashMap;
31 import java.util.Map;
32
33
34
35
36
37
38
39 @Deprecated
40 public class AuthorizationExceptionAction extends Action {
41
42 private static final String MESSAGE_FIELD = "message";
43
44 private static final Log LOG = LogFactory.getLog(AuthorizationExceptionAction.class);
45
46
47
48
49
50
51
52
53 @Override
54 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
55 if (LOG.isDebugEnabled()) {
56 LOG.debug(String.format("ENTRY %s%n%s", form.getClass().getSimpleName(), request.getRequestURI()));
57 }
58
59 ActionForward forward = null;
60
61 Throwable t = (Throwable) request.getAttribute(Globals.EXCEPTION_KEY);
62
63 if (t == null) {
64 forward = mapping.findForward(KRADConstants.MAPPING_CLOSE);
65 } else {
66 forward = processException(mapping, form, request, t);
67 }
68
69 if (LOG.isDebugEnabled()) {
70 LOG.debug(String.format("EXIT %s", (forward == null) ? "null" : forward.getPath()));
71 }
72
73 return forward;
74 }
75
76 private ActionForward processException(ActionMapping mapping, ActionForm form, HttpServletRequest request, Throwable t) throws Exception {
77 Map<String, String> properties = new HashMap<String, String>();
78 properties.put(MESSAGE_FIELD, t.getMessage());
79
80 request.setAttribute(AuthorizationExceptionAction.class.getName(), properties);
81
82 return mapping.findForward(RiceConstants.MAPPING_BASIC);
83 }
84
85 }