Hi All i want fetch list of confluence spaces which are enabled Anonymous access using groovy. can anyone please help me in this ..TIA
Regards
Akhil
Hi Akhil,
If I understand correctly, you would like to get a list of anonymous permissions of a space?
You can try the following:
import com.atlassian.confluence.spaces.SpaceManagerimport com.atlassian.sal.api.component.ComponentLocatordef space = ComponentLocator.getComponent(SpaceManager).getSpace("SPACEKEY")def anonymousPermissions = space.getPermissions().findAll { it.isAnonymousPermission() }
I hope this helps!
Cheers,Helmy
Hi Helmy Thanks for your response actually the script is need to search all the spaces and list out which space has the anonymous access. this is my actual requirement.
And u forget to mention one more thing ...if any space is enable the anonymous access an email has to be send to me and my manger that the space is enabled anonymous access..we are new to script runner for confluence ...so can you please help us in this please...
Thanks & regards
Apologies for the misunderstanding!
To search for all spaces and only list those that have anonymous access, you can do the following:
import com.atlassian.confluence.spaces.SpaceManagerimport com.atlassian.confluence.spaces.Spaceimport com.atlassian.sal.api.component.ComponentLocatordef spaces = ComponentLocator.getComponent(SpaceManager).allSpacesArrayList<Space> anonymousSpaces = []spaces.each { def permissions = it.getPermissions() def hasAnonymousPermission = permissions.find { it.isAnonymousPermission() } if (hasAnonymousPermission) { anonymousSpaces.add(it) }}// Return all spaces that has at least 1 anonymous permission accessreturn anonymousSpaces*.getName()
To send an email, you can follow the example here.
It looks like you're new here. Sign in or register to get started.