Hi all,
So, I wrote a user macro that copies the contents of a page to another content entity over REST. If the page has attachments, the macro then calls itself with a URL parameter and copies the attachments over to the new content entity using the attachmentManager. The page shows fine, images and everything are there and "Show storage format" shows a correctly formatted page. However, when I edit the page, all the attachments break and the "unknown attachment" image is inserted instead. The source code plugin shows a different code than the "Show storage format" option. If I save the new content entity, the image brakes completely and the "unknown attachment" image is hard saved into the entity as an image.
"body.storage.value" contains the correct markup, so do the other "body" formats over REST.
Reverting to the entity's v.1 after breaking the images restores the original images and makes the page editable without breaking the images again. I tried increasing the version of the entity by 1 via rest, but without any changes to the body it doesn't seem to register. When I open the entity in the editor and click 'Revert to last published version', the images are restored and the entity can be edited as if nothing happened. Funnily, when I call convertToHistoricalVersion on the entity, it breaks the images like when I'd go and edit and save the entity as described above.
Am I missing something? Does Confluence have a cache somewhere that notices missing attachments when creating content? I need the copied content to be editable by ordinary users straight away. I can't expect my users to edit and discard changes of the new content before doing actual changes.
Best
Jens
PS: This is on Server 6.14.3.
I would like to answer my own question:
I investigated the copy space plugin, because it does something similar to what I was trying to do, and that plugin calls saveContentEntity after making changes (like copying attachments or setting the original author). Calling saveContentEntity on the pageManager in my macro after copying over the attachments seems to fix the problem.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.