I’m trying to create a new confluence space and copy all the pages to it from another space.
I’ve managed to perform the copying using the deepCopyPage function of the PageManager class.
Here is the code I used for it:
PageCopyOptions pageCopyOptions = PageCopyOptions.builder() .withCopyAttachment(true) .withCopyLabel(true) .withContentProperty(true) .withCopyPermission(true) .withUser(userUtil.getCurrentUser()) .withProgressMeter(new ProgressMeter()) .build(); pageManager.deepCopyPage(pageCopyOptions, templateHomePage, homePage);
templateHomePage is the page of a space I want to copy from
homePage is the home page of the newly created space I want to copy to
Method worked fine besides the issue that now I have the structure of pages in a new space:
- homePage (current home page)
I am trying to achieve that:
- templateHomePage (becomes a home page)
That is I want to delete the default homePage of a newly created space and set a templateHomePage as a new homepage.
I tried to use space.setHomePage and then spaceManager.save(space) function but it does nothing, the old homePage is still there.
Has anyone worked with Java API for PageManager and SpaceManager. What is the correct way to achieve what I described above?