1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.core.document.ui.server; |
17 | |
|
18 | |
import java.util.List; |
19 | |
|
20 | |
import org.kuali.rice.kim.bo.types.dto.AttributeSet; |
21 | |
import org.kuali.student.common.dto.StatusInfo; |
22 | |
import org.kuali.student.common.exceptions.DoesNotExistException; |
23 | |
import org.kuali.student.common.rice.StudentIdentityConstants; |
24 | |
import org.kuali.student.common.rice.authorization.PermissionType; |
25 | |
import org.kuali.student.common.ui.server.gwt.BaseRpcGwtServletAbstract; |
26 | |
import org.kuali.student.core.document.dto.DocumentInfo; |
27 | |
import org.kuali.student.core.document.dto.RefDocRelationInfo; |
28 | |
import org.kuali.student.core.document.service.DocumentService; |
29 | |
import org.kuali.student.core.document.ui.client.service.DocumentRpcService; |
30 | |
|
31 | 0 | public class DocumentRpcGwtServlet extends BaseRpcGwtServletAbstract<DocumentService> implements DocumentRpcService{ |
32 | |
private static final long serialVersionUID = 1L; |
33 | |
|
34 | |
public DocumentInfo getDocument(String documentId) throws Exception{ |
35 | 0 | return service.getDocument(documentId); |
36 | |
} |
37 | |
|
38 | |
public List<DocumentInfo> getDocumentsByIdList(List<String> documentIdList)throws Exception{ |
39 | 0 | return service.getDocumentsByIdList(documentIdList); |
40 | |
} |
41 | |
|
42 | |
public StatusInfo deleteDocument(String documentId) throws Exception{ |
43 | 0 | return service.deleteDocument(documentId); |
44 | |
} |
45 | |
|
46 | |
public DocumentInfo updateDocument(String documentId, DocumentInfo documentInfo) throws Exception{ |
47 | 0 | return service.updateDocument(documentId, documentInfo); |
48 | |
} |
49 | |
|
50 | |
public StatusInfo addDocumentCategoryToDocument(String documentId, String documentCategoryKey) throws Exception{ |
51 | 0 | return service.addDocumentCategoryToDocument(documentId, documentCategoryKey); |
52 | |
} |
53 | |
|
54 | |
public StatusInfo removeDocumentCategoryFromDocument(String documentId, String documentCategoryKey) throws Exception{ |
55 | 0 | return service.removeDocumentCategoryFromDocument(documentId, documentCategoryKey); |
56 | |
} |
57 | |
|
58 | |
@Override |
59 | |
public Boolean isAuthorizedUploadDocuments(String id, String referenceTypeKey) { |
60 | 0 | if (id != null && (!"".equals(id.trim()))) { |
61 | 0 | String user = getCurrentUser(); |
62 | 0 | AttributeSet permissionDetails = new AttributeSet(StudentIdentityConstants.KS_REFERENCE_TYPE_KEY, referenceTypeKey); |
63 | 0 | if (getPermissionService().isPermissionDefinedForTemplateName(PermissionType.UPLOAD_DOCUMENTS.getPermissionNamespace(), PermissionType.UPLOAD_DOCUMENTS.getPermissionTemplateName(), permissionDetails)) { |
64 | 0 | AttributeSet roleQuals = new AttributeSet(); |
65 | 0 | roleQuals.put(referenceTypeKey, id); |
66 | 0 | return Boolean.valueOf(getPermissionService().isAuthorizedByTemplateName(user, PermissionType.UPLOAD_DOCUMENTS.getPermissionNamespace(), PermissionType.UPLOAD_DOCUMENTS.getPermissionTemplateName(), permissionDetails, roleQuals)); |
67 | |
} |
68 | |
} |
69 | 0 | return Boolean.TRUE; |
70 | |
} |
71 | |
|
72 | |
@Override |
73 | |
public StatusInfo deleteRefDocRelation(String documentId) throws Exception { |
74 | 0 | return service.deleteRefDocRelation(documentId); |
75 | |
} |
76 | |
|
77 | |
@Override |
78 | |
public List<RefDocRelationInfo> getRefDocIdsForRef(String refObjectTypeKey, String refObjectId) throws Exception{ |
79 | 0 | return service.getRefDocRelationsByRef(refObjectTypeKey, refObjectId); |
80 | |
} |
81 | |
|
82 | |
@Override |
83 | |
public StatusInfo deleteRefDocRelationAndOrphanedDoc(String docRelationId, String documentId) throws Exception { |
84 | |
|
85 | |
|
86 | 0 | service.deleteRefDocRelation(docRelationId); |
87 | |
|
88 | |
|
89 | |
try{ |
90 | 0 | List<RefDocRelationInfo> allRelations = service.getRefDocRelationsByDoc(documentId); |
91 | 0 | if(allRelations == null || allRelations.isEmpty()){ |
92 | 0 | service.deleteDocument(documentId); |
93 | |
} |
94 | 0 | }catch(DoesNotExistException e){ |
95 | 0 | service.deleteDocument(documentId); |
96 | 0 | } |
97 | 0 | return new StatusInfo(); |
98 | |
} |
99 | |
} |