Class VersionValidatingRequestBodyAdvice
- java.lang.Object
-
- org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdviceAdapter
-
- com.broadleafcommerce.cartoperation.web.advice.VersionValidatingRequestBodyAdvice
-
- All Implemented Interfaces:
org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice
@ControllerAdvice public class VersionValidatingRequestBodyAdvice extends org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdviceAdapter
Request body advice which validates that the cart version is present and up to date forCartVersionedRequest
s. Will also populate the version on the request body object if the version comes from something other than the request body (e.g. header, cookie).- Author:
- Jacob Mitash
-
-
Constructor Summary
Constructors Constructor Description VersionValidatingRequestBodyAdvice(CartHolder<com.broadleafcommerce.cart.client.domain.Cart> requestCartHolder, Set<CartVersionRequestValidator> validators, RequestCartVersionResolver requestCartVersionResolver, javax.servlet.http.HttpServletRequest request)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
afterBodyRead(Object body, org.springframework.http.HttpInputMessage inputMessage, org.springframework.core.MethodParameter parameter, Type targetType, Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> converterType)
protected javax.servlet.http.HttpServletRequest
getRequest()
protected CartHolder<com.broadleafcommerce.cart.client.domain.Cart>
getRequestCartHolder()
protected RequestCartVersionResolver
getRequestCartVersionResolver()
protected Set<CartVersionRequestValidator>
getValidators()
boolean
supports(org.springframework.core.MethodParameter methodParameter, Type targetType, Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> converterType)
-
-
-
Constructor Detail
-
VersionValidatingRequestBodyAdvice
public VersionValidatingRequestBodyAdvice(CartHolder<com.broadleafcommerce.cart.client.domain.Cart> requestCartHolder, Set<CartVersionRequestValidator> validators, RequestCartVersionResolver requestCartVersionResolver, javax.servlet.http.HttpServletRequest request)
-
-
Method Detail
-
supports
public boolean supports(@NonNull org.springframework.core.MethodParameter methodParameter, @NonNull Type targetType, @NonNull Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> converterType)
-
afterBodyRead
@NonNull public Object afterBodyRead(@NonNull Object body, @NonNull org.springframework.http.HttpInputMessage inputMessage, @NonNull org.springframework.core.MethodParameter parameter, @NonNull Type targetType, @NonNull Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> converterType)
- Specified by:
afterBodyRead
in interfaceorg.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice
- Overrides:
afterBodyRead
in classorg.springframework.web.servlet.mvc.method.annotation.RequestBodyAdviceAdapter
-
getRequestCartHolder
protected CartHolder<com.broadleafcommerce.cart.client.domain.Cart> getRequestCartHolder()
-
getValidators
protected Set<CartVersionRequestValidator> getValidators()
-
getRequestCartVersionResolver
protected RequestCartVersionResolver getRequestCartVersionResolver()
-
getRequest
protected javax.servlet.http.HttpServletRequest getRequest()
-
-