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

Permanently deleting a folder does not delete versions of documents under it

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 6.0-HF12
    • Fix Version/s: None
    • Component/s: Core

      Description

      How to reproduce:

      • Create a Folder
      • Create a File in it
      • Create a version of the File
      • Permanently delete the Folder
        NXQL query SELECT * FROM File returns the version of the File

      Unit tests showing the bug:

      package org.nuxeo.ecm.core.test;
      
      import static org.junit.Assert.*;
      
      import org.junit.Test;
      import org.junit.runner.RunWith;
      import org.nuxeo.ecm.core.api.CoreSession;
      import org.nuxeo.ecm.core.api.DocumentModel;
      import org.nuxeo.ecm.core.api.DocumentModelList;
      import org.nuxeo.ecm.core.api.DocumentRef;
      import org.nuxeo.ecm.core.api.VersioningOption;
      import org.nuxeo.ecm.core.event.EventService;
      import org.nuxeo.ecm.core.versioning.VersioningService;
      import org.nuxeo.ecm.platform.test.PlatformFeature;
      import org.nuxeo.runtime.test.runner.Features;
      import org.nuxeo.runtime.test.runner.FeaturesRunner;
      
      import com.google.inject.Inject;
      
      @RunWith(FeaturesRunner.class)
      @Features({ PlatformFeature.class })
      public class SUPNXP13808Test {
      
          @Inject
          protected CoreSession session;
      
          @Inject
          protected EventService eventService;
      
          @Test
          public void testSUPNXP13808_removeFile() {
              
              DocumentModel ws = session.createDocumentModel("Workspace");
              ws.setPathInfo("/", "ws");
              ws = session.createDocument(ws);
              // create a folder
              DocumentModel folder = session.createDocumentModel("Folder");
              folder.setPathInfo(ws.getPathAsString(), "folder");
              folder = session.createDocument(folder);
              // create a 'File' document
              DocumentModel file = session.createDocumentModel("File");
              file.setPathInfo(folder.getPathAsString(), "file");
              file = session.createDocument(file);
              DocumentRef fileRef = file.getRef();
              // add version to created document 
              file.setPropertyValue("dc:title", "a version");
              file.putContextData(VersioningService.VERSIONING_OPTION, VersioningOption.MINOR);
              file = session.saveDocument(file);
      
              DocumentModelList files = session.query("SELECT * FROM File");
              assertEquals(2, files.size());
              
              // delete 'File' document
              session.removeDocument(fileRef);
              session.save();
              eventService.waitForAsyncCompletion();
              files = session.query("SELECT * FROM File");
              assertEquals(0, files.size());
          }
      
          @Test
          public void testSUPNXP13808_removeFolder() {
              
              DocumentModel ws = session.createDocumentModel("Workspace");
              ws.setPathInfo("/", "ws");
              ws = session.createDocument(ws);
              // create a folder
              DocumentModel folder = session.createDocumentModel("Folder");
              folder.setPathInfo(ws.getPathAsString(), "folder");
              folder = session.createDocument(folder);
              // create a 'File' document
              DocumentModel file = session.createDocumentModel("File");
              file.setPathInfo(folder.getPathAsString(), "file");
              file = session.createDocument(file);
              // add version to created document 
              file.setPropertyValue("dc:title", "a version");
              file.putContextData(VersioningService.VERSIONING_OPTION, VersioningOption.MINOR);
              file = session.saveDocument(file);
      
              DocumentModelList files = session.query("SELECT * FROM File");
              assertEquals(2, files.size());
              
              // delete 'Folder' document
              session.removeDocument(folder.getRef());
              session.save();
              eventService.waitForAsyncCompletion();
              files = session.query("SELECT * FROM File");
              assertEquals(0, files.size());
          }
      
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                vdutat Vincent Dutat
                Participants:
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: