Hello experts!
I have a problem which started with Confluence 7 upgrade. Something has been changed and depreciated that previously perfectly worked code doesn’t work anymore.
That was used to get also About Me field information visible in a nice way. Originally code was taken from internet with a small tuning.
Here everything else is ok (macro prints profile picture and basic information) but parameter for line
#set($pi = $personalInformationManager.getOrCreatePersonalInformation($user))
doesn’t work. It used to be user earlier but now either username, user object or key doesn’t work. Variable $pi stays empty. Somewhere it was mentioned that using username isn’t supported anymore, but instead to use user object. That didn’t work either - or I did it wrong somehow.
I already changed getPersonalInformation to getOrCreatePersonalInformation as former was depreciated based on some documentation. But that didn’t help.
Somewhere was mentioned some accountId which will replace username, but I cannot spot it anywhere and cannot get it. All I got from variables are
$user is: ConfluenceUserImpl {name=‘xxxxx’, key=2c90659044c655310144c6559c38077a}
$key will be like “2c90659044c655310144c6559c38077a”
$u was just plain username
None of those work as a parameter anymore.
I’m out of ideas.
Can someone help me? Thanks.
Here’s code:
## @param Username:title=Username(s). If more than one, separate by comma|type=string|required=true
#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($personalInformationManager = $containerContext.getComponent('personalInformationManager'))
#set($wikiStyleRenderer = $containerContext.getComponent('wikiStyleRenderer'))
#if($paramUsername=="")
#set($paramUsername = $action.remoteUser)
#end
#set($all = $paramUsername.split(","))
#foreach ($u in $all)
#set($user = "")
#set($user = $userAccessor.getUserByName($u))
#set($key = "")
#set($key = $user.getKey())
#if($user!="")
#set($pi = $personalInformationManager.getOrCreatePersonalInformation($user))
#set($renderedAboutMe = $wikiStyleRenderer.convertWikiToXHtml($pi.toPageContext(), $pi.getBodyAsString()))
<div class="upp-profile-macro profile-minimal">
<div class="upp-basic-user-container">
<div class="uppuserlogo">
<ac:macro ac:name="profile-picture"><ac:parameter ac:name="User">$user.name</ac:parameter></ac:macro>
</div>
<div class="upp-basic-userdata">
<div class="uppusername">
<h4 title="$user.fullName" class="profile-username">
<a href="/conflu/display/~$user.name" class="url fn confluence-userlink" data-username="$user.name">
$user.fullName</a></h4>
</div>
<div class="uppusermail">
<a href="mailto:$user.email" title="Send Email to $user.fullName">$user.email</a>
</div>
</div>
<div class="upp-clear">
$renderedAboutMe
</div>
</div>
</div>
#end
#end