Hi,
we develop a custom macro that create pages into a workspace.
When we save the new page and call the API to add the new page to the page tree, it's not showned also is we invoke the reindex methods.
Here below our code:
Page parentPage = createRequirementPage(usr, sp, requirementTitle, sg, type, idReq, pdm);
List<Page> contribList = createContributePages(usr, sp, requirementTitle, sg, type, parentPage, idReq);
pageManager.saveContentEntity(parentPage, null);
indexer.index(parentPage);
for (Page contrib: contribList){
pageManager.saveContentEntity(contrib, null);
parentPage.addChild(contrib);
pageManager.saveContentEntity(parentPage, null);
indexer.index(contrib);
}
indexer.reIndex(parentPage);
indexer.reIndex(sp);
where createRequirementPage is:
Page page = createBasePage(usr, sp);
page.setTitle(sg+": "+requirementTitle);
page.setParentPage(sp.getHomePage());
page.setAncestors(new ArrayList<>(Arrays.asList(sp.getHomePage())));
and createContributePages is:
Page contrib = createBasePage(usr, sp);
contrib.setTitle(String.format("Contribute %s %s %s", idReq, sg, system));
contrib.setParentPage(reqPage);
contrib.setAncestors(new ArrayList<>(Arrays.asList(sp.getHomePage(), reqPage)));
private Page createBasePage(ConfluenceUser usr, Space sp){
Page page = new Page();
page.setVersion(1);
page.setCreator(usr);
page.setSpace(sp);
return page;
}
what happens is that not is shown on lateral page treebut is present when the move into the home.
Could you please assist with issue?
thank you and regards
Hello @aperrone !
This could be caused by a few reasons. However, we are not really sure what each class means in your code. I would like to ask you a few questions, here we go:
- Are we talking about User Macros?
[Confluence Server] Writing User Macros
- What is the parent page of the newly created page? (You can check it in the breadcrumb path at the top of your page when you visit it)
- Has this code worked at some point in the past?
I was not able to readily wrap my head around the code snippets you sent, but you need to be sure to set a parent page for your newly created page. If this does not happen, your page will be an orphan and have no place in your Page Tree.
You might be able to set the parent with updatePageInAncestorCollections from the PageManager class. I see you are using methods such as getHomePage and setAncestors. However, I am not sure how or if the values are being passed correctly to the methods.
You can reference our classes for Confluence 7.1.x here:
There is also the chance that you are affected by this bug:
Since this a technical development question, I believe you will have better results looking at our development community:
I hope this sheds some light on your issue! Looking forward to your reply.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.