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

Allow to override Cleanup in UnrestrictedSessionRunner

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.9.3
    • Component/s: Core

      Description

      When UnrestrictedSessionRunner is used to fetch Documents, these documents are associated with the unrestricted session.

      This is the very reason why, an UnrestrictedSessionRunner should never return live Documents.

      However, we sometimes have the requirement to do so : EasyShare plugin is a good exemple.

      Typically :

      • the interactive user is not authenticated
      • we use UnrestrictedSessionRunner to fetch documents
      • we then use a FreeMarker template to display content

      The problem is that the template rendering may trigger lazy-loading on the DocumentModel that will then try to access the session that has been closed previously.

      To avoid that issue, there are basicaly 2 options :

      Disconnect Documents

      The UnrestrictedSessionRunner implementation could disconned all Documents before returning them

      Sync session close with rendering closing

      This is what was done in the initial implementation.
      https://github.com/mobrebski/nuxeo-easyshare/blob/14ec509c9eca1faa2bfc01ebfc06d9c883a6cad1/src/main/java/org/nuxeo/easyshare/EasyShareUnrestrictedRunner.java

      Unfortunately, this forces the implementer to override a lot of code or to copy a lot of code.

      A better solution would be to make the cleanup method pluggable.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: