Coverage Report - org.kuali.rice.krad.service.impl.ParameterPermissionTypeServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ParameterPermissionTypeServiceImpl
0%
0/16
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.krad.service.impl;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.kim.api.permission.Permission;
 20  
 import org.kuali.rice.kim.impl.permission.PermissionBo;
 21  
 import org.kuali.rice.kim.util.KimConstants;
 22  
 
 23  
 import java.util.ArrayList;
 24  
 import java.util.List;
 25  
 import java.util.Map;
 26  
 
 27  
 /**
 28  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 29  
  */
 30  0
 public class ParameterPermissionTypeServiceImpl extends
 31  
                 NamespaceWildcardAllowedAndOrStringExactMatchPermissionTypeServiceImpl {
 32  
     
 33  
     {
 34  0
         requiredAttributes.add(KimConstants.AttributeConstants.PARAMETER_NAME);
 35  0
         requiredAttributes.add(KimConstants.AttributeConstants.COMPONENT_NAME);
 36  0
         checkRequiredAttributes = true;
 37  0
     }
 38  
     
 39  
     @Override
 40  
     protected List<Permission> performPermissionMatches(Map<String, String> requestedDetails, List<Permission> permissionsList) {
 41  0
         String requestedParameterName = requestedDetails.get(KimConstants.AttributeConstants.PARAMETER_NAME);
 42  0
         String requestedComponentName = requestedDetails.get(KimConstants.AttributeConstants.COMPONENT_NAME);
 43  0
         List<Permission> matchingPermissions = new ArrayList<Permission>();
 44  0
         for (Permission kpi : permissionsList ) {
 45  0
             PermissionBo bo = PermissionBo.from(kpi);
 46  0
             String parameterName = bo.getDetails().get(KimConstants.AttributeConstants.PARAMETER_NAME);
 47  0
             String componentName = bo.getDetails().get(KimConstants.AttributeConstants.COMPONENT_NAME);
 48  0
             if ( (StringUtils.isBlank(parameterName)
 49  
                     || StringUtils.equals(requestedParameterName, parameterName)) 
 50  
                 &&(StringUtils.isBlank(componentName)
 51  
                         || StringUtils.equals(requestedComponentName, componentName))) {
 52  0
                 matchingPermissions.add(kpi);
 53  
             }
 54  0
         }
 55  0
         return super.performPermissionMatches(requestedDetails, matchingPermissions);
 56  
     }    
 57  
 }