You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Thomas Draier (JIRA)" <ji...@apache.org> on 2010/01/21 12:57:54 UTC
[jira] Created: (JCR-2473) Cloning a tree containing shareable
nodes into another workspace throws ItemExistsException
Cloning a tree containing shareable nodes into another workspace throws ItemExistsException
-------------------------------------------------------------------------------------------
Key: JCR-2473
URL: https://issues.apache.org/jira/browse/JCR-2473
Project: Jackrabbit Content Repository
Issue Type: Bug
Components: jackrabbit-core
Affects Versions: 2.0-beta6
Reporter: Thomas Draier
There's a problem when trying to clone a tree in another workspace, when this tree contains shareable nodes.
Let ws1 be one workspace, which contains one node A. This node has two sub-nodes B and C. B and C share a shareable sub-node D :
A
| \
B C
| |
D D
Let ws2 be a second workspace. Then calling ws2.clone("ws1" , "/A" , "/A" , false) throws an ItemExistsException ( copyNodeState line 1628 ) . This is done when the copyNodeState is checking if the nodeId is already present in the workspace - which is the case when copying the second instance of the shareable node. I can't find in the specification something about this case - but it would be logical to add a share to the node when coming across this situation - at least in the CLONE ( and probable COPY too ) cases. I don't know what would be expected in the CLONE_REMOVE_EXISTING case - we might not want to remove the node if it's shareable, and also add a share here.
I fixed the issue by handling the case the node is shareable in the COPY and CLONE cases of copyNodeState - you'll find attached the corresponding patch. Do you think this solution is ok ?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (JCR-2473) Cloning a tree containing shareable
nodes into another workspace throws ItemExistsException
Posted by "Thomas Draier (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-2473?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12803268#action_12803268 ]
Thomas Draier commented on JCR-2473:
------------------------------------
Sorry , i cannot add the patch to the jira - here it is :
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java (revision 901309)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java (working copy)
@@ -1608,6 +1608,12 @@
boolean shareable = ent.includesNodeType(NameConstants.MIX_SHAREABLE);
switch (flag) {
case COPY:
+ if (shareable && refTracker.getMappedId(srcState.getNodeId()) != null) {
+ NodeId newId = refTracker.getMappedId(srcState.getNodeId());
+ NodeState sharedState = (NodeState) stateMgr.getItemState(newId);
+ sharedState.addShare(destParentId);
+ return sharedState;
+ }
// always create new uuid
id = new NodeId();
if (referenceable) {
@@ -1621,8 +1627,16 @@
id = new NodeId();
break;
}
+
// use same uuid as source node
id = srcState.getNodeId();
+
+ if (shareable && stateMgr.hasItemState(id)) {
+ NodeState sharedState = (NodeState) stateMgr.getItemState(id);
+ sharedState.addShare(destParentId);
+ return sharedState;
+ }
+
if (stateMgr.hasItemState(id)) {
// node with this uuid already exists
throw new ItemExistsException(safeGetJCRPath(id));
Regards
> Cloning a tree containing shareable nodes into another workspace throws ItemExistsException
> -------------------------------------------------------------------------------------------
>
> Key: JCR-2473
> URL: https://issues.apache.org/jira/browse/JCR-2473
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Components: jackrabbit-core
> Affects Versions: 2.0-beta6
> Reporter: Thomas Draier
>
> There's a problem when trying to clone a tree in another workspace, when this tree contains shareable nodes.
> Let ws1 be one workspace, which contains one node A. This node has two sub-nodes B and C. B and C share a shareable sub-node D :
> A
> | \
> B C
> | |
> D D
> Let ws2 be a second workspace. Then calling ws2.clone("ws1" , "/A" , "/A" , false) throws an ItemExistsException ( copyNodeState line 1628 ) . This is done when the copyNodeState is checking if the nodeId is already present in the workspace - which is the case when copying the second instance of the shareable node. I can't find in the specification something about this case - but it would be logical to add a share to the node when coming across this situation - at least in the CLONE ( and probable COPY too ) cases. I don't know what would be expected in the CLONE_REMOVE_EXISTING case - we might not want to remove the node if it's shareable, and also add a share here.
> I fixed the issue by handling the case the node is shareable in the COPY and CLONE cases of copyNodeState - you'll find attached the corresponding patch. Do you think this solution is ok ?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (JCR-2473) Cloning a tree containing shareable
nodes into another workspace throws ItemExistsException
Posted by "Dominique Pfister (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-2473?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dominique Pfister resolved JCR-2473.
------------------------------------
Resolution: Fixed
Assignee: Dominique Pfister
Thanks for detecting this issue and providing a patch! I added a test case with your setup.
Fixed in revision 902110.
> Cloning a tree containing shareable nodes into another workspace throws ItemExistsException
> -------------------------------------------------------------------------------------------
>
> Key: JCR-2473
> URL: https://issues.apache.org/jira/browse/JCR-2473
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Components: jackrabbit-core
> Affects Versions: 2.0-beta6
> Reporter: Thomas Draier
> Assignee: Dominique Pfister
>
> There's a problem when trying to clone a tree in another workspace, when this tree contains shareable nodes.
> Let ws1 be one workspace, which contains one node A. This node has two sub-nodes B and C. B and C share a shareable sub-node D :
> A
> | \
> B C
> | |
> D D
> Let ws2 be a second workspace. Then calling ws2.clone("ws1" , "/A" , "/A" , false) throws an ItemExistsException ( copyNodeState line 1628 ) . This is done when the copyNodeState is checking if the nodeId is already present in the workspace - which is the case when copying the second instance of the shareable node. I can't find in the specification something about this case - but it would be logical to add a share to the node when coming across this situation - at least in the CLONE ( and probable COPY too ) cases. I don't know what would be expected in the CLONE_REMOVE_EXISTING case - we might not want to remove the node if it's shareable, and also add a share here.
> I fixed the issue by handling the case the node is shareable in the COPY and CLONE cases of copyNodeState - you'll find attached the corresponding patch. Do you think this solution is ok ?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.