1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.web.controller;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.core.api.config.property.ConfigContext;
20 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
21 import org.kuali.rice.krad.service.KualiExceptionIncidentService;
22 import org.kuali.rice.krad.uif.UifConstants;
23 import org.kuali.rice.krad.uif.UifParameters;
24 import org.kuali.rice.krad.util.KRADConstants;
25 import org.kuali.rice.krad.web.form.IncidentReportForm;
26 import org.kuali.rice.krad.web.form.UifFormBase;
27 import org.springframework.stereotype.Controller;
28 import org.springframework.validation.BindingResult;
29 import org.springframework.web.bind.annotation.ModelAttribute;
30 import org.springframework.web.bind.annotation.RequestMapping;
31 import org.springframework.web.bind.annotation.RequestMethod;
32 import org.springframework.web.servlet.ModelAndView;
33
34 import javax.servlet.http.HttpServletRequest;
35 import javax.servlet.http.HttpServletResponse;
36 import java.util.Properties;
37
38
39
40
41
42
43 @Controller
44 @RequestMapping(value = "/incidentReport")
45 public class IncidentReportController extends UifControllerBase {
46
47
48
49
50 @Override
51 protected IncidentReportForm createInitialForm(HttpServletRequest request) {
52 return new IncidentReportForm();
53 }
54
55
56
57
58 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=submitReport")
59 public ModelAndView submitReport(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
60 HttpServletRequest request, HttpServletResponse response) throws Exception {
61
62 KualiExceptionIncidentService reporterService = KRADServiceLocatorWeb.getKualiExceptionIncidentService();
63 reporterService.emailReport(((IncidentReportForm) uifForm).createEmailSubject(),
64 ((IncidentReportForm) uifForm).createEmailMessage());
65
66
67 return back(uifForm, result, request, response);
68 }
69
70
71
72
73
74
75 @RequestMapping(params = "methodToCall=cancel")
76 public ModelAndView cancel(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
77 HttpServletRequest request, HttpServletResponse response) {
78 Properties props = new Properties();
79 props.put(UifParameters.METHOD_TO_CALL, UifConstants.MethodToCallNames.REFRESH);
80
81 if (StringUtils.isNotBlank(form.getReturnFormKey())) {
82 props.put(UifParameters.FORM_KEY, form.getReturnFormKey());
83 }
84
85 String returnUrl = ConfigContext.getCurrentContextConfig().getProperty(KRADConstants.APPLICATION_URL_KEY);
86
87 return performRedirect(form, returnUrl, props);
88 }
89
90 }