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 Details

  • Constructor Details

    • DefaultPreviewDateWebRequestResolver

      public DefaultPreviewDateWebRequestResolver()
  • Method Details

    • resolve

      public Instant resolve(org.springframework.web.context.request.NativeWebRequest webRequest)
      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 interface PreviewDateWebRequestResolver
      Parameters:
      webRequest - the current web request
      Returns:
      a preview date Instant or null
    • parseRequestHeader

      protected String parseRequestHeader(org.springframework.web.context.request.NativeWebRequest webRequest)
    • parseRequestParameter

      protected String parseRequestParameter(org.springframework.web.context.request.NativeWebRequest webRequest)
    • getHeaderName

      protected String getHeaderName()
    • setHeaderName

      public void setHeaderName(String headerName)
    • getParameterName

      protected String getParameterName()
    • setParameterName

      public void setParameterName(String parameterName)