Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

User Macro getGroup

Rene Hegewald
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!
March 21, 2018

I want to list users of a group, but if the group not exists, i get an error

 

## Users Pictures for Group - Confluence User Macro
##
##   Produces a pile of user profile pictures for members of a specific group
##
## WARNING:
##
##   Use very sparingly as this *will* slow down large Confluence instances.
##   Yes, it will try to print out 100,000 users if you have that many in the group
##
##   I generally remove this user macro after using once and add only when needed.
##   Or enable it for admins only.
##
## @param Group:title=Group Name|type=string|required=true|desc=The group name (yes, really)

 
#set($containerManagerClass = $action.class.forName('com.atlassian.spring.container.ContainerManager'))
#set($getInstanceMethod = $containerManagerClass.getDeclaredMethod('getInstance',null))
#set($containerManager = $getInstanceMethod.invoke(null,null))
#set($containerContext = $containerManager.containerContext)
 
#set($userAccessor = $containerManager.containerContext.getComponent('userAccessor'))
#set($groupManager = $containerManager.containerContext.getComponent("groupManager"))
#set($group = $groupManager.getGroup($paramGroup))
#set($users = $userAccessor.getMemberNamesAsList($group) )
#set($komma="")
#foreach( $username in $users )
    #if ( $username != "service" )
       $komma 
       #usernameLink($username)
    #end
    #set ($komma=",")
#end

is there a way to catch this erorr and wrote a message "Unknown group" ?

1 answer

0 votes
Gonchik Tsymzhitov
Community Champion
August 2, 2018

Hi! 

 

Looks like getMemberNamesAsList gets so slow. 

 

Because I have met the same situation in my plugin .

Have you fix it? 

 

Cheers,

Gonchik Tsymzhitov

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events