Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Pages which are generated in JAVA does not appear in Confluence tree browser

Orkun Gedik February 26, 2018

Hello, I am new at Confluence plugin development and I  have faced with a problem.

I have generated a couple of pages with Confluence Java API. I can see all generated pages on the "Recently Updated". Instead of that, pages are not appearing on the tree browser. I have tried to create a page manually just after the all pages are generated and then all pages including the pages which did not appear in the tree browser, appeared. Is there any way to handle this problem. Thanks.

1 answer

1 accepted

1 vote
Answer accepted
Christo Mastoroudes [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.
February 26, 2018

Hi Orkun,

You can try create a page with the correct state, and then index the page.

Something similar to this:

private void createPage(String title, String space) {
Page parentPage;
Page newPage = new Page();

newPage.setSpace(spaceManager.getSpace(space));
newPage.setTitle(title);
newPage.setCreationDate(new Date());
newPage.setCreator(AuthenticatedUserThreadLocal.get());
newPage.setVersion(1);

parentPage = pageManager.getPage(space, parentPageTitleHere);
setParentPage(newPage, parentPage);

pageManager
.saveContentEntity(newPage, new DefaultSaveContext(false, false, false));
parentPage.addChild(pageManager.getPage(space, title));

confluenceIndexer.reIndex(newPage);
}

private void setParentPage(Page newPage, Page parent) {
List<Page> ancestors = new ArrayList<>();
ancestors.add(parent);
newPage.setAncestors(ancestors);
newPage.setParentPage(parent);
}

Note that it is not good enough to just set the parent of the newly created page. You must also on the parent page set the new page as a child.

 

Let me know if this helps, and if it answers your question then please mark it as answered.

Orkun Gedik February 26, 2018

Thanks a lot Christo for your answer. The problem that I could not handle is using 


confluenceIndexer.reIndex(newPage);

Could you please give me a hint about usage of ConfluenceIndexer? 

Christo Mastoroudes [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.
February 26, 2018

Sure, you will have to inject the ConfluenceIndexer via constructor or setter injection.

In my example I have done it via setter injection because it was used in an action which does not work with constructor injection.

Something like:

private ConfluenceIndexer confluenceIndexer;


public void setConfluenceIndexer(ConfluenceIndexer confluenceIndexer) {
   this.confluenceIndexer = confluenceIndexer;
}
Deleted user May 2, 2018

If you miss the line:

parentPage.addChild(pageManager.getPage(space, title));

... then the page gets created inside of the database but you cannot see it on Confluence.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events