jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcel Reutegger <marcel.reuteg...@gmx.net>
Subject Re: Observation: update memory data after Event.NODE_REMOVED
Date Mon, 26 Nov 2007 08:13:44 GMT
Daniele Dellafiore wrote:
> Hi.
> In my application I have a util.List instance that keeps all data show
> on screen.
> Now I am using Observation to keep my data in memory in sync with
> modifications on the repository. So I register a listener and wait for
> Event.NODE_REMOVED event. All works.
> When I receive the event, the event instance contains the path of
> removed node. Now, If I want to update my List in memory removing the
> application object that wrap that Node. I can only lookup the object
> in memory via event.getPath().
> Now, what it seems to be needed here is a sort of mapping that has
> node path as the key and, as value, the index of application object in
> my List.
> Or, I can duplicate the path information of the node in my application
> object, so I can search for it in my List in memory. I cannot relay on
> the wrapped Node.getPath cause when I receive the NODE_REMOVED event,
> that node is gone and if I call getPath on it, I receive an exception
> like:
> javax.jcr.InvalidItemStateException:
> 9a8d806f-a3e9-48aa-84ab-a05a8c5436ca: the item does not exist anymore
> So, What I am trying to create is a binding between JCR and the data
> that I have actually in memory, the same way I use GlazedLists to bind
> data lists in memory and the swing models for the GUI.

I would probably use a LinkedHashMap to keep the in memory representation. When 
a node is added you get the path from the node and use it as a key in the map. 
This allows you to later look up the node by path as retrieved from the event.


View raw message