Class ViewHistory

java.lang.Object
io.goobi.viewer.model.urlresolution.ViewHistory

public final class ViewHistory extends Object
Offers methods to store information about the current and previous html-view (page) in the session store.

The fullscreen view is explicitly excluded from the recorded views, since it acts only as a magnification of the image view, not as a separate page

Author:
Florian Alpers
  • Method Details

    • setCurrentView

      public static void setCurrentView(ServletRequest request)
      Saves the current view information to the request and, if a session exists, to the session map. Also saves the previous view information to the session map if it represents a different view than the current view. Never creates a new http session.
      Parameters:
      request - a ServletRequest object.
    • setCurrentView

      public static void setCurrentView(ViewerPath currentPath, HttpServletRequest request)
      Saves the given currentPath as attribute of the given request and, if the request already has an http session, also to the session map (see setCurrentView(ViewerPath, HttpSession)). Never creates a new http session. Storing the path in the request makes it available to getCurrentView(ServletRequest) for the rest of the request even if no session exists yet.
      Parameters:
      currentPath - The path to store
      request - The current request. If null, nothing is stored
    • setCurrentView

      public static void setCurrentView(ViewerPath currentPath, HttpSession session)
      Saves the given currentPath to the session map, keeping the previously stored currentPath as previousPath if it has a different PageType than the current path.

      The path stored as currentPath can be retrieved by getCurrentView(ServletRequest); the previously stored path can be retrieved by getPreviousView(ServletRequest)

      Parameters:
      currentPath - The path to store
      session - The http session to store the path in
    • getCurrentView

      public static Optional<ViewerPath> getCurrentView(ServletRequest request)
      Retrieves the stored currentPath. The path stored in the passed request itself takes precedence; otherwise the path stored in the session associated with the request is returned.
      Parameters:
      request - a ServletRequest object.
      Returns:
      An optional containing the last stored current path if available. An empty optional if neither the request nor its session contain a path
    • getPreviousView

      public static Optional<ViewerPath> getPreviousView(ServletRequest request)
      Retrieves the stored previousPath from the session associated the the passed request.
      Parameters:
      request - a ServletRequest object.
      Returns:
      An optional containing the last stored previous path if available. An empty optional if no session is available or no previous path has been stored yet
    • redirectToUrl

      public static void redirectToUrl(String url) throws IOException
      Directly redirect to the given url.
      Parameters:
      url - The url to redirect to
      Throws:
      IOException - if any.