Move from AttachmentManager / PageManager to AttachmentService / ContentService

Hi.

There is an apparent move from AttachmentManager / PageManager (which are becoming internal) to AttachmentService / ContentService. Unfortunately there’s still a lack of any documentation on the matter (that I’m aware of). Ran into several issues while migrating to the new approach:

  • How to retrieve the raw body of an attachment using AttachmentService, to replace AttachmentManager.getAttachmentData(attachment)?
    Tried retrieve it using:
Content attachment = 
attachmentService.find(ExpansionsParser.parse("body"))
.withId(attachmentId)
.fetchOrNull();

attachment.getBody() always returns an empty Map.

  • How to return a specific version of an attachment?
    I assume ContentVersionService has something to do with it.
    Otherwise filtering versions from AttachmentService, by first fetching all of them, looks like a bad approach.

  • How to replicate Attachment.getDownloadPathWithoutVersion() using Content (com.atlassian.confluence.api.model.content.Content)?

  • Can attachments, pages, blog post and comments be created / updated / deleted using ContentService / AttachmentService, the same way it was done using PageManager / AttachmentManager?

Any help with the questions above would be greatly appreciated.

2 Likes

@GustavS, did you ever figure out what the answer here was? I also have not found a way to get the content of a specific attachment version without using the deprecated method AttachmentManager.getAttachment(long id).

2 Likes

Hi @GustavS, I also run into the same problem here. I tried to replicate Attachment.getDownloadPath() with Content but had no clue of how can we do it. Mind sharing your findings so far?