Coverage Report - org.kuali.rice.krad.web.struts.action.KualiTransactionalDocumentActionBase
 
Classes in this File Line Coverage Branch Coverage Complexity
KualiTransactionalDocumentActionBase
0%
0/20
0%
0/6
3
 
 1  
 /*
 2  
  * Copyright 2005-2008 The Kuali Foundation
 3  
  * 
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.krad.web.struts.action;
 17  
 
 18  
 import java.util.HashMap;
 19  
 import java.util.Map;
 20  
 import java.util.Set;
 21  
 
 22  
 import javax.servlet.http.HttpServletRequest;
 23  
 import javax.servlet.http.HttpServletResponse;
 24  
 
 25  
 import org.apache.struts.action.ActionForm;
 26  
 import org.apache.struts.action.ActionForward;
 27  
 import org.apache.struts.action.ActionMapping;
 28  
 import org.kuali.rice.core.util.RiceConstants;
 29  
 import org.kuali.rice.kim.bo.Person;
 30  
 import org.kuali.rice.krad.document.Copyable;
 31  
 import org.kuali.rice.krad.document.Document;
 32  
 import org.kuali.rice.krad.document.authorization.TransactionalDocumentAuthorizer;
 33  
 import org.kuali.rice.krad.document.authorization.TransactionalDocumentPresentationController;
 34  
 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
 35  
 import org.kuali.rice.krad.util.GlobalVariables;
 36  
 import org.kuali.rice.krad.util.KRADConstants;
 37  
 import org.kuali.rice.krad.web.struts.form.KualiDocumentFormBase;
 38  
 import org.kuali.rice.krad.web.struts.form.KualiTransactionalDocumentFormBase;
 39  
 
 40  
 /**
 41  
  * This class handles UI actions for all shared methods of transactional documents.
 42  
  */
 43  0
 public class KualiTransactionalDocumentActionBase extends KualiDocumentActionBase {
 44  
 //    private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KualiTransactionalDocumentActionBase.class);
 45  
 
 46  
     /**
 47  
      * Method that will take the current document and call its copy method if Copyable.
 48  
      */
 49  
     public ActionForward copy(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
 50  0
         KualiTransactionalDocumentFormBase tmpForm = (KualiTransactionalDocumentFormBase) form;
 51  
 
 52  0
         Document document = tmpForm.getDocument();
 53  
         
 54  0
         if (!tmpForm.getDocumentActions().containsKey(KRADConstants.KUALI_ACTION_CAN_COPY)) {
 55  0
             throw buildAuthorizationException("copy", document);
 56  
         }
 57  
 
 58  0
         ((Copyable) tmpForm.getTransactionalDocument()).toCopy();
 59  
 
 60  0
         return mapping.findForward(RiceConstants.MAPPING_BASIC);
 61  
     }
 62  
 
 63  
     @SuppressWarnings("unchecked")
 64  
         protected void populateAuthorizationFields(KualiDocumentFormBase formBase){
 65  0
             super.populateAuthorizationFields(formBase);
 66  0
             Document document = formBase.getDocument();
 67  0
             Map editMode = new HashMap();
 68  
             
 69  0
             if (formBase.isFormDocumentInitialized()) {
 70  0
                 Person user = GlobalVariables.getUserSession().getPerson();
 71  
                 
 72  0
                 TransactionalDocumentPresentationController documentPresentationController = (TransactionalDocumentPresentationController) getDocumentHelperService().getDocumentPresentationController(document);
 73  0
             TransactionalDocumentAuthorizer documentAuthorizer = (TransactionalDocumentAuthorizer) KRADServiceLocatorWeb
 74  
                     .getDocumentHelperService().getDocumentAuthorizer(document);
 75  0
             Set<String> editModes = documentAuthorizer.getEditModes(document, user, documentPresentationController.getEditModes(document));
 76  0
             editMode = this.convertSetToMap(editModes);
 77  0
             if (getDataDictionaryService().getDataDictionary().getDocumentEntry(document.getClass().getName()).getUsePessimisticLocking()) {
 78  0
                 editMode = getPessimisticLockService().establishLocks(document, editMode, user);
 79  
             }            
 80  
             }
 81  0
             formBase.setEditingMode(editMode);
 82  0
     }
 83  
 }