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