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

Child path not updated when parent restored from trash

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 10.10
    • Fix Version/s: 10.10-HF19, 11.1, 2021.0
    • Component/s: Core
    • Release Notes Summary:
      The path of trashed child documents is correctly restored.
    • Backlog priority:
      600
    • Team:
      PLATFORM
    • Sprint:
      nxplatform 11.1.21, nxplatform 11.1.22, nxplatform 11.1.23
    • Story Points:
      1

      Description

      This can be reproduced on nightly:

      1. create a folder named pouetFolder
      2. create a folder in it named pouetFolderChild
      3. trash pouetFolderChild
      4. trash pouetFolder
      5. After trashing the parent folder, its path is renamed and the isTrashed flag is set:
        curl -sSL -u Administrator:Administrator https://nightly.nuxeo.com/nuxeo/api/v1/path/default-domain/workspaces/pouetSpace/pouetFolder._1568188481461_.trashed | jq .
        {
          "entity-type": "document",
          "repository": "default",
          "uid": "3d3e1aae-5b1c-4314-b720-10b42e8d51d5",
          "path": "/default-domain/workspaces/pouetSpace/pouetFolder._1568188481461_.trashed",
          "type": "Folder",
          "state": "project",
          "parentRef": "e4e625f9-55cb-4d8b-bb12-8e8d363447ce",
          "isCheckedOut": true,
          "isVersion": false,
          "isProxy": false,
          "changeToken": "2-0",
          "isTrashed": true,
          "title": "pouetFolder",
          "lastModified": "2019-09-11T07:54:01.837Z",
          "facets": [
            "Folderish",
            "NXTag"
          ],
          "schemas": [
            "common",
            "dublincore",
            "facetedTag"
          ]
        }
        

        And so does the child:

        curl -sSL -u Administrator:Administrator https://nightly.nuxeo.com/nuxeo/api/v1/path/default-domain/workspaces/pouetSpace/pouetFolder._1568188481461_.trashed/pouetFolderChild._1568188472362_.trashed | jq .
        {
          "entity-type": "document",
          "repository": "default",
          "uid": "3ef8262d-00fa-4958-9524-58248461470f",
          "path": "/default-domain/workspaces/pouetSpace/pouetFolder._1568188481461_.trashed/pouetFolderChild._1568188472362_.trashed",
          "type": "Folder",
          "state": "project",
          "parentRef": "3d3e1aae-5b1c-4314-b720-10b42e8d51d5",
          "isCheckedOut": true,
          "isVersion": false,
          "isProxy": false,
          "changeToken": "2-0",
          "isTrashed": true,
          "title": "pouetFolderChild",
          "lastModified": "2019-09-11T07:54:17.323Z",
          "facets": [
            "Folderish",
            "NXTag"
          ],
          "schemas": [
            "common",
            "dublincore",
            "facetedTag"
          ]
        }
      6. Restore the parent pouetFolder and observe the parent's path is renamed and cannot be found by its trashed path:
        curl -sSL -u Administrator:Administrator [https://nightly.nuxeo.com/nuxeo/api/v1/path/default-domain/workspaces/pouetSpace/pouetFolder._1568188481461_.trashed] | jq .
        { "entity-type": "exception", "status": 404, "message": "/default-domain/workspaces/pouetSpace/pouetFolder._1568188481461_.trashed" }
        

        But only by its original path:

        curl -sSL -u Administrator:Administrator https://nightly.nuxeo.com/nuxeo/api/v1/path/default-domain/workspaces/pouetSpace/pouetFolder | jq .
        {
          "entity-type": "document",
          "repository": "default",
          "uid": "3d3e1aae-5b1c-4314-b720-10b42e8d51d5",
          "path": "/default-domain/workspaces/pouetSpace/pouetFolder",
          "type": "Folder",
          "state": "project",
          "parentRef": "e4e625f9-55cb-4d8b-bb12-8e8d363447ce",
          "isCheckedOut": true,
          "isVersion": false,
          "isProxy": false,
          "changeToken": "3-0",
          "isTrashed": false,
          "title": "pouetFolder",
          "lastModified": "2019-09-11T07:54:01.837Z",
          "facets": [
            "Folderish",
            "NXTag"
          ],
          "schemas": [
            "common",
            "dublincore",
            "facetedTag"
          ]
        }
        

        Which is correct and expected.

      7. Nevertheless, the child is untrashed but its path is not renamed.
        The isTrashed flag is unset but the trashed path remains.
        Trying to access it through its trashed path still works:
        curl -sSL -u Administrator:Administrator https://nightly.nuxeo.com/nuxeo/api/v1/path/default-domain/workspaces/pouetSpace/pouetFolder/pouetFolderChild._1568188472362_.trashed | jq .
        {
          "entity-type": "document",
          "repository": "default",
          "uid": "3ef8262d-00fa-4958-9524-58248461470f",
          "path": "/default-domain/workspaces/pouetSpace/pouetFolder/pouetFolderChild._1568188472362_.trashed",
          "type": "Folder",
          "state": "project",
          "parentRef": "3d3e1aae-5b1c-4314-b720-10b42e8d51d5",
          "isCheckedOut": true,
          "isVersion": false,
          "isProxy": false,
          "changeToken": "3-0",
          "isTrashed": false,
          "title": "pouetFolderChild",
          "lastModified": "2019-09-11T07:54:17.323Z",
          "facets": [
            "Folderish",
            "NXTag"
          ],
          "schemas": [
            "common",
            "dublincore",
            "facetedTag"
          ]
        }
        

        Obviously the original path has not been restored:

        curl -sSL -u Administrator:Administrator https://nightly.nuxeo.com/nuxeo/api/v1/path/default-domain/workspaces/pouetSpace/pouetFolder/pouetFolderChild | jq .
        {
          "entity-type": "exception",
          "status": 404,
          "message": "/default-domain/workspaces/pouetSpace/pouetFolder/pouetFolderChild"
        }
        

        Expected behavior: the restored children documents should have their path updated like the parent.

        Attachments

          Issue Links

            Activity

            Hide
            fguillaume Florent Guillaume added a comment -

            The problem lies in org.nuxeo.ecm.core.bulk.action.TrashAction which does not unmangle the name when untrashing. I'm not sure how the mangling is done correctly recursively when trashing to be honest...

            Show
            fguillaume Florent Guillaume added a comment - The problem lies in org.nuxeo.ecm.core.bulk.action.TrashAction which does not unmangle the name when untrashing. I'm not sure how the mangling is done correctly recursively when trashing to be honest...
            Hide
            nalkotob Nour Al Kotob added a comment - - edited

            I don't get the same result as Frantz.

            In the default-domain
            Created a chocolat workspace
            Created a choco folder
            Created a choc file
            Trashed the choco folder
            Made a get on the choc file by id:

            curl -u Administrator:Administrator http://localhost:8080/nuxeo/api/v1/id/{CHOC_ID} | jq
            
            
            {
              ...
              "path": "/default-domain/workspaces/chocolat/choco._1572888306094_.trashed/choc",
               ...
              "isTrashed": true,
              ...
            }
            

            As you can see I have no recursive mangling to start with. Yet, isTrashed is true.
            Mangling and unmangling is called on the file itself in the TrashService implementation then the propagation of the mangling is supposed to be done via events but it doesn't seem to work.

            So I get workspace/folder.mangled/file

            and when unmangling:

            curl -u Administrator:Administrator -XPOST -H "Content-Type: application/json" http://localhost:8080/nuxeo/site/automation/Document.Untrash -d '{"input":"doc:/default-domain/workspaces/chocolat/choco._1572888306094_.trashed"}'
            
            

             

            responds with the untrashed choco folder

            {"entity-type":"document","repository":"default","uid":"81af65b9-7fdd-4a0e-9bf5-4a0e2cfa3b8d","path":"/default-domain/workspaces/chocolat/choco","type":"Folder","state":"project","parentRef":"74c69280-c2e8-4e8e-80b8-0aee9b93fdaa","isCheckedOut":true,"isVersion":false,"isProxy":false,"changeToken":"3-0","isTrashed":false,"title":"choco","lastModified":"2019-11-04T17:23:36.000Z","facets":["Folderish","NXTag"],"schemas":[{"name":"common","prefix":"common"},{"name":"dublincore","prefix":"dc"...
            

             

            Which can be retrieved as usual:

            curl -u Administrator:Administrator http://localhost:8080/nuxeo/api/v1/path/default-domain/workspaces/chocolat/choco | jq
            

             

            resulting in

            {
              ...
              "path": "/default-domain/workspaces/chocolat/choco",
               ...
              "isTrashed": false,
              ...
            }
            

             

            Now checking on choc, everything is as it was before trashing:

            curl -u Administrator:Administrator http://localhost:8080/nuxeo/api/v1/path/default-domain/workspaces/chocolat/choco | jq
            
            {
              ...
              "path": "/default-domain/workspaces/chocolat/choco/choc",
              ...
              "isTrashed": false,
              ...
            }
            

             

             

            Show
            nalkotob Nour Al Kotob added a comment - - edited I don't get the same result as Frantz. In the default-domain Created a chocolat workspace Created a choco folder Created a choc file Trashed the choco folder Made a get on the choc file by id: curl -u Administrator:Administrator http://localhost:8080/nuxeo/api/v1/id/{CHOC_ID} | jq { ...   "path": "/default-domain/workspaces/chocolat/choco._1572888306094_.trashed/choc", ...   "isTrashed": true, ... } As you can see I have no recursive mangling to start with. Yet, isTrashed is true. Mangling and unmangling is called on the file itself in the TrashService implementation then the propagation of the mangling is supposed to be done via events but it doesn't seem to work. So I get workspace/folder.mangled/file and when unmangling: curl -u Administrator:Administrator -XPOST -H "Content-Type: application/json" http://localhost:8080/nuxeo/site/automation/Document.Untrash -d '{"input":"doc:/default-domain/workspaces/chocolat/choco._1572888306094_.trashed"}'   responds with the untrashed choco folder {"entity-type":"document","repository":"default","uid":"81af65b9-7fdd-4a0e-9bf5-4a0e2cfa3b8d","path":"/default-domain/workspaces/chocolat/choco","type":"Folder","state":"project","parentRef":"74c69280-c2e8-4e8e-80b8-0aee9b93fdaa","isCheckedOut":true,"isVersion":false,"isProxy":false,"changeToken":"3-0","isTrashed":false,"title":"choco","lastModified":"2019-11-04T17:23:36.000Z","facets":["Folderish","NXTag"],"schemas":[{"name":"common","prefix":"common"},{"name":"dublincore","prefix":"dc"...   Which can be retrieved as usual: curl -u Administrator:Administrator http://localhost:8080/nuxeo/api/v1/path/default-domain/workspaces/chocolat/choco | jq   resulting in { ...   "path": "/default-domain/workspaces/chocolat/choco", ...   "isTrashed": false, ... }   Now checking on choc, everything is as it was before trashing: curl -u Administrator:Administrator http://localhost:8080/nuxeo/api/v1/path/default-domain/workspaces/chocolat/choco | jq { ...   "path": "/default-domain/workspaces/chocolat/choco/choc", ...   "isTrashed": false, ... }    
            Hide
            ffischer Frantz Fischer added a comment -

            Indeed. Added missing step.

            Show
            ffischer Frantz Fischer added a comment - Indeed. Added missing step.
            Hide
            nalkotob Nour Al Kotob added a comment - - edited

            The problem is:

            let's say we have /folder/file1 and /folder/file2
            -trash file1 -> file1 is mangled AND flagged
            -trash folder -> folder is mangled and flagged but file2 is only flagged (which is normal) 
            -untrash folder -> folder is unmangle AND unflagged AND its children are just unflagged (which is normal for file2 but not file1)
            The problem is, the trashed file1 should not be unflagged since it was trashed independently from folder.
            The only way to make the difference between file1 and file2 to know which has to stay flagged or not is to check if its name is mangled or not. If it is mangled is should stay as such. If not, it should be unflagged.

            Show
            nalkotob Nour Al Kotob added a comment - - edited The problem is: let's say we have /folder/file1 and /folder/file2 -trash file1 -> file1 is mangled AND flagged -trash folder -> folder is mangled and flagged but file2 is only flagged (which is normal)  -untrash folder -> folder is unmangle AND unflagged AND its children are just unflagged (which is normal for file2 but not file1) The problem is, the trashed file1 should not be unflagged since it was trashed independently from folder. The only way to make the difference between file1 and file2 to know which has to stay flagged or not is to check if its name is mangled or not. If it is mangled is should stay as such. If not, it should be unflagged.
            Hide
            supporttechuser Support Tech User added a comment -

            SUCCESS: Integrated in 10.10 » nuxeo-10.10 #301
            NXP-28013: unmangle children when needed (nournuxeo: b706b4740d6169c541d474a6a2733d52a21c63fb)

            Show
            supporttechuser Support Tech User added a comment - SUCCESS: Integrated in 10.10 » nuxeo-10.10 #301 NXP-28013 : unmangle children when needed (nournuxeo: b706b4740d6169c541d474a6a2733d52a21c63fb )
            Hide
            hudson Jenkins added a comment -

            SUCCESS: Integrated in master » nuxeo-master #2749
            NXP-28013: Cleanup / Format (nournuxeo: a34097306406afbc67f76e1e9982b7040a97f923)
            NXP-28013: unmangle children when needed (nournuxeo: 34f717d56eb27db7e3db5d69dcba223ad19bd298)

            Show
            hudson Jenkins added a comment - SUCCESS: Integrated in master » nuxeo-master #2749 NXP-28013 : Cleanup / Format (nournuxeo: a34097306406afbc67f76e1e9982b7040a97f923 ) NXP-28013 : unmangle children when needed (nournuxeo: 34f717d56eb27db7e3db5d69dcba223ad19bd298 )
            Hide
            hudson Jenkins added a comment -

            FAILURE: Integrated in nuxeo » nuxeo » master #170
            NXP-28013: Cleanup / Format (47983949+nournuxeo: a34097306406afbc67f76e1e9982b7040a97f923)

            • (edit) nuxeo-core/nuxeo-core-test/src/test/java/org/nuxeo/ecm/core/trash/test/AbstractTestTrashService.java
            • (edit) nuxeo-core/nuxeo-core-api/src/main/java/org/nuxeo/ecm/core/api/trash/TrashService.java
            • (edit) nuxeo-core/nuxeo-core/src/main/java/org/nuxeo/ecm/core/lifecycle/event/BulkLifeCycleChangeListener.java
            • (edit) nuxeo-core/nuxeo-core/src/main/java/org/nuxeo/ecm/core/trash/AbstractTrashService.java
            • (edit) nuxeo-core/nuxeo-core-bulk/src/main/java/org/nuxeo/ecm/core/bulk/action/TrashAction.java
              NXP-28013: unmangle children when needed (47983949+nournuxeo: 34f717d56eb27db7e3db5d69dcba223ad19bd298)
            • (edit) nuxeo-core/nuxeo-core-test/src/test/java/org/nuxeo/ecm/core/trash/test/AbstractTestTrashService.java
            • (edit) nuxeo-core/nuxeo-core/src/main/java/org/nuxeo/ecm/core/lifecycle/event/BulkLifeCycleChangeListener.java
            • (edit) nuxeo-core/nuxeo-core-bulk/src/main/java/org/nuxeo/ecm/core/bulk/action/TrashAction.java
            • (edit) nuxeo-core/nuxeo-core/src/main/java/org/nuxeo/ecm/core/trash/AbstractTrashService.java
            • (edit) nuxeo-core/nuxeo-core-api/src/main/java/org/nuxeo/ecm/core/api/trash/TrashService.java
            Show
            hudson Jenkins added a comment - FAILURE: Integrated in nuxeo » nuxeo » master #170 NXP-28013 : Cleanup / Format (47983949+nournuxeo: a34097306406afbc67f76e1e9982b7040a97f923 ) (edit) nuxeo-core/nuxeo-core-test/src/test/java/org/nuxeo/ecm/core/trash/test/AbstractTestTrashService.java (edit) nuxeo-core/nuxeo-core-api/src/main/java/org/nuxeo/ecm/core/api/trash/TrashService.java (edit) nuxeo-core/nuxeo-core/src/main/java/org/nuxeo/ecm/core/lifecycle/event/BulkLifeCycleChangeListener.java (edit) nuxeo-core/nuxeo-core/src/main/java/org/nuxeo/ecm/core/trash/AbstractTrashService.java (edit) nuxeo-core/nuxeo-core-bulk/src/main/java/org/nuxeo/ecm/core/bulk/action/TrashAction.java NXP-28013 : unmangle children when needed (47983949+nournuxeo: 34f717d56eb27db7e3db5d69dcba223ad19bd298 ) (edit) nuxeo-core/nuxeo-core-test/src/test/java/org/nuxeo/ecm/core/trash/test/AbstractTestTrashService.java (edit) nuxeo-core/nuxeo-core/src/main/java/org/nuxeo/ecm/core/lifecycle/event/BulkLifeCycleChangeListener.java (edit) nuxeo-core/nuxeo-core-bulk/src/main/java/org/nuxeo/ecm/core/bulk/action/TrashAction.java (edit) nuxeo-core/nuxeo-core/src/main/java/org/nuxeo/ecm/core/trash/AbstractTrashService.java (edit) nuxeo-core/nuxeo-core-api/src/main/java/org/nuxeo/ecm/core/api/trash/TrashService.java

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 days, 3 hours, 30 minutes
                  3d 3h 30m