1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
logger.debug("Verification si l'appli est en mode maintenance");
MaintenanceService mtn = null;
HttpServletRequest hRequest = (HttpServletRequest) request;
try{
final WebApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(hRequest.getSession(false).getServletContext());
mtn = (MaintenanceService) ac.getBean("maintenanceSrv");
if(mtn.isEncoursMaintenance()){
logger.debug("Application a été mis en mode maintenance");
hRequest.getSession(true).setAttribute("inMtnce", new Object());
filterConfig.getServletContext().getRequestDispatcher("/WEB-INF/pages/maintenance.jsp").forward(request, response);
}
else{
if(hRequest.getSession(true).getAttribute("inMtnce")!=null)
filterConfig.getServletContext().getRequestDispatcher("/WEB-INF/pages/afterMntcRedirect.jsp").forward(request, response);
else
chain.doFilter(request, response);
}
}catch (Exception e) {
logger.error("Exception de type de NullPointerException a été levée dans le Filter",e);
filterConfig.getServletContext().getRequestDispatcher("/WEB-INF/pages/afterMntcRedirect.jsp").forward(request, response);
}
} |
Partager