Inside of a custom plugin I have a callback which is called when a new project is created in Jira. When this happens I would like to have a new page dynamically created in Confluence (preferablly based off a template). I am attempting to use PageManager to acheive this:
public void createNewPage(String project) { if( pageManager.getPage("UGP", project) == null ) { Page parentPage = pageManager.getPage(2392179); Page page = new Page(); page.setTitle(project); page.setParentPage(parentPage); page.setBodyAsString("Filler Content."); page.setVersion(1); page.setCreatorName("Auto-Created"); pageManager.saveContentEntity(page, null); } }
This seems to have no effect. I also was playing around with DraftManager but did not see a good path that way either. Any help is appreciated!
Community moderators have prevented the ability to post new answers.
This code is running in Confluence right? And jira is notifying it through a rest call or something?
I think you need page.setSpace(...)
But you should be seeing some kind of error if it's not working.
.setSpace() was the missing peice. I guess I assumed it wasnt required since setParent would imply the space. Thanks for the find!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, you have to set the Space
page.setSpace(space);
And do not forget to add the created page to the parent page:
parentPage.addChild(page);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Linking this issue associated with permission inheritance when programmatically creating a page.
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.