So using Confluence Java plugins I'm currently creating a page and adding certain labels to it, and a specific title, etc etc.
How can I programmatically add a macro to that page as well?
Thanks in advance, Matt
Community moderators have prevented the ability to post new answers.
You need to set the BodyContent for the page. The body is in XML, you should take an example from a real page with your macro to understand how it works.
If you download the source of Confluence, you'll find files such as TestPage.java. Go through them an see how they perform this operation.
For example, here's the contents of XhtmlSoapService:
public RemotePage storePage(String token, RemotePage page) throws RemoteException { PageContext pageContext; ContentEntityObject pageCeo = contentEntityObjectDao.getById(page.getId()); if (pageCeo != null) { pageContext = new PageContext(pageCeo); } else { pageContext = new PageContext(page.getSpace()); } String storageFormattedContent = migrateStorageFormat(pageContext, page.getContent()); page.setContent(storageFormattedContent); return pagesService.storePage(page); }
Ok well I can get the BodyContent as follows:
Page p = pageManager.getPage(pId); ContentEntityObject pageCeo = p.getContentEntityObject(); BodyContent bc = pageCeo.getBodyContent();
But it seems like the code you posted is turning this in to a string (and therefore making it open for manipulation) inside the 'migrateStorageFormat' function.
Could you show me what that's doing? Unfortunately our license doesn't cover us downloading the source.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It calls a method, which calls a method, which ... pretty much in the style of FizzBuzzEnterpriseEdition (It's a programmer joke in case it's not obvious).
More seriously, you just need to create a page with your macro, and call getBodyContent() on that page. I don't think looking at the code will be more efficient than looking at the result.
Could you show me what that's doing? Unfortunately our license doesn't cover us downloading the source.
If you don't have access to the source of Confluence, I'm not even sure it's legal for me to show it to you:
Hope you'll succeed in your license hunt!
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.