I am trying to make a user macro that has a table of strings showing the page version, published date, contributor, and comments.
I am trying to use the VersionHistorySummary from the ContentEntityManager interface to get a list of VersionHistorySummary objects. Then use a foreach loop for building the table content.
I have tried the velocity template below in the user macro. However, the getVersionHistory is not seems to return anything.
I once wrote a really big user macro for something like this. The script gets all childs and its versions. Here is some code sample:
#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( $pageManager=$containerContext.getComponent('pageManager') )
#set( $page = $pageManager.getPage($content.getId()) )
###GET ALL VERSIONS FOR FURTHER OPERATIONS
#set( $latestVersions =  )
#set( $allVersions= )
#foreach( $child in $page.getDescendants() )
#set( $childVersions = $pageManager.getVersionHistorySummaries($child.getEntity()) )
#foreach( $childVersion in $childVersions)
#set( $modDate = $childVersion.getLastModificationDate() )
As far as I know, the getVersionHistory is not working. I think, I struggled as well, so I used getVersionHistorySummaries()
Are you sure that your first call actually returns an ContentEntityManager?
I'm doing something where I need to retrieve pages based on their pageId and I've tried to get a ContentEntityManager using both your example above as well as
#set ( $contentEntityManager = $containerContext.getComponent('contentEntityManager') )
without any luck.
Maybe someone else has a suggestion?
Hi Atlassian Community, Remote work has shifted how teams collaborate, and we’ve heard from many of you that Microsoft Teams has become mission critical to many of your workflows, from how you chat...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events