Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-2359

Import increase referrers count

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 4.1.0.Final
    • 4.0.0.Final, 3.8.1.Final
    • JCR
    • None
    • Hide
          @Test
          public void shouldNotIncreaseReferrersCountAfterImport() throws Exception {
              registerNodeTypes("ab.cnd");
      
              // A - this is a simple referenceable node
              // [test:a] > mix:referenceable
              session.importXML("/", resourceStream("a.xml"), ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
              session().save();
      
              // For COUNT = 1 test well be green
              int COUNT = 2;
              for (int i = 0; i < COUNT; i++) {
                  // B - this is a simple node that refers to the node A
                  // [test:b] > mix:referenceable
                  // - test:prop_ref_a (reference) < test:a
                  session.importXML("/", resourceStream("b.xml"), ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
                  session().save();
              }
      
              // Remove node B.
              session().getNode("/b").remove();
              session().save();
      
              // After remove node B, node A should have zero referrers count and can be removed,
              // but we have ReferentialIntegrityException: Cannot remove the nodes: '[ee0a8387505d64aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa]' because there are existing nodes: '[ee0a8387505d64bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb]' which have strong references towards them.,
              // because import increase referrers count.
              // node A -> cache -> document -> referrers -> strong -> keyNodeB : COUNT - 1
              session().getNode("/a").remove();
              session().save();
          }
      
      
      Show
      @Test public void shouldNotIncreaseReferrersCountAfterImport() throws Exception { registerNodeTypes( "ab.cnd" ); // A - this is a simple referenceable node // [test:a] > mix:referenceable session.importXML( "/" , resourceStream( "a.xml" ), ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING); session().save(); // For COUNT = 1 test well be green int COUNT = 2; for ( int i = 0; i < COUNT; i++) { // B - this is a simple node that refers to the node A // [test:b] > mix:referenceable // - test:prop_ref_a (reference) < test:a session.importXML( "/" , resourceStream( "b.xml" ), ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING); session().save(); } // Remove node B. session().getNode( "/b" ).remove(); session().save(); // After remove node B, node A should have zero referrers count and can be removed, // but we have ReferentialIntegrityException: Cannot remove the nodes: '[ee0a8387505d64aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa]' because there are existing nodes: '[ee0a8387505d64bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb]' which have strong references towards them., // because import increase referrers count. // node A -> cache -> document -> referrers -> strong -> keyNodeB : COUNT - 1 session().getNode( "/a" ).remove(); session().save(); }

      We have a node A and node B which refers to the node A.
      If import node B multiple times from xml, for node A increases the number of referrers count (document -> referrers -> strong -> keyNodeB -> CNT).

      After remove node B, node A can not be removed.

              hchiorean Horia Chiorean (Inactive)
              gbelov_jira German Belov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: