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