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

document path not available in emptyDocumentModelCreated event context

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.10
    • Fix Version/s: 11.1, 2021.0
    • Component/s: Events / Works
    • Backlog priority:
      500
    • Impact type:
      API change
    • Upgrade notes:
      Hide

      DocumentModel#getRef behaviour has changed when called on a non-saved document. Before it was always returning null, now it may return a non-null PathRef value.

      If DocumentModel#getRef was wrongly used to test if a document is saved or not, code must be updated to rely on DocumentModel#getId instead.

      Show
      DocumentModel#getRef behaviour has changed when called on a non-saved document. Before it was always returning null , now it may return a non-null PathRef value. If DocumentModel#getRef was wrongly used to test if a document is saved or not, code must be updated to rely on DocumentModel#getId instead.
    • Sprint:
      nxplatform 11.1.23, nxplatform 11.1.25, nxplatform 11.1.24
    • Story Points:
      1

      Description

      Webui uses the @emptyWithDefaul REST adapter before displaying a create form for a new document.

      /api/v1/id/

      {docId}

      /@emptyWithDefault?type=File

      Using studio it is possible to configure an event handler for that event and run an automation chain/script.

      The issue is that the path or id of the parent document is missing.

      The following automation script breaks

      function run(input, params) {
        Document.GetParent(input, {});
      }
      
      Caused by: org.nuxeo.ecm.automation.OperationException: Failed to invoke operation Document.GetParent
      nuxeo_1  |      at org.nuxeo.ecm.automation.core.impl.InvokableMethod.invoke(InvokableMethod.java:189) ~[nuxeo-automation-core-10.10.jar:?]
      nuxeo_1  |      at org.nuxeo.ecm.automation.core.impl.OperationChainCompiler$OperationMethod.invoke(OperationChainCompiler.java:151) ~[nuxeo-automation-core-10.10.jar:?]
      nuxeo_1  |      at org.nuxeo.ecm.automation.core.impl.OperationChainCompiler$CompiledChainImpl.lambda$invoke$0(OperationChainCompiler.java:218) ~[nuxeo-automation-core-10.10.jar:?]
      nuxeo_1  |      at org.nuxeo.ecm.automation.OperationContext.call(OperationContext.java:326) ~[nuxeo-automation-core-10.10.jar:?]
      nuxeo_1  |      at org.nuxeo.ecm.automation.OperationContext.callWithChainParameters(OperationContext.java:291) ~[nuxeo-automation-core-10.10.jar:?]
      nuxeo_1  |      at org.nuxeo.ecm.automation.core.impl.OperationChainCompiler$CompiledChainImpl.invoke(OperationChainCompiler.java:215) ~[nuxeo-automation-core-10.10.jar:?]
      nuxeo_1  |      at org.nuxeo.automation.scripting.internals.AutomationMapper.executeOperation(AutomationMapper.java:116) ~[nuxeo-automation-scripting-10.10.jar:?]
      nuxeo_1  |      at jdk.nashorn.internal.scripts.Script$Recompilation$5$3022AA$\^eval\_.GetParent(<eval>:79) ~[?:?]
      nuxeo_1  |      at jdk.nashorn.internal.scripts.Script$Recompilation$4$28AA$\^eval\_.run(<eval>:3) ~[?:?]
      nuxeo_1  |      at org.nuxeo.automation.scripting.internals.ScriptingOperationImpl$Runnable$$NashornJavaAdapter.run(Unknown Source) ~[?:?]
      nuxeo_1  |      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181]
      nuxeo_1  |      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_181]
      nuxeo_1  |      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_181]
      nuxeo_1  |      at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_181]
      nuxeo_1  |      at org.nuxeo.automation.scripting.internals.AutomationScriptingServiceImpl$Bridge$1.invoke(AutomationScriptingServiceImpl.java:111) ~[nuxeo-automation-scripting-10.10.jar:?]
      nuxeo_1  |      at com.sun.proxy.$Proxy114.run(Unknown Source) ~[?:?]
      nuxeo_1  |      at org.nuxeo.automation.scripting.internals.ScriptingOperationImpl.run(ScriptingOperationImpl.java:66) ~[nuxeo-automation-scripting-10.10.jar:?]
      nuxeo_1  |      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181]
      nuxeo_1  |      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_181]
      nuxeo_1  |      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_181]
      nuxeo_1  |      at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_181]
      nuxeo_1  |      at org.nuxeo.ecm.automation.core.impl.InvokableMethod.doInvoke(InvokableMethod.java:174) ~[nuxeo-automation-core-10.10.jar:?]
      nuxeo_1  |      at org.nuxeo.ecm.automation.core.impl.InvokableMethod.invoke(InvokableMethod.java:179) ~[nuxeo-automation-core-10.10.jar:?]
      nuxeo_1  |      ... 133 more
      nuxeo_1  | Caused by: java.lang.IllegalArgumentException: null docRref
      

      This is an important piece of context and not having it reduces automation possibilities a lot

      Culprit seems to be that the path is set in the document model after the event is raised:
      https://github.com/nuxeo/nuxeo/blob/1ea4a1851ff580bcd6d349af6e2b0f458d84d7df/nuxeo-core/nuxeo-core/src/main/java/org/nuxeo/ecm/core/api/AbstractSession.java#L643

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 week
                1w