Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,557,113
Community Members
 
Community Events
184
Community Groups

how to list all the permissions of a space in confluence using groovy script

Hi all i am new to confluence and we are using script runner for confluence and we want list of permissions which a space have using groovy ..can anyone help me in this ..TIA

1 answer

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jul 26, 2021

What are you actually trying to achieve with this?

Most "I want to see the permissions of a space" questions can be answered by "look at the space permissions page in admin".  A request to do it with a script suggests you want to actually do something more clever, and rather than just give you a piece of it, it may be that we can give you a script that can do most of the task.

Hi Nic tnq for the quick response actually we want get the spaces list which were enabled the anonymous access by script runner for confluence for that we need a script can you please help me in this...

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jul 26, 2021

Ah, that makes sense.

I don't have a script for that, but I have a user-macro bookmarked that does something similar and could be adapted easily (a user-macro is probably a bit more useful than a script in this case, because you can put it on a page restricted to admins and then visit the page whenever you need it, rather than go look for a script every time).

This in fact lists all your administrators

#set($spaces = $spaceManager.getAllSpaces())

<table class="confluenceTable"> 
#foreach($thisSpace in $spaces )
  #if ($thisSpace.isGlobal() )
    <tr>
       <td class="confluenceTd">
            <img class="space logo" width="32" height="32" src="$spaceManager.getLogoForSpace($thisSpace.key).getDownloadPath()" alt="$thisSpace.key"/>
            $thisSpace.getName()
       </td>
       <td class="confluenceTd">
           #set($spaceAdmins = $spaceManager.getSpaceAdmins($thisSpace  ))
           #foreach($spaceAdmin in $spaceAdmins )
              #usernameLink($spaceAdmin.name)<BR>
           #end
        </td>
    </tr>
   #end
#end
</table>

But you could replace the "set($spaceadmins = ..." area with something like

#set($permissions = $thisSpace.getPermissions())

#foreach($perm in $permissions)

   $perm <BR>

#end

This would give you everything, which might be a bit much, I'd probably want to put in an "if" to only dump out the permissions I'm interested in

Hi Nic ...the macro is not working

Nisha Patel
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Apr 27, 2023

Thanks, this was so helpful!  Do you know how to have all the spaces have a hyperlink back to the space?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 28, 2023

You could change the code in the macro so that it embeds HTML links - I'd do it in the space name text myself.  Instead of 

$thisSpace.getName()

try something like the below (untested, I can't remember how to get the base URL, and I'm not sure the getKey is right)

<a href="<baseurl>/display/$thisSpace.getKey()">$thisSpace.getName()</a>

Nisha Patel
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Apr 28, 2023 • edited May 02, 2023

Thanks @Nic Brough -Adaptavist- , I ended up fixing this.

 

However, do you know how to show only active users:

 

#set($spaces = $spaceManager.getAllSpaces())


<table class="confluenceTable">
<thead>
<tr>
<th>Space Name</th>
<th>Space Administrator</th>
</tr>
</thead>

#foreach($thisSpace in $spaces )
#if ($thisSpace.isGlobal() )
<tr>
<td class="confluenceTd">
<img class="space logo" width="32" height="32" src="$spaceManager.getLogoForSpace($thisSpace.key).getDownloadPath()" alt="$thisSpace.key" />
<a href="$thisSpace.getUrlPath()">$thisSpace.name</a></td>

<td class="confluenceTd">
#set($spaceAdmins = $spaceManager.getSpaceAdmins($thisSpace ))
#foreach($spaceAdmin in $spaceAdmins )
#usernameLink($spaceAdmin.name)<BR>
#end
</td>
</tr>
#end
#end
</table>

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events