Hi,
I want to export a page to PDF through the Java API. I cannot use the REST api of e.g Scroll PDF because, the event listener that should trigger the export also modifies a custom active object earlier. This change to the custom AO is however not reflected during the REST export. If I understand the docs correctly this is due the way Confluence handles sessions and transactions. A REST call is in a separate session and therefore cannot see the changes. If I would export through the Java API, it should be in the same session.
Thanks!
Hi,
Scroll PDF Exporter does not expose any Java API to other plugins, so there is no way you could invoke it.
Furthermore exports are usually performed in a separate worker thread, which would not run in the scope of your transaction anyway.
Your best option would probably be to defer the export action until the transaction your event handler is running in has been commited.
AFAIK there still are no 'run-after-commit' event handlers so you would need to implement this on your own.
This is not trivial.
You could for example in your event handler submit sort of an export task along with the page revision from the event into an ExecutorService's queue, then when the task executes periodically (in individual transactions) poll the page manager for the page and check if it already returns your expected revision. Then launch the export by performing a REST API call. You'd also need to preserve the user context somehow so the REST API call is performed for the correct user.
Cheers,
Jens
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.