use of fi.otavanopisto.pyramus.breadcrumbs.Breadcrumbable 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);
}
}
Aggregations