Class UrlRedirectFilter

java.lang.Object
io.goobi.viewer.filters.UrlRedirectFilter
All Implemented Interfaces:
jakarta.servlet.Filter

public class UrlRedirectFilter extends Object implements jakarta.servlet.Filter
Filter for redirecting prettified calls to cmsPages.

Forwarding is handled by RequestDispatcher.forward(ServletRequest, ServletResponse), so the url displayed to the user doesn't change, but the internal handling of the request is according to the forwarded url

'prettified' in this context refers to calling CMSPages by either their 'alternative url' or the url of the static page they replace.

This filter needs to be placed in the filter chain before the RewriteFilter because the RewriteFilter (former PrettyFilter) needs to handle the actual CMSPage mapping (the PrettyFilter won't handle the request if it has been called already for this request, despite the forward)

This filter also stores the called url to the session map using ViewHistory.setCurrentView(ViewerPath, HttpSession). This is essential to leaving a view to return to a previous view (for example when leaving the reading mode)

  • Constructor Details

    • UrlRedirectFilter

      public UrlRedirectFilter()
  • Method Details

    • doFilter

      public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException
      Redirects prettified calls to cmsPages (either using alternative url or static url of a cmsPage) to the actual page url (The cmsPage pretty-url that is) Also stores the actually requested path in the current http session using ViewHistory.setCurrentView(ViewerPath, HttpSession)
      Specified by:
      doFilter in interface jakarta.servlet.Filter
      Throws:
      IOException
      jakarta.servlet.ServletException
    • destroy

      public void destroy()
      Specified by:
      destroy in interface jakarta.servlet.Filter
    • init

      public void init(jakarta.servlet.FilterConfig arg0) throws jakarta.servlet.ServletException
      Specified by:
      init in interface jakarta.servlet.Filter
      Throws:
      jakarta.servlet.ServletException