The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

How to Get page by id ?

Roman Kersky
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 Champions.
April 23, 2020

Hi all. 

Method getPage(long id) is Deprecated. since 7.3.0

Are there any examples of using PageManagerInternal to get a page by id?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Answer accepted
Lasse Langhorn
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 Champions.
April 23, 2020

Hi,

What about using getById: https://docs.atlassian.com/ConfluenceServer/javadoc/7.3.2/com/atlassian/confluence/core/ContentEntityManager.html#getById-long-

It should give you a https://docs.atlassian.com/ConfluenceServer/javadoc/7.3.2/com/atlassian/confluence/core/ContentEntityObject.html.

Pseudo Groovy code:

import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.pages.PageManager
import com.atlassian.sal.api.component.ComponentLocator

def pageManager = ComponentLocator.getComponent(PageManager)
def page = pageManager.getById(100L)
if (page instanceof Page) {
// Then do something with your Page object
}

Regards

Lasse Langhorn

Roman Kersky
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 Champions.
April 23, 2020

Thanks!

1 vote
Erik Buchholz
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 Champions.
December 6, 2023

Since Version 7.5.0 also ContentEntityManager.getById() is deprecated.

In the deprecation message is referred to ContentService.find()

In https://community.atlassian.com/t5/Confluence-questions/How-to-use-ContentService-instead-of-PageManager/qaq-p/1546008 is explained how to use these ContentServices. Unfortunately I can't use the output of these methods as I needed the original Page class and no api model class.

With some further research I found PageService.getIdPageLocator().

import com.atlassian.confluence.content.service.PageService
import com.atlassian.confluence.pages.Page
import com.atlassian.sal.api.component.ComponentLocator


final pageService = ComponentLocator.getComponent(PageService)
final Page page = pageService.getIdPageLocator(yourContentId).getPage()
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events