| 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 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 39 (39) | Complexity: 16 | Complexity Density: 0.7 |  | 
  
  
    | 30 |  | public class DocumentRpcGwtServlet extends BaseRpcGwtServletAbstract<DocumentService> implements DocumentRpcService{ | 
            
  
    | 31 |  | private static final long serialVersionUID = 1L; | 
            
  
    | 32 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 33 | 0 |  public DocumentInfo getDocument(String documentId) throws Exception{... | 
            
  
    | 34 | 0 | return service.getDocument(documentId); | 
            
  
    | 35 |  | } | 
            
  
    | 36 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 37 | 0 |  public List<DocumentInfo> getDocumentsByIdList(List<String> documentIdList)throws Exception{... | 
            
  
    | 38 | 0 | return service.getDocumentsByIdList(documentIdList); | 
            
  
    | 39 |  | } | 
            
  
    | 40 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 41 | 0 |  public StatusInfo deleteDocument(String documentId) throws Exception{... | 
            
  
    | 42 | 0 | return service.deleteDocument(documentId); | 
            
  
    | 43 |  | } | 
            
  
    | 44 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 45 | 0 |  public DocumentInfo updateDocument(String documentId, DocumentInfo documentInfo) throws Exception{... | 
            
  
    | 46 | 0 | return service.updateDocument(documentId, documentInfo); | 
            
  
    | 47 |  | } | 
            
  
    | 48 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 49 | 0 |  public StatusInfo addDocumentCategoryToDocument(String documentId, String documentCategoryKey) throws Exception{... | 
            
  
    | 50 | 0 | return service.addDocumentCategoryToDocument(documentId, documentCategoryKey); | 
            
  
    | 51 |  | } | 
            
  
    | 52 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 53 | 0 |  public StatusInfo removeDocumentCategoryFromDocument(String documentId, String documentCategoryKey) throws Exception{... | 
            
  
    | 54 | 0 | return service.removeDocumentCategoryFromDocument(documentId, documentCategoryKey); | 
            
  
    | 55 |  | } | 
            
  
    | 56 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 12 (12) | Complexity: 4 | Complexity Density: 0.5 |  | 
  
  
    | 57 | 0 |  @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 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 71 | 0 |  @Override... | 
            
  
    | 72 |  | public StatusInfo deleteRefDocRelation(String documentId) throws Exception { | 
            
  
    | 73 | 0 | return service.deleteRefDocRelation(documentId); | 
            
  
    | 74 |  | } | 
            
  
    | 75 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 76 | 0 |  @Override... | 
            
  
    | 77 |  | public List<RefDocRelationInfo> getRefDocIdsForRef(String refObjectTypeKey, String refObjectId) throws Exception{ | 
            
  
    | 78 | 0 | return service.getRefDocRelationsByRef(refObjectTypeKey, refObjectId); | 
            
  
    | 79 |  | } | 
            
  
    | 80 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 9 (9) | Complexity: 4 | Complexity Density: 0.57 |  | 
  
  
    | 81 | 0 |  @Override... | 
            
  
    | 82 |  | public StatusInfo deleteRefDocRelationAndOrphanedDoc(String docRelationId, String documentId) throws Exception { | 
            
  
    | 83 |  |  | 
            
  
    | 84 |  |  | 
            
  
    | 85 | 0 | service.deleteRefDocRelation(docRelationId); | 
            
  
    | 86 |  |  | 
            
  
    | 87 |  |  | 
            
  
    | 88 | 0 | try{ | 
            
  
    | 89 | 0 | List<RefDocRelationInfo> allRelations = service.getRefDocRelationsByDoc(documentId); | 
            
  
    | 90 | 0 | if(allRelations == null || allRelations.isEmpty()){ | 
            
  
    | 91 | 0 | service.deleteDocument(documentId); | 
            
  
    | 92 |  | } | 
            
  
    | 93 |  | }catch(DoesNotExistException e){ | 
            
  
    | 94 | 0 | service.deleteDocument(documentId); | 
            
  
    | 95 |  | } | 
            
  
    | 96 | 0 | return new StatusInfo(); | 
            
  
    | 97 |  | } | 
            
  
    | 98 |  | } |