Hi all,
I'm new in "Atlassian development". I want to realise a very simple task: Receive all Confluence user in my Confluence Macro and list them (I know, there already exists a similar pre-installed macro, but I want to extend my macro later). I have searched for many hours until now... wihtout success. Is there any example/tutorial etc. on the web? Has anybody a hint / an example for me how to realise this task? Unfortunately I have no starting point, which classes might I use?
Thank you very much for help (and sorry for my english, its not the best...),
Felix
Community moderators have prevented the ability to post new answers.
You coukd use the UsserAccessor component.
UserAccessor userAccessor= (UserAccessor )ContainerManager.getInstance().getContainerContext().getComponent("userAccessor"); Pager<User> users = userAccessor.getUsers(); Pager<String> userNames = userAccessor.getUserNames();
In a usermacro youn could do:
#set($containerManagerClass = $content.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= $containerContext.getComponent('userAccessor')) #set($users = $userAccessor.getUsers())
Hope this helps :-)
Hi, thank you very, very much. That was exactly the approach I have looked for :-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How do you know you you need com.atlassian.spring.container.ContainerManager to create an instance of com.atlassian.confluence.user.UserAccessor is beyond me, :) For reference this is how you do it using APIs: {code} userAccessor = (UserAccessor) ContainerManager.getInstance().getContainerContext().getComponent(UserAccessor.class); {code} Do you know how to create an instance of com.atlassian.user.GroupManager? I tried serveral ways but no luck. I need to to use with com.atlassian.confluence.user.UserAccessor's method getMembers(com.atlassian.user.Group group). Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.