You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Shaun Barriball <sb...@yahoo.co.uk> on 2007/02/22 09:40:38 UTC

Assigning unique identifiers with JackRabbit

Hi all,
We're using a combination of:

[acme:Sequence] > mix:Lockable 
	- acme:value (long) = '1' autocreated mandatory COPY 
 
...and a variation on the org.apache.jackrabbit.util.Locked utility we're
able to allocate unique Ids to certain classes of nodes (the native UUID is
too long to be used in our application). The "custom_id" field on the nodes
is mandatory so needs to be assigned before save.

2 questions:

 1) How best to trigger the assignment of the "custom_id" prior to save - I
presume using an EventListener NODE_ADDED is best? 

 2) Any comments on how best to handle this where items are imported? Do we
need to wrap the import in a custom utility to re-assign the 'custom_id'?
E.g. items could be imported with conflicting custom_id values.

Regards,
Shaun


	
	
		
___________________________________________________________ 
All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease of use." - PC Magazine 
http://uk.docs.yahoo.com/nowyoucan.html

Re: Assigning unique identifiers with JackRabbit

Posted by Marcel Reutegger <ma...@gmx.net>.
Shaun Barriball wrote:
>  1) How best to trigger the assignment of the "custom_id" prior to save - I
> presume using an EventListener NODE_ADDED is best? 

This will not work because events are triggered after changes are saved.

I guess you just have to assign them manually.

>  2) Any comments on how best to handle this where items are imported?

A custom ContentHandler implementation that filters the XML stream and adds 
appropriate custom_ids should do the trick.

> Do we
> need to wrap the import in a custom utility to re-assign the 'custom_id'?
> E.g. items could be imported with conflicting custom_id values.

Well, this depends on what you want to achieve. preserve the custom_ids? assign 
new a new custom_id? what should happen in case of a conflict?

Maybe you can also leverage the repository to maintain your node identities. If 
an imported node has a custom_id that already exists in the workspace, does the 
imported node have the same UUID like the already existing node?

See: 
http://www.day.com/maven/jsr170/javadocs/jcr-1.0/javax/jcr/ImportUUIDBehavior.html

regards
  marcel