You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by re...@apache.org on 2018/12/01 08:46:27 UTC

svn commit: r1847887 - in /jackrabbit/branches/2.16: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java jackrabbit-core/src/test/java/org/apache/jackrabbit/core/xml/SystemViewTest.java

Author: reschke
Date: Sat Dec  1 08:46:27 2018
New Revision: 1847887

URL: http://svn.apache.org/viewvc?rev=1847887&view=rev
Log:
JCR-4387: Incorrect exception message when same-name-sibling is prevented on import (ported to 2.16)

(patch by jfrantzius)

Added:
    jackrabbit/branches/2.16/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/xml/SystemViewTest.java
      - copied unchanged from r1846896, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/xml/SystemViewTest.java
Modified:
    jackrabbit/branches/2.16/   (props changed)
    jackrabbit/branches/2.16/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java

Propchange: jackrabbit/branches/2.16/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec  1 08:46:27 2018
@@ -1,3 +1,3 @@
 /jackrabbit/branches/JCR-2272:1173165-1176545
 /jackrabbit/sandbox/JCR-2415-lucene-3.0:1060860-1064038
-/jackrabbit/trunk:1816227,1817094,1817097-1817098,1817100,1817113,1817201,1817213,1817341,1817373,1817377,1818586,1819269,1819271,1819839,1819849,1820119,1820133,1820294,1820573,1820675,1820753,1821247,1821475,1821597,1821705,1821880,1822643,1822863,1822947,1822950,1824756,1824763-1824764,1824771,1824876,1826154,1826178,1826230,1826647,1826940,1826964,1828213,1830107,1830201,1830540,1830753,1830814,1830878,1830951,1831182,1831854,1831860,1832058,1832090,1832177,1833374,1833835,1833891,1834008,1834308,1834315,1834401,1834418,1834424,1834673,1834922,1835445,1835448,1835459,1836341,1836349,1836620,1836722,1836729,1836731,1836733,1836773,1836776,1836778,1836794,1836800,1839647,1839910,1839924,1839931,1839937,1839945,1839964,1839966,1840007,1840027,1841459,1841858,1841865,1841916-1841917,1841924,1843392,1843995,1844000,1844014,1844030,1844036,1844067,1846665,1847167
+/jackrabbit/trunk:1816227,1817094,1817097-1817098,1817100,1817113,1817201,1817213,1817341,1817373,1817377,1818586,1819269,1819271,1819839,1819849,1820119,1820133,1820294,1820573,1820675,1820753,1821247,1821475,1821597,1821705,1821880,1822643,1822863,1822947,1822950,1824756,1824763-1824764,1824771,1824876,1826154,1826178,1826230,1826647,1826940,1826964,1828213,1830107,1830201,1830540,1830753,1830814,1830878,1830951,1831182,1831854,1831860,1832058,1832090,1832177,1833374,1833835,1833891,1834008,1834308,1834315,1834401,1834418,1834424,1834673,1834922,1835445,1835448,1835459,1836341,1836349,1836620,1836722,1836729,1836731,1836733,1836773,1836776,1836778,1836794,1836800,1839647,1839910,1839924,1839931,1839937,1839945,1839964,1839966,1840007,1840027,1841459,1841858,1841865,1841916-1841917,1841924,1843392,1843995,1844000,1844014,1844030,1844036,1844067,1846665,1846896,1847167

Modified: jackrabbit/branches/2.16/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.16/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java?rev=1847887&r1=1847886&r2=1847887&view=diff
==============================================================================
--- jackrabbit/branches/2.16/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java (original)
+++ jackrabbit/branches/2.16/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java Sat Dec  1 08:46:27 2018
@@ -372,15 +372,21 @@ public class SessionImporter implements
                     // this node has already been auto-created, no need to create it
                     node = existing;
                 } else {
-                    // edge case: colliding node does have same uuid
-                    // (see http://issues.apache.org/jira/browse/JCR-1128)
-                    if (!(existing.getId().equals(id)
-                            && (uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING
-                            || uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING))) {
+                    // prevent same-name-sibling (we come here only if !def.allowsSameNameSiblings())  
+                    boolean sameId = existing.getId().equals(id);
+                    if (!sameId 
+                        // IMPORT_UUID_CREATE_NEW with same id would also result in same-name-sibling 
+                        // (no other ImportUUIDBehaviour would result in same-name-sibling)
+                        || (sameId && uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW)) {
                         throw new ItemExistsException(
-                                "Node with the same UUID exists:" + existing);
+                            "Same name sibling not allowed for " + existing + " by definition " + def.getName() + " (declaring type " + def.getDeclaringNodeType().getName() + ")");
                     }
-                    // fall through
+                    // truth table for previous if statement (we come here only if names are same):
+                    // same id | CREATE_NEW
+                    // false   | false      => Exception: same name + different id would result in sibling  
+                    // false   | true       => Exception: same name + different id would result in sibling
+                    // true    | false      => fall through: same name + same id, either replacing or removing original node or throwing exception
+                    // true    | true       => Exception: same name + same id would result in sibling due to CREATE_NEW
                 }
             }
         }