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