Coverage Report - org.kuali.rice.kim.impl.permission.PermissionServiceBase
 
Classes in this File Line Coverage Branch Coverage Complexity
PermissionServiceBase
0%
0/22
N/A
1
 
 1  
 /*
 2  
  * Copyright 2007-2010 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.kim.impl.permission;
 17  
 
 18  
 import com.google.common.collect.MapMaker;
 19  
 import org.kuali.rice.core.api.criteria.CriteriaLookupService;
 20  
 import org.kuali.rice.kim.api.permission.Permission;
 21  
 import org.kuali.rice.kim.api.permission.PermissionTypeService;
 22  
 import org.kuali.rice.kim.impl.role.RoleMemberAttributeDataBo;
 23  
 import org.kuali.rice.kim.util.KimConstants;
 24  
 import org.kuali.rice.krad.service.BusinessObjectService;
 25  
 import org.kuali.rice.krad.service.SequenceAccessorService;
 26  
 import org.kuali.rice.ksb.api.cache.RiceCacheAdministrator;
 27  
 
 28  
 import java.util.List;
 29  
 import java.util.Map;
 30  
 import java.util.concurrent.ConcurrentMap;
 31  
 
 32  
 /**
 33  
  * This is a description of what this class does - jjhanso don't forget to fill this in. 
 34  
  * 
 35  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 36  
  *
 37  
  */
 38  0
 public class PermissionServiceBase {
 39  
         protected static final String PERMISSION_IMPL_CACHE_PREFIX = "PermissionImpl-Template-";
 40  
         protected static final String PERMISSION_IMPL_NAME_CACHE_PREFIX = "PermissionImpl-Name-";
 41  
         protected static final String PERMISSION_IMPL_ID_CACHE_PREFIX = "PermissionImpl-Id-";
 42  
         protected static final String PERMISSION_IMPL_CACHE_GROUP = "PermissionImpl";
 43  
 
 44  
         protected static final String DEFAULT_PERMISSION_TYPE_SERVICE = "defaultPermissionTypeService";
 45  
         
 46  
         protected BusinessObjectService businessObjectService;
 47  
         protected CriteriaLookupService criteriaLookupService;
 48  
         protected SequenceAccessorService sequenceAccessorService;
 49  
         protected RiceCacheAdministrator cacheAdministrator;
 50  
         
 51  0
         private ConcurrentMap<List<Permission>,List<String>> permissionToRoleCache = new MapMaker().softValues().makeMap();
 52  
 
 53  
     // Not ThreadLocal or time limited- should not change during the life of the system
 54  0
         private ConcurrentMap<String,PermissionTypeService> permissionTypeServiceByNameCache = new MapMaker().makeMap();
 55  
         
 56  
 
 57  
         private static final long CACHE_MAX_AGE_SECONDS = 60L;
 58  
    
 59  
         public void flushPermissionImplCache() {
 60  0
             cacheAdministrator.flushGroup(PERMISSION_IMPL_CACHE_GROUP);
 61  0
     }
 62  
         
 63  
         /**
 64  
          * @return the permissionTypeServiceByNameCache
 65  
          */
 66  
         protected Map<String, PermissionTypeService> getPermissionTypeServiceByNameCache() {
 67  0
                 return this.permissionTypeServiceByNameCache;
 68  
         }
 69  
         
 70  
         protected void addRolesForPermissionsToCache( List<Permission> applicablePermissions, List<String> roleIds ) {
 71  0
             permissionToRoleCache.put( applicablePermissions, roleIds );
 72  0
     }
 73  
         
 74  
         protected List<String> getRolesForPermissionsFromCache( List<Permission> applicablePermissions ) {
 75  0
             return permissionToRoleCache.get( applicablePermissions );
 76  
     }
 77  
         
 78  
         protected String getPermissionImplByTemplateNameCacheKey( String namespaceCode, String permissionTemplateName ) {
 79  0
             return PERMISSION_IMPL_CACHE_PREFIX + namespaceCode + "-" + permissionTemplateName;
 80  
     }
 81  
     protected String getPermissionImplByNameCacheKey( String namespaceCode, String permissionName ) {
 82  0
             return PERMISSION_IMPL_NAME_CACHE_PREFIX + namespaceCode + "-" + permissionName;
 83  
     }
 84  
     protected String getPermissionImplByIdCacheKey( String permissionId ) {
 85  0
             return PERMISSION_IMPL_ID_CACHE_PREFIX + permissionId;
 86  
     }
 87  
     
 88  
         protected String getNewAttributeDataId(){        
 89  0
                 Long nextSeq = sequenceAccessorService.getNextAvailableSequenceNumber(
 90  
                                 KimConstants.SequenceNames.KRIM_ATTR_DATA_ID_S, 
 91  
                                 RoleMemberAttributeDataBo.class );
 92  0
                 return nextSeq.toString();
 93  
     }
 94  
         
 95  
     /**
 96  
      * Sets the sequenceAccessorService attribute value.
 97  
      *
 98  
      * @param sequenceAccessorService The sequenceAccessorService to set.
 99  
      */
 100  
     public void setSequenceAccessorService(final SequenceAccessorService sequenceAccessorService) {
 101  0
         this.sequenceAccessorService = sequenceAccessorService;
 102  0
     }
 103  
     
 104  
     /**
 105  
      * Sets the businessObjectService attribute value.
 106  
      *
 107  
      * @param businessObjectService The businessObjectService to set.
 108  
      */
 109  
     public void setBusinessObjectService(final BusinessObjectService businessObjectService) {
 110  0
         this.businessObjectService = businessObjectService;
 111  0
     }
 112  
 
 113  
     /**
 114  
      * Sets the criteriaLookupService attribute value.
 115  
      *
 116  
      * @param criteriaLookupService The criteriaLookupService to set.
 117  
      */
 118  
     public void setCriteriaLookupService(final CriteriaLookupService criteriaLookupService) {
 119  0
         this.criteriaLookupService = criteriaLookupService;
 120  0
     }
 121  
         
 122  
 
 123  
     /**
 124  
      * Sets the cacheAdministrator attribute value.
 125  
      *
 126  
      * @param cacheAdministrator The cacheAdministrator to set.
 127  
      */
 128  
     protected void setCacheAdministrator(RiceCacheAdministrator cacheAdministrator) {
 129  0
                 this.cacheAdministrator = cacheAdministrator;
 130  0
         }
 131  
 }