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

How can I copy a toplevel page from one space to another?

Michael Aglas
Contributor
August 30, 2022

Hello,

I am trying desperately to copy a toplevel page from one space to another, but I seriously don't understand or find the API mechanism for it. What I am currently doing is:

ListBuilder<Page> lsbPages = pgmgr.getTopLevelPagesBuilder(srcSpace)

for(int i=0; i<lsbPages.getAvailableSize(); i++){
Page page = lsbPages.getPage(i, 1).get(0)

Page newpage = (Page) page.clone()
//Page newpage = (Page) page.copyLatestVersion()

newpage.setSpace(tgtSpace)

pgmgr.movePageToTopLevel(newpage, tgtSpace)
//pgmgr.saveContentEntity(newpage, null)
//pgmgr.saveContentEntity(newpage, page, null)
}

but all it does is nothing... I either don't know if the cloning procedure is correct or if I need to use something else and I feel like there is also something missing to store the page correctly, but I have no clue what and the API docu is not really helpful. Currently I am just guessing. It is way different from what I am used to in Jira...

The only things I can find are about copying when there is already a page, but I am looking for creating basically a new page at top level (ideally a clone).

Can someone point me into the right direction? Was checking for sources the entire day, but no luck.

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Helmy Ibrahim _Adaptavist_
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.
September 1, 2022

Hi Michael,

The method movePageToTopLevel will not actually move/copy the page to another space. It would only order the page in a page tree.

We have a built-in script to copy a page tree from one space to another: Copy Page Tree

I hope this helps! 

Cheers,
Helmy

TAGS
AUG Leaders

Atlassian Community Events