Coverage Report - org.kuali.rice.kew.service.impl.AdhocReviewPermissionTypeServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
AdhocReviewPermissionTypeServiceImpl
0%
0/13
0%
0/8
6
 
 1  
 /*
 2  
  * Copyright 2007-2009 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.kew.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.service.support.KimPermissionTypeService;
 22  
 import org.kuali.rice.kim.util.KimConstants;
 23  
 import org.kuali.rice.krad.service.impl.DocumentTypePermissionTypeServiceImpl;
 24  
 
 25  
 import java.util.ArrayList;
 26  
 import java.util.List;
 27  
 import java.util.Map;
 28  
 
 29  
 /**
 30  
  * This is a description of what this class does - jonathan don't forget to fill
 31  
  * this in.
 32  
  * 
 33  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 34  
  * 
 35  
  */
 36  0
 public class AdhocReviewPermissionTypeServiceImpl extends DocumentTypePermissionTypeServiceImpl implements KimPermissionTypeService{
 37  
         
 38  
         {
 39  0
                 requiredAttributes.add( KimConstants.AttributeConstants.ACTION_REQUEST_CD );
 40  0
         }
 41  
 
 42  
         @Override
 43  
         public List<Permission> performPermissionMatches(
 44  
                         Map<String, String> requestedDetails,
 45  
                         List<Permission> permissionsList) {
 46  0
         List<Permission> matchingPermissions = new ArrayList<Permission>();
 47  0
                 if (requestedDetails == null) {
 48  0
                         return matchingPermissions; // empty list
 49  
                 }
 50  
                 // loop over the permissions, checking the non-document-related ones
 51  0
                 for (Permission kpi : permissionsList) {
 52  0
             PermissionBo bo = PermissionBo.from(kpi);
 53  0
                         if (!bo.getDetails().containsKey(KimConstants.AttributeConstants.ACTION_REQUEST_CD)
 54  
                           || StringUtils.equals(bo.getDetails().
 55  
                                  get(KimConstants.AttributeConstants.ACTION_REQUEST_CD), requestedDetails
 56  
                                         .get(KimConstants.AttributeConstants.ACTION_REQUEST_CD))) {
 57  0
                                 matchingPermissions.add(kpi);
 58  
                         }
 59  0
                 }
 60  
                 // now, filter the list to just those for the current document
 61  0
                 matchingPermissions = super.performPermissionMatches(requestedDetails,matchingPermissions);
 62  0
                 return matchingPermissions;
 63  
         }
 64  
 }