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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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
Diego Atlassian Team Jan 21, 2020

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 do you think is the most *delightful* Confluence feature? Comment for a prize!

- Create your own custom emoji 🔥 - "Shake for Feedback" on mobile 📱 - An endless supply of GIFs via GIPHY 🤩 Is there anything quite as nice as a pleasant surprise? Comment below with what...

415 views 23 8
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