class LogsearchFilter implements Filter {

  @Override
  public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
    HttpServletRequest request = (HttpServletRequest) servletRequest;
    if (requestMatcher.matches(request)) {
      StatusMessage errorResponse = statusProvider.getStatusMessage(request.getRequestURI());
      if (errorResponse != null) {
        logger.info("{} request is filtered out: {}", request.getRequestURL(), errorResponse.getMessage());
        HttpServletResponse resp = (HttpServletResponse) servletResponse;
        resp.setStatus(errorResponse.getStatusCode());
        resp.setContentType("application/json");
        resp.getWriter().print(toJson(errorResponse));
        return;
      }
    }
    filterChain.doFilter(servletRequest, servletResponse);
  }

  public  LogsearchFilter(RequestMatcher requestMatcher, StatusProvider statusProvider);
  public  LogsearchFilter(RequestMatcher requestMatcher, StatusProvider statusProvider, boolean enabled);

}