How to properly work with the Java API?

Hauke Bruno Wollentin
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.
September 21, 2023

Hi there,

I don't get how to work properly with the Java API of Confluence Data Center.

There are Manager interfaces like in Jira, for instance the PageManager. But all of the getPage() methods has been deprecated with a reference to the PageManagerInternal interface which do not provide simple getPage() methods, for example for just throwing in a known page ID.

So my question is: How to work with the Confluence Java API directly? We use ScriptRunner and do not (nor want to) write dedicated/custom plugins.

Best regards,
Hauke

1 answer

0 votes
Marcus Hansson
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 5, 2023

I am not very familiar with ScriptRunner. For my custom plugin I use:

com.atlassian.confluence.api.service.content.ContentService;
com.atlassian.confluence.api.service.content.SpaceService;
com.atlassian.confluence.api.service.people.GroupService;
com.atlassian.confluence.api.service.people.PersonService;

For ScriptRunner it should work using:
@PluginModule
ContentService contentService

Reference: https://community.developer.atlassian.com/t/how-to-use-expansions-on-contentpropertyservice/46866/4

They work similar to the REST API, here's an example using ContentService (page) and expanding the space.

ContentService.SingleContentFetcher contentFinder = contentService
.find(new Expansion(Content.Expansions.SPACE))
.withType(ContentType.PAGE)
.withId(ContentId.of(pageId));


Similar approaches is for the other services. If you need more specific example, let me know.

More about the ContentService can be found in ContentService (Atlassian Confluence 8.5.0 API)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events