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

Search and Edit BodyContent

Stefan Chapuis October 8, 2012

Hello,

I'm trying to search and edit the body of a confluence page. I can get the body (PageManager -> Page -> getBody) as String, modify it and save it. But I have to find a special macro and I think it's not proper way to make a string search.

Here my questions:

1. Is there any XHTML parse API from Atlassian to easy find macro or add some content?

2. If not I tried to parse the XHTML with the dom4j, but the body content is not a valid xml. Missing the name spaces and also don't accept the  . Is it possible to get and modify a valid xml?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Stefan Kleineikenscheidt _K15t_
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.
October 9, 2012

You could store the body content of the macro as a content property with the page (look for ContentPropertyManager), and read it from there.

Hth,
-Stefan

0 votes
Stefan Kleineikenscheidt _K15t_
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.
October 9, 2012

First of all, that approachs does not scale very well. Esp. when you use JDOM to parse the body content.

Instead, to search in confluence you should use lucene queries (look for LuceneSearcher) To search for a macro, which doesn't work out of the box, the macro indexer plugin [1] should help, a intro about the search syntax can be found at [2].

Hope this helps,
-Stefan

[1] https://marketplace.atlassian.com/plugins/com.atlassian.confluence.plugins.confluence-macro-indexer-plugin

[2] http://ffeathers.wordpress.com/2012/09/04/how-to-search-for-macros-and-macro-parameters-in-confluence-4/

Stefan Chapuis October 9, 2012

Thanks for the answer. I think this is not what I'm looking for. Perhaps I have to do a better description for our problem.

We are developing a help system for our application, based on Confluence. The user who is writing the help should be able to click for example on a textfield in our application and then this will add some content in a special page in the Confluence. So for this we have to edit the content of a page. If the user is clicking on an existing label it should return the right text. By the way this text somewhere on a confluence page, marked by a special macro.

Technical solution actual:

REST service for the communication between our application and the Confluence. Search for a macro tag, add it if necessary. Actaully the only way is to do the search and add with string manupulation. Is this really the way? Or did I undestand something wrong?

TAGS
AUG Leaders

Atlassian Community Events