java.lang.Object
javax.servlet.ServletRequestWrapper
javax.servlet.http.HttpServletRequestWrapper
com.aoapps.web.framework.WebSiteRequest
- All Implemented Interfaces:
HttpServletRequest
,ServletRequest
A
WebSiteSettings
contains all the values that a user may customize while they view the web site.- Author:
- AO Industries, Inc.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Shuts-down background clean-up thread on application stop. -
Field Summary
Modifier and TypeFieldDescriptionstatic final ScopeEE.Session.Attribute
<String> Parameter that selects theWebPageLayout
.static final String
Parameter that contains the login password during authentication.static final String
Parameter name used for login requests.static final String
Parameter that contains the login username during authentication.static final String
Parameter name used for logout requests.static final String
Parameter value forSEARCH_TARGET
to search the entire site.static final String
Parameter the contains the search query for in-site search on the current page.static final String
Parameter that contains the search target (currentSEARCH_ENTIRE_SITE
orSEARCH_THIS_AREA
).static final String
Parameter value forSEARCH_TARGET
to search the current area of the site.protected final WebPage
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
-
Constructor Summary
ConstructorDescriptionWebSiteRequest
(WebPage sourcePage, HttpServletRequest req) Creates a new website request wrapper. -
Method Summary
Modifier and TypeMethodDescriptionprotected static boolean
appendEncodedParam
(StringBuilder url, String encodedName, String encodedValue, boolean hasQuery) Appends an already-encoded parameter to a URL.protected static boolean
appendParam
(StringBuilder url, String name, String value, boolean hasQuery) Appends a parameter to a URL.protected static boolean
appendParam
(StringBuilder url, String name, String value, Set<String> finishedParams, boolean hasQuery) Appends a parameter to a URL.protected static boolean
appendParams
(StringBuilder url, URIParameters params, Set<String> finishedParams, boolean hasQuery) Appends the parameters to a URL.protected boolean
appendSettings
(Set<String> finishedParams, boolean hasQuery, StringBuilder url) getEncodedUrl
(WebPage page, URIParameters params, HttpServletResponse resp) getEncodedUrl
(WebPage page, HttpServletResponse resp) getEncodedUrl
(Class<? extends WebPage> clazz, URIParameters params, HttpServletResponse resp) getEncodedUrl
(Class<? extends WebPage> clazz, HttpServletResponse resp) getEncodedUrlForClass
(String classname, URIParameters params, String fragment, HttpServletResponse resp) getEncodedUrlForClass
(String classname, URIParameters params, HttpServletResponse resp) getEncodedUrlForClass
(String classAndParamsFragment, HttpServletResponse resp) getEncodedUrlForPath
(String path, URIParameters params, boolean keepSettings, HttpServletResponse resp) getEncodedUrlForPath
(String path, URIParameters params, HttpServletResponse resp) getEncodedUrlForPath
(String path, HttpServletResponse resp) A fast pseudo-random number generator for non-cryptographic purposes.getParameter
(String name) String[]
getParameterValues
(String name) Gets the random number generator used for this request.static UploadedFile
getUploadedFile
(WebSiteUser owner, Identifier id, ServletContext context) Gets a file that was uploaded given its ID.Gets the set of files uploaded during this request.Gets the context-relative URL to a web page.getUrl
(WebPage page, URIParameters params) Gets the context-relative URL to a web page.getUrl
(Class<? extends WebPage> clazz, URIParameters params) Gets the context-relative URL to a web page.getUrlForClass
(String classAndParamsFragment) Gets a context-relative URL from a String containing a classname and optional parameters/fragment.getUrlForClass
(String classname, URIParameters params) Gets a context-relative URL given its classname and optional parameters.getUrlForClass
(String classname, URIParameters params, String fragment) Gets a context-relative URL given its classname and optional parameters/fragment.getUrlForPath
(String path) Gets the URL String, keeping the current settings.getUrlForPath
(String path, URIParameters params) Gets the URL String with the given parameters embedded, keeping the current settings.getUrlForPath
(String path, URIParameters params, boolean keepSettings) Gets the context-relative URL, optionally with the settings embedded.Gets the person who is logged in ornull
if no login is performed for this request.boolean
Determines if the request is for a BlackBerry browser.boolean
isLinux()
Determines if the request is for a Linux browser.boolean
Determines if the user is currently logged in.boolean
isLynx()
Determines if the request is for a Lynx browser.void
logout
(HttpServletResponse resp) Logs out the current user or does nothing if not logged in.<__ extends FlowContent<__>>
voidprintFormFields
(__ form) Prints the hidden variables that contain all of the current settings.Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole, login, logout, upgrade
Methods inherited from class javax.servlet.ServletRequestWrapper
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameterMap, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setRequest, startAsync, startAsync
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.servlet.ServletRequest
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameterMap, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsync
-
Field Details
-
SEARCH_QUERY
Parameter the contains the search query for in-site search on the current page.- See Also:
-
SEARCH_TARGET
Parameter that contains the search target (currentSEARCH_ENTIRE_SITE
orSEARCH_THIS_AREA
).- See Also:
-
SEARCH_ENTIRE_SITE
Parameter value forSEARCH_TARGET
to search the entire site.- See Also:
-
SEARCH_THIS_AREA
Parameter value forSEARCH_TARGET
to search the current area of the site.- See Also:
-
LAYOUT
Parameter that selects theWebPageLayout
. -
LOGOUT_REQUESTED
Parameter name used for logout requests. Will perform logout when has a value that parses toBoolean.TRUE
.- See Also:
-
LOGIN_REQUESTED
Parameter name used for login requests. Will perform login when has a value that parses toBoolean.TRUE
.- See Also:
-
LOGIN_USERNAME
Parameter that contains the login username during authentication.- See Also:
-
LOGIN_PASSWORD
Parameter that contains the login password during authentication.- See Also:
-
sourcePage
-
-
Constructor Details
-
WebSiteRequest
Creates a new website request wrapper.- Throws:
ServletException
-
-
Method Details
-
getSecureRandom
Gets the random number generator used for this request.Note: This is not a strong instance to avoid blocking.
-
getFastRandom
A fast pseudo-random number generator for non-cryptographic purposes. -
appendEncodedParam
protected static boolean appendEncodedParam(StringBuilder url, String encodedName, String encodedValue, boolean hasQuery) Appends an already-encoded parameter to a URL.- Parameters:
encodedName
- the encoded nameencodedValue
- the encoded value
-
appendParam
protected static boolean appendParam(StringBuilder url, String name, String value, boolean hasQuery) Appends a parameter to a URL.- Parameters:
name
- the raw, unencoded namevalue
- the raw, unencoded value
-
appendParam
protected static boolean appendParam(StringBuilder url, String name, String value, Set<String> finishedParams, boolean hasQuery) Appends a parameter to a URL.- Parameters:
name
- the raw, unencoded namevalue
- the raw, unencoded valuefinishedParams
- Only adds a value when the name has not already been added to the URL. This does not support multiple values, only the first is used.
-
appendParams
protected static boolean appendParams(StringBuilder url, URIParameters params, Set<String> finishedParams, boolean hasQuery) Appends the parameters to a URL.- Parameters:
finishedParams
- Only adds a value when the name has not already been added to the URL. This does not support multiple values, only the first is used.
-
getUrlForClass
public String getUrlForClass(String classname, URIParameters params, String fragment) throws ServletException Gets a context-relative URL given its classname and optional parameters/fragment.- Parameters:
params
- Only adds a value when the name has not already been added to the URL. This does not support multiple values, only the first is used.- Throws:
ServletException
-
getEncodedUrlForClass
public String getEncodedUrlForClass(String classname, URIParameters params, String fragment, HttpServletResponse resp) throws ServletException Gets the URL. Including:- Prefixing context path
- Encoded to ASCII-only RFC 3986 format
- Then response encoding
- Parameters:
params
- Only adds a value when the name has not already been added to the URL. This does not support multiple values, only the first is used.- Throws:
ServletException
-
getUrlForClass
Gets a context-relative URL given its classname and optional parameters.- Parameters:
params
- Only adds a value when the name has not already been added to the URL. This does not support multiple values, only the first is used.- Throws:
ServletException
-
getEncodedUrlForClass
public String getEncodedUrlForClass(String classname, URIParameters params, HttpServletResponse resp) throws ServletException Gets the URL. Including:- Prefixing context path
- Encoded to ASCII-only RFC 3986 format
- Then response encoding
- Parameters:
params
- Only adds a value when the name has not already been added to the URL. This does not support multiple values, only the first is used.- Throws:
ServletException
-
getUrlForClass
Gets a context-relative URL from a String containing a classname and optional parameters/fragment. Parameters and fragment should already be URL encoded but not XML encoded.- Throws:
ServletException
-
getEncodedUrlForClass
public String getEncodedUrlForClass(String classAndParamsFragment, HttpServletResponse resp) throws ServletException Gets the URL. Including:- Prefixing context path
- Encoded to ASCII-only RFC 3986 format
- Then response encoding
- Throws:
ServletException
-
getUrlForPath
public String getUrlForPath(String path, URIParameters params, boolean keepSettings) throws ServletException Gets the context-relative URL, optionally with the settings embedded.- Parameters:
path
- the context-relative path, with a beginning slashparams
- Only adds a value when the name has not already been added to the URL. This does not support multiple values, only the first is used.- Throws:
ServletException
-
getEncodedUrlForPath
public String getEncodedUrlForPath(String path, URIParameters params, boolean keepSettings, HttpServletResponse resp) throws ServletException Gets the URL. Including:- Prefixing context path
- Encoded to ASCII-only RFC 3986 format
- Then response encoding
- Parameters:
path
- the context-relative path, with a beginning slashparams
- Only adds a value when the name has not already been added to the URL. This does not support multiple values, only the first is used.- Throws:
ServletException
-
appendSettings
-
getParameter
- Specified by:
getParameter
in interfaceServletRequest
- Overrides:
getParameter
in classServletRequestWrapper
-
getParameterNames
- Specified by:
getParameterNames
in interfaceServletRequest
- Overrides:
getParameterNames
in classServletRequestWrapper
-
getParameterValues
- Specified by:
getParameterValues
in interfaceServletRequest
- Overrides:
getParameterValues
in classServletRequestWrapper
-
getUrl
Gets the context-relative URL to a web page.- Throws:
ServletException
-
getEncodedUrl
Gets the URL. Including:- Prefixing context path
- Encoded to ASCII-only RFC 3986 format
- Then response encoding
- Throws:
ServletException
-
getUrl
Gets the context-relative URL to a web page.- Parameters:
params
- Only adds a value when the name has not already been added to the URL. This does not support multiple values, only the first is used.- Throws:
ServletException
-
getEncodedUrl
public String getEncodedUrl(WebPage page, URIParameters params, HttpServletResponse resp) throws ServletException Gets the URL. Including:- Prefixing context path
- Encoded to ASCII-only RFC 3986 format
- Then response encoding
- Parameters:
params
- Only adds a value when the name has not already been added to the URL. This does not support multiple values, only the first is used.- Throws:
ServletException
-
getUrl
Gets the context-relative URL to a web page.- Parameters:
params
- Only adds a value when the name has not already been added to the URL. This does not support multiple values, only the first is used.- Throws:
ServletException
-
getEncodedUrl
public String getEncodedUrl(Class<? extends WebPage> clazz, URIParameters params, HttpServletResponse resp) throws ServletException Gets the URL. Including:- Prefixing context path
- Encoded to ASCII-only RFC 3986 format
- Then response encoding
- Parameters:
params
- Only adds a value when the name has not already been added to the URL. This does not support multiple values, only the first is used.- Throws:
ServletException
-
getUrl
- Throws:
ServletException
-
getEncodedUrl
public String getEncodedUrl(Class<? extends WebPage> clazz, HttpServletResponse resp) throws ServletException Gets the URL. Including:- Prefixing context path
- Encoded to ASCII-only RFC 3986 format
- Then response encoding
- Throws:
ServletException
-
getUrlForPath
Gets the URL String with the given parameters embedded, keeping the current settings.- Parameters:
path
- the context-relative path, with a beginning slashparams
- Only adds a value when the name has not already been added to the URL. This does not support multiple values, only the first is used.- Throws:
ServletException
-
getUrlForPath
Gets the URL String, keeping the current settings.- Parameters:
path
- the context-relative path, with a beginning slash- Throws:
ServletException
-
getEncodedUrlForPath
public String getEncodedUrlForPath(String path, URIParameters params, HttpServletResponse resp) throws ServletException Gets the URL. Including:- Prefixing context path
- Encoded to ASCII-only RFC 3986 format
- Then response encoding
- Parameters:
path
- the context-relative path, with a beginning slashparams
- Only adds a value when the name has not already been added to the URL. This does not support multiple values, only the first is used.- Throws:
ServletException
-
getEncodedUrlForPath
Gets the URL. Including:- Prefixing context path
- Encoded to ASCII-only RFC 3986 format
- Then response encoding
- Parameters:
path
- the context-relative path, with a beginning slash- Throws:
ServletException
-
isLynx
public boolean isLynx()Determines if the request is for a Lynx browser. -
isBlackBerry
public boolean isBlackBerry()Determines if the request is for a BlackBerry browser. -
isLinux
public boolean isLinux()Determines if the request is for a Linux browser. -
printFormFields
public <__ extends FlowContent<__>> void printFormFields(__ form) throws ServletException, IOException Prints the hidden variables that contain all of the current settings.- Throws:
ServletException
IOException
-
getUploadedFiles
Gets the set of files uploaded during this request. -
getUploadedFile
public static UploadedFile getUploadedFile(WebSiteUser owner, Identifier id, ServletContext context) throws SecurityException Gets a file that was uploaded given its ID. The authentication credentials for this request must match those of the provided ID.- Parameters:
owner
- the owner of the object- Returns:
- the
UploadedFile
ornull
if not found - Throws:
SecurityException
- if the ID is not assigned to the person logged in
-
getWebSiteUser
Gets the person who is logged in ornull
if no login is performed for this request.- Parameters:
resp
- The current response ornull
when invoked fromWebPage.getLastModified(javax.servlet.http.HttpServletRequest)
- Throws:
LoginException
- if an invalid login attempt is made or the user credentials are not foundServletException
-
isLoggedIn
Determines if the user is currently logged in.- Throws:
ServletException
-
logout
Logs out the current user or does nothing if not logged in.
-