jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bertrand LEGA <legabertr...@yahoo.fr>
Subject Clone/copy a node
Date Mon, 06 Jun 2005 12:41:59 GMT


I would like to share with you the concerns I have about the clone, move 
and copy methods (Workspace class).

When copying a node, these methods don't return the modified/created 
node, though it would be very convenient, especially when the node you 
copied was created with the same name sibling option.

Let's take an example : I have the following structure.

   + articles
        + item
        + item
        + item
        + item
        + item (this is the node I want to copy to content/articles/item)

When I copy the last node to content/articles/item (so the name of the 
new name is the same as the old one), it's tricky to retreive the newly 
added node. Reading the specifications, I find out that the new node is 
created after my last item (so item[5], in my example).
So my code would look like :

    // 1. Compute the total number of item
    // In my example, n = 5

    // 2. Copy my node

   // 3. Return the n+1 th node
But in case I have multiple JCR sessions active in the same time, it is 
possible to have a other new node added (by another session) and saved 
between steps 2 and 3. And thus, in step 3, I have n=7 nodes under 
articles, and the method would not return the right node.

Do you think that makes sense ?

What do you think about the copy/clone/move methods returning the 
created/modified node ?


View raw message