You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Benjamin Brown <be...@thisisnumero.com> on 2009/05/29 11:25:03 UTC

Auditing required - JCR hack added

Hi,

I need to add low level auditing to JCR - the auditing class writes entries to a completely separate auditing database outside of JackRabbit. This should be similar in operation to a HibernateInterceptor in Hibernate, which operates at the point of item state changes in the API.

To do this I've implemented a NodeStateListener class - which seems to do everything that I need such as watching for added/removed nodes etc etc.
Unfortunately since the Session.getItemStateManager() method has a *protected* method (which is the object I need to add the listener to), the only *clean* way to add this listener is to wrap and override (as a minimum!!) jcrtemplate (we use Spring) sessionfactory, and session (not including having to wrap all the transactional and support interfaces too) .

So far I've cheated and used reflection to bodge it in instead - is there a better clean way of just adding the NodeStateListener to the session that I've missed - it seems this should be a basic operation, and support is already in the API, but unlike Hibernate's capability it doesn't seem publicly exposed?

Thanks,

Benjamin



Re: Auditing required - JCR hack added

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Mon, Jun 1, 2009 at 4:43 PM, Benjamin Brown
<be...@thisisnumero.com> wrote:
> I'm now using this interface but for a NODE_REMOVED event I need to find the node id
> of the now removed node (so I can audit that id as deleted).
> [...]
> How can I get the node id when using javax.jcr.observation.Event or
> org.apache.jackrabbit.core.observation.EventImpl classes?

Can you target your application to the upcoming JCR 2.0 standard? The
JCR 2.0 version of javax.jcr.observation.Event interface contains a
getIdentifier() method that's pretty much what you're looking for.

See the Jackrabbit dev@ list for current status of the JCR 2.0
implementation efforts.

BR,

Jukka Zitting

RE: Auditing required - JCR hack added

Posted by Benjamin Brown <be...@thisisnumero.com>.
> -----Original Message-----
> From: Benjamin Brown [mailto:benjamin.brown@thisisnumero.com]
> Sent: 29 May 2009 10:48
> To: users@jackrabbit.apache.org
> Subject: RE: Auditing required - JCR hack added
> 
> That looks ideal - I wonder why I missed that...!
> 
> Thanks,
> 
> Benjamin
> 
> > -----Original Message-----
> > From: Jukka Zitting [mailto:jukka.zitting@gmail.com]
> > Sent: 29 May 2009 10:50
> > To: users@jackrabbit.apache.org
> > Subject: Re: Auditing required - JCR hack added
> >
> > Hi,
> >
> > On Fri, May 29, 2009 at 11:25 AM, Benjamin Brown
> > <be...@thisisnumero.com> wrote:
> > > To do this I've implemented a NodeStateListener class - which seems to
> > do
> > > everything that I need such as watching for added/removed nodes etc
> etc.
> >
> > Couldn't you use the standard observation mechanism in JCR? That way
> > you wouldn't need to depend on Jackrabbit internals.
> >
> > BR,
> >
> > Jukka Zitting

Hi,

I'm now using this interface but for a NODE_REMOVED event I need to find the node id of the now removed node (so I can audit that id as deleted).

The javax.jcr.observation.Event interface only provides jcr path, event type and user id information, and the EventImpl implementation provides parent and child ids (but again no id of the node affected).

I've noticed the internal org.apache.jackrabbit.core.state.NodeState class has a getId (for my first approach mentioned above), as does the interface org.apache.jackrabbit.spi.Event (getItemId()). 

How can I get the node id when using javax.jcr.observation.Event or org.apache.jackrabbit.core.observation.EventImpl classes?

Thanks again,

Benjamin


RE: Auditing required - JCR hack added

Posted by Benjamin Brown <be...@thisisnumero.com>.
That looks ideal - I wonder why I missed that...!

Thanks,

Benjamin

> -----Original Message-----
> From: Jukka Zitting [mailto:jukka.zitting@gmail.com]
> Sent: 29 May 2009 10:50
> To: users@jackrabbit.apache.org
> Subject: Re: Auditing required - JCR hack added
> 
> Hi,
> 
> On Fri, May 29, 2009 at 11:25 AM, Benjamin Brown
> <be...@thisisnumero.com> wrote:
> > To do this I've implemented a NodeStateListener class - which seems to
> do
> > everything that I need such as watching for added/removed nodes etc etc.
> 
> Couldn't you use the standard observation mechanism in JCR? That way
> you wouldn't need to depend on Jackrabbit internals.
> 
> BR,
> 
> Jukka Zitting
> 
> ______________________________________________________________________
> This email has been scanned for viruses by www.epagency.net
> If you consider this email spam, please forward it to spam@epagency.net
> ______________________________________________________________________

Re: Auditing required - JCR hack added

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Fri, May 29, 2009 at 11:25 AM, Benjamin Brown
<be...@thisisnumero.com> wrote:
> To do this I've implemented a NodeStateListener class - which seems to do
> everything that I need such as watching for added/removed nodes etc etc.

Couldn't you use the standard observation mechanism in JCR? That way
you wouldn't need to depend on Jackrabbit internals.

BR,

Jukka Zitting