Coverage Report - org.kuali.rice.kns.service.impl.DocumentTypeAndNodeOrStatePermissionTypeServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentTypeAndNodeOrStatePermissionTypeServiceImpl
0%
0/14
0%
0/10
3.333
 
 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  
 import org.kuali.rice.kim.util.KimCommonUtils;
 26  
 
 27  
 /**
 28  
  * 
 29  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 30  
  *
 31  
  */
 32  0
 public class DocumentTypeAndNodeOrStatePermissionTypeServiceImpl extends DocumentTypePermissionTypeServiceImpl {
 33  
 
 34  
         {
 35  
 //                requiredAttributes.add(KimAttributes.ROUTE_NODE_NAME);
 36  
 //                requiredAttributes.add(KimAttributes.ROUTE_STATUS_CODE);
 37  0
         }
 38  
 
 39  
         /**
 40  
      *  Permission type service which can check the route node and status as well as the document hierarchy.
 41  
      *  
 42  
      *  Permission should be able to (in addition to taking the routingStatus, routingNote, and documentTypeName attributes) 
 43  
      *  should take a documentNumber and retrieve those values from workflow before performing the comparison.
 44  
      *
 45  
      *  consider the document type hierarchy - check for a permission that just specifies the document type first at each level 
 46  
      *  - then if you don't find that, check for the doc type and the node, then the doc type and the state. 
 47  
      * 
 48  
          * @see org.kuali.rice.kns.service.impl.DocumentTypePermissionTypeServiceImpl#performPermissionMatches(org.kuali.rice.kim.bo.types.dto.AttributeSet, java.util.List)
 49  
          */
 50  
     @Override
 51  
     protected List<KimPermissionInfo> performPermissionMatches(AttributeSet requestedDetails,
 52  
             List<KimPermissionInfo> permissionsList) {
 53  0
         List<KimPermissionInfo> matchingPermissions = new ArrayList<KimPermissionInfo>();
 54  
         // loop over the permissions, checking the non-document-related ones
 55  0
         for ( KimPermissionInfo kpi : permissionsList ) {
 56  0
             if ( routeNodeMatches(requestedDetails, kpi.getDetails()) && 
 57  
                     routeStatusMatches(requestedDetails, kpi.getDetails())) {
 58  0
                 matchingPermissions.add( kpi );
 59  
             }           
 60  
         }
 61  
         // now, filter the list to just those for the current document
 62  0
         matchingPermissions = super.performPermissionMatches( requestedDetails, matchingPermissions );
 63  0
         return matchingPermissions;
 64  
     }
 65  
         
 66  
         protected boolean routeNodeMatches(AttributeSet requestedDetails, AttributeSet permissionDetails) {
 67  0
                 if ( StringUtils.isBlank( permissionDetails.get(KimAttributes.ROUTE_NODE_NAME) ) ) {
 68  0
                         return true;
 69  
                 }
 70  0
                 return KimCommonUtils.isAttributeSetEntryEquals( requestedDetails, permissionDetails, 
 71  
                                 KimAttributes.ROUTE_NODE_NAME );
 72  
         }
 73  
         
 74  
         protected boolean routeStatusMatches(AttributeSet requestedDetails, AttributeSet permissionDetails) {
 75  0
                 if ( StringUtils.isBlank( permissionDetails.get(KimAttributes.ROUTE_STATUS_CODE) ) ) {
 76  0
                         return true;
 77  
                 }
 78  0
                 return KimCommonUtils.isAttributeSetEntryEquals( requestedDetails, permissionDetails, 
 79  
                                 KimAttributes.ROUTE_STATUS_CODE );
 80  
         }
 81  
 
 82  
 }