class ViewServlet extends HttpServlet {

  @Override
  protected void service(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse)
      throws ServletException, IOException
  {
    String uri = httpRequest.getRequestURI();
    if (httpRequest.getQueryString() != null) {
      uri = uri + "?" + httpRequest.getQueryString();
    }

    if (log.isDebugEnabled()) {
      log.debug("Servicing: {} {} ({})", httpRequest.getMethod(), uri, httpRequest.getRequestURL());
    }

    MDC.put(getClass().getName(), uri);
    try {
      doService(httpRequest, httpResponse);
      log.debug("Service completed");
    }
    catch (BadRequestException e) { // NOSONAR
      log.warn("Bad request. Reason: {}", e.getMessage());
      send(null, HttpResponses.badRequest(e.getMessage()), httpResponse);
    }
    catch (Exception e) {
      if (!(e instanceof AuthorizationException)) {
        log.warn("Failure servicing: {} {}", httpRequest.getMethod(), uri, e);
      }
      Throwables.propagateIfPossible(e, ServletException.class, IOException.class);
      throw new ServletException(e);
    }
    finally {
      MDC.remove(getClass().getName());
    }
  }

  @Inject public  ViewServlet(final RepositoryManager repositoryManager,
                     final HttpResponseSenderSelector httpResponseSenderSelector,
                     final DescriptionHelper descriptionHelper,
                     final DescriptionRenderer descriptionRenderer,
                     @Named("${nexus.repository.sandbox.enable:-true}") final boolean sandboxEnabled);

}