Coverage Report - org.kuali.rice.kns.service.impl.ParameterPermissionTypeServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ParameterPermissionTypeServiceImpl
0%
0/15
0%
0/10
6
 
 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  
 
 26  
 /**
 27  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 28  
  */
 29  0
 public class ParameterPermissionTypeServiceImpl extends
 30  
                 NamespaceWildcardAllowedAndOrStringExactMatchPermissionTypeServiceImpl {
 31  
     
 32  
     {
 33  0
         requiredAttributes.add(KimAttributes.PARAMETER_NAME);
 34  0
         requiredAttributes.add(KimAttributes.COMPONENT_NAME);
 35  0
         checkRequiredAttributes = true;
 36  0
     }
 37  
     
 38  
     @Override
 39  
     protected List<KimPermissionInfo> performPermissionMatches(AttributeSet requestedDetails, List<KimPermissionInfo> permissionsList) {
 40  0
         String requestedParameterName = requestedDetails.get(KimAttributes.PARAMETER_NAME);
 41  0
         String requestedComponentName = requestedDetails.get(KimAttributes.COMPONENT_NAME);
 42  0
         List<KimPermissionInfo> matchingPermissions = new ArrayList<KimPermissionInfo>();
 43  0
         for ( KimPermissionInfo kpi : permissionsList ) {
 44  0
             String parameterName = kpi.getDetails().get(KimAttributes.PARAMETER_NAME);
 45  0
             String componentName = kpi.getDetails().get(KimAttributes.COMPONENT_NAME);
 46  0
             if ( (StringUtils.isBlank(parameterName)
 47  
                     || StringUtils.equals(requestedParameterName, parameterName)) 
 48  
                 &&(StringUtils.isBlank(componentName)
 49  
                         || StringUtils.equals(requestedComponentName, componentName))) {
 50  0
                 matchingPermissions.add(kpi);
 51  
             }
 52  0
         }
 53  0
         return super.performPermissionMatches(requestedDetails, matchingPermissions);
 54  
     }    
 55  
 }