Coverage Report - org.kuali.student.core.document.ui.server.DocumentRpcGwtServlet
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentRpcGwtServlet
0%
0/26
0%
0/10
1.636
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 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.exceptions.OperationFailedException;
 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.DocumentTypeInfo;
 29  
 import org.kuali.student.core.document.dto.RefDocRelationInfo;
 30  
 import org.kuali.student.core.document.service.DocumentService;
 31  
 import org.kuali.student.core.document.ui.client.service.DocumentRpcService;
 32  
 
 33  0
 public class DocumentRpcGwtServlet extends BaseRpcGwtServletAbstract<DocumentService> implements DocumentRpcService{
 34  
         private static final long serialVersionUID = 1L;
 35  
         
 36  
          public List<DocumentTypeInfo> getDocumentTypes() throws Exception{    //KSLAB-2115
 37  
              
 38  0
              return service.getDocumentTypes();
 39  
          }
 40  
         
 41  
         public DocumentInfo getDocument(String documentId) throws Exception{
 42  0
                 return service.getDocument(documentId);
 43  
         }
 44  
         
 45  
         public List<DocumentInfo> getDocumentsByIdList(List<String> documentIdList)throws Exception{
 46  0
                 return service.getDocumentsByIdList(documentIdList);
 47  
         }
 48  
         
 49  
         public StatusInfo deleteDocument(String documentId) throws Exception{
 50  0
                 return service.deleteDocument(documentId);
 51  
         }
 52  
         
 53  
     public DocumentInfo updateDocument(String documentId, DocumentInfo documentInfo) throws Exception{
 54  0
             return service.updateDocument(documentId, documentInfo);
 55  
     }
 56  
         
 57  
         public StatusInfo addDocumentCategoryToDocument(String documentId, String documentCategoryKey) throws Exception{
 58  0
                 return service.addDocumentCategoryToDocument(documentId, documentCategoryKey);
 59  
         }
 60  
         
 61  
     public StatusInfo removeDocumentCategoryFromDocument(String documentId, String documentCategoryKey) throws Exception{
 62  0
             return service.removeDocumentCategoryFromDocument(documentId, documentCategoryKey);
 63  
     }
 64  
 
 65  
         @Override
 66  
     public Boolean isAuthorizedUploadDocuments(String id, String referenceTypeKey) {
 67  0
                 if (id != null && (!"".equals(id.trim()))) {
 68  0
                         String user = getCurrentUser();
 69  0
             AttributeSet permissionDetails = new AttributeSet(StudentIdentityConstants.KS_REFERENCE_TYPE_KEY, referenceTypeKey);
 70  0
                 if (getPermissionService().isPermissionDefinedForTemplateName(PermissionType.UPLOAD_DOCUMENTS.getPermissionNamespace(), PermissionType.UPLOAD_DOCUMENTS.getPermissionTemplateName(), permissionDetails)) {
 71  0
                     AttributeSet roleQuals = new AttributeSet();
 72  0
                     roleQuals.put(referenceTypeKey, id);
 73  0
                     return Boolean.valueOf(getPermissionService().isAuthorizedByTemplateName(user, PermissionType.UPLOAD_DOCUMENTS.getPermissionNamespace(), PermissionType.UPLOAD_DOCUMENTS.getPermissionTemplateName(), permissionDetails, roleQuals));
 74  
                 }
 75  
                 }
 76  0
                 return Boolean.TRUE;
 77  
     }
 78  
 
 79  
         @Override
 80  
         public StatusInfo deleteRefDocRelation(String documentId) throws Exception {
 81  0
                 return service.deleteRefDocRelation(documentId);
 82  
         }
 83  
 
 84  
         @Override
 85  
         public List<RefDocRelationInfo> getRefDocIdsForRef(String refObjectTypeKey, String refObjectId) throws Exception{
 86  0
                 return service.getRefDocRelationsByRef(refObjectTypeKey, refObjectId);
 87  
         }
 88  
 
 89  
         @Override
 90  
         public StatusInfo deleteRefDocRelationAndOrphanedDoc(String docRelationId, String documentId) throws Exception {
 91  
                 
 92  
                 //Delete the relation
 93  0
                 service.deleteRefDocRelation(docRelationId);
 94  
                 
 95  
                 //Also delete the document if there are no more relations to it
 96  
                 try{
 97  0
                         List<RefDocRelationInfo> allRelations = service.getRefDocRelationsByDoc(documentId);
 98  0
                         if(allRelations == null || allRelations.isEmpty()){
 99  0
                                 service.deleteDocument(documentId);
 100  
                         }
 101  0
                 }catch(DoesNotExistException e){
 102  0
                         service.deleteDocument(documentId);
 103  0
                 }
 104  0
                 return new StatusInfo();
 105  
         }
 106  
 }