1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.common.ui.server.gwt;
17
18 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
19 import org.apache.log4j.Logger;
20 import org.kuali.rice.kim.api.permission.PermissionService;
21 import org.kuali.student.common.ui.client.service.BaseRpcService;
22 import org.kuali.student.common.util.security.SecurityUtils;
23 import org.kuali.student.r1.common.dictionary.old.dto.ObjectStructure;
24 import org.kuali.student.r1.common.dictionary.service.old.DictionaryService;
25 import org.kuali.student.r2.common.exceptions.*;
26 import org.kuali.student.r2.core.search.dto.SearchRequestInfo;
27 import org.kuali.student.r2.core.search.dto.SearchResultInfo;
28 import org.kuali.student.r2.core.search.service.SearchService;
29 import org.kuali.student.r2.common.util.ContextUtils;
30 import org.kuali.student.r2.core.class1.type.dto.TypeInfo;
31
32 import java.util.List;
33
34
35
36
37
38
39
40
41
42 public abstract class BaseRpcGwtServletAbstract<SEI> extends RemoteServiceServlet implements BaseRpcService {
43 final Logger LOG = Logger.getLogger(BaseRpcGwtServletAbstract.class);
44 private static final long serialVersionUID = 1L;
45
46 protected SEI service;
47 protected PermissionService permissionService;
48
49 public SEI getService() {
50 return this.service;
51 }
52
53 public void setService(SEI service) {
54 this.service = service;
55 };
56
57 public PermissionService getPermissionService() {
58 return permissionService;
59 }
60
61 public void setPermissionService(PermissionService permissionService) {
62 this.permissionService = permissionService;
63 }
64
65
66
67
68 @Override
69 public ObjectStructure getObjectStructure(String objectTypeKey) {
70 return ((DictionaryService) getService()).getObjectStructure(objectTypeKey);
71 }
72
73
74
75
76 @Override
77 public List<String> getObjectTypes() {
78 return ((DictionaryService) getService()).getObjectTypes();
79 }
80
81
82
83
84
85
86
87 @Override
88 public TypeInfo getSearchType(String searchTypeKey) {
89 try {
90 return ((SearchService) getService()).getSearchType(searchTypeKey, ContextUtils.getContextInfo());
91 } catch (DoesNotExistException e) {
92 LOG.error(e);
93 } catch (InvalidParameterException e) {
94 LOG.error(e);
95 } catch (MissingParameterException e) {
96 LOG.error(e);
97 } catch (OperationFailedException e) {
98 LOG.error(e);
99 }
100 return null;
101 }
102
103
104
105
106
107 @Override
108 public List<TypeInfo> getSearchTypes() {
109 try {
110 return ((SearchService) getService()).getSearchTypes(ContextUtils.getContextInfo());
111 } catch (InvalidParameterException e) {
112 LOG.error(e);
113 } catch (MissingParameterException e) {
114 LOG.error(e);
115 } catch (OperationFailedException e) {
116 LOG.error(e);
117 }
118 return null;
119 }
120
121
122
123
124
125 @Override
126 public SearchResultInfo search(SearchRequestInfo searchRequest) {
127 try {
128 return ((SearchService) getService()).search(searchRequest, ContextUtils.getContextInfo());
129 } catch (OperationFailedException e) {
130 LOG.error(e);
131 } catch (InvalidParameterException e) {
132 LOG.error(e);
133 } catch (PermissionDeniedException e) {
134 LOG.error(e);
135 } catch (MissingParameterException e) {
136 LOG.error(e);
137 }
138 return null;
139 }
140
141 protected String getCurrentUser() {
142 String username = SecurityUtils.getCurrentUserId();
143
144 if (username == null && this.getThreadLocalRequest().getSession().getAttribute("backdoorId") != null) {
145 username = (String) this.getThreadLocalRequest().getSession().getAttribute("backdoorId");
146 }
147 return username;
148 }
149 }