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.
#set($contentManagerClass=$content.class.forName('com.atlassian.spring.container.ContentEntityManager'))
#set($getVersionHistory=$containerManagerClass.getDeclaredMethod('getVersionHistorySummaries'))
Hi all
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() )
#end
#end
As far as I know, the getVersionHistory is not working. I think, I struggled as well, so I used getVersionHistorySummaries()
Regards, Dominic
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.