Class FormThemeElFinderExplorerSession

  • All Implemented Interfaces:
    Serializable

    public final class FormThemeElFinderExplorerSession
    extends Object
    implements Serializable
    Represents a session for the elfinder explorer, used by the UI for editing the files of a file system. The session is usually bound to the lifecycle of a backing view scoped bean that is used for the UI view. The view scoped bean generates a unique UUID when its view scope begins. We then store a map of these sessions in the HTTP session, with the UUID as the key.

    The explorer session keeps a reference to the data that is required for the elFinder file explorer to work, such as the current file system and resource store manager. The lifecycle of the referenced objects should be bound to the backing view scoped bean.

    Effectively, this is a workaround to share some data with the view scoped bean, as the bean that handles the request from elFinder must be RequestScoped. We use PrimeFaces' dynamic resource feature, and that does not support view scoped beans.

    Since:
    8.3.0
    Author:
    XIMA MEDIA GmbH
    See Also:
    Serialized Form
    • Method Detail

      • model

        public FormThemeEditModeAdvancedModel model()
        Gets the view model to use with the current explorer session. It should be closed when the view scoped bean is destroyed.
        Returns:
        The elFinder connector settings.
      • findCurrentExplorerSession

        public static FormThemeElFinderExplorerSession findCurrentExplorerSession​(String explorerSessionIdParamName)
        Finds the explorer session for the current request, if any. The explorer session is stored in the HTTP session, and bound to the lifecycle of the view scoped bean. The explorer session ID is read from the URL parameter with the given name.
        Parameters:
        explorerSessionIdParamName - The name of the URL parameter that contains the explorer session ID.
        Returns:
        The explorer session, or null if none is found.
      • registerExplorerSession

        public static void registerExplorerSession​(javax.servlet.http.HttpSession httpSession,
                                                   String explorerSessionId,
                                                   FormThemeEditModeAdvancedModel model)
        Registers the given content view with the explorer session for the given explorer session ID. This session ID can then e.g. be used to create an elfinder connector URL for editing the files via the elfinder file manager.

        Passing null for any of the required data will unregister the explorer session for the given explorer session ID.

        Parameters:
        httpSession - The current HTTP session.
        explorerSessionId - The session ID for the explorer session, usually bound to the lifecycle of a view scoped bean.
        model - The view model to associate with the session, or null to unregister the session.
      • unregisterExplorerSession

        public static void unregisterExplorerSession​(javax.servlet.http.HttpSession session,
                                                     String explorerSessionId)
        Unregisters the explorer session with the given explorer session ID from the current HTTP session.
        Parameters:
        session - The current HTTP session.
        explorerSessionId - The session ID for the explorer session, usually bound to the lifecycle of a view scoped bean.