if ( uncachedRuntimeRoleNames.isEmpty() ) {
// no need to hit the repo
return new ArrayList<String>( cachedBoundLogicalRoleNames );
}
PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants( session );
final String phoNsPrefix = session.getNamespacePrefix( PentahoJcrConstants.PHO_NS ) + ":"; //$NON-NLS-1$
final String onlyPentahoPattern = phoNsPrefix + "*"; //$NON-NLS-1$
HashMultimap<String, String> boundLogicalRoleNames = HashMultimap.create();
Node runtimeRolesFolderNode = getRuntimeRolesFolderNode( session, tenant );
NodeIterator runtimeRoleNodes = runtimeRolesFolderNode.getNodes( onlyPentahoPattern );
if ( !runtimeRoleNodes.hasNext() ) {
// no bindings setup yet; fall back on bootstrap bindings
for ( String runtimeRoleName : uncachedRuntimeRoleNames ) {
String roleId = tenantedRoleNameUtils.getPrincipleId( tenant, runtimeRoleName );
if ( bootstrapRoleBindings.containsKey( runtimeRoleName ) ) {
boundLogicalRoleNames.putAll( roleId, bootstrapRoleBindings.get( runtimeRoleName ) );
}
}
} else {
for ( String runtimeRoleName : uncachedRuntimeRoleNames ) {
if ( NodeHelper.hasNode( runtimeRolesFolderNode, phoNsPrefix , runtimeRoleName ) ) {
Node runtimeRoleFolderNode = NodeHelper.getNode( runtimeRolesFolderNode, phoNsPrefix , runtimeRoleName );
if ( runtimeRoleFolderNode.hasProperty( pentahoJcrConstants.getPHO_BOUNDROLES() ) ) {
Value[] values = runtimeRoleFolderNode.getProperty( pentahoJcrConstants.getPHO_BOUNDROLES() ).getValues();
String roleId = tenantedRoleNameUtils.getPrincipleId( tenant, runtimeRoleName );
for ( Value value : values ) {
boundLogicalRoleNames.put( roleId, value.getString() );
}
}