Class BLCRequestUtils

java.lang.Object
org.broadleafcommerce.common.util.BLCRequestUtils

public class BLCRequestUtils extends Object
Convenience methods for interacting with the request
Author:
bpolster
  • Constructor Details

    • BLCRequestUtils

      public BLCRequestUtils()
  • Method Details

    • isOKtoUseSession

      public static boolean isOKtoUseSession(org.springframework.web.context.request.WebRequest request)
      Broadleaf "Resolver" and "Filter" classes may need to know if they are allowed to utilize the session. BLC uses a pattern where we will store an attribute in the request indicating whether or not the session can be used. For example, when using the REST APIs, we typically do not want to utilize the session.
    • isFilteringIgnoredForUri

      public static boolean isFilteringIgnoredForUri(org.springframework.web.context.request.WebRequest request)
    • getSessionAttributeIfOk

      public static Object getSessionAttributeIfOk(org.springframework.web.context.request.WebRequest request, String attribute)
      Takes isOKtoUseSession(WebRequest) into account when retrieving session attributes. If it's not ok, this will return null
    • setSessionAttributeIfOk

      public static boolean setSessionAttributeIfOk(org.springframework.web.context.request.WebRequest request, String attribute, Object value)
      Takes isOKtoUseSession(WebRequest) into account when setting a session attribute
      Returns:
      true if this set the session attribute, false otherwise
    • setOKtoUseSession

      public static void setOKtoUseSession(org.springframework.web.context.request.WebRequest request, Boolean value)
      Sets whether or not Broadleaf can utilize the session in request processing. Used by the REST API flow so that RESTful calls do not utilize the session.
    • setIsFilteringIgnoredForUri

      public static void setIsFilteringIgnoredForUri(org.springframework.web.context.request.WebRequest request, Boolean value)
    • getURLorHeaderParameter

      public static String getURLorHeaderParameter(org.springframework.web.context.request.WebRequest request, String varName)
      Get header or url parameter. Will obtain the parameter from a header variable or a URL parameter, preferring header values if they are set.
    • getRequestedServerPrefix

      public static String getRequestedServerPrefix()
      Convenience method to obtain the server prefix of the current request. Useful for many modules that configure Relative URL's and need to send absolute URL's to Third Party Gateways.
    • getRequestURIWithoutContext

      public static String getRequestURIWithoutContext(jakarta.servlet.http.HttpServletRequest request)