Going over the Confluence API documention (XML-RPC specifically) there doesn't seem to be a way to get a list of labels that might be applied to a specific page. I see every other API call in regards to label managment but not on the page level.
What am I not seeing here?
thanks!
Community moderators have prevented the ability to post new answers.
You should use this method:
For the "objectId", supply the ID of the page.
(Reference: https://developer.atlassian.com/display/CONFDEV/Remote+Confluence+Methods#RemoteConfluenceMethods-Labels)
Is there a similar Method for none Remote API?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is there a similar Method for none Remote API? Yes :-)
Page confPage = this.pageManager.getPage(Long.parseLong(key)); List<Label> labels = confPage .getLabels();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have adopted your suggestion, and made it work in Confluence 6.1 as a User Macro as shown below. I put this macro at the top of the page to promote the use of labels in my organization.
## Macro title: Show Labels of a Given Page
## Macro has a body: N
## Body processing: Rendered
## Output: Selected output option
##
## Developed by: an unknown. Half of the code below was taken from a user macro, called label-mgmt., on dev server; I'm not sure where Apeksha K. found it
## Date created: 28/11/2017
## Installed by: Khuong Vu
## @noparams
## This block was taken from a user macro, called label-mgmt., on libdev3; I'm not sure where Apeksha K. found it
#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 ( $contentEntityManager = $containerContext.getComponent('contentEntityManager') )
#set ( $spaceKey = $space.key )
#set ( $pageId = $content.getIdAsString() )
## Please note that for the next 2 lines to work variable long cannot be instantiated by setting it to 0
#set ( $long = $generalUtil.getSystemStartupTime() )
#set ( $pageIdLong = $long.parseLong($pageId) )
#set ( $pageIdLongAS = $pageIdLong.toString() )
## This div block was taken from page-source view of a page in L-Space, where the li element has been replaced with ours
<div id="labels-section" class="pageSection group">
<div class="labels-section-content content-column" entityid="22751371" entitytype="page">
<div class="labels-content">
<ul class="label-list label-list-right has-pen">
#set ( $labelPage = $contentEntityManager.getById($pageIdLong) )
#foreach ( $labels in $labelPage.getLabels() )
#set ( $labelString = $labels.toString() )
<li class="aui-label " data-label-id="13008901"><a class="aui-label-split-main" href="/label/$spaceKey/$labelString" rel="tag">$labelString</a></li>
#end
<li class="labels-edit-container">
<a href="#" class="show-labels-editor" title="Edit Labels">
<span class="aui-icon aui-icon-small aui-iconfont-edit-small">Edit Labels</span>
</a>
</li>
</ul>
</div>
</div>
</div>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.