Coverage Report - org.kuali.rice.kew.service.impl.AdhocReviewPermissionTypeServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
AdhocReviewPermissionTypeServiceImpl
0%
0/16
0%
0/10
4.5
 
 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.kew.service.impl;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
 20  
 import org.kuali.rice.kim.api.KimConstants;
 21  
 import org.kuali.rice.kim.api.permission.Permission;
 22  
 import org.kuali.rice.kim.framework.permission.PermissionTypeService;
 23  
 import org.kuali.rice.kim.impl.permission.PermissionBo;
 24  
 import org.kuali.rice.krad.service.impl.DocumentTypePermissionTypeServiceImpl;
 25  
 
 26  
 import java.util.ArrayList;
 27  
 import java.util.Collections;
 28  
 import java.util.List;
 29  
 import java.util.Map;
 30  
 
 31  
 /**
 32  
  * This is a description of what this class does - jonathan don't forget to fill
 33  
  * this in.
 34  
  * 
 35  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 36  
  * 
 37  
  */
 38  0
 public class AdhocReviewPermissionTypeServiceImpl extends DocumentTypePermissionTypeServiceImpl implements PermissionTypeService {
 39  
 
 40  
     @Override
 41  
     protected List<String> getRequiredAttributes() {
 42  0
         final List<String> attrs = new ArrayList<String>(super.getRequiredAttributes());
 43  0
         attrs.add(KimConstants.AttributeConstants.ACTION_REQUEST_CD);
 44  0
         return Collections.unmodifiableList(attrs);
 45  
     }
 46  
 
 47  
         @Override
 48  
         public List<Permission> performPermissionMatches(
 49  
                         Map<String, String> requestedDetails,
 50  
                         List<Permission> permissionsList) {
 51  
 
 52  0
         if (permissionsList == null) {
 53  0
             throw new RiceIllegalArgumentException("permissionsList was null or blank");
 54  
         }
 55  
 
 56  0
         if (requestedDetails == null) {
 57  0
             throw new RiceIllegalArgumentException("requestedDetails was null");
 58  
         }
 59  
 
 60  0
         List<Permission> matchingPermissions = new ArrayList<Permission>();
 61  
                 // loop over the permissions, checking the non-document-related ones
 62  0
                 for (Permission kpi : permissionsList) {
 63  0
             PermissionBo bo = PermissionBo.from(kpi);
 64  0
                         if (!bo.getDetails().containsKey(KimConstants.AttributeConstants.ACTION_REQUEST_CD)
 65  
                           || StringUtils.equals(bo.getDetails().
 66  
                                  get(KimConstants.AttributeConstants.ACTION_REQUEST_CD), requestedDetails
 67  
                                         .get(KimConstants.AttributeConstants.ACTION_REQUEST_CD))) {
 68  0
                                 matchingPermissions.add(kpi);
 69  
                         }
 70  0
                 }
 71  
                 // now, filter the list to just those for the current document
 72  0
                 matchingPermissions = super.performPermissionMatches(requestedDetails,matchingPermissions);
 73  0
                 return matchingPermissions;
 74  
         }
 75  
 }