It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Page tree generated via API not showned

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 treepic1.pngbut is present when the move into the home.pic2.png

Could you please assist with issue?

thank you and regards

 

1 answer

0 votes

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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

What project did you transition or start on Confluence with the shift to remote work?

It’s been great to hear from fellow users over the last few weeks about the best tips and fun moments you’ve had working on Confluence since the transition to working remote. I’d love to keep the c...

129 views 3 7
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you