|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  15 |     | 
     | 
  |  16 |     | 
   package org.kuali.rice.kim.service.impl;  | 
  |  17 |     | 
     | 
  |  18 |     | 
   import java.util.ArrayList;  | 
  |  19 |     | 
   import java.util.Collection;  | 
  |  20 |     | 
   import java.util.Collections;  | 
  |  21 |     | 
   import java.util.HashMap;  | 
  |  22 |     | 
   import java.util.HashSet;  | 
  |  23 |     | 
   import java.util.List;  | 
  |  24 |     | 
   import java.util.Map;  | 
  |  25 |     | 
   import java.util.Set;  | 
  |  26 |     | 
     | 
  |  27 |     | 
   import javax.xml.namespace.QName;  | 
  |  28 |     | 
     | 
  |  29 |     | 
   import org.apache.commons.collections.CollectionUtils;  | 
  |  30 |     | 
   import org.apache.commons.lang.StringUtils;  | 
  |  31 |     | 
   import org.kuali.rice.core.xml.dto.AttributeSet;  | 
  |  32 |     | 
   import org.kuali.rice.kew.service.KEWServiceLocator;  | 
  |  33 |     | 
   import org.kuali.rice.kew.util.KEWConstants;  | 
  |  34 |     | 
   import org.kuali.rice.kim.bo.Group;  | 
  |  35 |     | 
   import org.kuali.rice.kim.bo.Role;  | 
  |  36 |     | 
   import org.kuali.rice.kim.bo.entity.KimPrincipal;  | 
  |  37 |     | 
   import org.kuali.rice.kim.bo.impl.RoleImpl;  | 
  |  38 |     | 
   import org.kuali.rice.kim.bo.role.dto.DelegateMemberCompleteInfo;  | 
  |  39 |     | 
   import org.kuali.rice.kim.bo.role.dto.RoleMemberCompleteInfo;  | 
  |  40 |     | 
   import org.kuali.rice.kim.bo.role.dto.RoleResponsibilityActionInfo;  | 
  |  41 |     | 
   import org.kuali.rice.kim.bo.role.impl.KimDelegationImpl;  | 
  |  42 |     | 
   import org.kuali.rice.kim.bo.role.impl.KimDelegationMemberImpl;  | 
  |  43 |     | 
   import org.kuali.rice.kim.bo.role.impl.RoleMemberAttributeDataImpl;  | 
  |  44 |     | 
   import org.kuali.rice.kim.bo.role.impl.RoleMemberImpl;  | 
  |  45 |     | 
   import org.kuali.rice.kim.bo.role.impl.RoleResponsibilityActionImpl;  | 
  |  46 |     | 
   import org.kuali.rice.kim.bo.types.impl.KimAttributeImpl;  | 
  |  47 |     | 
   import org.kuali.rice.kim.dao.KimRoleDao;  | 
  |  48 |     | 
   import org.kuali.rice.kim.service.*;  | 
  |  49 |     | 
   import org.kuali.rice.kim.service.support.KimDelegationTypeService;  | 
  |  50 |     | 
   import org.kuali.rice.kim.service.support.KimRoleTypeService;  | 
  |  51 |     | 
   import org.kuali.rice.kim.util.KIMPropertyConstants;  | 
  |  52 |     | 
   import org.kuali.rice.kim.util.KimCommonUtilsInternal;  | 
  |  53 |     | 
   import org.kuali.rice.kim.util.KimConstants;  | 
  |  54 |     | 
   import org.kuali.rice.kns.service.*;  | 
  |  55 |     | 
   import org.kuali.rice.kns.util.KNSPropertyConstants;  | 
  |  56 |     | 
   import org.kuali.rice.ksb.cache.RiceCacheAdministrator;  | 
  |  57 |     | 
   import org.kuali.rice.ksb.service.KSBServiceLocator;  | 
  |  58 |     | 
     | 
  |  59 |     | 
     | 
  |  60 |     | 
     | 
  |  61 |     | 
     | 
  |  62 |     | 
     | 
  |  63 |     | 
     | 
  |  64 |     | 
     | 
  |  65 |    0 |    public class RoleServiceBase { | 
  |  66 |     | 
           protected static final String ROLE_IMPL_CACHE_PREFIX = "RoleImpl-ID-";  | 
  |  67 |     | 
           protected static final String ROLE_IMPL_BY_NAME_CACHE_PREFIX = "RoleImpl-Name-";  | 
  |  68 |     | 
           protected static final String ROLE_IMPL_CACHE_GROUP = "RoleImpl";  | 
  |  69 |     | 
             | 
  |  70 |     | 
           protected static final String ROLE_MEMBER_IMPL_CACHE_PREFIX = "RoleMemberImpl-ID-";  | 
  |  71 |     | 
           protected static final String ROLE_MEMBER_IMPL_LIST_CACHE_PREFIX = "RoleMemberImpl-List-";  | 
  |  72 |     | 
           protected static final String ROLE_MEMBER_IMPL_CACHE_GROUP = "RoleMemberImpl";  | 
  |  73 |     | 
             | 
  |  74 |     | 
           protected static final String DELEGATION_IMPL_CACHE_PREFIX = "KimDelegationImpl-ID-";  | 
  |  75 |     | 
           protected static final String DELEGATION_IMPL_LIST_CACHE_PREFIX = "KimDelegationImpl-List-";  | 
  |  76 |     | 
           protected static final String DELEGATION_IMPL_CACHE_GROUP = "KimDelegationImpl";  | 
  |  77 |     | 
             | 
  |  78 |     | 
           protected static final String DELEGATION_MEMBER_IMPL_CACHE_PREFIX = "KimDelegationMemberImpl-ID-";  | 
  |  79 |     | 
           protected static final String DELEGATION_MEMBER_IMPL_BY_DLGN_AND_ID_CACHE_PREFIX = "KimDelegationMemberImpl-DelegationAndId-";  | 
  |  80 |     | 
           protected static final String DELEGATION_MEMBER_IMPL_LIST_CACHE_PREFIX = "KimDelegationMemberImpl-List-";  | 
  |  81 |     | 
           protected static final String DELEGATION_MEMBER_IMPL_LIST_BY_MBR_DLGN_CACHE_PREFIX = "KimDelegationMemberImpl-List-MemberAndDelegationId-";  | 
  |  82 |     | 
           protected static final String DELEGATION_MEMBER_IMPL_CACHE_GROUP = "KimDelegationMemberImpl";  | 
  |  83 |     | 
             | 
  |  84 |     | 
           private BusinessObjectService businessObjectService;  | 
  |  85 |     | 
           private LookupService lookupService;  | 
  |  86 |     | 
           private RiceCacheAdministrator cacheAdministrator;  | 
  |  87 |     | 
           private SequenceAccessorService sequenceAccessorService;  | 
  |  88 |     | 
           private IdentityManagementService identityManagementService;  | 
  |  89 |     | 
           private ResponsibilityInternalService responsibilityInternalService;  | 
  |  90 |     | 
     | 
  |  91 |    0 |        private Map<String,KimRoleTypeService> roleTypeServiceCache = Collections.synchronizedMap( new HashMap<String,KimRoleTypeService>() );  | 
  |  92 |    0 |            private Map<String,KimDelegationTypeService> delegationTypeServiceCache = Collections.synchronizedMap( new HashMap<String,KimDelegationTypeService>() );  | 
  |  93 |     | 
     | 
  |  94 |    0 |            private Map<String,Boolean> applicationRoleTypeCache = Collections.synchronizedMap( new HashMap<String,Boolean>() );  | 
  |  95 |     | 
           private KimRoleDao roleDao;  | 
  |  96 |     | 
             | 
  |  97 |     | 
             | 
  |  98 |     | 
     | 
  |  99 |     | 
     | 
  |  100 |     | 
     | 
  |  101 |     | 
     | 
  |  102 |    0 |            protected static enum RoleDaoAction { | 
  |  103 |    0 |                    ROLE_PRINCIPALS_FOR_PRINCIPAL_ID_AND_ROLE_IDS("principalMembers-"), | 
  |  104 |    0 |                    ROLE_GROUPS_FOR_GROUP_IDS_AND_ROLE_IDS("groupMembers-"), | 
  |  105 |    0 |                    ROLE_MEMBERS_FOR_ROLE_IDS("membersOfRole-"), | 
  |  106 |    0 |                    ROLE_MEMBERSHIPS_FOR_ROLE_IDS_AS_MEMBERS("rolesAsMembers-"), | 
  |  107 |    0 |                    ROLE_MEMBERS_FOR_ROLE_IDS_WITH_FILTERS("roleIdsWithFilters-"), | 
  |  108 |    0 |                    DELEGATION_PRINCIPALS_FOR_PRINCIPAL_ID_AND_DELEGATION_IDS("delegationPrincipals-"), | 
  |  109 |    0 |                    DELEGATION_GROUPS_FOR_GROUP_IDS_AND_DELEGATION_IDS("delegationGroups-"), | 
  |  110 |    0 |                    DELEGATION_MEMBERS_FOR_DELEGATION_IDS("delegationMembers-"); | 
  |  111 |     | 
                     | 
  |  112 |     | 
                   public final String DAO_ACTION_CACHE_PREFIX;  | 
  |  113 |    0 |                    private RoleDaoAction(String daoActionCachePrefix) { this.DAO_ACTION_CACHE_PREFIX = daoActionCachePrefix;  } | 
  |  114 |     | 
           }  | 
  |  115 |     | 
             | 
  |  116 |     | 
         | 
  |  117 |     | 
         | 
  |  118 |     | 
         | 
  |  119 |     | 
     | 
  |  120 |     | 
             | 
  |  121 |     | 
     | 
  |  122 |     | 
     | 
  |  123 |     | 
     | 
  |  124 |     | 
     | 
  |  125 |     | 
     | 
  |  126 |     | 
           protected String getRoleMemberCacheKey(String roleMemberId) { | 
  |  127 |    0 |                    return ROLE_MEMBER_IMPL_CACHE_PREFIX + roleMemberId;  | 
  |  128 |     | 
           }  | 
  |  129 |     | 
             | 
  |  130 |     | 
             | 
  |  131 |     | 
     | 
  |  132 |     | 
     | 
  |  133 |     | 
     | 
  |  134 |     | 
     | 
  |  135 |     | 
     | 
  |  136 |     | 
     | 
  |  137 |     | 
     | 
  |  138 |     | 
     | 
  |  139 |     | 
     | 
  |  140 |     | 
     | 
  |  141 |     | 
     | 
  |  142 |     | 
     | 
  |  143 |     | 
     | 
  |  144 |     | 
     | 
  |  145 |     | 
           protected String getRoleMemberListCacheKey(RoleDaoAction roleDaoAction, String roleId, String principalId, String groupId, String memberTypeCode) { | 
  |  146 |    0 |                    switch (roleDaoAction) { | 
  |  147 |     | 
                           case ROLE_PRINCIPALS_FOR_PRINCIPAL_ID_AND_ROLE_IDS :   | 
  |  148 |    0 |                                    return new StringBuilder(ROLE_MEMBER_IMPL_LIST_CACHE_PREFIX).append(roleDaoAction.DAO_ACTION_CACHE_PREFIX).append(  | 
  |  149 |     | 
                                                   StringUtils.isBlank(roleId) ? "" : roleId).append('-').append(StringUtils.isBlank(principalId) ? "" : principalId).toString(); | 
  |  150 |     | 
                           case ROLE_GROUPS_FOR_GROUP_IDS_AND_ROLE_IDS :   | 
  |  151 |    0 |                                    return new StringBuilder(ROLE_MEMBER_IMPL_LIST_CACHE_PREFIX).append(roleDaoAction.DAO_ACTION_CACHE_PREFIX).append(  | 
  |  152 |     | 
                                                   StringUtils.isBlank(roleId) ? "" : roleId).append('-').append(StringUtils.isBlank(groupId) ? "" : groupId).toString(); | 
  |  153 |     | 
                           case ROLE_MEMBERS_FOR_ROLE_IDS :   | 
  |  154 |    0 |                                    return new StringBuilder(ROLE_MEMBER_IMPL_LIST_CACHE_PREFIX).append(roleDaoAction.DAO_ACTION_CACHE_PREFIX).append(  | 
  |  155 |     | 
                                                   StringUtils.isBlank(roleId) ? "" : roleId).append('-').append(StringUtils.isBlank(memberTypeCode) ? "" : memberTypeCode).toString(); | 
  |  156 |     | 
                           case ROLE_MEMBERSHIPS_FOR_ROLE_IDS_AS_MEMBERS :   | 
  |  157 |    0 |                                    return new StringBuilder(ROLE_MEMBER_IMPL_LIST_CACHE_PREFIX).append(roleDaoAction.DAO_ACTION_CACHE_PREFIX).append(  | 
  |  158 |     | 
                                                   StringUtils.isBlank(roleId) ? "" : roleId).toString();  | 
  |  159 |     | 
                           case ROLE_MEMBERS_FOR_ROLE_IDS_WITH_FILTERS :   | 
  |  160 |    0 |                                    return new StringBuilder(ROLE_MEMBER_IMPL_LIST_CACHE_PREFIX).append(roleDaoAction.DAO_ACTION_CACHE_PREFIX).append(  | 
  |  161 |     | 
                                                   StringUtils.isBlank(roleId) ? "" : roleId).append('-').append(StringUtils.isBlank(principalId) ? "" : principalId).append( | 
  |  162 |     | 
                                                                   '-').append(StringUtils.isBlank(groupId) ? "" : groupId).append('-').append( | 
  |  163 |     | 
                                                                                   StringUtils.isBlank(memberTypeCode) ? "" : memberTypeCode).toString();  | 
  |  164 |     | 
                           default :   | 
  |  165 |    0 |                                    throw new IllegalArgumentException("The 'roleDaoAction' parameter cannot refer to a non-role-member-related value!"); | 
  |  166 |     | 
                   }  | 
  |  167 |     | 
           }  | 
  |  168 |     | 
             | 
  |  169 |     | 
             | 
  |  170 |     | 
     | 
  |  171 |     | 
     | 
  |  172 |     | 
     | 
  |  173 |     | 
     | 
  |  174 |     | 
             | 
  |  175 |     | 
           private AttributeSet convertQualifierKeys(AttributeSet qualification) { | 
  |  176 |    0 |                    AttributeSet convertedQualification = new AttributeSet();  | 
  |  177 |    0 |                    if(qualification != null && CollectionUtils.isNotEmpty(qualification.keySet())) {  | 
  |  178 |    0 |                            for(String attributeName : qualification.keySet()) { | 
  |  179 |    0 |                                    if(StringUtils.isNotEmpty(getKimAttributeId(attributeName))) { | 
  |  180 |    0 |                                            convertedQualification.put(getKimAttributeId(attributeName), qualification.get(attributeName));  | 
  |  181 |     | 
                                   }  | 
  |  182 |     | 
                           }  | 
  |  183 |     | 
                   }  | 
  |  184 |    0 |                    return convertedQualification;  | 
  |  185 |     | 
           }  | 
  |  186 |     | 
             | 
  |  187 |     | 
       public Set<String> getRoleTypeRoleMemberIds( String roleId ){ | 
  |  188 |    0 |                Set<String> results = new HashSet();  | 
  |  189 |    0 |                getNestedRoleTypeMemberIds( roleId, results);  | 
  |  190 |    0 |                return results;  | 
  |  191 |     | 
       }  | 
  |  192 |     | 
     | 
  |  193 |     | 
       protected void getNestedRoleTypeMemberIds( String roleId, Set members) throws RuntimeException  | 
  |  194 |     | 
       { | 
  |  195 |    0 |                ArrayList<String> roleList = new ArrayList<String>( 1 );  | 
  |  196 |    0 |                    roleList.add( roleId );  | 
  |  197 |    0 |                    List<RoleMemberImpl> firstLevelMembers = getStoredRoleMembersForRoleIds(roleList, KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE, null);  | 
  |  198 |    0 |                    for (RoleMemberImpl member : firstLevelMembers) { | 
  |  199 |    0 |                            if (KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(member.getMemberTypeCode())){ | 
  |  200 |    0 |                                    if (!members.contains(member.getMemberId())){ | 
  |  201 |    0 |                                            members.add(member.getMemberId());  | 
  |  202 |    0 |                                            getNestedRoleTypeMemberIds( member.getMemberId(), members);  | 
  |  203 |     | 
                                   }  | 
  |  204 |     | 
                           }  | 
  |  205 |     | 
               }              | 
  |  206 |    0 |        }  | 
  |  207 |     | 
         | 
  |  208 |     | 
       public List<String> getMemberParentRoleIds(String memberType, String memberId) {         | 
  |  209 |    0 |                    List<RoleMemberImpl> parentRoleMembers = roleDao.getRoleMembershipsForMemberId(memberType, memberId, null);  | 
  |  210 |     | 
     | 
  |  211 |    0 |                    List<String> parentRoleIds = new ArrayList<String>(parentRoleMembers.size());  | 
  |  212 |    0 |                    for (RoleMemberImpl parentRoleMember: parentRoleMembers) { | 
  |  213 |    0 |                            parentRoleIds.add(parentRoleMember.getRoleId());  | 
  |  214 |     | 
                   }  | 
  |  215 |     | 
                     | 
  |  216 |    0 |                return parentRoleIds;  | 
  |  217 |     | 
       }  | 
  |  218 |     | 
         | 
  |  219 |     | 
             | 
  |  220 |     | 
     | 
  |  221 |     | 
     | 
  |  222 |     | 
     | 
  |  223 |     | 
     | 
  |  224 |     | 
     | 
  |  225 |     | 
     | 
  |  226 |     | 
     | 
  |  227 |     | 
     | 
  |  228 |     | 
     | 
  |  229 |     | 
     | 
  |  230 |     | 
     | 
  |  231 |     | 
           protected List<RoleMemberImpl> getRoleMemberImplList(RoleDaoAction daoActionToTake, Collection<String> roleIds, String principalId,  | 
  |  232 |     | 
                           Collection<String> groupIds, String memberTypeCode, AttributeSet qualification) { | 
  |  233 |    0 |                    List<RoleMemberImpl> finalResults = new ArrayList<RoleMemberImpl>();  | 
  |  234 |    0 |                    List<RoleMemberCacheKeyHelper> searchKeys = new ArrayList<RoleMemberCacheKeyHelper>();  | 
  |  235 |    0 |                    List<RoleMemberCacheKeyHelper> uncachedKeys = new ArrayList<RoleMemberCacheKeyHelper>();  | 
  |  236 |    0 |                    Set<String> usedKeys = new HashSet<String>();  | 
  |  237 |    0 |                    AttributeSet convertedQualification = convertQualifierKeys(qualification);  | 
  |  238 |     | 
                     | 
  |  239 |    0 |                    if (roleIds == null || roleIds.isEmpty()) { roleIds = Collections.singletonList(null); } | 
  |  240 |    0 |                    if (groupIds == null || groupIds.isEmpty()) { groupIds = Collections.singletonList(null); } | 
  |  241 |     | 
                     | 
  |  242 |     | 
                     | 
  |  243 |    0 |                    switch (daoActionToTake) { | 
  |  244 |     | 
                           case ROLE_PRINCIPALS_FOR_PRINCIPAL_ID_AND_ROLE_IDS :   | 
  |  245 |    0 |                                    for (String roleId : roleIds) { | 
  |  246 |    0 |                                            searchKeys.add(new RoleMemberCacheKeyHelper(daoActionToTake, roleId, principalId, null, Role.PRINCIPAL_MEMBER_TYPE));  | 
  |  247 |     | 
                                   }  | 
  |  248 |    0 |                                    break;  | 
  |  249 |     | 
                           case ROLE_GROUPS_FOR_GROUP_IDS_AND_ROLE_IDS :   | 
  |  250 |    0 |                                    for (String roleId : roleIds) { | 
  |  251 |    0 |                                            for (String groupId : groupIds) { | 
  |  252 |    0 |                                                    searchKeys.add(new RoleMemberCacheKeyHelper(daoActionToTake, roleId, null, groupId, Role.GROUP_MEMBER_TYPE));  | 
  |  253 |     | 
                                           }  | 
  |  254 |     | 
                                   }  | 
  |  255 |    0 |                                    break;  | 
  |  256 |     | 
                           case ROLE_MEMBERS_FOR_ROLE_IDS :   | 
  |  257 |    0 |                                    for (String roleId : roleIds) { | 
  |  258 |    0 |                                            searchKeys.add(new RoleMemberCacheKeyHelper(daoActionToTake, roleId, null, null, memberTypeCode));  | 
  |  259 |     | 
                                   }  | 
  |  260 |    0 |                                    break;  | 
  |  261 |     | 
                           case ROLE_MEMBERSHIPS_FOR_ROLE_IDS_AS_MEMBERS :   | 
  |  262 |    0 |                                    for (String roleId : roleIds) { | 
  |  263 |    0 |                                            searchKeys.add(new RoleMemberCacheKeyHelper(daoActionToTake, roleId, null, null, Role.ROLE_MEMBER_TYPE));  | 
  |  264 |     | 
                                   }  | 
  |  265 |    0 |                                    break;  | 
  |  266 |     | 
                           case ROLE_MEMBERS_FOR_ROLE_IDS_WITH_FILTERS :   | 
  |  267 |    0 |                                    for (String roleId : roleIds) { | 
  |  268 |    0 |                                            searchKeys.add(new RoleMemberCacheKeyHelper(daoActionToTake, roleId, null, null, Role.ROLE_MEMBER_TYPE));  | 
  |  269 |    0 |                                            searchKeys.add(new RoleMemberCacheKeyHelper(daoActionToTake, roleId, principalId, null, Role.PRINCIPAL_MEMBER_TYPE));  | 
  |  270 |    0 |                                            for (String groupId : groupIds) { | 
  |  271 |    0 |                                                    searchKeys.add(new RoleMemberCacheKeyHelper(daoActionToTake, roleId, null, groupId, Role.GROUP_MEMBER_TYPE));  | 
  |  272 |     | 
                                           }  | 
  |  273 |     | 
                                   }  | 
  |  274 |    0 |                                    break;  | 
  |  275 |     | 
                           default :   | 
  |  276 |    0 |                                    throw new IllegalArgumentException("The 'daoActionToTake' parameter cannot refer to a non-role-member-related value!"); | 
  |  277 |     | 
                   }  | 
  |  278 |     | 
                     | 
  |  279 |     | 
                     | 
  |  280 |    0 |                    for (RoleMemberCacheKeyHelper searchKey : searchKeys) { | 
  |  281 |    0 |                            if (!usedKeys.contains(searchKey.getCacheKey())) { | 
  |  282 |    0 |                                    List<RoleMemberImpl> tempMembers = (List<RoleMemberImpl>) getCacheAdministrator().getFromCache(searchKey.getCacheKey());  | 
  |  283 |    0 |                                    if (tempMembers != null) { | 
  |  284 |    0 |                                            finalResults.addAll(tempMembers);  | 
  |  285 |     | 
                                   } else { | 
  |  286 |    0 |                                            uncachedKeys.add(searchKey);  | 
  |  287 |     | 
                                   }  | 
  |  288 |    0 |                                    usedKeys.add(searchKey.getCacheKey());  | 
  |  289 |    0 |                            }  | 
  |  290 |     | 
                   }  | 
  |  291 |     | 
                     | 
  |  292 |     | 
                     | 
  |  293 |    0 |                    if (!uncachedKeys.isEmpty()) { | 
  |  294 |    0 |                            Set<String> uncachedRoleSet = new HashSet<String>();  | 
  |  295 |    0 |                            Set<String> uncachedGroupSet = new HashSet<String>();  | 
  |  296 |    0 |                            for (RoleMemberCacheKeyHelper uncachedKey : uncachedKeys) { | 
  |  297 |    0 |                                    if (uncachedKey.ROLE_ID != null) { uncachedRoleSet.add(uncachedKey.ROLE_ID); } | 
  |  298 |    0 |                                    if (uncachedKey.GROUP_ID != null) { uncachedGroupSet.add(uncachedKey.GROUP_ID); } | 
  |  299 |     | 
                           }  | 
  |  300 |     | 
                             | 
  |  301 |    0 |                            List<String> uncachedRoles = (uncachedRoleSet.isEmpty()) ? null : new ArrayList<String>(uncachedRoleSet);  | 
  |  302 |    0 |                            List<String> uncachedGroups = (uncachedGroupSet.isEmpty()) ? null : new ArrayList<String>(uncachedGroupSet);  | 
  |  303 |    0 |                            List<RoleMemberImpl> uncachedResults = null;  | 
  |  304 |     | 
                             | 
  |  305 |     | 
                             | 
  |  306 |    0 |                            switch (daoActionToTake) { | 
  |  307 |     | 
                                   case ROLE_PRINCIPALS_FOR_PRINCIPAL_ID_AND_ROLE_IDS :   | 
  |  308 |    0 |                                            uncachedResults = roleDao.getRolePrincipalsForPrincipalIdAndRoleIds(uncachedRoles, principalId, convertedQualification);  | 
  |  309 |    0 |                                            break;  | 
  |  310 |     | 
                                   case ROLE_GROUPS_FOR_GROUP_IDS_AND_ROLE_IDS :   | 
  |  311 |    0 |                                            uncachedResults = roleDao.getRoleGroupsForGroupIdsAndRoleIds(uncachedRoles, uncachedGroups, convertedQualification);  | 
  |  312 |    0 |                                            break;  | 
  |  313 |     | 
                                   case ROLE_MEMBERS_FOR_ROLE_IDS :   | 
  |  314 |    0 |                                            uncachedResults = roleDao.getRoleMembersForRoleIds(uncachedRoles, memberTypeCode, convertedQualification);  | 
  |  315 |    0 |                                            break;  | 
  |  316 |     | 
                                   case ROLE_MEMBERSHIPS_FOR_ROLE_IDS_AS_MEMBERS :   | 
  |  317 |    0 |                                            uncachedResults = roleDao.getRoleMembershipsForRoleIdsAsMembers(uncachedRoles, convertedQualification);  | 
  |  318 |    0 |                                            break;  | 
  |  319 |     | 
                                   case ROLE_MEMBERS_FOR_ROLE_IDS_WITH_FILTERS :   | 
  |  320 |    0 |                                            uncachedResults = roleDao.getRoleMembersForRoleIdsWithFilters(uncachedRoles, principalId, uncachedGroups, convertedQualification);  | 
  |  321 |    0 |                                            break;  | 
  |  322 |     | 
                                   default :   | 
  |  323 |    0 |                                            throw new IllegalArgumentException("The 'daoActionToTake' parameter cannot refer to a non-role-member-related value!"); | 
  |  324 |     | 
                           }  | 
  |  325 |     | 
                             | 
  |  326 |    0 |                            cacheRoleMemberLists(uncachedKeys, uncachedResults);  | 
  |  327 |    0 |                            for (RoleMemberImpl uncachedMember : uncachedResults) { | 
  |  328 |    0 |                                    addRoleMemberImplToCache(uncachedMember);  | 
  |  329 |     | 
                           }  | 
  |  330 |    0 |                            finalResults.addAll(uncachedResults);  | 
  |  331 |     | 
                   }  | 
  |  332 |    0 |                    return finalResults;  | 
  |  333 |     | 
           }  | 
  |  334 |     | 
             | 
  |  335 |     | 
             | 
  |  336 |     | 
     | 
  |  337 |     | 
     | 
  |  338 |     | 
     | 
  |  339 |     | 
     | 
  |  340 |     | 
     | 
  |  341 |     | 
     | 
  |  342 |     | 
           private void cacheRoleMemberLists(List<RoleMemberCacheKeyHelper> keysToCache, List<RoleMemberImpl> membersToCache) { | 
  |  343 |    0 |                    if (membersToCache == null) { membersToCache = new ArrayList<RoleMemberImpl>(); } | 
  |  344 |    0 |                    for (RoleMemberCacheKeyHelper keyToCache : keysToCache) { | 
  |  345 |    0 |                            List<RoleMemberImpl> roleMembers = new ArrayList<RoleMemberImpl>();  | 
  |  346 |     | 
                             | 
  |  347 |     | 
                             | 
  |  348 |    0 |                            if (RoleDaoAction.ROLE_MEMBERSHIPS_FOR_ROLE_IDS_AS_MEMBERS.equals(keyToCache.ROLE_DAO_ACTION)) { | 
  |  349 |    0 |                                    boolean safeToCacheList = true;  | 
  |  350 |    0 |                                    for (RoleMemberImpl memberToCache : membersToCache) { | 
  |  351 |    0 |                                            if ( (keyToCache.ROLE_ID == null || keyToCache.ROLE_ID.equals(memberToCache.getMemberId())) &&  | 
  |  352 |     | 
                                                           (keyToCache.MEMBER_TYPE_CODE == null || keyToCache.MEMBER_TYPE_CODE.equals(memberToCache.getMemberTypeCode())) ) { | 
  |  353 |    0 |                                                    if (shouldCacheMembersOfRole(memberToCache.getRoleId())) { | 
  |  354 |    0 |                                                            roleMembers.add(memberToCache);  | 
  |  355 |     | 
                                                   } else { | 
  |  356 |    0 |                                                            safeToCacheList = false;  | 
  |  357 |    0 |                                                            break;  | 
  |  358 |     | 
                                                   }  | 
  |  359 |     | 
                                           }  | 
  |  360 |     | 
                                   }  | 
  |  361 |    0 |                                    if (safeToCacheList) { getCacheAdministrator().putInCache(keyToCache.getCacheKey(), roleMembers, ROLE_MEMBER_IMPL_CACHE_GROUP); } | 
  |  362 |    0 |                            } else if (keyToCache.ROLE_ID == null || shouldCacheMembersOfRole(keyToCache.ROLE_ID)) { | 
  |  363 |    0 |                                    for (RoleMemberImpl memberToCache : membersToCache) { | 
  |  364 |    0 |                                            if ( (keyToCache.ROLE_ID == null || keyToCache.ROLE_ID.equals(memberToCache.getRoleId())) &&  | 
  |  365 |     | 
                                                           (keyToCache.PRINCIPAL_ID == null || keyToCache.PRINCIPAL_ID.equals(memberToCache.getMemberId())) &&  | 
  |  366 |     | 
                                                           (keyToCache.GROUP_ID == null || keyToCache.GROUP_ID.equals(memberToCache.getMemberId())) &&  | 
  |  367 |     | 
                                                           (keyToCache.MEMBER_TYPE_CODE == null || keyToCache.MEMBER_TYPE_CODE.equals(memberToCache.getMemberTypeCode())) ) { | 
  |  368 |    0 |                                                    roleMembers.add(memberToCache);  | 
  |  369 |     | 
                                           }  | 
  |  370 |     | 
                                   }  | 
  |  371 |    0 |                                    getCacheAdministrator().putInCache(keyToCache.getCacheKey(), roleMembers, ROLE_MEMBER_IMPL_CACHE_GROUP);  | 
  |  372 |     | 
                           }  | 
  |  373 |    0 |                    }  | 
  |  374 |    0 |            }  | 
  |  375 |     | 
             | 
  |  376 |     | 
             | 
  |  377 |     | 
           protected List<RoleMemberImpl> getStoredRolePrincipalsForPrincipalIdAndRoleIds(Collection<String> roleIds, String principalId, AttributeSet qualification) { | 
  |  378 |    0 |                    return getRoleMemberImplList(RoleDaoAction.ROLE_PRINCIPALS_FOR_PRINCIPAL_ID_AND_ROLE_IDS, roleIds, principalId, null, null, qualification);  | 
  |  379 |     | 
           }  | 
  |  380 |     | 
             | 
  |  381 |     | 
             | 
  |  382 |     | 
           protected List<RoleMemberImpl> getStoredRoleGroupsForGroupIdsAndRoleIds(Collection<String> roleIds, Collection<String> groupIds, AttributeSet qualification) { | 
  |  383 |    0 |                    return getRoleMemberImplList(RoleDaoAction.ROLE_GROUPS_FOR_GROUP_IDS_AND_ROLE_IDS, roleIds, null, groupIds, null, qualification);  | 
  |  384 |     | 
           }  | 
  |  385 |     | 
             | 
  |  386 |     | 
             | 
  |  387 |     | 
           protected List<RoleMemberImpl> getStoredRoleMembersForRoleIds(Collection<String> roleIds, String memberTypeCode, AttributeSet qualification) { | 
  |  388 |    0 |                    return getRoleMemberImplList(RoleDaoAction.ROLE_MEMBERS_FOR_ROLE_IDS, roleIds, null, null, memberTypeCode, qualification);  | 
  |  389 |     | 
           }  | 
  |  390 |     | 
             | 
  |  391 |     | 
             | 
  |  392 |     | 
           protected List<RoleMemberImpl> getStoredRoleMembershipsForRoleIdsAsMembers(Collection<String> roleIds, AttributeSet qualification) { | 
  |  393 |    0 |                    return getRoleMemberImplList(RoleDaoAction.ROLE_MEMBERSHIPS_FOR_ROLE_IDS_AS_MEMBERS, roleIds, null, null, null, qualification);  | 
  |  394 |     | 
           }  | 
  |  395 |     | 
             | 
  |  396 |     | 
             | 
  |  397 |     | 
           protected List<RoleMemberImpl> getStoredRoleMembersForRoleIdsWithFilters(Collection<String> roleIds, String principalId, List<String> groupIds, AttributeSet qualification) { | 
  |  398 |    0 |                    return getRoleMemberImplList(RoleDaoAction.ROLE_MEMBERS_FOR_ROLE_IDS_WITH_FILTERS, roleIds, principalId, groupIds, null, qualification);  | 
  |  399 |     | 
           }  | 
  |  400 |     | 
             | 
  |  401 |     | 
             | 
  |  402 |     | 
     | 
  |  403 |     | 
     | 
  |  404 |     | 
     | 
  |  405 |     | 
     | 
  |  406 |     | 
     | 
  |  407 |     | 
     | 
  |  408 |     | 
           protected boolean shouldCacheMembersOfRole(String roleId) { | 
  |  409 |    0 |                    return true;  | 
  |  410 |     | 
           }  | 
  |  411 |     | 
             | 
  |  412 |     | 
           protected void addRoleMemberImplToCache(RoleMemberImpl roleMember) { | 
  |  413 |    0 |                    if (roleMember != null && shouldCacheMembersOfRole(roleMember.getRoleId())) { | 
  |  414 |    0 |                            getCacheAdministrator().putInCache(getRoleMemberCacheKey(roleMember.getRoleMemberId()), roleMember, ROLE_MEMBER_IMPL_CACHE_GROUP);  | 
  |  415 |     | 
                   }  | 
  |  416 |    0 |            }  | 
  |  417 |     | 
             | 
  |  418 |     | 
           protected RoleMemberImpl getRoleMemberFromCache(String roleMemberId) { | 
  |  419 |    0 |                    return (RoleMemberImpl)getCacheAdministrator().getFromCache(getRoleMemberCacheKey(roleMemberId));  | 
  |  420 |     | 
           }  | 
  |  421 |     | 
             | 
  |  422 |     | 
           public void flushInternalRoleMemberCache() { | 
  |  423 |    0 |                    getCacheAdministrator().flushGroup(ROLE_MEMBER_IMPL_CACHE_GROUP);  | 
  |  424 |    0 |            }  | 
  |  425 |     | 
             | 
  |  426 |     | 
             | 
  |  427 |     | 
     | 
  |  428 |     | 
     | 
  |  429 |     | 
     | 
  |  430 |     | 
     | 
  |  431 |     | 
       protected RoleMemberImpl getRoleMemberImpl( String roleMemberId ) { | 
  |  432 |    0 |                if (StringUtils.isBlank(roleMemberId)) { | 
  |  433 |    0 |                        return null;  | 
  |  434 |     | 
               }  | 
  |  435 |     | 
                 | 
  |  436 |     | 
                 | 
  |  437 |    0 |                RoleMemberImpl tempRoleMemberImpl = getRoleMemberFromCache(roleMemberId);  | 
  |  438 |    0 |                if (tempRoleMemberImpl != null) { | 
  |  439 |    0 |                        return tempRoleMemberImpl;  | 
  |  440 |     | 
               }  | 
  |  441 |     | 
                 | 
  |  442 |    0 |                tempRoleMemberImpl = (RoleMemberImpl)getBusinessObjectService().findByPrimaryKey( RoleMemberImpl.class,  | 
  |  443 |     | 
                               Collections.singletonMap(KIMPropertyConstants.RoleMember.ROLE_MEMBER_ID, roleMemberId) );  | 
  |  444 |    0 |                addRoleMemberImplToCache(tempRoleMemberImpl);  | 
  |  445 |    0 |                return tempRoleMemberImpl;  | 
  |  446 |     | 
       }  | 
  |  447 |     | 
             | 
  |  448 |     | 
         | 
  |  449 |     | 
         | 
  |  450 |     | 
         | 
  |  451 |     | 
         | 
  |  452 |     | 
             | 
  |  453 |     | 
     | 
  |  454 |     | 
     | 
  |  455 |     | 
     | 
  |  456 |     | 
     | 
  |  457 |     | 
     | 
  |  458 |     | 
           protected String getDelegationCacheKey(String delegationId) { | 
  |  459 |    0 |                    return DELEGATION_IMPL_CACHE_PREFIX + delegationId;  | 
  |  460 |     | 
           }  | 
  |  461 |     | 
     | 
  |  462 |     | 
         | 
  |  463 |     | 
     | 
  |  464 |     | 
     | 
  |  465 |     | 
     | 
  |  466 |     | 
     | 
  |  467 |     | 
       protected String getDelegationListCacheKey(String roleId) { | 
  |  468 |    0 |                return DELEGATION_IMPL_LIST_CACHE_PREFIX + (StringUtils.isBlank(roleId) ? "" : roleId);  | 
  |  469 |     | 
       }  | 
  |  470 |     | 
             | 
  |  471 |     | 
         | 
  |  472 |     | 
           protected Map<String,KimDelegationImpl> getStoredDelegationImplMapFromRoleIds(Collection<String> roleIds) { | 
  |  473 |    0 |                    Map<String,KimDelegationImpl> finalResults = Collections.emptyMap();  | 
  |  474 |     | 
                     | 
  |  475 |    0 |                    if (roleIds != null && !roleIds.isEmpty()) { | 
  |  476 |    0 |                            Map<String,List<KimDelegationImpl>> uncachedLists = new HashMap<String,List<KimDelegationImpl>>();  | 
  |  477 |     | 
                             | 
  |  478 |    0 |                            finalResults = getKimDelegationImplMap(uncachedLists, roleIds);  | 
  |  479 |     | 
                             | 
  |  480 |     | 
                             | 
  |  481 |    0 |                            if (!uncachedLists.isEmpty()) { | 
  |  482 |    0 |                                    Map<String,KimDelegationImpl> uncachedResults = roleDao.getDelegationImplMapFromRoleIds(uncachedLists.keySet());  | 
  |  483 |     | 
                                     | 
  |  484 |    0 |                                    for (Map.Entry<String,KimDelegationImpl> uncachedResult : uncachedResults.entrySet()) { | 
  |  485 |    0 |                                            finalResults.put(uncachedResult.getKey(), uncachedResult.getValue());  | 
  |  486 |    0 |                                            addKimDelegationImplToCache(uncachedResult.getValue());  | 
  |  487 |    0 |                                            uncachedLists.get(uncachedResult.getValue().getRoleId()).add(uncachedResult.getValue());  | 
  |  488 |     | 
                                   }  | 
  |  489 |    0 |                                    for (Map.Entry<String,List<KimDelegationImpl>> uncachedList : uncachedLists.entrySet()) { | 
  |  490 |    0 |                                            getCacheAdministrator().putInCache(getDelegationListCacheKey(uncachedList.getKey()),  | 
  |  491 |     | 
                                                           uncachedList.getValue(), DELEGATION_IMPL_CACHE_GROUP);  | 
  |  492 |     | 
                                   }  | 
  |  493 |     | 
                           }  | 
  |  494 |     | 
                   }  | 
  |  495 |     | 
                     | 
  |  496 |    0 |                    return finalResults;  | 
  |  497 |     | 
           }  | 
  |  498 |     | 
             | 
  |  499 |     | 
             | 
  |  500 |     | 
           protected List<KimDelegationImpl> getStoredDelegationImplsForRoleIds(Collection<String> roleIds) { | 
  |  501 |    0 |                    List<KimDelegationImpl> finalResults = new ArrayList<KimDelegationImpl>();  | 
  |  502 |     | 
                     | 
  |  503 |    0 |                    if (roleIds != null && !roleIds.isEmpty()) { | 
  |  504 |    0 |                            Map<String,List<KimDelegationImpl>> uncachedLists = new HashMap<String,List<KimDelegationImpl>>();  | 
  |  505 |     | 
                             | 
  |  506 |    0 |                            Map<String,KimDelegationImpl> tempDelegations = getKimDelegationImplMap(uncachedLists, roleIds);  | 
  |  507 |    0 |                            finalResults.addAll(tempDelegations.values());  | 
  |  508 |     | 
                             | 
  |  509 |     | 
                             | 
  |  510 |    0 |                            if (!uncachedLists.isEmpty()) { | 
  |  511 |    0 |                                    List<KimDelegationImpl> uncachedResults = roleDao.getDelegationImplsForRoleIds(uncachedLists.keySet());  | 
  |  512 |     | 
                                     | 
  |  513 |    0 |                                    for (KimDelegationImpl uncachedResult : uncachedResults) { | 
  |  514 |    0 |                                            addKimDelegationImplToCache(uncachedResult);  | 
  |  515 |    0 |                                            uncachedLists.get(uncachedResult.getRoleId()).add(uncachedResult);  | 
  |  516 |     | 
                                   }  | 
  |  517 |    0 |                                    for (Map.Entry<String,List<KimDelegationImpl>> uncachedList : uncachedLists.entrySet()) { | 
  |  518 |    0 |                                            getCacheAdministrator().putInCache(getDelegationListCacheKey(uncachedList.getKey()),  | 
  |  519 |     | 
                                                           uncachedList.getValue(), DELEGATION_IMPL_CACHE_GROUP);  | 
  |  520 |     | 
                                   }  | 
  |  521 |    0 |                                    finalResults.addAll(uncachedResults);  | 
  |  522 |     | 
                           }  | 
  |  523 |     | 
                   }  | 
  |  524 |     | 
                     | 
  |  525 |    0 |                    return finalResults;  | 
  |  526 |     | 
           }  | 
  |  527 |     | 
             | 
  |  528 |     | 
             | 
  |  529 |     | 
     | 
  |  530 |     | 
     | 
  |  531 |     | 
     | 
  |  532 |     | 
     | 
  |  533 |     | 
     | 
  |  534 |     | 
     | 
  |  535 |     | 
     | 
  |  536 |     | 
     | 
  |  537 |     | 
           protected Map<String,KimDelegationImpl> getKimDelegationImplMap(Map<String,List<KimDelegationImpl>> uncachedLists, Collection<String> roleIds) { | 
  |  538 |    0 |                    if (uncachedLists == null) { | 
  |  539 |    0 |                            throw new IllegalArgumentException("'uncachedLists' parameter cannot be null!"); | 
  |  540 |     | 
                   }  | 
  |  541 |    0 |                    Map<String,KimDelegationImpl> delegationMap = new HashMap<String,KimDelegationImpl>();  | 
  |  542 |     | 
                     | 
  |  543 |     | 
                     | 
  |  544 |    0 |                    if (roleIds != null && !roleIds.isEmpty()) { | 
  |  545 |    0 |                            for (String roleId : roleIds) { | 
  |  546 |    0 |                                    List<KimDelegationImpl> tempDelegations = (List<KimDelegationImpl>) getCacheAdministrator().getFromCache(getDelegationListCacheKey(roleId));  | 
  |  547 |    0 |                                    if (tempDelegations != null) { | 
  |  548 |    0 |                                            for (KimDelegationImpl tempDelegation : tempDelegations) { | 
  |  549 |    0 |                                                    delegationMap.put(tempDelegation.getDelegationId(), tempDelegation);  | 
  |  550 |     | 
                                           }  | 
  |  551 |     | 
                                   } else { | 
  |  552 |    0 |                                            uncachedLists.put(roleId, new ArrayList<KimDelegationImpl>());  | 
  |  553 |     | 
                                   }  | 
  |  554 |    0 |                            }  | 
  |  555 |     | 
                   }  | 
  |  556 |     | 
                     | 
  |  557 |    0 |                    return delegationMap;  | 
  |  558 |     | 
           }  | 
  |  559 |     | 
             | 
  |  560 |     | 
           protected void addKimDelegationImplToCache(KimDelegationImpl delegation) { | 
  |  561 |    0 |                    if (delegation != null) { | 
  |  562 |    0 |                            getCacheAdministrator().putInCache(getDelegationCacheKey(delegation.getDelegationId()),  | 
  |  563 |     | 
                                           delegation, DELEGATION_IMPL_CACHE_GROUP);  | 
  |  564 |     | 
                   }  | 
  |  565 |    0 |            }  | 
  |  566 |     | 
             | 
  |  567 |     | 
           protected KimDelegationImpl getDelegationFromCache(String delegationId) { | 
  |  568 |    0 |                    return (KimDelegationImpl)getCacheAdministrator().getFromCache(getDelegationCacheKey(delegationId));  | 
  |  569 |     | 
           }  | 
  |  570 |     | 
             | 
  |  571 |     | 
           public void flushInternalDelegationCache() { | 
  |  572 |    0 |                    getCacheAdministrator().flushGroup(DELEGATION_IMPL_CACHE_GROUP);  | 
  |  573 |    0 |            }  | 
  |  574 |     | 
             | 
  |  575 |     | 
             | 
  |  576 |     | 
     | 
  |  577 |     | 
     | 
  |  578 |     | 
     | 
  |  579 |     | 
       protected KimDelegationImpl getKimDelegationImpl( String delegationId ) { | 
  |  580 |    0 |                if (StringUtils.isBlank(delegationId)) { | 
  |  581 |    0 |                        return null;  | 
  |  582 |     | 
               }  | 
  |  583 |     | 
                 | 
  |  584 |     | 
                 | 
  |  585 |    0 |                KimDelegationImpl tempDelegation = getDelegationFromCache(delegationId);  | 
  |  586 |    0 |                if (tempDelegation != null) { | 
  |  587 |    0 |                        return tempDelegation;  | 
  |  588 |     | 
               }  | 
  |  589 |     | 
                 | 
  |  590 |    0 |                tempDelegation = (KimDelegationImpl)getBusinessObjectService().findByPrimaryKey( KimDelegationImpl.class,  | 
  |  591 |     | 
                               Collections.singletonMap(KimConstants.PrimaryKeyConstants.DELEGATION_ID, delegationId) );  | 
  |  592 |    0 |                addKimDelegationImplToCache(tempDelegation);  | 
  |  593 |    0 |                return tempDelegation;  | 
  |  594 |     | 
       }  | 
  |  595 |     | 
         | 
  |  596 |     | 
         | 
  |  597 |     | 
         | 
  |  598 |     | 
         | 
  |  599 |     | 
         | 
  |  600 |     | 
             | 
  |  601 |     | 
     | 
  |  602 |     | 
     | 
  |  603 |     | 
     | 
  |  604 |     | 
     | 
  |  605 |     | 
     | 
  |  606 |     | 
           protected String getDelegationMemberCacheKey(String delegationMemberId) { | 
  |  607 |    0 |                    return DELEGATION_MEMBER_IMPL_CACHE_PREFIX + delegationMemberId;  | 
  |  608 |     | 
           }  | 
  |  609 |     | 
         | 
  |  610 |     | 
             | 
  |  611 |     | 
     | 
  |  612 |     | 
     | 
  |  613 |     | 
     | 
  |  614 |     | 
     | 
  |  615 |     | 
     | 
  |  616 |     | 
     | 
  |  617 |     | 
           protected String getDelegationMemberByDelegationAndIdCacheKey(String delegationId, String delegationMemberId) { | 
  |  618 |    0 |                    return new StringBuilder(DELEGATION_MEMBER_IMPL_BY_DLGN_AND_ID_CACHE_PREFIX).append(delegationId).append('-').append(delegationMemberId).toString(); | 
  |  619 |     | 
           }  | 
  |  620 |     | 
             | 
  |  621 |     | 
             | 
  |  622 |     | 
     | 
  |  623 |     | 
     | 
  |  624 |     | 
     | 
  |  625 |     | 
     | 
  |  626 |     | 
     | 
  |  627 |     | 
     | 
  |  628 |     | 
           protected String getDelegationMemberListByMemberAndDelegationIdCacheKey(String memberId, String delegationId) { | 
  |  629 |    0 |                    return new StringBuilder(DELEGATION_MEMBER_IMPL_LIST_BY_MBR_DLGN_CACHE_PREFIX).append(StringUtils.isBlank(memberId) ? "" : memberId).append(  | 
  |  630 |     | 
                                   '-').append(StringUtils.isBlank(delegationId) ? "" : delegationId).toString();  | 
  |  631 |     | 
           }  | 
  |  632 |     | 
             | 
  |  633 |     | 
             | 
  |  634 |     | 
     | 
  |  635 |     | 
     | 
  |  636 |     | 
     | 
  |  637 |     | 
     | 
  |  638 |     | 
     | 
  |  639 |     | 
     | 
  |  640 |     | 
     | 
  |  641 |     | 
     | 
  |  642 |     | 
     | 
  |  643 |     | 
     | 
  |  644 |     | 
           protected String getDelegationMemberListCacheKey(RoleDaoAction daoAction, String delegationId, String principalId, String groupId) { | 
  |  645 |    0 |                    switch (daoAction) { | 
  |  646 |     | 
                           case DELEGATION_PRINCIPALS_FOR_PRINCIPAL_ID_AND_DELEGATION_IDS :   | 
  |  647 |    0 |                                    return new StringBuilder(DELEGATION_MEMBER_IMPL_LIST_CACHE_PREFIX).append(daoAction.DAO_ACTION_CACHE_PREFIX).append(  | 
  |  648 |     | 
                                                   StringUtils.isBlank(delegationId) ? "" : delegationId).append('-').append( | 
  |  649 |     | 
                                                                   StringUtils.isBlank(principalId) ? "" : principalId).toString();  | 
  |  650 |     | 
                           case DELEGATION_GROUPS_FOR_GROUP_IDS_AND_DELEGATION_IDS :   | 
  |  651 |    0 |                                    return new StringBuilder(DELEGATION_MEMBER_IMPL_LIST_CACHE_PREFIX).append(daoAction.DAO_ACTION_CACHE_PREFIX).append(  | 
  |  652 |     | 
                                                   StringUtils.isBlank(delegationId) ? "" : delegationId).append('-').append(StringUtils.isBlank(groupId) ? "" : groupId).toString(); | 
  |  653 |     | 
                           case DELEGATION_MEMBERS_FOR_DELEGATION_IDS :   | 
  |  654 |    0 |                                    return new StringBuilder(DELEGATION_MEMBER_IMPL_LIST_CACHE_PREFIX).append(daoAction.DAO_ACTION_CACHE_PREFIX).append(  | 
  |  655 |     | 
                                                   StringUtils.isBlank(delegationId) ? "" : delegationId).toString();  | 
  |  656 |     | 
                           default :   | 
  |  657 |    0 |                                    throw new IllegalArgumentException("The 'daoActionToTake' parameter cannot refer to a non-delegation-member-related value!"); | 
  |  658 |     | 
                   }  | 
  |  659 |     | 
           }  | 
  |  660 |     | 
             | 
  |  661 |     | 
             | 
  |  662 |     | 
     | 
  |  663 |     | 
     | 
  |  664 |     | 
     | 
  |  665 |     | 
     | 
  |  666 |     | 
     | 
  |  667 |     | 
     | 
  |  668 |     | 
     | 
  |  669 |     | 
     | 
  |  670 |     | 
     | 
  |  671 |     | 
           protected List<KimDelegationMemberImpl> getKimDelegationMemberImplList(RoleDaoAction daoActionToTake, Collection<String> delegationIds,  | 
  |  672 |     | 
                           String principalId, List<String> groupIds) { | 
  |  673 |    0 |                    List<KimDelegationMemberImpl> finalResults = new ArrayList<KimDelegationMemberImpl>();  | 
  |  674 |    0 |                    List<String[]> uncachedKeys = new ArrayList<String[]>();  | 
  |  675 |    0 |                    Set<String> usedKeys = new HashSet<String>();  | 
  |  676 |    0 |                    if (delegationIds == null || delegationIds.isEmpty()) { delegationIds = Collections.singletonList(null); } | 
  |  677 |    0 |                    if (groupIds == null || groupIds.isEmpty()) { groupIds = Collections.singletonList(null); } | 
  |  678 |     | 
                     | 
  |  679 |     | 
                     | 
  |  680 |    0 |                    switch (daoActionToTake) { | 
  |  681 |     | 
                           case DELEGATION_PRINCIPALS_FOR_PRINCIPAL_ID_AND_DELEGATION_IDS :   | 
  |  682 |    0 |                                    for (String delegationId : delegationIds) { | 
  |  683 |    0 |                                            String tempKey = getDelegationMemberListCacheKey(daoActionToTake, delegationId, principalId, null);  | 
  |  684 |    0 |                                            if (!usedKeys.contains(tempKey)) { | 
  |  685 |    0 |                                                    List<KimDelegationMemberImpl> tempMembers = (List<KimDelegationMemberImpl>) getCacheAdministrator().getFromCache(tempKey);  | 
  |  686 |    0 |                                                    if (tempMembers != null) { | 
  |  687 |    0 |                                                            finalResults.addAll(tempMembers);  | 
  |  688 |     | 
                                                   } else { | 
  |  689 |    0 |                                                            uncachedKeys.add(new String[] {delegationId, principalId, null}); | 
  |  690 |     | 
                                                   }  | 
  |  691 |    0 |                                                    usedKeys.add(tempKey);  | 
  |  692 |     | 
                                           }  | 
  |  693 |    0 |                                    }  | 
  |  694 |    0 |                                    break;  | 
  |  695 |     | 
                           case DELEGATION_GROUPS_FOR_GROUP_IDS_AND_DELEGATION_IDS :   | 
  |  696 |    0 |                                    for (String delegationId : delegationIds) { | 
  |  697 |    0 |                                            for (String groupId : groupIds) { | 
  |  698 |    0 |                                                    String tempKey = getDelegationMemberListCacheKey(daoActionToTake, delegationId, null, groupId);  | 
  |  699 |    0 |                                                    if (!usedKeys.contains(tempKey)) { | 
  |  700 |    0 |                                                            List<KimDelegationMemberImpl> tempMembers = (List<KimDelegationMemberImpl>) getCacheAdministrator().getFromCache(tempKey);  | 
  |  701 |    0 |                                                            if (tempMembers != null) { | 
  |  702 |    0 |                                                                    finalResults.addAll(tempMembers);  | 
  |  703 |     | 
                                                           } else { | 
  |  704 |    0 |                                                                    uncachedKeys.add(new String[] {delegationId, null, groupId}); | 
  |  705 |     | 
                                                           }  | 
  |  706 |     | 
                                                   }  | 
  |  707 |    0 |                                            }  | 
  |  708 |     | 
                                   }  | 
  |  709 |    0 |                                    break;  | 
  |  710 |     | 
                           default :   | 
  |  711 |    0 |                                    throw new IllegalArgumentException("The 'daoActionToTake' parameter cannot refer to a non-delegation-member-list-related value!"); | 
  |  712 |     | 
                   }  | 
  |  713 |     | 
                     | 
  |  714 |     | 
                     | 
  |  715 |    0 |                    if (!uncachedKeys.isEmpty()) { | 
  |  716 |    0 |                            List<KimDelegationMemberImpl> uncachedResults = new ArrayList<KimDelegationMemberImpl>();  | 
  |  717 |    0 |                            Set<String> uncachedDelegationSet = new HashSet<String>();  | 
  |  718 |    0 |                            Set<String> uncachedGroupSet = new HashSet<String>();  | 
  |  719 |    0 |                            for (String[] uncachedKey : uncachedKeys) { | 
  |  720 |    0 |                                    if (uncachedKey[0] != null) { uncachedDelegationSet.add(uncachedKey[0]); } | 
  |  721 |    0 |                                    if (uncachedKey[2] != null) { uncachedGroupSet.add(uncachedKey[2]); } | 
  |  722 |     | 
                           }  | 
  |  723 |    0 |                            List<String> uncachedDelegations = (uncachedDelegationSet.isEmpty()) ? null : new ArrayList<String>(uncachedDelegationSet);  | 
  |  724 |    0 |                            List<String> uncachedGroups = (uncachedGroupSet.isEmpty()) ? null : new ArrayList<String>(uncachedGroupSet);  | 
  |  725 |    0 |                            String memberTypeCode = null;  | 
  |  726 |     | 
                             | 
  |  727 |     | 
                             | 
  |  728 |    0 |                            switch (daoActionToTake) { | 
  |  729 |     | 
                                   case DELEGATION_PRINCIPALS_FOR_PRINCIPAL_ID_AND_DELEGATION_IDS :   | 
  |  730 |    0 |                                            uncachedResults = roleDao.getDelegationPrincipalsForPrincipalIdAndDelegationIds(uncachedDelegations, principalId);  | 
  |  731 |    0 |                                            memberTypeCode = Role.PRINCIPAL_MEMBER_TYPE;  | 
  |  732 |    0 |                                            break;  | 
  |  733 |     | 
                                   case DELEGATION_GROUPS_FOR_GROUP_IDS_AND_DELEGATION_IDS :   | 
  |  734 |    0 |                                            uncachedResults = roleDao.getDelegationGroupsForGroupIdsAndDelegationIds(uncachedDelegations, uncachedGroups);  | 
  |  735 |    0 |                                            memberTypeCode = Role.GROUP_MEMBER_TYPE;  | 
  |  736 |    0 |                                            break;  | 
  |  737 |     | 
                                   default :   | 
  |  738 |    0 |                                            throw new IllegalArgumentException("The 'daoActionToTake' parameter cannot refer to a non-delegation-member-list-related value!"); | 
  |  739 |     | 
                           }  | 
  |  740 |     | 
                             | 
  |  741 |     | 
                             | 
  |  742 |    0 |                            cacheDelegationMemberLists(daoActionToTake, uncachedKeys, memberTypeCode, uncachedResults);  | 
  |  743 |    0 |                            for (KimDelegationMemberImpl uncachedResult : uncachedResults) { | 
  |  744 |    0 |                                    addKimDelegationMemberImplToCache(uncachedResult);  | 
  |  745 |     | 
                           }  | 
  |  746 |    0 |                            finalResults.addAll(uncachedResults);  | 
  |  747 |     | 
                   }  | 
  |  748 |     | 
                     | 
  |  749 |    0 |                    return finalResults;  | 
  |  750 |     | 
           }  | 
  |  751 |     | 
             | 
  |  752 |     | 
             | 
  |  753 |     | 
     | 
  |  754 |     | 
     | 
  |  755 |     | 
     | 
  |  756 |     | 
     | 
  |  757 |     | 
     | 
  |  758 |     | 
     | 
  |  759 |     | 
     | 
  |  760 |     | 
           private void cacheDelegationMemberLists(RoleDaoAction daoActionToTake, List<String[]> uncachedKeys,  | 
  |  761 |     | 
                           String memberTypeCode, List<KimDelegationMemberImpl> uncachedMembers) { | 
  |  762 |     | 
                     | 
  |  763 |    0 |                    for (String[] uncachedKey : uncachedKeys) { | 
  |  764 |    0 |                            List<KimDelegationMemberImpl> tempMembers = new ArrayList<KimDelegationMemberImpl>();  | 
  |  765 |    0 |                            for (KimDelegationMemberImpl uncachedMember : uncachedMembers) { | 
  |  766 |    0 |                                    if ( (memberTypeCode == null || memberTypeCode.equals(uncachedMember.getMemberTypeCode())) &&  | 
  |  767 |     | 
                                                   (uncachedKey[0] == null || uncachedKey[0].equals(uncachedMember.getDelegationId())) &&  | 
  |  768 |     | 
                                                                   (uncachedKey[1] == null || uncachedKey[1].equals(uncachedMember.getMemberId())) &&  | 
  |  769 |     | 
                                                                                   (uncachedKey[2] == null || uncachedKey[2].equals(uncachedMember.getMemberId())) ) { | 
  |  770 |    0 |                                            tempMembers.add(uncachedMember);  | 
  |  771 |     | 
                                   }  | 
  |  772 |     | 
                           }  | 
  |  773 |    0 |                            getCacheAdministrator().putInCache(getDelegationMemberListCacheKey(daoActionToTake, uncachedKey[0], uncachedKey[1], uncachedKey[2]),  | 
  |  774 |     | 
                                           tempMembers, DELEGATION_MEMBER_IMPL_CACHE_GROUP);  | 
  |  775 |    0 |                    }  | 
  |  776 |    0 |            }  | 
  |  777 |     | 
             | 
  |  778 |     | 
             | 
  |  779 |     | 
           protected List<KimDelegationMemberImpl> getStoredDelegationPrincipalsForPrincipalIdAndDelegationIds(Collection<String> delegationIds,String principalId){ | 
  |  780 |    0 |                    return getKimDelegationMemberImplList(RoleDaoAction.DELEGATION_PRINCIPALS_FOR_PRINCIPAL_ID_AND_DELEGATION_IDS, delegationIds, principalId, null);  | 
  |  781 |     | 
           }  | 
  |  782 |     | 
             | 
  |  783 |     | 
             | 
  |  784 |     | 
           protected List<KimDelegationMemberImpl> getStoredDelegationGroupsForGroupIdsAndDelegationIds(Collection<String> delegationIds, List<String> groupIds) { | 
  |  785 |    0 |                    return getKimDelegationMemberImplList(RoleDaoAction.DELEGATION_GROUPS_FOR_GROUP_IDS_AND_DELEGATION_IDS, delegationIds, null, groupIds);  | 
  |  786 |     | 
           }  | 
  |  787 |     | 
             | 
  |  788 |     | 
             | 
  |  789 |     | 
           protected Map<String,List<KimDelegationMemberImpl>> getStoredDelegationMembersForDelegationIds(List<String> delegationIds) { | 
  |  790 |    0 |                    Map<String,List<KimDelegationMemberImpl>> finalResults = new HashMap<String,List<KimDelegationMemberImpl>>();  | 
  |  791 |    0 |                    Set<String> uncachedDelegationIds = new HashSet<String>();  | 
  |  792 |    0 |                    boolean idListWasNullOrEmpty = (delegationIds == null || delegationIds.isEmpty());  | 
  |  793 |    0 |                    if (idListWasNullOrEmpty) { delegationIds = Collections.singletonList(null); } | 
  |  794 |     | 
                     | 
  |  795 |     | 
                     | 
  |  796 |    0 |                    for (String delegationId : delegationIds) { | 
  |  797 |    0 |                            List<KimDelegationMemberImpl> tempMembers = (List<KimDelegationMemberImpl>) getCacheAdministrator().getFromCache(  | 
  |  798 |     | 
                                           getDelegationMemberListCacheKey(RoleDaoAction.DELEGATION_MEMBERS_FOR_DELEGATION_IDS, delegationId, null, null));  | 
  |  799 |    0 |                            if (tempMembers != null) { | 
  |  800 |    0 |                                    finalResults.put(delegationId, tempMembers);  | 
  |  801 |     | 
                           } else { | 
  |  802 |    0 |                                    uncachedDelegationIds.add(delegationId);  | 
  |  803 |     | 
                           }  | 
  |  804 |    0 |                    }  | 
  |  805 |     | 
                     | 
  |  806 |     | 
                     | 
  |  807 |    0 |                    if (!uncachedDelegationIds.isEmpty()) { | 
  |  808 |    0 |                            List<String> uncachedIdsList = (idListWasNullOrEmpty) ? new ArrayList<String>() : new ArrayList<String>(uncachedDelegationIds);  | 
  |  809 |     | 
                             | 
  |  810 |    0 |                            Map<String,List<KimDelegationMemberImpl>> tempMemberMap = roleDao.getDelegationMembersForDelegationIds(uncachedIdsList);  | 
  |  811 |    0 |                            List<KimDelegationMemberImpl> allMembers = new ArrayList<KimDelegationMemberImpl>();  | 
  |  812 |     | 
                             | 
  |  813 |    0 |                            for (Map.Entry<String,List<KimDelegationMemberImpl>> tempMemberEntry : tempMemberMap.entrySet()) { | 
  |  814 |    0 |                                    getCacheAdministrator().putInCache(getDelegationMemberListCacheKey(RoleDaoAction.DELEGATION_MEMBERS_FOR_DELEGATION_IDS,  | 
  |  815 |     | 
                                                   tempMemberEntry.getKey(), null, null), tempMemberEntry.getValue(), DELEGATION_MEMBER_IMPL_CACHE_GROUP);  | 
  |  816 |    0 |                                    for (KimDelegationMemberImpl tempMember : tempMemberEntry.getValue()) { | 
  |  817 |    0 |                                            addKimDelegationMemberImplToCache(tempMember);  | 
  |  818 |     | 
                                   }  | 
  |  819 |    0 |                                    if (idListWasNullOrEmpty) { | 
  |  820 |    0 |                                            allMembers.addAll(tempMemberEntry.getValue());  | 
  |  821 |     | 
                                   }  | 
  |  822 |    0 |                                    finalResults.put(tempMemberEntry.getKey(), tempMemberEntry.getValue());  | 
  |  823 |     | 
                           }  | 
  |  824 |     | 
                             | 
  |  825 |    0 |                            if (idListWasNullOrEmpty) { | 
  |  826 |    0 |                                    getCacheAdministrator().putInCache(getDelegationMemberListCacheKey(RoleDaoAction.DELEGATION_MEMBERS_FOR_DELEGATION_IDS,  | 
  |  827 |     | 
                                                   null, null, null), allMembers, DELEGATION_MEMBER_IMPL_CACHE_GROUP);  | 
  |  828 |     | 
                           }  | 
  |  829 |     | 
                   }  | 
  |  830 |     | 
                     | 
  |  831 |    0 |                    return finalResults;  | 
  |  832 |     | 
           }  | 
  |  833 |     | 
             | 
  |  834 |     | 
           protected void addKimDelegationMemberImplToCache(KimDelegationMemberImpl delegationMember) { | 
  |  835 |    0 |                    if (delegationMember != null) { | 
  |  836 |    0 |                            getCacheAdministrator().putInCache(getDelegationMemberCacheKey(delegationMember.getDelegationMemberId()),  | 
  |  837 |     | 
                                           delegationMember, DELEGATION_MEMBER_IMPL_CACHE_GROUP);  | 
  |  838 |    0 |                            getCacheAdministrator().putInCache(getDelegationMemberByDelegationAndIdCacheKey(delegationMember.getDelegationId(),  | 
  |  839 |     | 
                                           delegationMember.getDelegationMemberId()), delegationMember, DELEGATION_MEMBER_IMPL_CACHE_GROUP);  | 
  |  840 |     | 
                   }  | 
  |  841 |    0 |            }  | 
  |  842 |     | 
             | 
  |  843 |     | 
           protected void addKimDelegationMemberImplListByMemberAndDelegationIdToCache(  | 
  |  844 |     | 
                           List<KimDelegationMemberImpl> memberList, String memberId, String delegationId) { | 
  |  845 |    0 |                    if (memberList != null) { | 
  |  846 |    0 |                            getCacheAdministrator().putInCache(getDelegationMemberListByMemberAndDelegationIdCacheKey(memberId, delegationId),  | 
  |  847 |     | 
                                           memberList, DELEGATION_MEMBER_IMPL_CACHE_GROUP);  | 
  |  848 |     | 
                   }  | 
  |  849 |    0 |            }  | 
  |  850 |     | 
             | 
  |  851 |     | 
           protected KimDelegationMemberImpl getDelegationMemberFromCache(String delegationMemberId) { | 
  |  852 |    0 |                    return (KimDelegationMemberImpl)getCacheAdministrator().getFromCache(getDelegationMemberCacheKey(delegationMemberId));  | 
  |  853 |     | 
           }  | 
  |  854 |     | 
             | 
  |  855 |     | 
           protected KimDelegationMemberImpl getDelegationMemberByDelegationAndIdFromCache(String delegationId, String delegationMemberId) { | 
  |  856 |    0 |                    return (KimDelegationMemberImpl)getCacheAdministrator().getFromCache(getDelegationMemberByDelegationAndIdCacheKey(delegationId,delegationMemberId));  | 
  |  857 |     | 
           }  | 
  |  858 |     | 
             | 
  |  859 |     | 
           protected List<KimDelegationMemberImpl> getDelegationMemberListByMemberAndDelegationIdFromCache(String memberId, String delegationId) { | 
  |  860 |    0 |                    return (List<KimDelegationMemberImpl>)  | 
  |  861 |     | 
                                   getCacheAdministrator().getFromCache(getDelegationMemberListByMemberAndDelegationIdCacheKey(memberId, delegationId));  | 
  |  862 |     | 
           }  | 
  |  863 |     | 
             | 
  |  864 |     | 
           public void flushInternalDelegationMemberCache() { | 
  |  865 |    0 |                    getCacheAdministrator().flushGroup(DELEGATION_MEMBER_IMPL_CACHE_GROUP);  | 
  |  866 |    0 |            }  | 
  |  867 |     | 
             | 
  |  868 |     | 
             | 
  |  869 |     | 
     | 
  |  870 |     | 
     | 
  |  871 |     | 
     | 
  |  872 |     | 
       protected KimDelegationMemberImpl getKimDelegationMemberImpl( String delegationMemberId ) { | 
  |  873 |    0 |                if (StringUtils.isBlank(delegationMemberId)) { | 
  |  874 |    0 |                        return null;  | 
  |  875 |     | 
               }  | 
  |  876 |     | 
                 | 
  |  877 |     | 
                 | 
  |  878 |    0 |                KimDelegationMemberImpl tempDelegationMember = getDelegationMemberFromCache(delegationMemberId);  | 
  |  879 |    0 |                if (tempDelegationMember != null) { | 
  |  880 |    0 |                        return tempDelegationMember;  | 
  |  881 |     | 
               }  | 
  |  882 |     | 
                 | 
  |  883 |    0 |                tempDelegationMember = (KimDelegationMemberImpl)getBusinessObjectService().findByPrimaryKey( KimDelegationMemberImpl.class,  | 
  |  884 |     | 
                               Collections.singletonMap(KimConstants.PrimaryKeyConstants.DELEGATION_MEMBER_ID, delegationMemberId) );  | 
  |  885 |    0 |                addKimDelegationMemberImplToCache(tempDelegationMember);  | 
  |  886 |    0 |                return tempDelegationMember;  | 
  |  887 |     | 
       }  | 
  |  888 |     | 
     | 
  |  889 |     | 
         | 
  |  890 |     | 
     | 
  |  891 |     | 
     | 
  |  892 |     | 
     | 
  |  893 |     | 
           protected KimDelegationMemberImpl getKimDelegationMemberImplByDelegationAndId(String delegationId, String delegationMemberId) { | 
  |  894 |    0 |                    if (StringUtils.isBlank(delegationId) || StringUtils.isBlank(delegationMemberId)) { | 
  |  895 |    0 |                        return null;  | 
  |  896 |     | 
               }  | 
  |  897 |     | 
                 | 
  |  898 |     | 
                 | 
  |  899 |    0 |                KimDelegationMemberImpl tempDelegationMember = getDelegationMemberByDelegationAndIdFromCache(delegationId, delegationMemberId);  | 
  |  900 |    0 |                if (tempDelegationMember != null) { | 
  |  901 |    0 |                        return tempDelegationMember;  | 
  |  902 |     | 
               }  | 
  |  903 |     | 
                 | 
  |  904 |    0 |                Map<String,String> searchCriteria = new HashMap<String,String>();  | 
  |  905 |    0 |                searchCriteria.put(KimConstants.PrimaryKeyConstants.DELEGATION_ID, delegationId);  | 
  |  906 |    0 |                searchCriteria.put(KimConstants.PrimaryKeyConstants.DELEGATION_MEMBER_ID, delegationMemberId);  | 
  |  907 |    0 |                List<KimDelegationMemberImpl> memberList =  | 
  |  908 |     | 
                       (List<KimDelegationMemberImpl>) getBusinessObjectService().findMatching(KimDelegationMemberImpl.class, searchCriteria);  | 
  |  909 |    0 |                if (memberList != null && !memberList.isEmpty()) { | 
  |  910 |    0 |                        tempDelegationMember = memberList.get(0);  | 
  |  911 |    0 |                        addKimDelegationMemberImplToCache(tempDelegationMember);  | 
  |  912 |     | 
               }  | 
  |  913 |    0 |                return tempDelegationMember;  | 
  |  914 |     | 
           }  | 
  |  915 |     | 
         | 
  |  916 |     | 
             | 
  |  917 |     | 
     | 
  |  918 |     | 
     | 
  |  919 |     | 
     | 
  |  920 |     | 
           protected List<KimDelegationMemberImpl> getKimDelegationMemberImplListByMemberAndDelegationId(String memberId, String delegationId) { | 
  |  921 |     | 
                     | 
  |  922 |    0 |                List<KimDelegationMemberImpl> memberList = getDelegationMemberListByMemberAndDelegationIdFromCache(memberId, delegationId);  | 
  |  923 |    0 |                if (memberList != null) { | 
  |  924 |    0 |                        return memberList;  | 
  |  925 |     | 
               }  | 
  |  926 |     | 
                     | 
  |  927 |     | 
                 | 
  |  928 |    0 |                Map<String,String> searchCriteria = new HashMap<String,String>();  | 
  |  929 |    0 |                    searchCriteria.put(KimConstants.PrimaryKeyConstants.MEMBER_ID, memberId);  | 
  |  930 |    0 |                searchCriteria.put(KimConstants.PrimaryKeyConstants.DELEGATION_ID, delegationId);  | 
  |  931 |    0 |                List<KimDelegationMemberImpl> tempList =  | 
  |  932 |     | 
                       (List<KimDelegationMemberImpl>)getBusinessObjectService().findMatching(KimDelegationMemberImpl.class, searchCriteria);  | 
  |  933 |    0 |                if (tempList != null && !tempList.isEmpty()) { | 
  |  934 |    0 |                        memberList = new ArrayList<KimDelegationMemberImpl>();  | 
  |  935 |    0 |                        memberList.addAll(tempList);  | 
  |  936 |    0 |                        addKimDelegationMemberImplListByMemberAndDelegationIdToCache(memberList, memberId, delegationId);  | 
  |  937 |     | 
               }  | 
  |  938 |    0 |                    return memberList;  | 
  |  939 |     | 
           }  | 
  |  940 |     | 
             | 
  |  941 |     | 
           public void flushInternalRoleCache() { | 
  |  942 |    0 |                getCacheAdministrator().flushGroup(ROLE_IMPL_CACHE_GROUP);  | 
  |  943 |    0 |        }  | 
  |  944 |     | 
             | 
  |  945 |     | 
           public RoleMemberCompleteInfo findRoleMemberCompleteInfo(String roleMemberId){ | 
  |  946 |    0 |                Map<String, String> fieldValues = new HashMap<String, String>();  | 
  |  947 |    0 |                fieldValues.put(KimConstants.PrimaryKeyConstants.ROLE_MEMBER_ID, roleMemberId);  | 
  |  948 |    0 |                List<RoleMemberCompleteInfo> roleMemberInfos = findRoleMembersCompleteInfo(fieldValues);  | 
  |  949 |    0 |                if(roleMemberInfos!=null && roleMemberInfos.size()>0)  | 
  |  950 |    0 |                        return roleMemberInfos.get(0);  | 
  |  951 |    0 |                return null;  | 
  |  952 |     | 
       }  | 
  |  953 |     | 
             | 
  |  954 |     | 
           public List<RoleMemberCompleteInfo> findRoleMembersCompleteInfo(Map<String, String> fieldValues){ | 
  |  955 |    0 |                List<RoleMemberCompleteInfo> roleMembersCompleteInfos = new ArrayList<RoleMemberCompleteInfo>();  | 
  |  956 |     | 
               RoleMemberCompleteInfo roleMembersCompleteInfo;  | 
  |  957 |    0 |                List<RoleMemberImpl> roleMembers = (List<RoleMemberImpl>)getLookupService().findCollectionBySearchHelper(  | 
  |  958 |     | 
                                   RoleMemberImpl.class, fieldValues, true);  | 
  |  959 |    0 |                for(RoleMemberImpl roleMember: roleMembers){ | 
  |  960 |    0 |                        roleMembersCompleteInfo = roleMember.toSimpleInfo();  | 
  |  961 |    0 |                            Object member = getMember(roleMembersCompleteInfo.getMemberTypeCode(), roleMembersCompleteInfo.getMemberId());  | 
  |  962 |    0 |                            roleMembersCompleteInfo.setMemberName(getMemberName(member));  | 
  |  963 |    0 |                            roleMembersCompleteInfo.setMemberNamespaceCode(getMemberNamespaceCode(member));  | 
  |  964 |    0 |                            roleMembersCompleteInfo.setRoleRspActions(getRoleMemberResponsibilityActionInfo(roleMember.getRoleMemberId()));  | 
  |  965 |    0 |                            roleMembersCompleteInfos.add(roleMembersCompleteInfo);  | 
  |  966 |    0 |                }  | 
  |  967 |    0 |                return roleMembersCompleteInfos;  | 
  |  968 |     | 
       }  | 
  |  969 |     | 
             | 
  |  970 |     | 
           public List<RoleResponsibilityActionInfo> getRoleMemberResponsibilityActionInfo(String roleMemberId){ | 
  |  971 |    0 |                    Map<String, String> criteria = new HashMap<String, String>(1);                  | 
  |  972 |    0 |                    criteria.put(KimConstants.PrimaryKeyConstants.ROLE_MEMBER_ID, roleMemberId);  | 
  |  973 |    0 |                    List<RoleResponsibilityActionImpl> responsibilityImpls = (List<RoleResponsibilityActionImpl>)  | 
  |  974 |     | 
                           getBusinessObjectService().findMatching(RoleResponsibilityActionImpl.class, criteria);  | 
  |  975 |    0 |                    List<RoleResponsibilityActionInfo> roleResponsibilityActionInfos = new ArrayList<RoleResponsibilityActionInfo>();  | 
  |  976 |     | 
                   RoleResponsibilityActionInfo roleResponsibilityActionInfo;  | 
  |  977 |    0 |                    for(RoleResponsibilityActionImpl responsibilityActionImpl: responsibilityImpls){ | 
  |  978 |    0 |                            roleResponsibilityActionInfo = new RoleResponsibilityActionInfo();  | 
  |  979 |    0 |                            KimCommonUtilsInternal.copyProperties(roleResponsibilityActionInfo, responsibilityActionImpl);  | 
  |  980 |    0 |                            roleResponsibilityActionInfos.add(roleResponsibilityActionInfo);  | 
  |  981 |     | 
                   }  | 
  |  982 |    0 |                    return roleResponsibilityActionInfos;  | 
  |  983 |     | 
           }  | 
  |  984 |     | 
             | 
  |  985 |     | 
           public List<DelegateMemberCompleteInfo> findDelegateMembersCompleteInfo(final Map<String, String> fieldValues){ | 
  |  986 |    0 |                List<DelegateMemberCompleteInfo> delegateMembersCompleteInfo = new ArrayList<DelegateMemberCompleteInfo>();  | 
  |  987 |     | 
               DelegateMemberCompleteInfo delegateMemberCompleteInfo;  | 
  |  988 |    0 |                List<KimDelegationImpl> delegations = (List<KimDelegationImpl>)getLookupService().findCollectionBySearchHelper(  | 
  |  989 |     | 
                                   KimDelegationImpl.class, fieldValues, true);  | 
  |  990 |    0 |                if(delegations!=null && !delegations.isEmpty()){ | 
  |  991 |    0 |                        Map<String, String> delegationMemberFieldValues = new HashMap<String, String>();  | 
  |  992 |    0 |                        for(String key: fieldValues.keySet()){ | 
  |  993 |    0 |                                if(key.startsWith(KimConstants.KimUIConstants.MEMBER_ID_PREFIX)){ | 
  |  994 |    0 |                                        delegationMemberFieldValues.put(  | 
  |  995 |     | 
                                                       key.substring(key.indexOf(  | 
  |  996 |     | 
                                                       KimConstants.KimUIConstants.MEMBER_ID_PREFIX)+KimConstants.KimUIConstants.MEMBER_ID_PREFIX.length()),   | 
  |  997 |     | 
                                                       fieldValues.get(key));  | 
  |  998 |     | 
                               }  | 
  |  999 |     | 
                       }  | 
  |  1000 |    0 |                            StringBuffer memberQueryString = new StringBuffer();  | 
  |  1001 |    0 |                        for(KimDelegationImpl delegation: delegations)  | 
  |  1002 |    0 |                                memberQueryString.append(delegation.getDelegationId()+KimConstants.KimUIConstants.OR_OPERATOR);  | 
  |  1003 |    0 |                        delegationMemberFieldValues.put(KimConstants.PrimaryKeyConstants.DELEGATION_ID,   | 
  |  1004 |     | 
                                       KimCommonUtilsInternal.stripEnd(memberQueryString.toString(), KimConstants.KimUIConstants.OR_OPERATOR));  | 
  |  1005 |    0 |                        List<KimDelegationMemberImpl> delegateMembers = (List<KimDelegationMemberImpl>)getLookupService().findCollectionBySearchHelper(  | 
  |  1006 |     | 
                                           KimDelegationMemberImpl.class, delegationMemberFieldValues, true);  | 
  |  1007 |     | 
                       KimDelegationImpl delegationTemp;  | 
  |  1008 |    0 |                        for(KimDelegationMemberImpl delegateMember: delegateMembers){ | 
  |  1009 |    0 |                                delegateMemberCompleteInfo = delegateMember.toSimpleInfo();  | 
  |  1010 |    0 |                                delegationTemp = getDelegationImpl(delegations, delegateMember.getDelegationId());  | 
  |  1011 |    0 |                                delegateMemberCompleteInfo.setRoleId(delegationTemp.getRoleId());  | 
  |  1012 |    0 |                                delegateMemberCompleteInfo.setDelegationTypeCode(delegationTemp.getDelegationTypeCode());  | 
  |  1013 |    0 |                                    Object member = getMember(delegateMemberCompleteInfo.getMemberTypeCode(), delegateMemberCompleteInfo.getMemberId());  | 
  |  1014 |    0 |                                    delegateMemberCompleteInfo.setMemberName(getMemberName(member));  | 
  |  1015 |    0 |                                    delegateMemberCompleteInfo.setMemberNamespaceCode(getMemberNamespaceCode(member));  | 
  |  1016 |    0 |                                    delegateMembersCompleteInfo.add(delegateMemberCompleteInfo);  | 
  |  1017 |    0 |                        }  | 
  |  1018 |     | 
     | 
  |  1019 |     | 
               }  | 
  |  1020 |    0 |                return delegateMembersCompleteInfo;  | 
  |  1021 |     | 
       }  | 
  |  1022 |     | 
             | 
  |  1023 |     | 
           protected KimDelegationImpl getDelegationImpl(List<KimDelegationImpl> delegations, String delegationId){ | 
  |  1024 |    0 |                if(StringUtils.isEmpty(delegationId) || delegations==null)  | 
  |  1025 |    0 |                        return null;  | 
  |  1026 |    0 |                for(KimDelegationImpl delegation: delegations){ | 
  |  1027 |    0 |                        if(StringUtils.equals(delegation.getDelegationId(), delegationId))  | 
  |  1028 |    0 |                                return delegation;  | 
  |  1029 |     | 
               }  | 
  |  1030 |    0 |                return null;  | 
  |  1031 |     | 
       }  | 
  |  1032 |     | 
             | 
  |  1033 |     | 
           protected Object getMember(String memberTypeCode, String memberId){ | 
  |  1034 |    0 |                    if ( StringUtils.isBlank(memberId) ) { | 
  |  1035 |    0 |                            return null;  | 
  |  1036 |     | 
                   }  | 
  |  1037 |    0 |            if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode)){ | 
  |  1038 |    0 |                    return getIdentityManagementService().getPrincipal(memberId);  | 
  |  1039 |    0 |            } else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode)){ | 
  |  1040 |    0 |                    return getIdentityManagementService().getGroup(memberId);  | 
  |  1041 |    0 |            } else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode)){ | 
  |  1042 |    0 |                    return getRoleImpl(memberId);  | 
  |  1043 |     | 
           }  | 
  |  1044 |    0 |            return null;  | 
  |  1045 |     | 
       }  | 
  |  1046 |     | 
             | 
  |  1047 |     | 
           protected String getMemberName(Object member){ | 
  |  1048 |    0 |            if( member == null ) { | 
  |  1049 |    0 |                    return "";  | 
  |  1050 |     | 
           }  | 
  |  1051 |    0 |            if ( member instanceof KimPrincipal ) { | 
  |  1052 |    0 |                    return ((KimPrincipal)member).getPrincipalName();  | 
  |  1053 |     | 
           }  | 
  |  1054 |    0 |            if ( member instanceof Group ) { | 
  |  1055 |    0 |                    return ((Group)member).getGroupName();  | 
  |  1056 |     | 
           }  | 
  |  1057 |    0 |            if ( member instanceof Role ) { | 
  |  1058 |    0 |                    return ((Role)member).getRoleName();  | 
  |  1059 |     | 
           }  | 
  |  1060 |    0 |            return member.toString();  | 
  |  1061 |     | 
       }  | 
  |  1062 |     | 
             | 
  |  1063 |     | 
           protected String getMemberNamespaceCode(Object member){ | 
  |  1064 |    0 |            if( member == null ) { | 
  |  1065 |    0 |                    return "";  | 
  |  1066 |     | 
           }  | 
  |  1067 |    0 |            if ( member instanceof KimPrincipal ) { | 
  |  1068 |    0 |                    return "";  | 
  |  1069 |     | 
           }  | 
  |  1070 |    0 |            if ( member instanceof Group ) { | 
  |  1071 |    0 |                    return ((Group)member).getNamespaceCode();  | 
  |  1072 |     | 
           }  | 
  |  1073 |    0 |            if ( member instanceof Role ) { | 
  |  1074 |    0 |                    return ((Role)member).getNamespaceCode();  | 
  |  1075 |     | 
           }  | 
  |  1076 |    0 |            return "";  | 
  |  1077 |     | 
       }  | 
  |  1078 |     | 
             | 
  |  1079 |     | 
           protected RoleImpl getRoleImpl(String roleId) { | 
  |  1080 |    0 |                    if ( StringUtils.isBlank( roleId ) ) { | 
  |  1081 |    0 |                            return null;  | 
  |  1082 |     | 
                   }  | 
  |  1083 |     | 
                     | 
  |  1084 |    0 |                    RoleImpl cachedResult = getRoleFromCache( roleId );  | 
  |  1085 |    0 |                    if ( cachedResult != null ) { | 
  |  1086 |    0 |                            return cachedResult;  | 
  |  1087 |     | 
                   }  | 
  |  1088 |     | 
                     | 
  |  1089 |    0 |                    RoleImpl result = (RoleImpl)getBusinessObjectService().findBySinglePrimaryKey(RoleImpl.class, roleId);  | 
  |  1090 |    0 |                    addRoleImplToCache( result );  | 
  |  1091 |    0 |                    return result;  | 
  |  1092 |     | 
           }  | 
  |  1093 |     | 
             | 
  |  1094 |     | 
           protected KimDelegationImpl getDelegationOfType(String roleId, String delegationTypeCode){ | 
  |  1095 |    0 |                List<KimDelegationImpl> roleDelegations = getRoleDelegations(roleId);  | 
  |  1096 |    0 |            if(isDelegationPrimary(delegationTypeCode))  | 
  |  1097 |    0 |                return getPrimaryDelegation(roleId, roleDelegations);  | 
  |  1098 |     | 
           else  | 
  |  1099 |    0 |                return getSecondaryDelegation(roleId, roleDelegations);  | 
  |  1100 |     | 
       }  | 
  |  1101 |     | 
             | 
  |  1102 |     | 
           private KimDelegationImpl getSecondaryDelegation(String roleId, List<KimDelegationImpl> roleDelegations){ | 
  |  1103 |    0 |            KimDelegationImpl secondaryDelegation = null;  | 
  |  1104 |    0 |            RoleImpl roleImpl = getRoleImpl(roleId);  | 
  |  1105 |    0 |            for(KimDelegationImpl delegation: roleDelegations){ | 
  |  1106 |    0 |                if(isDelegationSecondary(delegation.getDelegationTypeCode()))  | 
  |  1107 |    0 |                    secondaryDelegation = delegation;  | 
  |  1108 |     | 
           }  | 
  |  1109 |    0 |            if(secondaryDelegation==null){ | 
  |  1110 |    0 |                secondaryDelegation = new KimDelegationImpl();  | 
  |  1111 |    0 |                secondaryDelegation.setRoleId(roleId);  | 
  |  1112 |    0 |                secondaryDelegation.setDelegationId(getNewDelegationId());  | 
  |  1113 |    0 |                secondaryDelegation.setDelegationTypeCode(KEWConstants.DELEGATION_SECONDARY);  | 
  |  1114 |    0 |                secondaryDelegation.setKimTypeId(roleImpl.getKimTypeId());  | 
  |  1115 |     | 
           }  | 
  |  1116 |    0 |            return secondaryDelegation;  | 
  |  1117 |     | 
       }  | 
  |  1118 |     | 
             | 
  |  1119 |     | 
           protected KimDelegationImpl getPrimaryDelegation(String roleId, List<KimDelegationImpl> roleDelegations){ | 
  |  1120 |    0 |            KimDelegationImpl primaryDelegation = null;  | 
  |  1121 |    0 |            RoleImpl roleImpl = getRoleImpl(roleId);  | 
  |  1122 |    0 |            for(KimDelegationImpl delegation: roleDelegations){ | 
  |  1123 |    0 |                if(isDelegationPrimary(delegation.getDelegationTypeCode()))  | 
  |  1124 |    0 |                    primaryDelegation = delegation;  | 
  |  1125 |     | 
           }  | 
  |  1126 |    0 |            if(primaryDelegation==null){ | 
  |  1127 |    0 |                primaryDelegation = new KimDelegationImpl();  | 
  |  1128 |    0 |                primaryDelegation.setRoleId(roleId);  | 
  |  1129 |    0 |                primaryDelegation.setDelegationId(getNewDelegationId());  | 
  |  1130 |    0 |                primaryDelegation.setDelegationTypeCode(KEWConstants.DELEGATION_PRIMARY);  | 
  |  1131 |    0 |                primaryDelegation.setKimTypeId(roleImpl.getKimTypeId());  | 
  |  1132 |     | 
           }  | 
  |  1133 |    0 |            return primaryDelegation;  | 
  |  1134 |     | 
       }  | 
  |  1135 |     | 
             | 
  |  1136 |     | 
           protected RoleMemberImpl matchingMemberRecord( List<RoleMemberImpl> roleMembers, String memberId, String memberTypeCode, AttributeSet qualifier ) { | 
  |  1137 |    0 |                    for ( RoleMemberImpl rm : roleMembers ) { | 
  |  1138 |    0 |                            if ( doesMemberMatch( rm, memberId, memberTypeCode, qualifier ) ) { | 
  |  1139 |    0 |                                    return rm;  | 
  |  1140 |     | 
                           }  | 
  |  1141 |     | 
                   }  | 
  |  1142 |    0 |                    return null;  | 
  |  1143 |     | 
           }  | 
  |  1144 |     | 
             | 
  |  1145 |     | 
           protected boolean isDelegationPrimary(String delegationTypeCode){ | 
  |  1146 |    0 |            return KEWConstants.DELEGATION_PRIMARY.equals(delegationTypeCode);  | 
  |  1147 |     | 
       }  | 
  |  1148 |     | 
             | 
  |  1149 |     | 
           protected boolean isDelegationSecondary(String delegationTypeCode){ | 
  |  1150 |    0 |            return KEWConstants.DELEGATION_SECONDARY.equals(delegationTypeCode);  | 
  |  1151 |     | 
       }  | 
  |  1152 |     | 
             | 
  |  1153 |     | 
             | 
  |  1154 |     | 
           private List<KimDelegationImpl> getRoleDelegations(String roleId){ | 
  |  1155 |    0 |                    if(roleId==null)  | 
  |  1156 |    0 |                            return new ArrayList<KimDelegationImpl>();  | 
  |  1157 |    0 |                    return getStoredDelegationImplsForRoleIds(Collections.singletonList(roleId));  | 
  |  1158 |     | 
     | 
  |  1159 |     | 
           }  | 
  |  1160 |     | 
             | 
  |  1161 |     | 
           protected RoleImpl getRoleImplByName( String namespaceCode, String roleName ) { | 
  |  1162 |    0 |                    if ( StringUtils.isBlank( namespaceCode )  | 
  |  1163 |     | 
                                   || StringUtils.isBlank( roleName ) ) { | 
  |  1164 |    0 |                            return null;  | 
  |  1165 |     | 
                   }  | 
  |  1166 |     | 
                     | 
  |  1167 |    0 |                    RoleImpl cachedResult = getRoleFromCache( namespaceCode, roleName );  | 
  |  1168 |    0 |                    if ( cachedResult != null ) { | 
  |  1169 |    0 |                            return cachedResult;  | 
  |  1170 |     | 
                   }  | 
  |  1171 |    0 |                    AttributeSet criteria = new AttributeSet();  | 
  |  1172 |    0 |                    criteria.put(KimConstants.UniqueKeyConstants.NAMESPACE_CODE, namespaceCode);  | 
  |  1173 |    0 |                    criteria.put(KimConstants.UniqueKeyConstants.ROLE_NAME, roleName);  | 
  |  1174 |    0 |                    criteria.put(KNSPropertyConstants.ACTIVE, "Y");  | 
  |  1175 |     | 
                     | 
  |  1176 |    0 |                    RoleImpl result = (RoleImpl)getBusinessObjectService().findByPrimaryKey(RoleImpl.class, criteria);  | 
  |  1177 |    0 |                    addRoleImplToCache( result );  | 
  |  1178 |    0 |                    return result;  | 
  |  1179 |     | 
           }  | 
  |  1180 |     | 
             | 
  |  1181 |     | 
           protected boolean doAnyMemberRecordsMatch( List<RoleMemberImpl> roleMembers, String memberId, String memberTypeCode, AttributeSet qualifier ) { | 
  |  1182 |    0 |                    for ( RoleMemberImpl rm : roleMembers ) { | 
  |  1183 |    0 |                            if ( doesMemberMatch( rm, memberId, memberTypeCode, qualifier ) ) { | 
  |  1184 |    0 |                                    return true;  | 
  |  1185 |     | 
                           }  | 
  |  1186 |     | 
                   }  | 
  |  1187 |    0 |                    return false;  | 
  |  1188 |     | 
           }  | 
  |  1189 |     | 
             | 
  |  1190 |     | 
           protected boolean doesMemberMatch( RoleMemberImpl roleMember, String memberId, String memberTypeCode, AttributeSet qualifier ) { | 
  |  1191 |    0 |                    if ( roleMember.getMemberId().equals( memberId ) && roleMember.getMemberTypeCode().equals( memberTypeCode ) ) { | 
  |  1192 |     | 
                             | 
  |  1193 |    0 |                        AttributeSet roleQualifier = roleMember.getQualifier();  | 
  |  1194 |    0 |                        if ( (qualifier == null || qualifier.isEmpty())  | 
  |  1195 |     | 
                                       && (roleQualifier == null || roleQualifier.isEmpty()) ) { | 
  |  1196 |    0 |                                return true;   | 
  |  1197 |     | 
                       } else { | 
  |  1198 |    0 |                                if ( qualifier != null && roleQualifier != null && qualifier.equals( roleQualifier ) ) { | 
  |  1199 |    0 |                                        return true;   | 
  |  1200 |     | 
                               }  | 
  |  1201 |     | 
                       }  | 
  |  1202 |     | 
                   }  | 
  |  1203 |    0 |                    return false;  | 
  |  1204 |     | 
           }  | 
  |  1205 |     | 
     | 
  |  1206 |     | 
             | 
  |  1207 |     | 
     | 
  |  1208 |     | 
     | 
  |  1209 |     | 
     | 
  |  1210 |     | 
     | 
  |  1211 |     | 
     | 
  |  1212 |     | 
     | 
  |  1213 |     | 
     | 
  |  1214 |     | 
     | 
  |  1215 |     | 
     | 
  |  1216 |     | 
           protected boolean checkForCircularRoleMembership( String newMemberId, RoleImpl role ) { | 
  |  1217 |     | 
                     | 
  |  1218 |    0 |                    Set<String> newRoleMemberIds = getRoleTypeRoleMemberIds(newMemberId);  | 
  |  1219 |    0 |                    if (newRoleMemberIds.contains(role.getRoleId())){ | 
  |  1220 |    0 |                                            return false;  | 
  |  1221 |     | 
                   }  | 
  |  1222 |    0 |                    return true;  | 
  |  1223 |     | 
           }  | 
  |  1224 |     | 
             | 
  |  1225 |     | 
             | 
  |  1226 |     | 
           @SuppressWarnings("unchecked") | 
  |  1227 |     | 
           protected String getKimAttributeId( String attributeName ) { | 
  |  1228 |    0 |                    String result = null;  | 
  |  1229 |    0 |                    Map<String,Object> critieria = new HashMap<String,Object>( 1 );  | 
  |  1230 |    0 |                    critieria.put( "attributeName", attributeName );  | 
  |  1231 |    0 |                    Collection<KimAttributeImpl> defs = getBusinessObjectService().findMatching( KimAttributeImpl.class, critieria );  | 
  |  1232 |    0 |                    if(CollectionUtils.isNotEmpty(defs)) { | 
  |  1233 |    0 |                            result = defs.iterator().next().getKimAttributeId();  | 
  |  1234 |     | 
                   }  | 
  |  1235 |    0 |                    return result;  | 
  |  1236 |     | 
           }  | 
  |  1237 |     | 
             | 
  |  1238 |     | 
         | 
  |  1239 |     | 
     | 
  |  1240 |     | 
     | 
  |  1241 |     | 
           protected Map<String, Boolean> getApplicationRoleTypeCache() { | 
  |  1242 |    0 |                    return this.applicationRoleTypeCache;  | 
  |  1243 |     | 
           }  | 
  |  1244 |     | 
             | 
  |  1245 |     | 
     | 
  |  1246 |     | 
     | 
  |  1247 |     | 
           protected Map<String, KimRoleTypeService> getRoleTypeServiceCache() { | 
  |  1248 |    0 |                    return this.roleTypeServiceCache;  | 
  |  1249 |     | 
           }  | 
  |  1250 |     | 
     | 
  |  1251 |     | 
             | 
  |  1252 |     | 
     | 
  |  1253 |     | 
     | 
  |  1254 |     | 
           protected Map<String, KimDelegationTypeService> getDelegationTypeServiceCache() { | 
  |  1255 |    0 |                    return this.delegationTypeServiceCache;  | 
  |  1256 |     | 
           }  | 
  |  1257 |     | 
           protected String getRoleCacheKey( String roleId ) { | 
  |  1258 |    0 |                return ROLE_IMPL_CACHE_PREFIX + roleId;  | 
  |  1259 |     | 
       }  | 
  |  1260 |     | 
     | 
  |  1261 |     | 
       protected String getRoleByNameCacheKey( String namespaceCode, String roleName ) { | 
  |  1262 |    0 |                return ROLE_IMPL_BY_NAME_CACHE_PREFIX + namespaceCode + "-" + roleName;  | 
  |  1263 |     | 
               }  | 
  |  1264 |     | 
     | 
  |  1265 |     | 
       protected void addRoleImplToCache( RoleImpl role ) { | 
  |  1266 |    0 |                if (role != null) { | 
  |  1267 |    0 |                        getCacheAdministrator().putInCache(getRoleCacheKey(role.getRoleId()), role, ROLE_IMPL_CACHE_GROUP);  | 
  |  1268 |    0 |                        getCacheAdministrator().putInCache(getRoleByNameCacheKey(role.getNamespaceCode(),role.getRoleName()), role, ROLE_IMPL_CACHE_GROUP);  | 
  |  1269 |     | 
                       }  | 
  |  1270 |    0 |                }  | 
  |  1271 |     | 
     | 
  |  1272 |     | 
       protected RoleImpl getRoleFromCache( String roleId ) { | 
  |  1273 |    0 |                return (RoleImpl)getCacheAdministrator().getFromCache(getRoleCacheKey(roleId));  | 
  |  1274 |     | 
       }  | 
  |  1275 |     | 
     | 
  |  1276 |     | 
       protected RoleImpl getRoleFromCache( String namespaceCode, String roleName ) { | 
  |  1277 |    0 |                return (RoleImpl)getCacheAdministrator().getFromCache(getRoleByNameCacheKey(namespaceCode,roleName));  | 
  |  1278 |     | 
       }  | 
  |  1279 |     | 
         | 
  |  1280 |     | 
       protected String getNewDelegationId(){ | 
  |  1281 |    0 |                SequenceAccessorService sas = getSequenceAccessorService();  | 
  |  1282 |    0 |                Long nextSeq = sas.getNextAvailableSequenceNumber(  | 
  |  1283 |     | 
                   KimConstants.SequenceNames.KRIM_DLGN_ID_S,  | 
  |  1284 |     | 
                   KimDelegationImpl.class);  | 
  |  1285 |    0 |            return nextSeq.toString();  | 
  |  1286 |     | 
       }  | 
  |  1287 |     | 
     | 
  |  1288 |     | 
       protected String getNewAttributeDataId(){ | 
  |  1289 |    0 |                    SequenceAccessorService sas = getSequenceAccessorService();                  | 
  |  1290 |    0 |                    Long nextSeq = sas.getNextAvailableSequenceNumber(  | 
  |  1291 |     | 
                                   KimConstants.SequenceNames.KRIM_ATTR_DATA_ID_S,   | 
  |  1292 |     | 
                                   RoleMemberAttributeDataImpl.class );  | 
  |  1293 |    0 |                    return nextSeq.toString();  | 
  |  1294 |     | 
       }  | 
  |  1295 |     | 
         | 
  |  1296 |     | 
       protected String getNewDelegationMemberId(){ | 
  |  1297 |    0 |                SequenceAccessorService sas = getSequenceAccessorService();  | 
  |  1298 |    0 |                Long nextSeq = sas.getNextAvailableSequenceNumber(  | 
  |  1299 |     | 
                   KimConstants.SequenceNames.KRIM_DLGN_MBR_ID_S,  | 
  |  1300 |     | 
                   KimDelegationImpl.class);  | 
  |  1301 |    0 |            return nextSeq.toString();  | 
  |  1302 |     | 
       }  | 
  |  1303 |     | 
         | 
  |  1304 |     | 
       protected BusinessObjectService getBusinessObjectService() { | 
  |  1305 |    0 |                    if ( businessObjectService == null ) { | 
  |  1306 |    0 |                            businessObjectService = KNSServiceLocator.getBusinessObjectService();  | 
  |  1307 |     | 
                   }  | 
  |  1308 |    0 |                    return businessObjectService;  | 
  |  1309 |     | 
           }  | 
  |  1310 |     | 
         | 
  |  1311 |     | 
         | 
  |  1312 |     | 
     | 
  |  1313 |     | 
     | 
  |  1314 |     | 
       protected LookupService getLookupService() { | 
  |  1315 |    0 |                    if(lookupService == null) { | 
  |  1316 |    0 |                            lookupService = KNSServiceLocatorWeb.getLookupService();  | 
  |  1317 |     | 
                   }  | 
  |  1318 |    0 |                    return lookupService;  | 
  |  1319 |     | 
           }  | 
  |  1320 |     | 
         | 
  |  1321 |     | 
       protected RiceCacheAdministrator getCacheAdministrator() { | 
  |  1322 |    0 |                    if ( cacheAdministrator == null ) { | 
  |  1323 |    0 |                            cacheAdministrator = KEWServiceLocator.getCacheAdministrator();  | 
  |  1324 |     | 
                   }  | 
  |  1325 |    0 |                    return cacheAdministrator;  | 
  |  1326 |     | 
       }  | 
  |  1327 |     | 
         | 
  |  1328 |     | 
       protected IdentityManagementService getIdentityManagementService() { | 
  |  1329 |    0 |                    if ( identityManagementService == null ) { | 
  |  1330 |    0 |                            identityManagementService = KIMServiceLocator.getIdentityManagementService();  | 
  |  1331 |     | 
                   }  | 
  |  1332 |     | 
     | 
  |  1333 |    0 |                    return identityManagementService;  | 
  |  1334 |     | 
           }  | 
  |  1335 |     | 
     | 
  |  1336 |     | 
           protected SequenceAccessorService getSequenceAccessorService() { | 
  |  1337 |    0 |                    if ( sequenceAccessorService == null ) { | 
  |  1338 |    0 |                            sequenceAccessorService = KNSServiceLocator.getSequenceAccessorService();  | 
  |  1339 |     | 
                   }  | 
  |  1340 |    0 |                    return sequenceAccessorService;  | 
  |  1341 |     | 
           }  | 
  |  1342 |     | 
             | 
  |  1343 |     | 
           protected ResponsibilityInternalService getResponsibilityInternalService() { | 
  |  1344 |    0 |                    if ( responsibilityInternalService == null ) { | 
  |  1345 |    0 |                            responsibilityInternalService = KIMServiceLocatorInternal.getResponsibilityInternalService();  | 
  |  1346 |     | 
                   }  | 
  |  1347 |    0 |                    return responsibilityInternalService;  | 
  |  1348 |     | 
           }  | 
  |  1349 |     | 
             | 
  |  1350 |     | 
           protected IdentityManagementNotificationService getIdentityManagementNotificationService() { | 
  |  1351 |    0 |            return (IdentityManagementNotificationService)KSBServiceLocator.getMessageHelper().getServiceAsynchronously(new QName("KIM", "kimIdentityManagementNotificationService")); | 
  |  1352 |     | 
       }  | 
  |  1353 |     | 
             | 
  |  1354 |     | 
             | 
  |  1355 |     | 
     | 
  |  1356 |     | 
     | 
  |  1357 |     | 
     | 
  |  1358 |     | 
     | 
  |  1359 |    0 |            private class RoleMemberCacheKeyHelper { | 
  |  1360 |     | 
                   private final RoleDaoAction ROLE_DAO_ACTION;  | 
  |  1361 |     | 
                   private final String ROLE_ID;  | 
  |  1362 |     | 
                   private final String PRINCIPAL_ID;  | 
  |  1363 |     | 
                   private final String GROUP_ID;  | 
  |  1364 |     | 
                   private final String MEMBER_TYPE_CODE;  | 
  |  1365 |     | 
                   private String cacheKey;  | 
  |  1366 |     | 
                     | 
  |  1367 |    0 |                    private RoleMemberCacheKeyHelper(RoleDaoAction roleDaoAction, String roleId, String principalId, String groupId, String memberTypeCode) { | 
  |  1368 |    0 |                            this.ROLE_DAO_ACTION = roleDaoAction;  | 
  |  1369 |    0 |                            this.ROLE_ID = roleId;  | 
  |  1370 |    0 |                            this.PRINCIPAL_ID = principalId;  | 
  |  1371 |    0 |                            this.GROUP_ID = groupId;  | 
  |  1372 |    0 |                            this.MEMBER_TYPE_CODE = memberTypeCode;  | 
  |  1373 |    0 |                    }  | 
  |  1374 |     | 
                     | 
  |  1375 |     | 
                   private String getCacheKey() { | 
  |  1376 |    0 |                            if (this.cacheKey == null) { | 
  |  1377 |    0 |                                    this.cacheKey = getRoleMemberListCacheKey(ROLE_DAO_ACTION, ROLE_ID, PRINCIPAL_ID, GROUP_ID, MEMBER_TYPE_CODE);  | 
  |  1378 |     | 
                           }  | 
  |  1379 |    0 |                            return this.cacheKey;  | 
  |  1380 |     | 
                   }  | 
  |  1381 |     | 
           }  | 
  |  1382 |     | 
             | 
  |  1383 |     | 
     | 
  |  1384 |     | 
     | 
  |  1385 |     | 
           public KimRoleDao getRoleDao() { | 
  |  1386 |    0 |                    return this.roleDao;  | 
  |  1387 |     | 
           }  | 
  |  1388 |     | 
     | 
  |  1389 |     | 
             | 
  |  1390 |     | 
     | 
  |  1391 |     | 
     | 
  |  1392 |     | 
           public void setRoleDao(KimRoleDao roleDao) { | 
  |  1393 |    0 |                    this.roleDao = roleDao;  | 
  |  1394 |    0 |            }  | 
  |  1395 |     | 
   }  |