Search in sources :

Example 1 with SiteNotFoundException

use of org.broadleafcommerce.common.exception.SiteNotFoundException in project BroadleafCommerce by BroadleafCommerce.

the class BroadleafRequestFilter method doFilterInternalUnlessIgnored.

@Override
protected void doFilterInternalUnlessIgnored(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException {
    if (!shouldProcessURL(request, request.getRequestURI())) {
        if (LOG.isTraceEnabled()) {
            LOG.trace(String.format("%s not processing URL %s", getClass().getName(), request.getRequestURI()));
        }
        filterChain.doFilter(request, response);
        return;
    }
    if (LOG.isTraceEnabled()) {
        String requestURIWithoutContext;
        if (request.getContextPath() != null) {
            requestURIWithoutContext = request.getRequestURI().substring(request.getContextPath().length());
        } else {
            requestURIWithoutContext = request.getRequestURI();
        }
        // Remove JSESSION-ID or other modifiers
        int pos = requestURIWithoutContext.indexOf(";");
        if (pos >= 0) {
            requestURIWithoutContext = requestURIWithoutContext.substring(0, pos);
        }
        LOG.trace("Process URL Filter Begin " + requestURIWithoutContext);
    }
    if (request.getAttribute(REQUEST_DTO_PARAM_NAME) == null) {
        request.setAttribute(REQUEST_DTO_PARAM_NAME, new RequestDTOImpl(request));
    }
    try {
        requestProcessor.process(new ServletWebRequest(request, response));
        filterChain.doFilter(request, response);
    } catch (HaltFilterChainException e) {
        return;
    } catch (SiteNotFoundException e) {
        LOG.warn("Could not resolve a site for the given request, returning not found");
        response.setStatus(HttpServletResponse.SC_NOT_FOUND);
    } finally {
        requestProcessor.postProcess(new ServletWebRequest(request, response));
    }
}
Also used : RequestDTOImpl(org.broadleafcommerce.common.RequestDTOImpl) HaltFilterChainException(org.broadleafcommerce.common.web.exception.HaltFilterChainException) ServletWebRequest(org.springframework.web.context.request.ServletWebRequest) SiteNotFoundException(org.broadleafcommerce.common.exception.SiteNotFoundException)

Aggregations

RequestDTOImpl (org.broadleafcommerce.common.RequestDTOImpl)1 SiteNotFoundException (org.broadleafcommerce.common.exception.SiteNotFoundException)1 HaltFilterChainException (org.broadleafcommerce.common.web.exception.HaltFilterChainException)1 ServletWebRequest (org.springframework.web.context.request.ServletWebRequest)1