private URLProcessor determineURLProcessor(String requestURI) { for (URLProcessor processor : getUrlProcessorList()) { if (processor.canProcessURL(requestURI)) { if (LOG.isDebugEnabled()) { LOG.debug( "URLProcessor found for URI " + requestURI + " - " + processor.getClass().getName()); } return processor; } } // Indicates that this URL is not handled by a URLProcessor return NullURLProcessor.getInstance(); }
/** * (non-Javadoc) * * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, * javax.servlet.FilterChain) */ public void doFilterInternal( HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException { if (!shouldProcessURL(request, request.getRequestURI())) { if (LOG.isTraceEnabled()) { LOG.trace("Process URL not processing URL " + request.getRequestURI()); } filterChain.doFilter(request, response); return; } final String requestURIWithoutContext; if (request.getContextPath() != null) { requestURIWithoutContext = request.getRequestURI().substring(request.getContextPath().length()); } else { requestURIWithoutContext = request.getRequestURI(); } if (LOG.isTraceEnabled()) { LOG.trace("Process URL Filter Begin " + requestURIWithoutContext); } if (request.getAttribute(REQUEST_DTO) == null) { request.setAttribute(REQUEST_DTO, new RequestDTOImpl(request)); } Site site = determineSite(request); SandBox currentSandbox = determineSandbox(request, site); BroadleafRequestContext brc = new BroadleafRequestContext(); brc.setLocale(determineLocale(request, site)); brc.setSandbox(currentSandbox); brc.setRequest(request); brc.setResponse(response); BroadleafRequestContext.setBroadleafRequestContext(brc); try { URLProcessor urlProcessor = null; if (isProduction(currentSandbox)) { try { urlProcessor = lookupProcessorFromCache(requestURIWithoutContext); } catch (ExecutionException e) { LOG.error(e); } } if (urlProcessor == null) { urlProcessor = determineURLProcessor(requestURIWithoutContext); } if (urlProcessor instanceof NullURLProcessor) { // Pass request down the filter chain if (LOG.isTraceEnabled()) { LOG.trace( "URL not being processed by a Broadleaf URLProcessor " + requestURIWithoutContext); } StatusExposingServletResponse sesResponse = new StatusExposingServletResponse(response); filterChain.doFilter(request, sesResponse); if (sesResponse.getStatus() == sesResponse.SC_NOT_FOUND) { if (LOG.isWarnEnabled()) { LOG.warn("Page not found. Unable to render " + requestURIWithoutContext); } urlCache.invalidate(requestURIWithoutContext); } } else { if (LOG.isTraceEnabled()) { LOG.trace( "URL about to be processed by a Broadleaf URLProcessor " + requestURIWithoutContext); } urlProcessor.processURL(requestURIWithoutContext); } } finally { // If the system-time was overridden, set it back to normal SystemTime.resetLocalTimeSource(); } }