How to populate PageContext for rendering

I am working on integrating our Confluence content into a custom search index. To facilitate this, I am listening for various events (e.g. PageCreateEvent)- when the listener method fires off, I need to render the page content and put it into a custom table. Later, this table's contents will be pulled into the search index. I'm spring injecting the wikiStyleRenderer into my manager. I then call wikiStyleRenderer.convertWikiToXHtml to get the rendered content.

An issue I'm encountering is the rendering of attached images on the page. The markup


is rendered as:

<span class="error">Unable to render embedded object: File (test.png) not found.</span>

The convertWikiToXHtml method needs a RenderContext, which I get from contentEntityObject.toPageContext(). I bet that this RenderContext needs to be passed a value from which it can retrieve the image attachment. I set the attachment path on the renderContext via this code:


but that doesn't seem to be helping either. Any ideas?

1 answer

1 accepted

0 votes
Accepted answer

Debugging the code, the attachment is found, but I don't have permission to view it. This is because the authenticated user in the ThreadLocal is null, since I spawned off a new thread for this processing via a ThreadPoolExecutor.

My PageContext is working just fine, but I need to make sure I'm performing my processing while the ThreadLocal's user is set.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Thursday in Agile

How Scrum works? It starts with training and education

To answer “How scrum works,” most of the teams I've worked with first addressed the question: “where to start?”  That question applies to both implementation and improvements on the Scrum framew...

184 views 3 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you