1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.student.common.ui.server.gwt.old; |
17 |
|
|
18 |
|
import java.util.Map; |
19 |
|
|
20 |
|
import org.apache.commons.lang.StringUtils; |
21 |
|
import org.apache.log4j.Logger; |
22 |
|
import org.kuali.rice.kew.service.WorkflowUtility; |
23 |
|
import org.kuali.rice.kew.webservice.SimpleDocumentActionsWebService; |
24 |
|
import org.kuali.rice.kim.bo.types.dto.AttributeSet; |
25 |
|
import org.kuali.rice.kim.service.IdentityManagementService; |
26 |
|
import org.kuali.rice.kim.service.IdentityManagementService; |
27 |
|
import org.kuali.student.common.ui.client.service.BaseDataOrchestrationRpcService; |
28 |
|
import org.kuali.student.common.ui.client.service.DataSaveResult; |
29 |
|
import org.kuali.student.common.ui.client.service.exceptions.OperationFailedException; |
30 |
|
import org.kuali.student.common.ui.shared.IdAttributes; |
31 |
|
import org.kuali.student.common.util.security.SecurityUtils; |
32 |
|
import org.kuali.student.core.assembly.data.AssemblyException; |
33 |
|
import org.kuali.student.core.assembly.data.Data; |
34 |
|
import org.kuali.student.core.assembly.data.Metadata; |
35 |
|
import org.kuali.student.core.assembly.old.Assembler; |
36 |
|
import org.kuali.student.core.assembly.old.data.SaveResult; |
37 |
|
import org.kuali.student.core.rice.StudentIdentityConstants; |
38 |
|
import org.kuali.student.core.rice.authorization.PermissionType; |
39 |
|
|
40 |
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
@Deprecated |
|
|
| 0% |
Uncovered Elements: 82 (82) |
Complexity: 28 |
Complexity Density: 0.54 |
|
47 |
|
public abstract class AbstractBaseDataOrchestrationRpcGwtServlet extends RemoteServiceServlet implements BaseDataOrchestrationRpcService { |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
private static final long serialVersionUID = 1L; |
55 |
|
|
56 |
|
final Logger LOG = Logger.getLogger(AbstractBaseDataOrchestrationRpcGwtServlet.class); |
57 |
|
|
58 |
|
private Assembler<Data, Void> assembler; |
59 |
|
|
60 |
|
private SimpleDocumentActionsWebService simpleDocService; |
61 |
|
private WorkflowUtility workflowUtilityService; |
62 |
|
private IdentityManagementService permissionService; |
63 |
|
private IdentityManagementService identityService; |
64 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
65 |
0
|
@Override... |
66 |
|
public Data getData(String dataId) { |
67 |
0
|
try { |
68 |
0
|
return assembler.get(dataId); |
69 |
|
} catch (AssemblyException e) { |
70 |
0
|
LOG.error("Error getting Data.",e); |
71 |
|
} |
72 |
0
|
return null; |
73 |
|
} |
74 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
75 |
0
|
@Override... |
76 |
|
public Metadata getMetadata(String id, Map<String,String> idAttributes) { |
77 |
|
|
78 |
0
|
try { |
79 |
|
|
80 |
0
|
String idType = ""; |
81 |
0
|
if (idAttributes != null){ |
82 |
0
|
idType = idAttributes.get(IdAttributes.ID_TYPE); |
83 |
|
} |
84 |
0
|
return assembler.getMetadata(idType, id, getDefaultMetaDataType(), getDefaultMetaDataState()); |
85 |
|
} catch (AssemblyException e) { |
86 |
0
|
LOG.error("Error getting Metadata.",e); |
87 |
|
} |
88 |
0
|
return null; |
89 |
|
} |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
91 |
0
|
@Override... |
92 |
|
public DataSaveResult saveData(Data data) throws OperationFailedException { |
93 |
0
|
try { |
94 |
0
|
SaveResult<Data> saveResult = assembler.save(data); |
95 |
0
|
if (saveResult != null) { |
96 |
0
|
return new DataSaveResult(saveResult.getValidationResults(), saveResult.getValue()); |
97 |
|
} |
98 |
|
} catch (Exception e) { |
99 |
0
|
LOG.error("Unable to save", e); |
100 |
0
|
throw new OperationFailedException("Unable to save"); |
101 |
|
} |
102 |
0
|
return null; |
103 |
|
} |
104 |
|
|
105 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
106 |
0
|
protected String getCurrentUser() {... |
107 |
0
|
String username = SecurityUtils.getCurrentUserId(); |
108 |
|
|
109 |
0
|
if(username==null&&this.getThreadLocalRequest().getSession().getAttribute("backdoorId")!=null){ |
110 |
0
|
username=(String)this.getThreadLocalRequest().getSession().getAttribute("backdoorId"); |
111 |
|
} |
112 |
0
|
return username; |
113 |
|
} |
114 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
115 |
0
|
protected boolean checkDocumentLevelPermissions() {... |
116 |
0
|
return false; |
117 |
|
} |
118 |
|
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 6 |
Complexity Density: 0.32 |
|
119 |
0
|
public Boolean isAuthorized(PermissionType type, Map<String,String> attributes) {... |
120 |
0
|
String user = getCurrentUser(); |
121 |
0
|
boolean result = false; |
122 |
0
|
if (checkDocumentLevelPermissions()) { |
123 |
0
|
if (type == null) { |
124 |
0
|
return null; |
125 |
|
} |
126 |
0
|
String namespaceCode = type.getPermissionNamespace(); |
127 |
0
|
String permissionTemplateName = type.getPermissionTemplateName(); |
128 |
0
|
AttributeSet roleQuals = new AttributeSet(StudentIdentityConstants.DOCUMENT_TYPE_NAME, getDefaultWorkflowDocumentType()); |
129 |
0
|
if (attributes != null) { |
130 |
0
|
roleQuals.putAll(attributes); |
131 |
|
} |
132 |
0
|
if (StringUtils.isNotBlank(namespaceCode) && StringUtils.isNotBlank(permissionTemplateName)) { |
133 |
0
|
LOG.info("Checking Permission '" + namespaceCode + "/" + permissionTemplateName + "' for user '" + user + "'"); |
134 |
0
|
result = getPermissionService().isAuthorizedByTemplateName(user, namespaceCode, permissionTemplateName, null, roleQuals); |
135 |
|
} |
136 |
|
else { |
137 |
0
|
LOG.info("Can not check Permission with namespace '" + namespaceCode + "' and template name '" + permissionTemplateName + "' for user '" + user + "'"); |
138 |
0
|
return Boolean.TRUE; |
139 |
|
} |
140 |
|
} |
141 |
|
else { |
142 |
0
|
LOG.info("Will not check for document level permissions. Defaulting authorization to true."); |
143 |
0
|
result = true; |
144 |
|
} |
145 |
0
|
LOG.info("Result of authorization check for user '" + user + "': " + result); |
146 |
0
|
return Boolean.valueOf(result); |
147 |
|
} |
148 |
|
|
149 |
|
protected abstract String deriveAppIdFromData(Data data); |
150 |
|
protected abstract String deriveDocContentFromData(Data data); |
151 |
|
protected abstract String getDefaultWorkflowDocumentType(); |
152 |
|
protected abstract String getDefaultMetaDataState(); |
153 |
|
protected abstract String getDefaultMetaDataType(); |
154 |
|
|
155 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
156 |
0
|
public void setAssembler(Assembler<Data, Void> assembler) {... |
157 |
0
|
this.assembler = assembler; |
158 |
|
} |
159 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
160 |
0
|
public IdentityManagementService getPermissionService() {... |
161 |
0
|
return permissionService; |
162 |
|
} |
163 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
164 |
0
|
public void setPermissionService(IdentityManagementService permissionService) {... |
165 |
0
|
this.permissionService = permissionService; |
166 |
|
} |
167 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
168 |
0
|
public IdentityManagementService getIdentityService() {... |
169 |
0
|
return identityService; |
170 |
|
} |
171 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
172 |
0
|
public void setIdentityService(IdentityManagementService identityService) {... |
173 |
0
|
this.identityService = identityService; |
174 |
|
} |
175 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
176 |
0
|
public void setSimpleDocService(SimpleDocumentActionsWebService simpleDocService) {... |
177 |
0
|
this.simpleDocService = simpleDocService; |
178 |
|
} |
179 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
180 |
0
|
public void setWorkflowUtilityService(WorkflowUtility workflowUtilityService) {... |
181 |
0
|
this.workflowUtilityService = workflowUtilityService; |
182 |
|
} |
183 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
184 |
0
|
protected Assembler<Data, Void> getAssembler() {... |
185 |
0
|
return assembler; |
186 |
|
} |
187 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
188 |
0
|
protected SimpleDocumentActionsWebService getSimpleDocService() {... |
189 |
0
|
return simpleDocService; |
190 |
|
} |
191 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
192 |
0
|
protected WorkflowUtility getWorkflowUtilityService() {... |
193 |
0
|
return workflowUtilityService; |
194 |
|
} |
195 |
|
|
196 |
|
|
197 |
|
} |