Coverage Report - org.kuali.rice.kim.service.support.impl.KimPermissionTypeServiceBase
 
Classes in this File Line Coverage Branch Coverage Complexity
KimPermissionTypeServiceBase
0%
0/14
0%
0/12
3
 
 1  
 /*
 2  
  * Copyright 2007-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.kim.service.support.impl;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.List;
 20  
 
 21  
 import org.apache.commons.lang.StringUtils;
 22  
 import org.kuali.rice.core.util.AttributeSet;
 23  
 import org.kuali.rice.kim.bo.role.dto.KimPermissionInfo;
 24  
 import org.kuali.rice.kim.service.support.KimPermissionTypeService;
 25  
 
 26  
 /**
 27  
  * This is a description of what this class does - bhargavp don't forget to fill this in. 
 28  
  * 
 29  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 30  
  *
 31  
  */
 32  0
 public class KimPermissionTypeServiceBase extends KimTypeServiceBase implements KimPermissionTypeService {
 33  
 
 34  
         /**
 35  
          * @see org.kuali.rice.kim.service.support.KimPermissionTypeService#getMatchingPermissions(AttributeSet, List)
 36  
          */
 37  
         public final List<KimPermissionInfo> getMatchingPermissions( AttributeSet requestedDetails, List<KimPermissionInfo> permissionsList ) {
 38  0
                 requestedDetails = translateInputAttributeSet(requestedDetails);
 39  0
                 validateRequiredAttributesAgainstReceived(requestedDetails);
 40  0
                 return performPermissionMatches(requestedDetails, permissionsList);
 41  
         }
 42  
 
 43  
         /**
 44  
          * Internal method for matching permissions.  Override this method to customize the matching behavior.
 45  
          * 
 46  
          * This base implementation uses the {@link #performMatch(AttributeSet, AttributeSet)} method
 47  
          * to perform an exact match on the permission details and return all that are equal.
 48  
          */
 49  
         protected List<KimPermissionInfo> performPermissionMatches(AttributeSet requestedDetails, List<KimPermissionInfo> permissionsList) {
 50  0
                 List<KimPermissionInfo> matchingPermissions = new ArrayList<KimPermissionInfo>();
 51  0
                 for (KimPermissionInfo permission : permissionsList) {
 52  0
                         if ( performMatch(requestedDetails, permission.getDetails()) ) {
 53  0
                                 matchingPermissions.add( permission );
 54  
                         }
 55  
                 }
 56  0
                 return matchingPermissions;
 57  
         }
 58  
         
 59  
         /**
 60  
          * 
 61  
          * Internal method for checking if property name matches
 62  
          * 
 63  
          * @param requestedDetailsPropertyName name of requested details property
 64  
          * @param permissionDetailsPropertyName name of permission details property
 65  
          * @return boolean 
 66  
          */
 67  
         protected boolean doesPropertyNameMatch(
 68  
                         String requestedDetailsPropertyName,
 69  
                         String permissionDetailsPropertyName) {
 70  0
                 if (StringUtils.isBlank(permissionDetailsPropertyName)) {
 71  0
                         return true;
 72  
                 }
 73  0
                 if ( requestedDetailsPropertyName == null ) {
 74  0
                     requestedDetailsPropertyName = ""; // prevent NPE
 75  
                 }
 76  0
                 return StringUtils.equals(requestedDetailsPropertyName, permissionDetailsPropertyName)
 77  
                                 || (requestedDetailsPropertyName.startsWith(permissionDetailsPropertyName+"."));
 78  
         }
 79  
 }