|  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.sql.Date;  | 
  |  19 |     | 
   import java.util.ArrayList;  | 
  |  20 |     | 
   import java.util.Collection;  | 
  |  21 |     | 
   import java.util.Collections;  | 
  |  22 |     | 
   import java.util.HashMap;  | 
  |  23 |     | 
   import java.util.HashSet;  | 
  |  24 |     | 
   import java.util.Iterator;  | 
  |  25 |     | 
   import java.util.List;  | 
  |  26 |     | 
   import java.util.Map;  | 
  |  27 |     | 
   import java.util.Set;  | 
  |  28 |     | 
     | 
  |  29 |     | 
   import javax.jws.WebParam;  | 
  |  30 |     | 
     | 
  |  31 |     | 
   import org.apache.commons.lang.exception.ExceptionUtils;  | 
  |  32 |     | 
   import org.apache.log4j.Logger;  | 
  |  33 |     | 
   import org.kuali.rice.core.util.MaxAgeSoftReference;  | 
  |  34 |     | 
   import org.kuali.rice.core.util.MaxSizeMap;  | 
  |  35 |     | 
   import org.kuali.rice.core.xml.dto.AttributeSet;  | 
  |  36 |     | 
   import org.kuali.rice.kim.bo.Role;  | 
  |  37 |     | 
   import org.kuali.rice.kim.bo.entity.KimPrincipal;  | 
  |  38 |     | 
   import org.kuali.rice.kim.bo.role.dto.DelegateMemberCompleteInfo;  | 
  |  39 |     | 
   import org.kuali.rice.kim.bo.role.dto.DelegateTypeInfo;  | 
  |  40 |     | 
   import org.kuali.rice.kim.bo.role.dto.KimRoleInfo;  | 
  |  41 |     | 
   import org.kuali.rice.kim.bo.role.dto.RoleMemberCompleteInfo;  | 
  |  42 |     | 
   import org.kuali.rice.kim.bo.role.dto.RoleMembershipInfo;  | 
  |  43 |     | 
   import org.kuali.rice.kim.bo.role.dto.RoleResponsibilityActionInfo;  | 
  |  44 |     | 
   import org.kuali.rice.kim.bo.role.dto.RoleResponsibilityInfo;  | 
  |  45 |     | 
   import org.kuali.rice.kim.bo.types.dto.KimTypeInfo;  | 
  |  46 |     | 
   import org.kuali.rice.kim.service.*;  | 
  |  47 |     | 
   import org.kuali.rice.kim.service.support.KimRoleTypeService;  | 
  |  48 |     | 
   import org.kuali.rice.kim.service.support.KimTypeService;  | 
  |  49 |     | 
   import org.springframework.beans.factory.InitializingBean;  | 
  |  50 |     | 
     | 
  |  51 |     | 
     | 
  |  52 |     | 
     | 
  |  53 |     | 
     | 
  |  54 |    0 |    public class RoleManagementServiceImpl implements RoleManagementService, InitializingBean { | 
  |  55 |    0 |            private static final Logger LOG = Logger.getLogger( RoleManagementServiceImpl.class );  | 
  |  56 |     | 
             | 
  |  57 |     | 
           private RoleService roleService;  | 
  |  58 |     | 
           private KimTypeInfoService typeInfoService;  | 
  |  59 |     | 
           private RoleUpdateService roleUpdateService;  | 
  |  60 |     | 
             | 
  |  61 |     | 
             | 
  |  62 |    0 |            protected int roleCacheMaxSize = 200;  | 
  |  63 |    0 |            protected int roleCacheMaxAgeSeconds = 30;  | 
  |  64 |     | 
             | 
  |  65 |     | 
           protected Map<String,MaxAgeSoftReference<KimRoleInfo>> roleByIdCache;  | 
  |  66 |     | 
           protected Map<String,MaxAgeSoftReference<KimRoleInfo>> roleByNameCache;  | 
  |  67 |     | 
           protected Map<String,MaxAgeSoftReference<List<RoleMembershipInfo>>> roleMembersWithDelegationCache;  | 
  |  68 |     | 
           protected Map<String,MaxAgeSoftReference<List<AttributeSet>>> roleQualifiersForPrincipalCache;  | 
  |  69 |     | 
           protected Map<String,MaxAgeSoftReference<Boolean>> principalHasRoleCache;  | 
  |  70 |     | 
           protected Map<String,MaxAgeSoftReference<Collection<String>>> memberPrincipalIdsCache;  | 
  |  71 |     | 
             | 
  |  72 |     | 
           protected Map<String, Boolean> shouldCacheRoleCache;  | 
  |  73 |     | 
             | 
  |  74 |     | 
           public void afterPropertiesSet() throws Exception { | 
  |  75 |    0 |                    roleByIdCache = Collections.synchronizedMap( new MaxSizeMap<String,MaxAgeSoftReference<KimRoleInfo>>( roleCacheMaxSize ) );  | 
  |  76 |    0 |                    roleByNameCache = Collections.synchronizedMap( new MaxSizeMap<String,MaxAgeSoftReference<KimRoleInfo>>( roleCacheMaxSize ) );  | 
  |  77 |    0 |                    roleMembersWithDelegationCache = Collections.synchronizedMap( new MaxSizeMap<String,MaxAgeSoftReference<List<RoleMembershipInfo>>>( roleCacheMaxSize ) );  | 
  |  78 |    0 |                    roleQualifiersForPrincipalCache = Collections.synchronizedMap( new MaxSizeMap<String,MaxAgeSoftReference<List<AttributeSet>>>( roleCacheMaxSize ) );  | 
  |  79 |    0 |                    principalHasRoleCache = Collections.synchronizedMap( new MaxSizeMap<String,MaxAgeSoftReference<Boolean>>( roleCacheMaxSize ) );  | 
  |  80 |    0 |                    memberPrincipalIdsCache = Collections.synchronizedMap( new MaxSizeMap<String,MaxAgeSoftReference<Collection<String>>>( roleCacheMaxSize ) );  | 
  |  81 |    0 |                    shouldCacheRoleCache = Collections.synchronizedMap(new HashMap<String, Boolean>());  | 
  |  82 |    0 |            }  | 
  |  83 |     | 
             | 
  |  84 |     | 
           public void flushRoleCaches() { | 
  |  85 |    0 |                    flushInternalRoleCache();  | 
  |  86 |    0 |                    flushInternalRoleMemberCache();  | 
  |  87 |    0 |                    flushInternalDelegationCache();  | 
  |  88 |    0 |                    flushInternalDelegationMemberCache();  | 
  |  89 |    0 |                    roleByIdCache.clear();  | 
  |  90 |    0 |                    roleByNameCache.clear();  | 
  |  91 |    0 |                    roleMembersWithDelegationCache.clear();  | 
  |  92 |    0 |                    roleQualifiersForPrincipalCache.clear();  | 
  |  93 |    0 |                    principalHasRoleCache.clear();  | 
  |  94 |    0 |                    memberPrincipalIdsCache.clear();  | 
  |  95 |    0 |                    shouldCacheRoleCache.clear();  | 
  |  96 |    0 |            }  | 
  |  97 |     | 
             | 
  |  98 |     | 
           public void flushRoleMemberCaches() { | 
  |  99 |    0 |                    flushInternalRoleMemberCache();  | 
  |  100 |    0 |                    roleMembersWithDelegationCache.clear();  | 
  |  101 |    0 |                    memberPrincipalIdsCache.clear();  | 
  |  102 |    0 |            }  | 
  |  103 |     | 
             | 
  |  104 |     | 
           public void flushDelegationCaches() { | 
  |  105 |    0 |                    flushInternalDelegationCache();  | 
  |  106 |    0 |                    flushInternalDelegationMemberCache();  | 
  |  107 |    0 |                    roleMembersWithDelegationCache.clear();  | 
  |  108 |    0 |            }  | 
  |  109 |     | 
             | 
  |  110 |     | 
           public void flushDelegationMemberCaches() { | 
  |  111 |    0 |                    flushInternalDelegationMemberCache();  | 
  |  112 |    0 |                    roleMembersWithDelegationCache.clear();  | 
  |  113 |    0 |            }  | 
  |  114 |     | 
             | 
  |  115 |     | 
             | 
  |  116 |     | 
     | 
  |  117 |     | 
           protected KimRoleInfo getRoleByIdCache( String roleId ) { | 
  |  118 |    0 |                    MaxAgeSoftReference<KimRoleInfo> roleRef = roleByIdCache.get( roleId );  | 
  |  119 |    0 |                    if ( roleRef != null ) { | 
  |  120 |    0 |                            return roleRef.get();  | 
  |  121 |     | 
                   }  | 
  |  122 |    0 |                    return null;  | 
  |  123 |     | 
           }  | 
  |  124 |     | 
     | 
  |  125 |     | 
           protected KimRoleInfo getRoleByNameCache( String key ) { | 
  |  126 |    0 |                    MaxAgeSoftReference<KimRoleInfo> roleRef = roleByNameCache.get( key );  | 
  |  127 |    0 |                    if ( roleRef != null ) { | 
  |  128 |    0 |                            return roleRef.get();  | 
  |  129 |     | 
                   }  | 
  |  130 |    0 |                    return null;  | 
  |  131 |     | 
           }  | 
  |  132 |     | 
             | 
  |  133 |     | 
           protected List<RoleMembershipInfo> getRoleMembersWithDelegationCache( String key ) { | 
  |  134 |    0 |                    MaxAgeSoftReference<List<RoleMembershipInfo>> roleMembersRef = roleMembersWithDelegationCache.get( key );  | 
  |  135 |    0 |                    if ( roleMembersRef != null ) { | 
  |  136 |    0 |                            return roleMembersRef.get();  | 
  |  137 |     | 
                   }  | 
  |  138 |    0 |                    return null;  | 
  |  139 |     | 
           }  | 
  |  140 |     | 
             | 
  |  141 |     | 
           protected List<AttributeSet> getRoleQualifiersForPrincipalCache( String key ) { | 
  |  142 |    0 |                    MaxAgeSoftReference<List<AttributeSet>> qualifiersRef = roleQualifiersForPrincipalCache.get( key );  | 
  |  143 |    0 |                    if ( qualifiersRef != null ) { | 
  |  144 |    0 |                            return qualifiersRef.get();  | 
  |  145 |     | 
                   }  | 
  |  146 |    0 |                    return null;  | 
  |  147 |     | 
           }  | 
  |  148 |     | 
             | 
  |  149 |     | 
           protected Boolean getPrincipalHasRoleCacheCache( String key ) { | 
  |  150 |    0 |                    MaxAgeSoftReference<Boolean> hasRoleRef = principalHasRoleCache.get( key );  | 
  |  151 |    0 |                    if ( hasRoleRef != null ) { | 
  |  152 |    0 |                            return hasRoleRef.get();  | 
  |  153 |     | 
                   }  | 
  |  154 |    0 |                    return null;  | 
  |  155 |     | 
           }  | 
  |  156 |     | 
             | 
  |  157 |     | 
           protected void addRoleToCaches( KimRoleInfo role ) { | 
  |  158 |    0 |                    if ( role != null ) { | 
  |  159 |    0 |                            roleByNameCache.put( role.getNamespaceCode() + "-" + role.getRoleName(), new MaxAgeSoftReference<KimRoleInfo>( roleCacheMaxAgeSeconds, role ) );  | 
  |  160 |    0 |                            roleByIdCache.put( role.getRoleId(), new MaxAgeSoftReference<KimRoleInfo>( roleCacheMaxAgeSeconds, role ) );  | 
  |  161 |     | 
                   }  | 
  |  162 |    0 |            }  | 
  |  163 |     | 
     | 
  |  164 |     | 
           protected void addRoleMembersWithDelegationToCache( String key, List<RoleMembershipInfo> members ) { | 
  |  165 |    0 |                    if ( members != null ) { | 
  |  166 |    0 |                            roleMembersWithDelegationCache.put( key, new MaxAgeSoftReference<List<RoleMembershipInfo>>( roleCacheMaxAgeSeconds, members ) );  | 
  |  167 |     | 
                   }  | 
  |  168 |    0 |            }  | 
  |  169 |     | 
     | 
  |  170 |     | 
           protected void addRoleQualifiersForPrincipalToCache( String key, List<AttributeSet> qualifiers ) { | 
  |  171 |    0 |                    if ( qualifiers != null ) { | 
  |  172 |    0 |                            roleQualifiersForPrincipalCache.put( key, new MaxAgeSoftReference<List<AttributeSet>>( roleCacheMaxAgeSeconds, qualifiers ) );  | 
  |  173 |     | 
                   }  | 
  |  174 |    0 |            }  | 
  |  175 |     | 
             | 
  |  176 |     | 
           protected void addPrincipalHasRoleToCache( String key, boolean hasRole ) { | 
  |  177 |    0 |                    principalHasRoleCache.put( key, new MaxAgeSoftReference<Boolean>( roleCacheMaxAgeSeconds, hasRole ) );  | 
  |  178 |    0 |            }  | 
  |  179 |     | 
                     | 
  |  180 |     | 
             | 
  |  181 |     | 
     | 
  |  182 |     | 
           protected Collection<String> getRoleMemberPrincipalIdsCache(String key) { | 
  |  183 |    0 |                    MaxAgeSoftReference<Collection<String>> memberPrincipalIdsRef = memberPrincipalIdsCache.get(key);  | 
  |  184 |    0 |                    if ( memberPrincipalIdsRef != null ) { | 
  |  185 |    0 |                            return memberPrincipalIdsRef.get();  | 
  |  186 |     | 
                   }  | 
  |  187 |    0 |                    return null;  | 
  |  188 |     | 
           }  | 
  |  189 |     | 
             | 
  |  190 |     | 
           protected void addRoleMemberPrincipalIdsToCache(String key, Collection<String> principalIds) { | 
  |  191 |    0 |                    memberPrincipalIdsCache.put(key, new MaxAgeSoftReference<Collection<String>>(roleCacheMaxAgeSeconds, principalIds ));  | 
  |  192 |    0 |            }  | 
  |  193 |     | 
             | 
  |  194 |     | 
             | 
  |  195 |     | 
     | 
  |  196 |     | 
     | 
  |  197 |     | 
           public Collection<String> getRoleMemberPrincipalIds(String namespaceCode, String roleName, AttributeSet qualification) { | 
  |  198 |    0 |                    StringBuffer cacheKey = new StringBuffer();  | 
  |  199 |    0 |                    cacheKey.append( namespaceCode ).append( '/' ).append( roleName );  | 
  |  200 |    0 |                    addAttributesToKey(cacheKey, qualification);  | 
  |  201 |    0 |                    String key = cacheKey.toString();  | 
  |  202 |    0 |                    Collection<String> principalIds = getRoleMemberPrincipalIdsCache(key);  | 
  |  203 |    0 |                    if (principalIds != null) { | 
  |  204 |    0 |                            return principalIds;  | 
  |  205 |     | 
                   }  | 
  |  206 |    0 |                    principalIds = getRoleService().getRoleMemberPrincipalIds(namespaceCode, roleName, qualification);  | 
  |  207 |    0 |                    addRoleMemberPrincipalIdsToCache(key, principalIds);  | 
  |  208 |    0 |                    return principalIds;  | 
  |  209 |     | 
           }  | 
  |  210 |     | 
     | 
  |  211 |     | 
             | 
  |  212 |     | 
     | 
  |  213 |     | 
     | 
  |  214 |     | 
           public KimRoleInfo getRole(String roleId) { | 
  |  215 |    0 |                    KimRoleInfo role = getRoleByIdCache(roleId);  | 
  |  216 |    0 |                    if (role != null) { | 
  |  217 |    0 |                            return role;  | 
  |  218 |     | 
                   }  | 
  |  219 |    0 |                    role = getRoleService().getRole(roleId);  | 
  |  220 |    0 |                    addRoleToCaches(role);  | 
  |  221 |    0 |                return role;  | 
  |  222 |     | 
           }  | 
  |  223 |     | 
     | 
  |  224 |     | 
             | 
  |  225 |     | 
     | 
  |  226 |     | 
     | 
  |  227 |     | 
           public KimRoleInfo getRoleByName(String namespaceCode, String roleName) { | 
  |  228 |    0 |                    KimRoleInfo role = getRoleByNameCache(namespaceCode + "-" + roleName);  | 
  |  229 |    0 |                    if (role != null) { | 
  |  230 |    0 |                            return role;  | 
  |  231 |     | 
                   }  | 
  |  232 |    0 |                    role = getRoleService().getRoleByName(namespaceCode, roleName);  | 
  |  233 |    0 |                    addRoleToCaches(role);  | 
  |  234 |    0 |                return role;  | 
  |  235 |     | 
           }  | 
  |  236 |     | 
     | 
  |  237 |     | 
             | 
  |  238 |     | 
     | 
  |  239 |     | 
     | 
  |  240 |     | 
           public String getRoleIdByName(String namespaceCode, String roleName) { | 
  |  241 |    0 |                    KimRoleInfo role = getRoleByName( namespaceCode, roleName );  | 
  |  242 |    0 |                    if ( role == null ) { | 
  |  243 |    0 |                            return null;  | 
  |  244 |     | 
                   }  | 
  |  245 |    0 |                    return role.getRoleId();  | 
  |  246 |     | 
           }  | 
  |  247 |     | 
                     | 
  |  248 |     | 
             | 
  |  249 |     | 
     | 
  |  250 |     | 
     | 
  |  251 |     | 
           public List<KimRoleInfo> getRoles(List<String> roleIds) { | 
  |  252 |    0 |                    return getRoleService().getRoles(roleIds);  | 
  |  253 |     | 
           }  | 
  |  254 |     | 
     | 
  |  255 |     | 
           protected void addIdsToKey( StringBuffer key, List<String> idList ) { | 
  |  256 |    0 |                    if ( idList == null || idList.isEmpty() ) { | 
  |  257 |    0 |                            key.append( "[null]" );  | 
  |  258 |     | 
                   } else { | 
  |  259 |    0 |                            for ( String id : idList ) { | 
  |  260 |    0 |                                    key.append( '|' ).append( id ).append( '|' );  | 
  |  261 |     | 
                           }  | 
  |  262 |     | 
                   }  | 
  |  263 |    0 |            }  | 
  |  264 |     | 
             | 
  |  265 |     | 
           protected void addAttributesToKey( StringBuffer key, AttributeSet attributes ) { | 
  |  266 |    0 |                    if ( attributes == null || attributes.isEmpty() ) { | 
  |  267 |    0 |                            key.append( "[null]" );  | 
  |  268 |     | 
                   } else { | 
  |  269 |    0 |                            for (Map.Entry<String, String> entry : attributes.entrySet()) { | 
  |  270 |    0 |                                    key.append( entry.getKey() ).append( '=' ).append( entry.getValue() ).append( '|' );  | 
  |  271 |     | 
                           }  | 
  |  272 |     | 
                   }  | 
  |  273 |    0 |            }  | 
  |  274 |     | 
     | 
  |  275 |     | 
             | 
  |  276 |     | 
     | 
  |  277 |     | 
     | 
  |  278 |     | 
           public List<RoleMembershipInfo> getRoleMembers(List<String> roleIds, AttributeSet qualification) { | 
  |  279 |    0 |                    List<String>[] filteredRoles = filterRoleIdsByCachingAbility(roleIds);  | 
  |  280 |    0 |                    List<String> cacheRoles = filteredRoles[0];  | 
  |  281 |    0 |                    List<String> noCacheRoles = filteredRoles[1];  | 
  |  282 |     | 
                     | 
  |  283 |    0 |                    List<RoleMembershipInfo> members = null;  | 
  |  284 |    0 |                    String key = null;  | 
  |  285 |     | 
                     | 
  |  286 |    0 |                    if (!cacheRoles.isEmpty()) { | 
  |  287 |    0 |                            StringBuffer cacheKey = new StringBuffer();  | 
  |  288 |    0 |                            addIdsToKey( cacheKey, cacheRoles );  | 
  |  289 |    0 |                            cacheKey.append(  '/' );  | 
  |  290 |    0 |                            addAttributesToKey( cacheKey, qualification );  | 
  |  291 |    0 |                            key = cacheKey.toString();  | 
  |  292 |    0 |                            members = getRoleMembersWithDelegationCache(key);  | 
  |  293 |     | 
                   }  | 
  |  294 |    0 |                    if (members != null) { | 
  |  295 |    0 |                            if (!noCacheRoles.isEmpty()) { | 
  |  296 |    0 |                                    members.addAll(getRoleService().getRoleMembers(noCacheRoles, qualification));  | 
  |  297 |     | 
                           }  | 
  |  298 |    0 |                            return members;  | 
  |  299 |     | 
                   }  | 
  |  300 |     | 
                     | 
  |  301 |    0 |                    if (!cacheRoles.isEmpty()) { | 
  |  302 |    0 |                            members = getRoleService().getRoleMembers(cacheRoles, qualification);  | 
  |  303 |    0 |                            addRoleMembersWithDelegationToCache(key, members);  | 
  |  304 |     | 
                   } else { | 
  |  305 |    0 |                            members = new ArrayList<RoleMembershipInfo>();  | 
  |  306 |     | 
                   }  | 
  |  307 |    0 |                    if (!noCacheRoles.isEmpty()) { | 
  |  308 |    0 |                            members.addAll(getRoleService().getRoleMembers(noCacheRoles, qualification));  | 
  |  309 |     | 
                   }  | 
  |  310 |    0 |                return members;  | 
  |  311 |     | 
       }  | 
  |  312 |     | 
     | 
  |  313 |     | 
             | 
  |  314 |     | 
     | 
  |  315 |     | 
     | 
  |  316 |     | 
           public List<AttributeSet> getRoleQualifiersForPrincipal(String principalId, List<String> roleIds, AttributeSet qualification) {                 | 
  |  317 |    0 |                    StringBuffer cacheKey = new StringBuffer( principalId );  | 
  |  318 |    0 |                    cacheKey.append( '/' );  | 
  |  319 |    0 |                    addIdsToKey( cacheKey, roleIds );  | 
  |  320 |    0 |                    cacheKey.append(  '/' );  | 
  |  321 |    0 |                    addAttributesToKey( cacheKey, qualification );  | 
  |  322 |    0 |                    String key = cacheKey.toString();  | 
  |  323 |    0 |                    List<AttributeSet> qualifiers = getRoleQualifiersForPrincipalCache(key);  | 
  |  324 |    0 |                    if (qualifiers != null) { | 
  |  325 |    0 |                            return qualifiers;  | 
  |  326 |     | 
                   }  | 
  |  327 |    0 |                    qualifiers = getRoleService().getRoleQualifiersForPrincipal(principalId, roleIds, qualification);  | 
  |  328 |    0 |                    addRoleQualifiersForPrincipalToCache(key, qualifiers);  | 
  |  329 |    0 |                return qualifiers;  | 
  |  330 |     | 
           }  | 
  |  331 |     | 
     | 
  |  332 |     | 
             | 
  |  333 |     | 
     | 
  |  334 |     | 
     | 
  |  335 |     | 
           public List<AttributeSet> getRoleQualifiersForPrincipal(String principalId, String namespaceCode, String roleName, AttributeSet qualification) { | 
  |  336 |    0 |                    StringBuffer cacheKey = new StringBuffer( principalId );  | 
  |  337 |    0 |                    cacheKey.append( '/' );  | 
  |  338 |    0 |                    cacheKey.append( namespaceCode ).append( '-' ).append( roleName );  | 
  |  339 |    0 |                    cacheKey.append( '/' );  | 
  |  340 |    0 |                    addAttributesToKey( cacheKey, qualification );  | 
  |  341 |    0 |                    String key = cacheKey.toString();  | 
  |  342 |    0 |                    List<AttributeSet> qualifiers = getRoleQualifiersForPrincipalCache(key);  | 
  |  343 |    0 |                    if (qualifiers != null) { | 
  |  344 |    0 |                            return qualifiers;  | 
  |  345 |     | 
                   }  | 
  |  346 |    0 |                    qualifiers = getRoleService().getRoleQualifiersForPrincipal(principalId, namespaceCode, roleName, qualification);  | 
  |  347 |    0 |                    addRoleQualifiersForPrincipalToCache(key, qualifiers);  | 
  |  348 |    0 |                return qualifiers;  | 
  |  349 |     | 
           }  | 
  |  350 |     | 
     | 
  |  351 |     | 
           public boolean isRoleActive(String roleId) { | 
  |  352 |    0 |                    KimRoleInfo role = getRole( roleId );  | 
  |  353 |    0 |                    return role != null && role.isActive();  | 
  |  354 |     | 
           }  | 
  |  355 |     | 
     | 
  |  356 |     | 
           public boolean principalHasRole(String principalId, List<String> roleIds, AttributeSet qualification) { | 
  |  357 |    0 |                    if ( LOG.isDebugEnabled() ) { | 
  |  358 |    0 |                            logPrincipalHasRoleCheck(principalId, roleIds, qualification);  | 
  |  359 |     | 
                   }  | 
  |  360 |    0 |                    List<String>[] filteredRoles = filterRoleIdsByCachingAbility(roleIds);  | 
  |  361 |    0 |                    List<String> cacheRoles = filteredRoles[0];  | 
  |  362 |    0 |                    List<String> noCacheRoles = filteredRoles[1];  | 
  |  363 |     | 
                     | 
  |  364 |    0 |                    Boolean hasRole = null;  | 
  |  365 |    0 |                    String key = null;  | 
  |  366 |    0 |                    if (!cacheRoles.isEmpty()) { | 
  |  367 |    0 |                            StringBuffer cacheKey = new StringBuffer();  | 
  |  368 |    0 |                            cacheKey.append( principalId );  | 
  |  369 |    0 |                            cacheKey.append( '/' );  | 
  |  370 |    0 |                            addIdsToKey( cacheKey, cacheRoles );  | 
  |  371 |    0 |                            cacheKey.append( '/' );  | 
  |  372 |    0 |                            addAttributesToKey( cacheKey, qualification );  | 
  |  373 |    0 |                            key = cacheKey.toString();  | 
  |  374 |    0 |                            hasRole = getPrincipalHasRoleCacheCache(key);  | 
  |  375 |     | 
                   }  | 
  |  376 |    0 |                    if (hasRole == null || !hasRole.booleanValue()) { | 
  |  377 |    0 |                            if (!cacheRoles.isEmpty()) { | 
  |  378 |    0 |                                    hasRole = getRoleService().principalHasRole(principalId, cacheRoles, qualification);  | 
  |  379 |    0 |                                    addPrincipalHasRoleToCache(key, hasRole);  | 
  |  380 |     | 
                           }  | 
  |  381 |    0 |                            if ((hasRole == null || !hasRole.booleanValue()) && !noCacheRoles.isEmpty()) { | 
  |  382 |    0 |                                    hasRole = getRoleService().principalHasRole(principalId, noCacheRoles, qualification);  | 
  |  383 |     | 
                           }  | 
  |  384 |    0 |                        if ( LOG.isDebugEnabled() ) { | 
  |  385 |    0 |                                LOG.debug( "Result: " + hasRole );  | 
  |  386 |     | 
                       }  | 
  |  387 |     | 
                   } else { | 
  |  388 |    0 |                            if ( LOG.isDebugEnabled() ) { | 
  |  389 |    0 |                                    LOG.debug( "Result Found in cache using key: " + key + "\nResult: " + hasRole );  | 
  |  390 |     | 
                           }  | 
  |  391 |     | 
                   }  | 
  |  392 |    0 |                return hasRole;  | 
  |  393 |     | 
           }  | 
  |  394 |     | 
             | 
  |  395 |     | 
             | 
  |  396 |     | 
     | 
  |  397 |     | 
     | 
  |  398 |     | 
     | 
  |  399 |     | 
     | 
  |  400 |     | 
     | 
  |  401 |     | 
           protected boolean shouldCacheRole(String roleId) { | 
  |  402 |    0 |                    Boolean shouldCacheRoleAnswer = shouldCacheRoleCache.get(roleId);  | 
  |  403 |    0 |                    if (shouldCacheRoleAnswer == null) { | 
  |  404 |     | 
                     | 
  |  405 |    0 |                            final KimRoleTypeService roleType = getRoleTypeService(roleId);  | 
  |  406 |    0 |                            final KimRoleInfo roleInfo = this.getRole(roleId);  | 
  |  407 |    0 |                            if (roleType != null && roleInfo != null) { | 
  |  408 |     | 
                               try { | 
  |  409 |    0 |                                    shouldCacheRoleAnswer = new Boolean(roleType.shouldCacheRoleMembershipResults(roleInfo.getNamespaceCode(), roleInfo.getRoleName()));  | 
  |  410 |    0 |                                    shouldCacheRoleCache.put(roleId, shouldCacheRoleAnswer);  | 
  |  411 |    0 |                                } catch (Exception e) { | 
  |  412 |    0 |                                    LOG.warn("Unable to connect to remote service for roleType " + roleInfo.getNamespaceCode() + "-" + roleInfo.getRoleName()); | 
  |  413 |    0 |                        LOG.warn(e.getMessage());  | 
  |  414 |    0 |                                    return Boolean.FALSE;  | 
  |  415 |    0 |                                }  | 
  |  416 |     | 
                           } else { | 
  |  417 |    0 |                                    shouldCacheRoleAnswer = Boolean.TRUE;   | 
  |  418 |    0 |                                    shouldCacheRoleCache.put(roleId, shouldCacheRoleAnswer);  | 
  |  419 |     | 
                           }  | 
  |  420 |     | 
                   }  | 
  |  421 |    0 |                    return shouldCacheRoleAnswer.booleanValue();  | 
  |  422 |     | 
           }  | 
  |  423 |     | 
             | 
  |  424 |     | 
             | 
  |  425 |     | 
     | 
  |  426 |     | 
     | 
  |  427 |     | 
     | 
  |  428 |     | 
     | 
  |  429 |     | 
     | 
  |  430 |     | 
     | 
  |  431 |     | 
           @SuppressWarnings("unchecked") | 
  |  432 |     | 
           protected List<String>[] filterRoleIdsByCachingAbility(List<String> roleIds) { | 
  |  433 |    0 |                    List<String> cacheRoles = new ArrayList<String>();  | 
  |  434 |    0 |                    List<String> noCacheRoles = new ArrayList<String>();  | 
  |  435 |    0 |                    Set<String> alreadyFilteredRoles = new HashSet<String>();  | 
  |  436 |     | 
                     | 
  |  437 |    0 |                    for (String roleId : roleIds) { | 
  |  438 |    0 |                            if (!alreadyFilteredRoles.contains(roleId)) { | 
  |  439 |    0 |                                    alreadyFilteredRoles.add(roleId);  | 
  |  440 |    0 |                                    if (shouldCacheRole(roleId)) { | 
  |  441 |    0 |                                            cacheRoles.add(roleId);  | 
  |  442 |     | 
                                   } else { | 
  |  443 |    0 |                                            noCacheRoles.add(roleId);  | 
  |  444 |     | 
                                   }  | 
  |  445 |     | 
                           }  | 
  |  446 |     | 
                   }  | 
  |  447 |    0 |                    return (List<String>[])new List[] { cacheRoles, noCacheRoles }; | 
  |  448 |     | 
           }  | 
  |  449 |     | 
             | 
  |  450 |     | 
             | 
  |  451 |     | 
     | 
  |  452 |     | 
     | 
  |  453 |     | 
     | 
  |  454 |     | 
     | 
  |  455 |     | 
     | 
  |  456 |     | 
       protected KimRoleTypeService getRoleTypeService( String roleId ) { | 
  |  457 |    0 |                KimRoleTypeService service = null;  | 
  |  458 |     | 
                         | 
  |  459 |    0 |                final KimRoleInfo roleInfo = getRoleService().getRole(roleId);  | 
  |  460 |    0 |                if (roleInfo != null) { | 
  |  461 |    0 |                        final KimTypeInfo roleType = getTypeInfoService().getKimType(roleInfo.getKimTypeId());  | 
  |  462 |    0 |                        if ( roleType != null ) { | 
  |  463 |    0 |                            service = getRoleTypeService(roleType);  | 
  |  464 |     | 
                       }  | 
  |  465 |     | 
               }  | 
  |  466 |    0 |                return service;  | 
  |  467 |     | 
       }  | 
  |  468 |     | 
     | 
  |  469 |     | 
             | 
  |  470 |     | 
     | 
  |  471 |     | 
     | 
  |  472 |     | 
     | 
  |  473 |     | 
     | 
  |  474 |     | 
     | 
  |  475 |     | 
           protected KimRoleTypeService getRoleTypeService( KimTypeInfo typeInfo ) { | 
  |  476 |    0 |                    String serviceName = typeInfo.getKimTypeServiceName();  | 
  |  477 |    0 |                    if ( serviceName != null ) { | 
  |  478 |     | 
                           try { | 
  |  479 |    0 |                                    KimTypeService service = (KimTypeService) KIMServiceLocatorInternal.getService(serviceName);  | 
  |  480 |    0 |                                    if ( service != null && service instanceof KimRoleTypeService) { | 
  |  481 |    0 |                                            return (KimRoleTypeService)service;  | 
  |  482 |     | 
                                   } else { | 
  |  483 |    0 |                                            return (KimRoleTypeService) KIMServiceLocatorInternal.getService("kimNoMembersRoleTypeService"); | 
  |  484 |     | 
                                   }  | 
  |  485 |    0 |                            } catch ( Exception ex ) { | 
  |  486 |    0 |                                    LOG.error( "Unable to find role type service with name: " + serviceName );  | 
  |  487 |    0 |                                    LOG.error( ex.getClass().getName() + " : " + ex.getMessage() );  | 
  |  488 |    0 |                                    return (KimRoleTypeService) KIMServiceLocatorInternal.getService("kimNoMembersRoleTypeService"); | 
  |  489 |     | 
                           }  | 
  |  490 |     | 
                   }  | 
  |  491 |    0 |                    return null;  | 
  |  492 |     | 
           }  | 
  |  493 |     | 
     | 
  |  494 |     | 
             | 
  |  495 |     | 
     | 
  |  496 |     | 
     | 
  |  497 |     | 
           public List<String> getPrincipalIdSubListWithRole(  | 
  |  498 |     | 
                           List<String> principalIds, String roleNamespaceCode,  | 
  |  499 |     | 
                           String roleName, AttributeSet qualification) { | 
  |  500 |    0 |                    return getRoleService().getPrincipalIdSubListWithRole(principalIds,  | 
  |  501 |     | 
                                   roleNamespaceCode, roleName, qualification);  | 
  |  502 |     | 
           }  | 
  |  503 |     | 
     | 
  |  504 |     | 
             | 
  |  505 |     | 
     | 
  |  506 |     | 
             | 
  |  507 |     | 
             | 
  |  508 |     | 
           public void removeCacheEntries( String roleId, String principalId ) { | 
  |  509 |    0 |                    if ( principalId != null ) { | 
  |  510 |    0 |                            String keyPrefix = principalId + "-";  | 
  |  511 |    0 |                            synchronized ( principalHasRoleCache ) { | 
  |  512 |    0 |                                    Iterator<String> cacheIterator = principalHasRoleCache.keySet().iterator();  | 
  |  513 |    0 |                                    while ( cacheIterator.hasNext() ) { | 
  |  514 |    0 |                                            String cacheKey = cacheIterator.next();  | 
  |  515 |    0 |                                            if ( cacheKey.startsWith( keyPrefix ) ) { | 
  |  516 |    0 |                                                    cacheIterator.remove();  | 
  |  517 |     | 
                                           }  | 
  |  518 |    0 |                                    }  | 
  |  519 |    0 |                            }  | 
  |  520 |    0 |                            synchronized ( roleQualifiersForPrincipalCache ) { | 
  |  521 |    0 |                                    Iterator<String> cacheIterator = roleQualifiersForPrincipalCache.keySet().iterator();  | 
  |  522 |    0 |                                    while ( cacheIterator.hasNext() ) { | 
  |  523 |    0 |                                            String cacheKey = cacheIterator.next();  | 
  |  524 |    0 |                                            if ( cacheKey.startsWith( keyPrefix ) ) { | 
  |  525 |    0 |                                                    cacheIterator.remove();  | 
  |  526 |     | 
                                           }  | 
  |  527 |    0 |                                    }  | 
  |  528 |    0 |                            }  | 
  |  529 |     | 
                   }  | 
  |  530 |    0 |                    if ( roleId != null ) { | 
  |  531 |    0 |                            roleByIdCache.remove( roleId );  | 
  |  532 |    0 |                            roleByNameCache.clear();  | 
  |  533 |    0 |                            String keySubstring = "|" + roleId + "|";  | 
  |  534 |    0 |                            synchronized ( principalHasRoleCache ) { | 
  |  535 |    0 |                                    Iterator<String> cacheIterator = principalHasRoleCache.keySet().iterator();  | 
  |  536 |    0 |                                    while ( cacheIterator.hasNext() ) { | 
  |  537 |    0 |                                            String cacheKey = cacheIterator.next();  | 
  |  538 |    0 |                                            if( cacheKey.contains( keySubstring ) ) { | 
  |  539 |    0 |                                                    cacheIterator.remove();  | 
  |  540 |     | 
                                           }  | 
  |  541 |    0 |                                    }  | 
  |  542 |    0 |                            }  | 
  |  543 |    0 |                            synchronized ( roleQualifiersForPrincipalCache ) { | 
  |  544 |    0 |                                    Iterator<String> cacheIterator = roleQualifiersForPrincipalCache.keySet().iterator();  | 
  |  545 |    0 |                                    while ( cacheIterator.hasNext() ) { | 
  |  546 |    0 |                                            String cacheKey = cacheIterator.next();  | 
  |  547 |    0 |                                            if( cacheKey.contains( keySubstring ) ) { | 
  |  548 |    0 |                                                    cacheIterator.remove();  | 
  |  549 |     | 
                                           }  | 
  |  550 |    0 |                                    }  | 
  |  551 |    0 |                            }  | 
  |  552 |    0 |                            synchronized ( roleMembersWithDelegationCache ) { | 
  |  553 |    0 |                                    Iterator<String> cacheIterator = roleMembersWithDelegationCache.keySet().iterator();  | 
  |  554 |    0 |                                    while ( cacheIterator.hasNext() ) { | 
  |  555 |    0 |                                            String cacheKey = cacheIterator.next();  | 
  |  556 |    0 |                                            if( cacheKey.contains( keySubstring ) ) { | 
  |  557 |    0 |                                                    cacheIterator.remove();  | 
  |  558 |     | 
                                           }  | 
  |  559 |    0 |                                    }  | 
  |  560 |    0 |                            }  | 
  |  561 |    0 |                            synchronized ( memberPrincipalIdsCache ) { | 
  |  562 |    0 |                                    Iterator<String> cacheIterator = memberPrincipalIdsCache.keySet().iterator();  | 
  |  563 |    0 |                                    while ( cacheIterator.hasNext() ) { | 
  |  564 |    0 |                                            String cacheKey = cacheIterator.next();  | 
  |  565 |    0 |                                            if( cacheKey.contains( keySubstring ) ) { | 
  |  566 |    0 |                                                    cacheIterator.remove();  | 
  |  567 |     | 
                                           }  | 
  |  568 |    0 |                                    }  | 
  |  569 |    0 |                            }  | 
  |  570 |    0 |                            shouldCacheRoleCache.remove(roleId);  | 
  |  571 |     | 
                   }  | 
  |  572 |    0 |            }  | 
  |  573 |     | 
             | 
  |  574 |     | 
             | 
  |  575 |     | 
     | 
  |  576 |     | 
     | 
  |  577 |     | 
           public List<AttributeSet> getRoleQualifiersForPrincipalIncludingNested(  | 
  |  578 |     | 
                           String principalId, List<String> roleIds, AttributeSet qualification) { | 
  |  579 |    0 |                    return getRoleService().getRoleQualifiersForPrincipalIncludingNested(principalId, roleIds, qualification);  | 
  |  580 |     | 
           }  | 
  |  581 |     | 
             | 
  |  582 |     | 
             | 
  |  583 |     | 
     | 
  |  584 |     | 
     | 
  |  585 |     | 
           public List<AttributeSet> getRoleQualifiersForPrincipalIncludingNested(  | 
  |  586 |     | 
                           String principalId, String namespaceCode, String roleName,  | 
  |  587 |     | 
                           AttributeSet qualification) { | 
  |  588 |    0 |                    return getRoleService().getRoleQualifiersForPrincipalIncludingNested(principalId, namespaceCode, roleName, qualification);  | 
  |  589 |     | 
           }  | 
  |  590 |     | 
             | 
  |  591 |     | 
           public void assignGroupToRole(String groupId, String namespaceCode, String roleName,  | 
  |  592 |     | 
                           AttributeSet qualifications) { | 
  |  593 |    0 |                    getRoleUpdateService().assignGroupToRole( groupId, namespaceCode, roleName, qualifications );  | 
  |  594 |    0 |                    KimRoleInfo role = getRoleByName( namespaceCode, roleName );  | 
  |  595 |    0 |                    removeCacheEntries( role.getRoleId(), null );  | 
  |  596 |    0 |            }  | 
  |  597 |     | 
     | 
  |  598 |     | 
           public void assignPrincipalToRole(String principalId, String namespaceCode, String roleName,  | 
  |  599 |     | 
                           AttributeSet qualifications) { | 
  |  600 |    0 |                    KimRoleInfo role = getRoleByName( namespaceCode, roleName );  | 
  |  601 |    0 |                    getRoleUpdateService().assignPrincipalToRole( principalId, namespaceCode, roleName, qualifications );  | 
  |  602 |    0 |                    removeCacheEntries( role.getRoleId(), principalId );  | 
  |  603 |    0 |            }  | 
  |  604 |     | 
     | 
  |  605 |     | 
           public void removeGroupFromRole(String groupId, String namespaceCode, String roleName,  | 
  |  606 |     | 
                           AttributeSet qualifications) { | 
  |  607 |    0 |                    getRoleUpdateService().removeGroupFromRole( groupId, namespaceCode, roleName, qualifications );  | 
  |  608 |    0 |                    KimRoleInfo role = getRoleByName( namespaceCode, roleName );  | 
  |  609 |    0 |                    removeCacheEntries( role.getRoleId(), null );  | 
  |  610 |    0 |            }  | 
  |  611 |     | 
     | 
  |  612 |     | 
           public void removePrincipalFromRole(String principalId, String namespaceCode, String roleName,  | 
  |  613 |     | 
                           AttributeSet qualifications) { | 
  |  614 |    0 |                    KimRoleInfo role = getRoleByName( namespaceCode, roleName );  | 
  |  615 |    0 |                    getRoleUpdateService().removePrincipalFromRole( principalId, namespaceCode, roleName, qualifications );  | 
  |  616 |    0 |                    removeCacheEntries( role.getRoleId(), principalId );  | 
  |  617 |    0 |            }  | 
  |  618 |     | 
     | 
  |  619 |     | 
             | 
  |  620 |     | 
     | 
  |  621 |     | 
     | 
  |  622 |     | 
           public List<? extends Role> getRolesSearchResults(  | 
  |  623 |     | 
                           Map<String, String> fieldValues) { | 
  |  624 |    0 |                    return getRoleService().getRolesSearchResults(fieldValues);  | 
  |  625 |     | 
           }  | 
  |  626 |     | 
     | 
  |  627 |     | 
       protected void logPrincipalHasRoleCheck(String principalId, List<String> roleIds, AttributeSet roleQualifiers ) { | 
  |  628 |    0 |                    StringBuilder sb = new StringBuilder();  | 
  |  629 |    0 |                    sb.append(  '\n' );  | 
  |  630 |    0 |                    sb.append( "Has Role     : " ).append( roleIds ).append( '\n' );  | 
  |  631 |    0 |                    if ( roleIds != null ) { | 
  |  632 |    0 |                            for ( String roleId : roleIds ) { | 
  |  633 |    0 |                                    KimRoleInfo role = getRole( roleId );  | 
  |  634 |    0 |                                    if ( role != null ) { | 
  |  635 |    0 |                                            sb.append( "        Name : " ).append( role.getNamespaceCode() ).append( '/').append( role.getRoleName() );  | 
  |  636 |    0 |                                            sb.append( " (" ).append( roleId ).append( ')' ); | 
  |  637 |    0 |                                            sb.append( '\n' );  | 
  |  638 |     | 
                                   }  | 
  |  639 |    0 |                            }  | 
  |  640 |     | 
                   }  | 
  |  641 |    0 |                    sb.append( "   Principal : " ).append( principalId );  | 
  |  642 |    0 |                    if ( principalId != null ) { | 
  |  643 |    0 |                            KimPrincipal principal = KIMServiceLocator.getIdentityManagementService().getPrincipal( principalId );  | 
  |  644 |    0 |                            if ( principal != null ) { | 
  |  645 |    0 |                                    sb.append( " (" ).append( principal.getPrincipalName() ).append( ')' ); | 
  |  646 |     | 
                           }  | 
  |  647 |     | 
                   }  | 
  |  648 |    0 |                    sb.append( '\n' );  | 
  |  649 |    0 |                    sb.append( "     Details :\n" );  | 
  |  650 |    0 |                    if ( roleQualifiers != null ) { | 
  |  651 |    0 |                            sb.append( roleQualifiers.formattedDump( 15 ) );  | 
  |  652 |     | 
                   } else { | 
  |  653 |    0 |                            sb.append( "               [null]\n" );  | 
  |  654 |     | 
                   }  | 
  |  655 |    0 |                    if (LOG.isTraceEnabled()) {  | 
  |  656 |    0 |                            LOG.trace( sb.append(ExceptionUtils.getStackTrace(new Throwable())));  | 
  |  657 |     | 
                   } else { | 
  |  658 |    0 |                            LOG.debug(sb.toString());  | 
  |  659 |     | 
                   }  | 
  |  660 |    0 |        }  | 
  |  661 |     | 
     | 
  |  662 |     | 
         | 
  |  663 |     | 
     | 
  |  664 |     | 
     | 
  |  665 |     | 
       public void principalInactivated(String principalId) { | 
  |  666 |    0 |                getRoleService().principalInactivated(principalId);      | 
  |  667 |    0 |                removeCacheEntries(null, principalId);  | 
  |  668 |    0 |        }  | 
  |  669 |     | 
         | 
  |  670 |     | 
         | 
  |  671 |     | 
     | 
  |  672 |     | 
     | 
  |  673 |     | 
       public void roleInactivated(String roleId) { | 
  |  674 |    0 |                getRoleService().roleInactivated(roleId);      | 
  |  675 |    0 |                removeCacheEntries(roleId, null);  | 
  |  676 |    0 |        }  | 
  |  677 |     | 
         | 
  |  678 |     | 
         | 
  |  679 |     | 
     | 
  |  680 |     | 
     | 
  |  681 |     | 
       public void groupInactivated(String groupId) { | 
  |  682 |    0 |                getRoleService().groupInactivated(groupId);      | 
  |  683 |    0 |        }  | 
  |  684 |     | 
     | 
  |  685 |     | 
       public List<RoleMembershipInfo> getFirstLevelRoleMembers(List<String> roleIds){ | 
  |  686 |    0 |                return getRoleService().getFirstLevelRoleMembers(roleIds);  | 
  |  687 |     | 
       }  | 
  |  688 |     | 
     | 
  |  689 |     | 
       public List<RoleMembershipInfo> findRoleMembers(Map<String, String> fieldValues){ | 
  |  690 |    0 |                return getRoleService().findRoleMembers(fieldValues);  | 
  |  691 |     | 
       }  | 
  |  692 |     | 
     | 
  |  693 |     | 
           public void assignRoleToRole(String roleId, String namespaceCode, String roleName,  | 
  |  694 |     | 
                           AttributeSet qualifications) { | 
  |  695 |    0 |                    getRoleUpdateService().assignRoleToRole(   | 
  |  696 |     | 
                                   roleId, namespaceCode, roleName, qualifications);  | 
  |  697 |    0 |                    KimRoleInfo role = getRoleByName( namespaceCode, roleName );  | 
  |  698 |    0 |                    removeCacheEntries( role.getRoleId(), null );  | 
  |  699 |    0 |            }  | 
  |  700 |     | 
     | 
  |  701 |     | 
         | 
  |  702 |     | 
     | 
  |  703 |     | 
     | 
  |  704 |     | 
           public void saveDelegationMemberForRole(String delegationMemberId, String roleMemberId, String memberId, String memberTypeCode,   | 
  |  705 |     | 
                           String delegationTypeCode, String roleId, AttributeSet qualifications,   | 
  |  706 |     | 
                           Date activeFromDate, Date activeToDate) throws UnsupportedOperationException{ | 
  |  707 |    0 |                getRoleUpdateService().saveDelegationMemberForRole(delegationMemberId, roleMemberId, memberId, memberTypeCode, delegationTypeCode, roleId, qualifications, activeFromDate, activeToDate);  | 
  |  708 |    0 |                    KimRoleInfo role = getRole( roleId );  | 
  |  709 |    0 |                    removeCacheEntries( role.getRoleId(), null );  | 
  |  710 |    0 |        }  | 
  |  711 |     | 
     | 
  |  712 |     | 
       public RoleMemberCompleteInfo saveRoleMemberForRole(String roleMemberId, String memberId, String memberTypeCode,   | 
  |  713 |     | 
                       String roleId, AttributeSet qualifications, Date activeFromDate, Date activeToDate) throws UnsupportedOperationException{ | 
  |  714 |    0 |                    KimRoleInfo role = getRole( roleId );  | 
  |  715 |    0 |                    RoleMemberCompleteInfo roleMemberCompleteInfo = getRoleUpdateService().saveRoleMemberForRole(roleMemberId, memberId, memberTypeCode, roleId, qualifications, activeFromDate, activeToDate);  | 
  |  716 |    0 |                    removeCacheEntries( role.getRoleId(), memberId );  | 
  |  717 |    0 |                    return roleMemberCompleteInfo;  | 
  |  718 |     | 
       }  | 
  |  719 |     | 
         | 
  |  720 |     | 
           public void removeRoleFromRole(String roleId, String namespaceCode, String roleName,  | 
  |  721 |     | 
                           AttributeSet qualifications) { | 
  |  722 |    0 |                    getRoleUpdateService().removeRoleFromRole( roleId, namespaceCode, roleName, qualifications );  | 
  |  723 |    0 |                    KimRoleInfo role = getRoleByName( namespaceCode, roleName );  | 
  |  724 |    0 |                    removeCacheEntries( role.getRoleId(), null );  | 
  |  725 |    0 |            }  | 
  |  726 |     | 
     | 
  |  727 |     | 
       public List<RoleMemberCompleteInfo> findRoleMembersCompleteInfo(Map<String, String> fieldValues){ | 
  |  728 |    0 |                return getRoleService().findRoleMembersCompleteInfo(fieldValues);  | 
  |  729 |     | 
       }  | 
  |  730 |     | 
         | 
  |  731 |     | 
       public List<DelegateMemberCompleteInfo> findDelegateMembersCompleteInfo(Map<String, String> fieldValues){ | 
  |  732 |    0 |                return getRoleService().findDelegateMembersCompleteInfo(fieldValues);  | 
  |  733 |     | 
       }  | 
  |  734 |     | 
             | 
  |  735 |     | 
       public List<DelegateMemberCompleteInfo> getDelegationMembersByDelegationId(@WebParam(name="delegationId") String delegationId){ | 
  |  736 |    0 |                    return getRoleService().getDelegationMembersByDelegationId(delegationId);  | 
  |  737 |     | 
           }  | 
  |  738 |     | 
             | 
  |  739 |     | 
           public DelegateMemberCompleteInfo getDelegationMemberByDelegationAndMemberId(@WebParam(name="delegationId") String delegationId, @WebParam(name="memberId") String memberId){ | 
  |  740 |    0 |                    return getRoleService().getDelegationMemberByDelegationAndMemberId(delegationId, memberId);  | 
  |  741 |     | 
           }  | 
  |  742 |     | 
             | 
  |  743 |     | 
           public DelegateMemberCompleteInfo getDelegationMemberById(@WebParam(name="delegationMemberId") String delegationMemberId){ | 
  |  744 |    0 |                    return getRoleService().getDelegationMemberById(delegationMemberId);          | 
  |  745 |     | 
           }  | 
  |  746 |     | 
     | 
  |  747 |     | 
           public List<RoleResponsibilityActionInfo> getRoleMemberResponsibilityActionInfo(String roleMemberId){ | 
  |  748 |    0 |                    return getRoleService().getRoleMemberResponsibilityActionInfo(roleMemberId);  | 
  |  749 |     | 
           }  | 
  |  750 |     | 
             | 
  |  751 |     | 
           public DelegateTypeInfo getDelegateTypeInfo(String roleId, String delegationTypeCode){ | 
  |  752 |    0 |                    return getRoleService().getDelegateTypeInfo(roleId, delegationTypeCode);  | 
  |  753 |     | 
           }  | 
  |  754 |     | 
     | 
  |  755 |     | 
           public DelegateTypeInfo getDelegateTypeInfoById(String delegationId){ | 
  |  756 |    0 |                    return getRoleService().getDelegateTypeInfoById(delegationId);  | 
  |  757 |     | 
           }  | 
  |  758 |     | 
             | 
  |  759 |     | 
           public void saveRoleRspActions(String roleResponsibilityActionId, String roleId, String roleResponsibilityId, String roleMemberId,   | 
  |  760 |     | 
                           String actionTypeCode, String actionPolicyCode, Integer priorityNumber, Boolean forceAction){ | 
  |  761 |    0 |                getRoleUpdateService().saveRoleRspActions(roleResponsibilityActionId, roleId, roleResponsibilityId, roleMemberId, actionTypeCode, actionPolicyCode, priorityNumber, forceAction);  | 
  |  762 |    0 |                    removeCacheEntries(roleId, null);  | 
  |  763 |    0 |            }  | 
  |  764 |     | 
     | 
  |  765 |     | 
           public List<RoleResponsibilityInfo> getRoleResponsibilities(String roleId){ | 
  |  766 |    0 |                    return getRoleService().getRoleResponsibilities(roleId);  | 
  |  767 |     | 
           }  | 
  |  768 |     | 
             | 
  |  769 |     | 
           public void applicationRoleMembershipChanged(String roleId) { | 
  |  770 |    0 |                    removeCacheEntries(roleId, null);  | 
  |  771 |    0 |                    getRoleService().applicationRoleMembershipChanged(roleId);                  | 
  |  772 |    0 |            }  | 
  |  773 |     | 
             | 
  |  774 |     | 
             | 
  |  775 |     | 
             | 
  |  776 |     | 
           public RoleService getRoleService() { | 
  |  777 |    0 |                    if ( roleService == null ) { | 
  |  778 |    0 |                            roleService = KIMServiceLocator.getRoleService();  | 
  |  779 |     | 
                   }  | 
  |  780 |    0 |                    return roleService;  | 
  |  781 |     | 
           }  | 
  |  782 |     | 
             | 
  |  783 |     | 
           public KimTypeInfoService getTypeInfoService() { | 
  |  784 |    0 |                    if (typeInfoService == null) { | 
  |  785 |    0 |                            typeInfoService = KIMServiceLocatorWeb.getTypeInfoService();  | 
  |  786 |     | 
                   }  | 
  |  787 |    0 |                    return typeInfoService;  | 
  |  788 |     | 
           }  | 
  |  789 |     | 
     | 
  |  790 |     | 
           public RoleUpdateService getRoleUpdateService() { | 
  |  791 |     | 
                   try { | 
  |  792 |    0 |                            if ( roleUpdateService == null ) { | 
  |  793 |    0 |                                    roleUpdateService = KIMServiceLocatorInternal.getRoleUpdateService();  | 
  |  794 |    0 |                                    if ( roleUpdateService == null ) { | 
  |  795 |    0 |                                            throw new UnsupportedOperationException( "null returned for RoleUpdateService, unable to update role data");  | 
  |  796 |     | 
                                   }  | 
  |  797 |     | 
                           }  | 
  |  798 |    0 |                    } catch ( Exception ex ) { | 
  |  799 |    0 |                            throw new UnsupportedOperationException( "unable to obtain a RoleUpdateService, unable to update role data", ex);  | 
  |  800 |    0 |                    }  | 
  |  801 |    0 |                    return roleUpdateService;  | 
  |  802 |     | 
           }  | 
  |  803 |     | 
             | 
  |  804 |     | 
           public void setRoleCacheMaxSize(int roleCacheMaxSize) { | 
  |  805 |    0 |                    this.roleCacheMaxSize = roleCacheMaxSize;  | 
  |  806 |    0 |            }  | 
  |  807 |     | 
     | 
  |  808 |     | 
           public void setRoleCacheMaxAgeSeconds(int roleCacheMaxAge) { | 
  |  809 |    0 |                    this.roleCacheMaxAgeSeconds = roleCacheMaxAge;  | 
  |  810 |    0 |            }  | 
  |  811 |     | 
             | 
  |  812 |     | 
             | 
  |  813 |     | 
     | 
  |  814 |     | 
     | 
  |  815 |     | 
     | 
  |  816 |     | 
     | 
  |  817 |     | 
     | 
  |  818 |     | 
           public List<KimRoleInfo> lookupRoles(Map<String, String> searchCriteria) { | 
  |  819 |    0 |                    return getRoleService().lookupRoles(searchCriteria);  | 
  |  820 |     | 
           }  | 
  |  821 |     | 
     | 
  |  822 |     | 
           public void flushInternalRoleCache() { | 
  |  823 |    0 |                    getRoleService().flushInternalRoleCache();  | 
  |  824 |    0 |            }  | 
  |  825 |     | 
             | 
  |  826 |     | 
           public void flushInternalRoleMemberCache() { | 
  |  827 |    0 |                    getRoleService().flushInternalRoleMemberCache();  | 
  |  828 |    0 |            }  | 
  |  829 |     | 
             | 
  |  830 |     | 
           public void flushInternalDelegationCache() { | 
  |  831 |    0 |                    getRoleService().flushInternalDelegationCache();  | 
  |  832 |    0 |            }  | 
  |  833 |     | 
             | 
  |  834 |     | 
           public void flushInternalDelegationMemberCache() { | 
  |  835 |    0 |                    getRoleService().flushInternalDelegationMemberCache();  | 
  |  836 |    0 |            }  | 
  |  837 |     | 
     | 
  |  838 |     | 
       public void assignPermissionToRole(String permissionId, String roleId) throws UnsupportedOperationException { | 
  |  839 |    0 |            getRoleUpdateService().assignPermissionToRole(permissionId, roleId);  | 
  |  840 |    0 |        }  | 
  |  841 |     | 
     | 
  |  842 |     | 
       public String getNextAvailableRoleId() throws UnsupportedOperationException { | 
  |  843 |    0 |            return getRoleUpdateService().getNextAvailableRoleId();  | 
  |  844 |     | 
       }  | 
  |  845 |     | 
     | 
  |  846 |     | 
       public void saveRole(String roleId, String roleName, String roleDescription, boolean active, String kimTypeId, String namespaceCode) throws UnsupportedOperationException { | 
  |  847 |    0 |            getRoleUpdateService().saveRole(roleId, roleName, roleDescription, active, kimTypeId, namespaceCode);  | 
  |  848 |    0 |        }  | 
  |  849 |     | 
     | 
  |  850 |     | 
             | 
  |  851 |     | 
     | 
  |  852 |     | 
     | 
  |  853 |     | 
     | 
  |  854 |     | 
     | 
  |  855 |     | 
           public List<String> getMemberParentRoleIds(String memberType,  | 
  |  856 |     | 
                           String memberId) { | 
  |  857 |    0 |                    return getRoleService().getMemberParentRoleIds(memberType, memberId);  | 
  |  858 |     | 
           }  | 
  |  859 |     | 
   }  |