Class RepositorySessionManager

All Implemented Interfaces:
IPageFlowScopeAdapter, EventListener, HttpSessionBindingListener

public class RepositorySessionManager extends BaseFacesSessionBean
Wrapper around a JCR session that takes care of cleaning up when the http session is invalidated. Also exposes a few JCR session methods in a JSF friendly way.
Since:
8.0
  • Field Details

    • fRepositoryJNDIName

      protected String fRepositoryJNDIName
      Holds the JNDI name to get a reference to the Repository
    • fWorkspaceNameJNDIName

      protected String fWorkspaceNameJNDIName
      Holds the JNDI name of the workspace name
    • fWorkspaceName

      protected String fWorkspaceName
      Holds the current workspace name
    • fCurrentSession

      protected javax.jcr.Session fCurrentSession
      Holds the current JCR session
    • fImpersonatedUser

      protected String fImpersonatedUser
      Holds the id of the impersonated user
    • fRepository

      protected javax.jcr.Repository fRepository
      Holds reference to the JCR Repository
    • fCredentials

      protected javax.jcr.Credentials fCredentials
      Holds reference to the user credentials. If this is null, and we are a MwS inproc app, then the current MwS user will be used.
  • Constructor Details

    • RepositorySessionManager

      public RepositorySessionManager()
  • Method Details

    • getRepository

      public javax.jcr.Repository getRepository()
      Get the handle to the repository by using a JNDI lookup
      Returns:
      the repository
    • getCredentials

      public javax.jcr.Credentials getCredentials()
      Return the credentials used to create a JCR session
    • setCredentials

      public void setCredentials(javax.jcr.Credentials credentials)
      Sets the credentials to use
      Parameters:
      credentials - the credentials to set
    • getCurrentSession

      public javax.jcr.Session getCurrentSession()
      Return the currently active session is it exists and is still live, otherwise a new JCR session is created and returned. This API will also attempt user impersonation if an impersonatedUser has been supplied. NOTE: the real user must be a member of the admin role to impersonate other users.
      Returns:
      the currentSession
    • release

      protected void release()
      Overrides the default to logout the current JCR session
      Specified by:
      release in class BaseFacesSessionBean
      See Also:
    • finalize

      protected void finalize() throws Throwable
      Overrides the default to logout the current JCR session
      Overrides:
      finalize in class Object
      Throws:
      Throwable
      See Also:
    • startNewSession

      public String startNewSession()
      This is a convenience method to throw away the current JCR session.
      Returns:
      action status: "ok" or "error"
    • save

      public String save()
      This is a convenience method to expose the Session.save() API for use in a MethodBinding expression. Any RepositoryException is caught and exposed as a FacesMessage.
      Returns:
      action status: "ok" or "error"
    • refreshDiscardUnsaved

      public String refreshDiscardUnsaved()
      This is a convenience method to expose the Session.refresh(boolean) API for use in a MethodBinding expression. Any RepositoryException is caught and exposed as a FacesMessage. Refreshes the state in the current session. All unsaved transient nodes/properties will be discarded.
      Returns:
      action status: "ok" or "error"
    • refreshKeepUnsaved

      public String refreshKeepUnsaved()
      This is a convenience method to expose the Session.refresh(boolean) API for use in a MethodBinding expression. Any RepositoryException is caught and exposed as a FacesMessage. Refresh the state in the current session. All unsaved transient nodes/properties will be preserved.
      Returns:
      action status: "ok" or "error"
    • getImpersonatedUser

      public String getImpersonatedUser()
      Returns the user that the current session will impersonate
    • setImpersonatedUser

      public void setImpersonatedUser(String impersonatedUser)
      Sets the user that the session will attempt to impersonate
      Parameters:
      impersonatedUser - the userid to impersonate