Missed Team ’24? Catch up on announcements here.

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

How to programtically create new page?

Scott Flynn December 13, 2012

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!

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
JamieA
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.
December 13, 2012

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.

Scott Flynn December 13, 2012

.setSpace() was the missing peice. I guess I assumed it wasnt required since setParent would imply the space. Thanks for the find!

Bastian Kippelt
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.
January 25, 2016

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);

 

0 votes
Deleted user September 9, 2016

Linking this issue associated with permission inheritance when programmatically creating a page.

https://answers.atlassian.com/questions/41469980

TAGS
AUG Leaders

Atlassian Community Events