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 javax.servlet.http.HttpServletRequest;
19 import javax.servlet.http.HttpServletResponse;
20
21 import org.apache.struts.action.ActionForm;
22 import org.apache.struts.action.ActionForward;
23 import org.apache.struts.action.ActionMapping;
24 import org.kuali.rice.core.api.util.RiceConstants;
25 import org.kuali.rice.kim.api.identity.Person;
26 import org.kuali.rice.kns.web.struts.form.KualiFeedbackHandlerForm;
27 import org.kuali.rice.krad.UserSession;
28 import org.kuali.rice.krad.exception.AuthorizationException;
29 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
30 import org.kuali.rice.krad.service.KualiFeedbackService;
31 import org.kuali.rice.krad.util.KRADConstants;
32
33
34
35
36
37
38
39 @Deprecated
40 public class KualiFeedbackHandlerAction extends KualiAction {
41
42 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
43 if (findMethodToCall(form, request) == null || findMethodToCall(form, request).equals("docHandler")) {
44 return executeFeedback(mapping, form, request, response);
45 }
46 else {
47 return super.execute(mapping, form, request, response);
48 }
49 }
50
51 public ActionForward executeFeedback(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
52 ActionForward returnForward = null;
53 KualiFeedbackHandlerForm formObject = (KualiFeedbackHandlerForm) form;
54 if (!formObject.isCancel()) {
55 populateRequest(form, request);
56 returnForward = mapping.findForward(RiceConstants.MAPPING_BASIC);
57 }
58 else {
59 returnForward = mapping.findForward(KRADConstants.MAPPING_CANCEL);
60 }
61
62 return returnForward;
63 }
64
65 public ActionForward submitFeedback(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
66 if (form instanceof KualiFeedbackHandlerForm) {
67 KualiFeedbackHandlerForm feedbackForm = (KualiFeedbackHandlerForm) form;
68 KualiFeedbackService reporterService = KRADServiceLocatorWeb.getKualiFeedbackService();
69 reporterService.sendFeedback(feedbackForm.getDocumentId(), feedbackForm.getComponentName(), feedbackForm.getDescription());
70 }
71 return mapping.findForward(KRADConstants.MAPPING_CLOSE);
72 }
73
74 private void populateRequest(ActionForm form, HttpServletRequest request) {
75 UserSession userSession = (UserSession) request.getSession().getAttribute(KRADConstants.USER_SESSION_KEY);
76 Person sessionUser = null;
77 if (userSession != null) {
78 sessionUser = userSession.getPerson();
79 }
80 if (sessionUser != null) {
81 request.setAttribute("principalName", sessionUser.getPrincipalName());
82 }
83 }
84
85 @Override
86 protected void checkAuthorization(ActionForm form, String methodToCall) throws AuthorizationException {
87 }
88 }