How to Use confluence class api such as ContentPermissionmanager api in User macro

Hi Team ,

I’m developing a user macro where i need to display user who have edit access on the page .

I have tried below template code in macro

@noparams

#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)

the contentPermissionManager gives you access to the page permissions

#set($contentPermissionManager=$containerContext.getComponent(‘contentPermissionManager’))

Users with edit Permission
<ul>

##iterate over all view contentpermissionssets
#foreach( $contentPermissionSet in $contentPermissionManager.getContentPermissionSets($content,“EDIT”) )

#foreach( $contentPermission in $contentPermissionSet )   
     
    ##is the current permission a user permission
    #if($contentPermission.isUserPermission() )
         
        ##if yes print the name
        <h1> $contentPermission.userName </h1>
    #end

#end

#end

So i have checked above code it’s not even entering the for loop . Please give me any macro code which uses contentPermissionManager which works in your instance .

So i will try to use it and make it work .

One more thing my confluence has collabrative editing enable , I think its not related anyway but just want to mention .

Please its somewhat critical to me but help me .

Thanks & Regards,
Rahul.