1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.web.service.impl;
17
18 import org.kuali.rice.kim.api.identity.Person;
19 import org.kuali.rice.krad.exception.AuthorizationException;
20 import org.kuali.rice.krad.uif.view.View;
21 import org.kuali.rice.krad.util.GlobalVariables;
22 import org.kuali.rice.krad.web.form.UifFormBase;
23 import org.kuali.rice.krad.web.service.ControllerService;
24 import org.kuali.rice.krad.web.service.ModelAndViewService;
25 import org.kuali.rice.krad.web.service.NavigationControllerService;
26 import org.springframework.web.servlet.ModelAndView;
27
28
29
30
31 public class ControllerServiceImpl implements ControllerService {
32
33 private ModelAndViewService modelAndViewService;
34 private NavigationControllerService navigationControllerService;
35
36
37
38
39 @Override
40 public ModelAndView start(UifFormBase form) {
41 checkViewAuthorization(form);
42
43 if (form.getView() != null) {
44 form.setApplyDefaultValues(true);
45 }
46
47 return getModelAndViewService().getModelAndView(form);
48 }
49
50
51
52
53 @Override
54 public void checkViewAuthorization(UifFormBase form) throws AuthorizationException {
55
56 View view = form.getView();
57 if ((GlobalVariables.getUserSession() == null) || view == null) {
58 return;
59 }
60
61 Person user = GlobalVariables.getUserSession().getPerson();
62 boolean viewAuthorized = view.getAuthorizer().canOpenView(view, form, user);
63
64 if (!viewAuthorized) {
65 throw new AuthorizationException(user.getPrincipalName(), "open", view.getId(),
66 "User '" + user.getPrincipalName() + "' is not authorized to open view ID: " +
67 view.getId(), null);
68 }
69 }
70
71
72
73
74
75
76 @Override
77 public ModelAndView sessionTimeout(UifFormBase form) {
78 return getModelAndViewService().getModelAndView(form);
79 }
80
81
82
83
84
85
86
87
88 @Override
89 public ModelAndView cancel(UifFormBase form) {
90 GlobalVariables.getUifFormManager().removeSessionForm(form);
91
92 return getNavigationControllerService().returnToHistory(form, false, false, true);
93 }
94
95 protected ModelAndViewService getModelAndViewService() {
96 return modelAndViewService;
97 }
98
99 public void setModelAndViewService(ModelAndViewService modelAndViewService) {
100 this.modelAndViewService = modelAndViewService;
101 }
102
103 protected NavigationControllerService getNavigationControllerService() {
104 return navigationControllerService;
105 }
106
107 public void setNavigationControllerService(NavigationControllerService navigationControllerService) {
108 this.navigationControllerService = navigationControllerService;
109 }
110 }