Coverage Report - org.kuali.rice.krad.document.authorization.TransactionalDocumentAuthorizerBase
 
Classes in this File Line Coverage Branch Coverage Complexity
TransactionalDocumentAuthorizerBase
0%
0/10
0%
0/6
4
 
 1  
 /*
 2  
  * Copyright 2007 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.document.authorization;
 17  
 
 18  
 import org.kuali.rice.kim.bo.Person;
 19  
 import org.kuali.rice.kim.util.KimConstants;
 20  
 import org.kuali.rice.krad.document.Document;
 21  
 import org.kuali.rice.krad.util.KRADConstants;
 22  
 
 23  
 import java.util.HashMap;
 24  
 import java.util.HashSet;
 25  
 import java.util.Map;
 26  
 import java.util.Set;
 27  
 
 28  
 /**
 29  
  * Base class for all TransactionalDocumentAuthorizers.
 30  
  */
 31  0
 public class TransactionalDocumentAuthorizerBase extends DocumentAuthorizerBase
 32  
                 implements TransactionalDocumentAuthorizer {
 33  
         public final Set<String> getEditModes(Document document, Person user,
 34  
                         Set<String> editModes) {
 35  0
                 Set<String> unauthorizedEditModes = new HashSet<String>();
 36  0
                 for (String editMode : editModes) {
 37  0
                         Map<String, String> additionalPermissionDetails = new HashMap<String, String>();
 38  0
                         additionalPermissionDetails.put(KimConstants.AttributeConstants.EDIT_MODE, editMode);
 39  0
                         if (permissionExistsByTemplate(
 40  
                                         document,
 41  
                                         KRADConstants.KRAD_NAMESPACE,
 42  
                                         KimConstants.PermissionTemplateNames.USE_TRANSACTIONAL_DOCUMENT,
 43  
                                         additionalPermissionDetails)
 44  
                                         && !isAuthorizedByTemplate(
 45  
                                                         document,
 46  
                                                         KRADConstants.KRAD_NAMESPACE,
 47  
                                                         KimConstants.PermissionTemplateNames.USE_TRANSACTIONAL_DOCUMENT,
 48  
                                                         user.getPrincipalId(), additionalPermissionDetails,
 49  
                                                         null)) {
 50  0
                                 unauthorizedEditModes.add(editMode);
 51  
                         }
 52  0
                 }
 53  0
                 editModes.removeAll(unauthorizedEditModes);
 54  0
                 return editModes;
 55  
         }
 56  
 }