Coverage Report - org.kuali.rice.kns.service.impl.ComponentFieldPermissionTypeServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ComponentFieldPermissionTypeServiceImpl
0%
0/22
0%
0/14
10
 
 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.kns.service.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.kim.bo.impl.KimAttributes;
 23  
 import org.kuali.rice.kim.bo.role.dto.KimPermissionInfo;
 24  
 import org.kuali.rice.kim.bo.types.dto.AttributeSet;
 25  
 import org.kuali.rice.kim.service.support.impl.KimPermissionTypeServiceBase;
 26  
 import org.kuali.rice.kim.util.KimCommonUtils;
 27  
 
 28  
 /**
 29  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 30  
  */
 31  0
 public class ComponentFieldPermissionTypeServiceImpl extends KimPermissionTypeServiceBase {
 32  
 
 33  
         {
 34  
 //                requiredAttributes.add(KimAttributes.COMPONENT_NAME);
 35  
 //                requiredAttributes.add(KimAttributes.PROPERTY_NAME);
 36  0
         }
 37  
         
 38  
         /**
 39  
          * Compare the component and property names between the request and matching permissions.
 40  
          * Make entries with a matching property name take precedence over those with blank property 
 41  
          * names on the stored permissions.  Only match entries with blank property names if
 42  
          * no entries match on the exact property name. 
 43  
          * 
 44  
          * @see org.kuali.rice.kim.service.support.impl.KimPermissionTypeServiceBase#performPermissionMatches(org.kuali.rice.kim.bo.types.dto.AttributeSet, java.util.List)
 45  
          */
 46  
         @Override
 47  
         protected List<KimPermissionInfo> performPermissionMatches(AttributeSet requestedDetails,
 48  
                         List<KimPermissionInfo> permissionsList) {
 49  0
                 List<KimPermissionInfo> propertyMatches = new ArrayList<KimPermissionInfo>();
 50  0
                 List<KimPermissionInfo> prefixPropertyMatches = new ArrayList<KimPermissionInfo>();
 51  0
                 List<KimPermissionInfo> blankPropertyMatches = new ArrayList<KimPermissionInfo>();
 52  0
                 String propertyName = requestedDetails.get(KimAttributes.PROPERTY_NAME);
 53  0
                 String componentName = requestedDetails.get(KimAttributes.COMPONENT_NAME);
 54  0
                 for ( KimPermissionInfo kpi : permissionsList ) {
 55  0
                         if ( StringUtils.equals( componentName, kpi.getDetails().get( KimAttributes.COMPONENT_NAME ) ) ) {
 56  0
                                 String permPropertyName = kpi.getDetails().get(KimAttributes.PROPERTY_NAME);
 57  0
                                 if ( StringUtils.isBlank( permPropertyName ) ) {
 58  0
                                         blankPropertyMatches.add( kpi );
 59  0
                                 } else if ( StringUtils.equals( propertyName, permPropertyName ) ) {
 60  0
                                         propertyMatches.add( kpi );
 61  0
                                 } else if ( KimCommonUtils.doesPropertyNameMatch(propertyName, permPropertyName) ) {
 62  0
                                         prefixPropertyMatches.add( kpi );
 63  
                                 }
 64  0
                         }
 65  
                 }
 66  0
                 if ( !propertyMatches.isEmpty() ) {
 67  0
                         return propertyMatches;
 68  0
                 } else if ( !prefixPropertyMatches.isEmpty() ) {
 69  0
                         return prefixPropertyMatches;
 70  
                 } else {
 71  0
                         return blankPropertyMatches;
 72  
                 }
 73  
         }
 74  
 
 75  
 }