Search in sources :

Example 11 with ServletContext

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());
}
Also used : ServletException(javax.servlet.ServletException) ServletContext(javax.servlet.ServletContext) Dispatcher(org.eclipse.jetty.server.Dispatcher) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 12 with ServletContext

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);
}
Also used : ServletContext(javax.servlet.ServletContext) ShutdownManager(org.mifos.application.admin.system.ShutdownManager)

Example 13 with ServletContext

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.");
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ServletContext(javax.servlet.ServletContext) SystemException(org.mifos.framework.exceptions.SystemException) TaskSystemException(org.mifos.framework.components.batchjobs.exceptions.TaskSystemException) XMLReaderException(org.mifos.framework.exceptions.XMLReaderException) HibernateProcessException(org.mifos.framework.exceptions.HibernateProcessException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ConfigurationException(org.mifos.config.exceptions.ConfigurationException) AppNotConfiguredException(org.mifos.framework.exceptions.AppNotConfiguredException) AccountException(org.mifos.accounts.exceptions.AccountException) FinancialException(org.mifos.accounts.financial.exceptions.FinancialException) NameAlreadyBoundException(javax.naming.NameAlreadyBoundException) IOException(java.io.IOException) HibernateStartUpException(org.mifos.framework.exceptions.HibernateStartUpException) ApplicationException(org.mifos.framework.exceptions.ApplicationException)

Example 14 with ServletContext

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;
}
Also used : Locale(java.util.Locale) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) ServletContext(javax.servlet.ServletContext) RequestContext(org.springframework.web.servlet.support.RequestContext) SystemInformationDto(org.mifos.application.admin.servicefacade.SystemInformationDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with ServletContext

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;
}
Also used : ServletContext(javax.servlet.ServletContext) BatchjobsDto(org.mifos.application.admin.servicefacade.BatchjobsDto) Date(java.util.Date) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ReflectionException(org.mifos.reports.pentaho.util.ReflectionException) ReportProcessingException(org.pentaho.reporting.engine.classic.core.ReportProcessingException) IOException(java.io.IOException) AccessDeniedException(org.springframework.security.access.AccessDeniedException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

ServletContext (javax.servlet.ServletContext)1111 Test (org.junit.Test)259 HttpServletRequest (javax.servlet.http.HttpServletRequest)186 HttpServletResponse (javax.servlet.http.HttpServletResponse)143 IOException (java.io.IOException)136 ServletException (javax.servlet.ServletException)101 ServletConfig (javax.servlet.ServletConfig)79 File (java.io.File)78 FilterConfig (javax.servlet.FilterConfig)66 HashMap (java.util.HashMap)64 Enumeration (java.util.Enumeration)52 InputStream (java.io.InputStream)51 ArrayList (java.util.ArrayList)50 URL (java.net.URL)48 HttpSession (javax.servlet.http.HttpSession)43 Map (java.util.Map)39 Locale (java.util.Locale)38 List (java.util.List)33 PrintWriter (java.io.PrintWriter)32 LinkedHashMap (java.util.LinkedHashMap)30