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

Checking in versionable node should make subgraph read-only

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Critical
    • 2.8.0.Final, 3.0.0.Alpha2
    • 2.7.0.Final, 3.0.0.Alpha1
    • JCR
    • None

    Description

      When checking in a versionable node, that node and its subgraph should be read-only. In particular, Section 15.2.2 of the JCR 2.0 specification has the relevant bits:

      When a versionable node is checked in, it and its subgraph become read-only. The effect of read-only status on a node depends on the on-parent-version (OPV) status of each of its child items.

      When a node N becomes read-only:

      • No property of N can be added, removed or have its value changed unless it has an on-parent-version setting of IGNORE.
      • No child node of N can be added or removed unless it has an on-parent-version setting of IGNORE.
      • Every existing child node of N becomes read-only unless it has an on- parent-version setting of IGNORE or has an on-parent-version setting of VERSION and is itself versionable.

      Apparently we restrict the adding/modification/removal of properties (tho we should verify that with additional tests), but we do not restrict the adding or removal of nodes. Additionally, even when the OPV setting of a child node definition is VERSION, the expected behavior differs depending upon whether the actual child node is versionable.

      Consider these node types:

      [A] > mix:versionable
        - name (string) copy
        + b (B) multiple version
      
      [B]
        - name (string) copy
      

      and this code:

      Node root = session.getRootNode();
      Node a    = root.addNode("node", "A");
      a.setProperty("name", "aaa");
      session.save();
      versionManager.checkin(a.getPath());
      // The next call is correctly prevented ...
      // a.setProperty("name", "aaa");
      
      // But the next call should result in an exception, but doesn't
      Node b = a.addNode("b", "B");
      session.save();
      
      // This shouldn't be possible either ...
      b.remove();
      
      session.save();
      

      The a.setProperty("name", "aaa") statement (commented out) is not possible without an exception:

      javax.jcr.version.VersionException: '/node' (or its nearest versionable ancestor) is checked in, preventing this action
                at org.modeshape.jcr.JcrNode.doRemove(JcrNode.java:118)
                at org.modeshape.jcr.AbstractJcrNode.removeShare(AbstractJcrNode.java:2415)
                at org.modeshape.jcr.AbstractJcrNode.remove(AbstractJcrNode.java:2458)
                at au.com.infomedix.documentstore.cnd.TestLoadCND.main(TestLoadCND.java:88)
      

      However, the a.addNode("b", "B") should not be possible either without an exception. And once there is a child named 'b', whether its properties can be changed depends on whether 'b' is versionable. Currently, setting a property on 'b' when 'a' is checked out is not currently possible, even when 'b' is versionable.

      See the forum post for more context and detail.

      Attachments

        Activity

          People

            rhauch Randall Hauch (Inactive)
            rhauch Randall Hauch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: