
Hi all!!
I am developing a macro to know all view permissions for a specific user in every spaces in Confluence. For that, first I loop for all the spaces looking for his view individual permissions, and then I loop again to loop through the groups with permissions in the space to know if the user is there.
The problem is that we have many users and spaces, and after thinking for a while it shows the error that I attach.
Here is my macro:
## Macro title: User permissions
## Macro has a body: Y or N (N)
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Arantxa Lacasa Madero
## Date created: 01/08/2012
## Installed by: Arantxa Lacasa Madero
## Macro que lista todos los espacios en los que un usuario tiene acceso
## @param nombreusuario:title=Nombre de usuario|type=string|desc=El nombre de inicio de sesion del usuario|required=true
#set($allSpaces = $spaceManager.getAllSpaces())
<h1>Permisos del usuario</h1>
<h3>Permisos individuales</h3>
<table class="confluenceTable">
<tr>
<th class="confluenceTh">Espacio</th>
</tr>
#foreach($space in $allSpaces)
#foreach ($permission in $space.getPermissions())
#if ($permission.isUserPermission() && $permission.getType() == "VIEWSPACE" && $permission.getUserName() == ($paramnombreusuario))
<tr>
<td class="confluenceTd">$space.getName()</td>
</tr>
#end
#end
#end
</table>
<h3>Permisos en grupos</h3>
<table class="confluenceTable">
<tr>
<th class="confluenceTh">Espacio</th>
<th class="confluenceTh">Grupo</th>
</tr>
#foreach($space in $allSpaces)
#foreach ($permission in $space.getPermissions())
#if ($permission.isGroupPermission() && $permission.getType() == "VIEWSPACE")
#set ( $groupString = $permission.getGroup() )
#set ( $groupObject = $userAccessor.getGroup($groupString) )
#set ( $memberList = $userAccessor.getMemberNamesAsList($groupObject) )
#foreach ($member in $memberList)
#if ($member == "$paramnombreusuario")
<tr>
<td class="confluenceTd">$space.getName()</td>
<td class="confluenceTd">$groupString</td>
</tr>
#end
#end
#end
#end
#end
</table>
Any ideas of how could I optimizate it?
Or is it something wrong in it?
Thanks!!