Search in sources :

Example 1 with PyramusViewController2

use of fi.otavanopisto.pyramus.framework.PyramusViewController2 in project pyramus by otavanopisto.

the class BreadcrumbFilter method doFilter.

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    try {
        if (request instanceof HttpServletRequest) {
            HttpServletRequest httpRequest = (HttpServletRequest) request;
            String uri = httpRequest.getRequestURI();
            String ctxPath = httpRequest.getContextPath();
            String controllerName = uri.substring(ctxPath.length() + 1);
            // TODO: Needed??
            // if (StringUtils.isNotBlank(applicationPath)) {
            // controllerName = controllerName.substring(applicationPath.length());
            // }
            RequestController requestController = RequestControllerMapper.getRequestController(controllerName);
            if ((requestController instanceof PyramusViewController || requestController instanceof PyramusViewController2) && requestController instanceof Breadcrumbable) {
                BreadcrumbHandler breadcrumbHandler = getBreadcrumbHandler(httpRequest);
                if (request.getParameter("resetbreadcrumb") != null) {
                    breadcrumbHandler.clear();
                }
                if (requestController instanceof Breadcrumbable && "GET".equals(httpRequest.getMethod())) {
                    Breadcrumbable breadcrumbable = (Breadcrumbable) requestController;
                    breadcrumbHandler.process(httpRequest, breadcrumbable);
                }
            }
        }
    } finally {
        chain.doFilter(request, response);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PyramusViewController(fi.otavanopisto.pyramus.framework.PyramusViewController) Breadcrumbable(fi.otavanopisto.pyramus.breadcrumbs.Breadcrumbable) RequestController(fi.internetix.smvc.controllers.RequestController) PyramusViewController2(fi.otavanopisto.pyramus.framework.PyramusViewController2) BreadcrumbHandler(fi.otavanopisto.pyramus.breadcrumbs.BreadcrumbHandler)

Aggregations

RequestController (fi.internetix.smvc.controllers.RequestController)1 BreadcrumbHandler (fi.otavanopisto.pyramus.breadcrumbs.BreadcrumbHandler)1 Breadcrumbable (fi.otavanopisto.pyramus.breadcrumbs.Breadcrumbable)1 PyramusViewController (fi.otavanopisto.pyramus.framework.PyramusViewController)1 PyramusViewController2 (fi.otavanopisto.pyramus.framework.PyramusViewController2)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1