Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-2880

CoreSession.move crash when the target folder already has a document with the same local id (using the JCR backend)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Cannot Reproduce
    • Affects Version/s: 5.1.6, 5.2 M3
    • Fix Version/s: 5.1.x, 5.2 M4
    • Component/s: Core

      Description

      Step to reproduce:

      • create two workspace (with title "Workspace 1" and "Workspace 2").
      • in each workspace create a document with identical titles "My Document"
      • try to move document from workspace 2 to workspace 1

      JCRSession.move does not test whether a document already exist with the same path and we get the following stacktrace:

      Caused by: org.nuxeo.ecm.core.api.WrappedException: Exception: org.nuxeo.ecm.core.api.DocumentException. message: Could not move the document to /domain/workspaces/workspace-1
      at org.nuxeo.ecm.core.repository.jcr.JCRSession.move(JCRSession.java:345)
      at org.nuxeo.ecm.core.api.AbstractSession.move(AbstractSession.java:503)
      ... 209 more
      Caused by: org.nuxeo.ecm.core.api.WrappedException: Exception: javax.jcr.ItemExistsException. message: /ecm:root/ecm:children/domain/ecm:children/workspaces/ecm:children/workspace-1/ecm:children/my-document
      at org.apache.jackrabbit.core.SessionImpl.move(SessionImpl.java:971)
      at org.nuxeo.ecm.core.repository.jcr.JCRSession.move(JCRSession.java:342)
      ... 210 more

      Proposed solution is to add test and generate a new local id if necessary as done in JCRSession.copy:

      // test whether source document and naive target document have
      // conflicting JCR paths
      String dstPath = ((JCRDocument) dstContainer).getNode().getPath()
      + '/' + ModelAdapter.getChildPath(dstName);

      if (dstContainer.hasChild(dstName))

      { // we have a conflict, generate a new locally unique name based // on the title of the document dstName = generateDocumentName(src.getString("title")); dstPath = ((JCRDocument) dstContainer).getNode().getPath() + '/' + ModelAdapter.getChildPath(dstName); }

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 4 hours
                4h
                Remaining:
                Remaining Estimate - 4 hours
                4h
                Logged:
                Time Spent - Not Specified
                Not Specified