Broken Java API in Confluence 8 EAP: ContentSearch, getById(), etc

Hey @MatthiasClasen , please keep us posted on the progress of this if there is any. Some of us would be more than happy to contribute to the effort.

1 Like

Hy @MatthiasClasen, are there any concrete plans if and when you want to publish your library open source?

1 Like

Jumping on the train here, since we are also running into the problem with the ContentSearch and specifically the permission filter.

This is really poorly communicated and it is certainly not helping that the one available code sample still shows the old (removed) API without even mentioning that this does not work in 8.x upwards.

That said - we also have to create an app that works both on 7.x pre 20 and 8.x onward.

While we could use reflection to call the correct ContentSearch constructor, I can’t figure out how to create the correct permission filter dynamically, since the only way to get an instance of the SiteSearchPermissionsQueryFactory seems to be via a component import, and TBH I have no idea to do THIS dynamically (right now the code that actually executes the query isn’t even amenable to component injection, but I guess we could refactor that part).

Any ideas/solutions? We are certainly not going to recomponentize our whole app just to work around this mess; we’d rather just forego the permissions check completely (sorry guys).

Atlassian staff: If you break an API in that way, there NEEDS to be a clear migration guide and at the very least some samples that do work in both versions. This is really disappointing for a multi million dollar company.

Quick follow-up - would it be allowed to create to different versions of the same app that target 7.x and 8.x separately? Or would this mess up marketplace logic and/or not be permissible under some maintenance rules for confluence DC?

I was experiencing the exact same problem to retrieve a draft by ID. The following worked in the end:

contentService.find()
    .withAnyStatus()
    .withType(ContentType.PAGE, ContentType.BLOG_POST)
    .withId(ContentId.of(contentEntityId))
    .fetchOrNull();

Hi,
I am trying to replace the deprecated getById() functions in SpaceManager and PageManager, as these have been niggling me for many years now.

So a lot of my code has been converted to using Content class, with ContentService.find(), rather than Pages, BlogPosts and ContentEntityObjects. This is the suggested NEW way to get Content, but it has very poor documentation and seems to be missing critical implementations to make PageManager and SpaceManager functions redundant.

However, there are some fundamental things I can’t get from Content objects, in particular, who the creator is, using GetCreator() replacement like in PageManager.

So, my question is, after doing a ContentService.find(), how do I get the Content creator without using any depricated API calls?

[By the way, I have tried using the Content history and getting the user from the VERY FIRST history item, but this has failed on customers’ sites, as someone removed history from pages, so this is a failure, and we can’t rely on info that can be deleted.]

Thanks

2 Likes