use of fi.otavanopisto.pyramus.breadcrumbs.BreadcrumbHandler in project pyramus by otavanopisto.
the class BreadcrumbFilter method getBreadcrumbHandler.
private synchronized BreadcrumbHandler getBreadcrumbHandler(HttpServletRequest request) {
HttpSession session = request.getSession(true);
BreadcrumbHandler breadcrumbHandler = (BreadcrumbHandler) session.getAttribute("breadcrumbHandler");
if (breadcrumbHandler == null) {
breadcrumbHandler = new BreadcrumbHandler();
session.setAttribute("breadcrumbHandler", breadcrumbHandler);
}
return breadcrumbHandler;
}
use of fi.otavanopisto.pyramus.breadcrumbs.BreadcrumbHandler 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