As you can see, we were able to obtain the page body as a string. This approach is currently still working. however, method getPage on PageManager is deprecated, so I have rewritten the code to this:
The Page returned thru the page manager is com.atlassian.confluence.pages.Page but Page returned with ContentService is Content. Is there any way how to convert content to that Page object? Similar problem I have with Space & SpaceService.
How to get the page body described above? Content was returned correctly, page is found, so why content.getBody() is returning an empty map where pageManger.getPage().getBodyAsString() is returning expected string.
I moved on with my problem since that find() was required a new Expansion which I was not able to find in documentation with any reasonable explanation what properties I could pass in and what is the format since you can pass also Expansions. Nevertheless I’m facing similar problem with attachementService which also returns Content.
I can’t use AttachmentDao becuase the spring is failing for finding that bean.
What I’m currently failing on, is how to get real content of the attached file. Originally, the code was:
Attachment storedData = attachmentManager.getAttachment(space.getHomePage(), ATTACHMENT_NAME);
if (storedData != null) {
InputStream is = attachmentManager.getAttachmentData(storedData);
but now with content I don’t know how to achieve that. If I use:
attachmentService.find(
new Expansion("body",
new Expansions(
new Expansion("storage"))
))
.withFilename(ATTACHMENT_NAME)
.withContainerId(ContentId.of(space.getHomePage().getId()))
.fetch();
and then try to get the body, it always return value of the body as “”. The original code was able to read the content of the attachment (which is JSON btw).
And If there is any real documentation how to work with Content Object which is returned with that new API then please please point me there.