Class DefaultPreviewDateWebRequestResolver
java.lang.Object
com.broadleafcommerce.data.tracking.core.preview.context.DefaultPreviewDateWebRequestResolver
- All Implemented Interfaces:
PreviewDateWebRequestResolver
public class DefaultPreviewDateWebRequestResolver
extends Object
implements PreviewDateWebRequestResolver
The default implementation of
PreviewDateWebRequestResolver
that resolves a preview date
Instant
from a NativeWebRequest
when there is a PreviewToken
present.
This resolver will look for a header named getHeaderName()
or a request parameter named
getParameterName()
to detect a preview date String
. If a date-string is found,
it will use Instant.parse(CharSequence)
to construct an Instant
from the value.
If successful, and the PreviewToken
is found, it will return the Instant
.
If this resolver either fails to detect a preview date, or fails to parse a found date-string,
then it will return null
.
- Author:
- Nick Crum (ncrum)
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
protected String
protected String
parseRequestHeader
(org.springframework.web.context.request.NativeWebRequest webRequest) protected String
parseRequestParameter
(org.springframework.web.context.request.NativeWebRequest webRequest) resolve
(org.springframework.web.context.request.NativeWebRequest webRequest) Attempts to resolve a preview date for the provided request and preview token.void
setHeaderName
(String headerName) void
setParameterName
(String parameterName)
-
Field Details
-
DEFAULT_HEADER_NAME
- See Also:
-
DEFAULT_PARAMETER_NAME
- See Also:
-
-
Constructor Details
-
DefaultPreviewDateWebRequestResolver
public DefaultPreviewDateWebRequestResolver()
-
-
Method Details
-
resolve
Description copied from interface:PreviewDateWebRequestResolver
Attempts to resolve a preview date for the provided request and preview token.If no preview date is found this method is expected to return
null
.- Specified by:
resolve
in interfacePreviewDateWebRequestResolver
- Parameters:
webRequest
- the current web request- Returns:
- a preview date
Instant
ornull
-
parseRequestHeader
protected String parseRequestHeader(org.springframework.web.context.request.NativeWebRequest webRequest) -
parseRequestParameter
protected String parseRequestParameter(org.springframework.web.context.request.NativeWebRequest webRequest) -
getHeaderName
-
setHeaderName
-
getParameterName
-
setParameterName
-