Class ViewerPathBuilder
java.lang.Object
io.goobi.viewer.model.urlresolution.ViewerPathBuilder
Offers static methods to create
ViewerPaths from a http request.- Author:
- Florian Alpers
-
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<ViewerPath> createPath(HttpServletRequest httpRequest) Returns the request path of the givenhttpRequestas aViewerPath, including information on associated CMSPage and targeted PageType.static Optional<ViewerPath> createPath(HttpServletRequest request, String baseUrl) createPath.static Optional<ViewerPath> createPath(String applicationUrl, String applicationName, String serviceUrl, String queryString) Create a combined path from the given url.getCampaign(URI servicePath) getCampaign.getCmsPage(URI servicePath) Gets the best matching CMSPage which alternative url ('persistent url') matches the beginning of the given path.getPageType(URI servicePath) Gets thePageTypethat the given path refers to, if any.static URIstatic URIresolve.static URIresolve.static booleanstartsWith(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 '/').
-
Method Details
-
createPath
Returns the request path of the givenhttpRequestas aViewerPath, 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:
- an Optional containing the ViewerPath for the request URL, or empty if not resolvable
- Throws:
DAOException- if any.
-
createPath
public static Optional<ViewerPath> createPath(HttpServletRequest request, String baseUrl) throws DAOException createPath.- Parameters:
request- incoming HTTP request providing server URL and contextbaseUrl- absolute URL to resolve into a ViewerPath- Returns:
- an Optional containing the ViewerPath for the given URL, or empty if not resolvable
- 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 thehostUrl. May be emptyserviceUrl- The complete requested url, optionally including the hostUrlqueryString- the raw HTTP query string, may be null- Returns:
- A
ViewerPathcontaining the complete path information - Throws:
DAOException- if any.
-
getCmsPage
Gets the best matching CMSPage which alternative url ('persistent url') matches the beginning of the given path.- Parameters:
servicePath- requested service path to match against CMS page URLs- Returns:
- an Optional containing the best-matching CMSPage, or empty if none matches
- Throws:
DAOException- if any.
-
getCampaign
getCampaign.- Parameters:
servicePath- requested service path to match against campaign permalinks- Returns:
- an Optional containing the best-matching Campaign, or empty if none matches
- Throws:
DAOException- if any.
-
getPageType
Gets thePageTypethat the given path refers to, if any.- Parameters:
servicePath- requested service path to match against known page types- Returns:
- an Optional containing the best-matching PageType, or empty if the path matches no known page type
-
startsWith
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- URI whose leading path segments are comparedstring- path string to match against the URI prefix- Returns:
- true if the leading path segments of the URI match all segments of the given string, false otherwise
-
resolve
resolve.- Parameters:
master- base URI to resolve againstslave- URI whose string form is appended to the base URIfragment- optional URL fragment to append (without '#')query- optional query string to append (without '?')- Returns:
- the resolved URI combining master and slave with optional fragment and query
-
resolve
- Parameters:
master- the base URIslave- the path segment to append to the base URI- Returns:
- a
URIobject
-
resolve
resolve.- Parameters:
master- base URI to resolve againstslave- path string to append to the base URIfragment- optional URL fragment to append (without '#')query- optional query string to append (without '?')- Returns:
- the resolved URI combining master and slave path with optional fragment and query
-