Exemplo n.º 1
0
  protected void initApplicationContext() throws BeansException {
    super.initApplicationContext();

    myConverter = new GeoServerServletConverter(getServletContext());
    myConverter.setTarget(createRoot());

    callbacks = GeoServerExtensions.extensions(DispatcherCallback.class, getApplicationContext());
  }
Exemplo n.º 2
0
  protected ModelAndView handleRequestInternal(HttpServletRequest req, HttpServletResponse resp)
      throws Exception {

    try {
      myConverter.service(req, resp);
    } catch (Exception e) {
      RestletException re = null;
      if (e instanceof RestletException) {
        re = (RestletException) e;
      }
      if (re == null && e.getCause() instanceof RestletException) {
        re = (RestletException) e.getCause();
      }

      if (re != null) {
        resp.setStatus(re.getStatus().getCode());

        String reStr = re.getRepresentation().getText();
        if (reStr != null) {
          LOG.severe(reStr);
          resp.setContentType("text/plain");
          resp.getOutputStream().write(reStr.getBytes());
        }

        // log the full exception at a higher level
        LOG.log(Level.SEVERE, "", re);
      } else {
        LOG.log(Level.SEVERE, "", e);
        resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);

        if (e.getMessage() != null) {
          resp.getOutputStream().write(e.getMessage().getBytes());
        }
      }
      resp.getOutputStream().flush();
    }

    return null;
  }