class ViewServlet extends HttpServlet {

  @VisibleForTesting
  void dispatchAndSend(final Request request,
                       final ViewFacet facet,
                       final HttpResponseSender sender,
                       final HttpServletResponse httpResponse)
      throws Exception
  {
    Response response = null;
    Exception failure = null;
    try {
      response = facet.dispatch(request);
    }
    catch (Exception e) {
      failure = e;
    }

    String describeFlags = request.getParameters().get(P_DESCRIBE);
    log.trace("Describe flags: {}", describeFlags);
    if (describeFlags != null) {
      send(request, describe(request, response, failure, describeFlags), httpResponse);
    }
    else {
      if (failure != null) {
        throw failure;
      }
      log.debug("Request: {}", request);
      sender.send(request, response, httpResponse);
    }
  }

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

}