use of javax.servlet.ServletContext in project jetty.project by eclipse.
the class ErrorHandler method doError.
@Override
public void doError(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException {
String method = request.getMethod();
if (!HttpMethod.GET.is(method) && !HttpMethod.POST.is(method) && !HttpMethod.HEAD.is(method)) {
baseRequest.setHandled(true);
return;
}
if (this instanceof ErrorPageMapper) {
String error_page = ((ErrorPageMapper) this).getErrorPage(request);
if (error_page != null) {
String old_error_page = (String) request.getAttribute(ERROR_PAGE);
ServletContext servlet_context = request.getServletContext();
if (servlet_context == null)
servlet_context = ContextHandler.getCurrentContext();
if (servlet_context == null) {
LOG.warn("No ServletContext for error page {}", error_page);
} else if (old_error_page != null && old_error_page.equals(error_page)) {
LOG.warn("Error page loop {}", error_page);
} else {
request.setAttribute(ERROR_PAGE, error_page);
Dispatcher dispatcher = (Dispatcher) servlet_context.getRequestDispatcher(error_page);
try {
if (LOG.isDebugEnabled())
LOG.debug("error page dispatch {}->{}", error_page, dispatcher);
if (dispatcher != null) {
dispatcher.error(request, response);
return;
}
LOG.warn("No error page found " + error_page);
} catch (ServletException e) {
LOG.warn(Log.EXCEPTION, e);
return;
}
}
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("No Error Page mapping for request({} {}) (using default)", request.getMethod(), request.getRequestURI());
}
}
}
if (_cacheControl != null)
response.setHeader(HttpHeader.CACHE_CONTROL.asString(), _cacheControl);
generateAcceptableResponse(baseRequest, request, response, response.getStatus(), baseRequest.getResponse().getReason());
}
use of javax.servlet.ServletContext in project head by mifos.
the class ApplicationInitializer method sessionCreated.
@Override
public void sessionCreated(HttpSessionEvent httpSessionEvent) {
ServletContext ctx = httpSessionEvent.getSession().getServletContext();
final ShutdownManager shutdownManager = (ShutdownManager) ctx.getAttribute(ShutdownManager.class.getName());
shutdownManager.sessionCreated(httpSessionEvent);
}
use of javax.servlet.ServletContext in project head by mifos.
the class ApplicationInitializer method init.
public void init(ServletContextEvent servletContextEvent) {
ServletContext servletContext = servletContextEvent.getServletContext();
try {
// prevent ehcache "phone home"
System.setProperty("net.sf.ehcache.skipUpdateCheck", "true");
// prevent quartz "phone home"
System.setProperty("org.terracotta.quartz.skipUpdateCheck", "true");
synchronized (ApplicationInitializer.class) {
ApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
if (servletContext != null) {
dbUpgrade(applicationContext);
}
initJNDIforPentaho(applicationContext);
setAttributesOnContext(servletContext);
copyResources(servletContext);
copyLogo(servletContext);
}
} catch (Exception e) {
String errMsgStart = "unable to start Mifos web application";
if (null == logger) {
System.err.println(errMsgStart + " and logger is not available!");
e.printStackTrace();
} else {
logger.error(errMsgStart, e);
}
throw new Error(e);
}
logger.info("Mifos is ready.");
}
use of javax.servlet.ServletContext in project head by mifos.
the class SystemInformationController method viewSystemInformation.
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "NP_UNWRITTEN_FIELD", justification = "request is not null")
@RequestMapping(method = RequestMethod.GET)
public ModelAndView viewSystemInformation(HttpServletRequest request) {
ServletContext context = request.getSession().getServletContext();
RequestContext requestContext = new RequestContext(request);
Locale locale = requestContext.getLocale();
SystemInformationDto systemInformationDto = systemInformationServiceFacade.getSystemInformation(context, locale);
Map<String, Object> model = new HashMap<String, Object>();
model.put("request", request);
model.put("systemInformationDto", systemInformationDto);
Map<String, Object> status = new HashMap<String, Object>();
List<String> errorMessages = new ArrayList<String>();
status.put("errorMessages", errorMessages);
ModelAndView modelAndView = new ModelAndView("systemInformation", "model", model);
modelAndView.addObject("status", status);
return modelAndView;
}
use of javax.servlet.ServletContext in project head by mifos.
the class PentahoReportsServiceImpl method getEtlLastUpdateDate.
@Override
@PreAuthorize("isFullyAuthenticated()")
public Date getEtlLastUpdateDate(HttpServletRequest request) {
ServletContext context = request.getSession().getServletContext();
Date lastSucessfulRunEtl = null;
try {
List<BatchjobsDto> batchjobs = batchjobsServiceFacade.getBatchjobs(context);
for (BatchjobsDto batchjob : batchjobs) {
if (batchjob.getName().equals("ETLReportDWTaskJob")) {
lastSucessfulRunEtl = batchjob.getLastSuccessfulRun();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return lastSucessfulRunEtl;
}
Aggregations