Confluence User Details from macro in 7.1.1

Hey all,
I have a user macro code which worked fine at 6.15.1 but since upgrade to 7.1.1 it returns null while trying to get department and position of users. Can’t find what changed or deprecated.

## @noparams
#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($userDetailsManager = $containerContext.getComponent('userDetailsManager'))

#set($conf_users = $userAccessor.getGroup("confluence-users"))
#set($users = $userAccessor.getMemberNames($conf_users))
#set($bots = ['admin','conf_adm','atl-admin','root','gdadmin'])
#set($count = 0)

#foreach($user in $users)
	#if ($bots.contains($user))
		##special user/bot
	#else
		#set($count = $count + 1)
		#set($userN = $userAccessor.getUser($user))
		<div class="sc-user" style="border:1px solid; width: 230px; height: 320px; padding: 10px; text-align: center; margin: 5px; float: left; overflow: auto;">
			<img class="userLogo logo" src="$userAccessor.getUserProfilePicture($userN).getUriReference()" alt="User icon: $user" title="" style="height: 150px; width: 150px;" />
			<p>#usernameLink($userN.name)</p>
			
			#if ($userDetailsManager.getStringProperty($userN, 'position'))
				<p>$userDetailsManager.getStringProperty($userN, 'position')</p>
			#else
				<p style="color:red">No position</p>
			#end
			
			#if ($userDetailsManager.getStringProperty($userN, 'department'))
				<p>$userDetailsManager.getStringProperty($userN, 'department')</p>
			#else
				<p style="color:red">No department</p>
			#end
		</div>
	#end
#end

<p style="clear:both;padding:10px">Total users: $count.</p>

Any suggestions?

1 Like

In:

#set($containerManagerClass = $content.class.forName('com.atlassian.spring.container.ContainerManager'))

Please notice you Cannot retrieve method forName from object of class java.lang.Class due to security restrictions.

You might want to relax (on your own risk) the velocity settings in Confluence 7.

Please check:

Best
JP

Hi all,

I’ve created a Suggestion to keep track of customer affected by this change so please refer to my reply here:

and vote on the suggestion