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.SpaceManager
import com.atlassian.sal.api.component.ComponentLocator
def 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
Akhil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Akhil,
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.SpaceManager
import com.atlassian.confluence.spaces.Space
import com.atlassian.sal.api.component.ComponentLocator
def spaces = ComponentLocator.getComponent(SpaceManager).allSpaces
ArrayList<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 access
return anonymousSpaces*.getName()
To send an email, you can follow the example here.
I hope this helps!
Cheers,
Helmy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.