Hi, I’m trying to implement an event listener that triggered on document publish/save/delete/etc… In this event listener I want to get document being published/saved/deleted/etc., serialize it to json and the post the json to an external service.
What I want to know is how I can get a bean representation of a Node (the subject document) so I can serialize it to json using Gson.
I’ve seen an example of how to do this inside the site app where there is a HstRquestContext, like so:
HstRequestContext context = RequestContextProvider.get();
Object documentObject = context.getObjectConverter().getObject(node);
However, from inside a repository managed component (my event listener) there is no HstRequestContext available through which I can do a call of
context.getObjectConverter().getObject(node) to get the document bean and then serialize it to json.
How can I convert a JCR Node to a document bean and from there serialize it to json inside a repository managed event listener?