Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

(How) can I remove all labels of a page my macro?

Stefan Eike
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 18, 2012

Hi,

(how) is it possible to remove all labels of a page by macro?

Best regards

Stefan

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Matthew J. Horn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 18, 2012

You can use the DefaultLabelManager (which implements the LabelManager class) to remove labels from a page. The LabelManager class is described here:

http://docs.atlassian.com/atlassian-confluence/latest/com/atlassian/confluence/labels/LabelManager.html

I'm pretty sure you can get a reference to it in a macro by doing something like this:

#set($containerManagerClass=$action.class.forName('com.atlassian.spring.container.ContainerManager'))
#set($getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null))
#set($containerManager=$getInstanceMethod.invoke(null,null))
#set($containerContext=$containerManager.containerContext)
#set($labelManager=$containerContext.getComponent('labelManager'))

(code borrowed from https://answers.atlassian.com/questions/25933/confluence-user-macro-popular-labels-with-new-label-filter-why-is-this-not-working-on-the-current-space)

hth,

matt

Stefan Eike
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 19, 2012

Thanks matt,

I've never used Velocity yet, so I need some hours to dive into it. Your snippet is very useful and I'll post my final macro (or a link to it) here after completion.

cheers

Stefan

TAGS
AUG Leaders

Atlassian Community Events