Class ViewerPathBuilder

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

public final class ViewerPathBuilder extends Object
This class offers static methods to create ViewerPaths from a http request.
Author:
Florian Alpers
  • Method Details

    • createPath

      public static Optional<ViewerPath> createPath(javax.servlet.http.HttpServletRequest httpRequest) throws DAOException
      Returns the request path of the given httpRequest as a ViewerPath, including information on associated CMSPage and targeted PageType If the url has a pretty-url context and only consists of the server url, "/index" is appended to the url to redirect to the index pretty-mapping Any occurrences of "index.(x)html" are removed from the url to get the actual pretty url
      Parameters:
      httpRequest - The request from which the path is generated
      Returns:
      a Optional object.
      Throws:
      DAOException - if any.
    • createPath

      public static Optional<ViewerPath> createPath(javax.servlet.http.HttpServletRequest request, String baseUrl) throws DAOException

      createPath.

      Parameters:
      request - a HttpServletRequest object.
      baseUrl - a String object.
      Returns:
      a Optional object.
      Throws:
      DAOException - if any.
    • createPath

      public static Optional<ViewerPath> createPath(String applicationUrl, String applicationName, String serviceUrl, String queryString) throws DAOException
      Create a combined path from the given url. If the url leads to a known PageType, associates the PageType with the combined path. If the path leads to a cmsPage, either through direct url /cmds/..., the cmsPages alternative url or a static page mapping, the cmsPage is associated with this path
      Parameters:
      applicationUrl - The absolute url of the web-application including the application name ('viewer')
      applicationName - The name of the web-application. This is always the last part of the hostUrl. May be empty
      serviceUrl - The complete requested url, optionally including the hostUrl
      queryString -
      Returns:
      A ViewerPath containing the complete path information
      Throws:
      DAOException - if any.
    • getCmsPage

      public static Optional<CMSPage> getCmsPage(URI servicePath) throws DAOException
      Gets the best matching CMSPage which alternative url ('persistent url') matches the beginning of the given path
      Parameters:
      servicePath - a URI object.
      Returns:
      a Optional object.
      Throws:
      DAOException - if any.
    • getCampaign

      public static Optional<Campaign> getCampaign(URI servicePath) throws DAOException

      getCampaign.

      Parameters:
      servicePath - a URI object.
      Returns:
      a Optional object.
      Throws:
      DAOException - if any.
    • getPageType

      public static Optional<PageType> getPageType(URI servicePath)
      Gets the PageType that the given path refers to, if any
      Parameters:
      servicePath - a URI object.
      Returns:
      a Optional object.
    • startsWith

      public static boolean startsWith(URI uri, String string)
      Returns true if the first parts of the uri (separated by '/') are equal to all parts of the given string (separated by '/'). If the string has more parts than the uri, false is returned
      Parameters:
      uri - a URI object.
      string - a String object.
      Returns:
      a boolean.
    • resolve

      public static URI resolve(URI master, URI slave, String fragment, String query)

      resolve.

      Parameters:
      master - a URI object.
      slave - a URI object.
      fragment -
      query -
      Returns:
      a URI object.
    • resolve

      public static URI resolve(URI master, String slave)
      Parameters:
      master -
      slave -
      Returns:
      a URI object
    • resolve

      public static URI resolve(URI master, String slave, String fragment, String query)

      resolve.

      Parameters:
      master - a URI object.
      slave - a String object.
      fragment -
      query -
      Returns:
      a URI object.