Setting a new confluence space homepage using Java API

Hi everyone,

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)
    • templateHomePage
      • page1
      • page2
      • page3

I am trying to achieve that:

  • templateHomePage (becomes a home page)
    • page1
    • page2
    • page3

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?

Hello @Stas,

your problem is exactly what i was looking for.
Is it possible to post the complete .class to look how it should work? I can’t figure out how it works.

Regards,
Tim