package fr.insee.rmes.config;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class StaticFilter implements javax.servlet.Filter {
    private RequestDispatcher defaultRequestDispatcher;

    @Override
    public void destroy() {
        throw new UnsupportedOperationException();
    }

    @Override
    public void doFilter(
        ServletRequest request,
        ServletResponse response,
        FilterChain chain) throws IOException, ServletException {
        HttpServletResponse resp = (HttpServletResponse) response;
        HttpServletRequest req = (HttpServletRequest) request;
        if (req.getRequestURI().endsWith("/swagger-ui")) {
            resp.sendRedirect(req.getRequestURI() + "/index.html");
        }
        else if (req.getRequestURI().endsWith("/swagger-ui/")) {
            resp.sendRedirect(req.getRequestURI() + "index.html");
        }
        else if (req.getRequestURI().endsWith("/")) {
            resp.sendRedirect(req.getRequestURI() + "swagger-ui/index.html");
        }
        else {
            defaultRequestDispatcher.forward(request, response);
        }
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        this.defaultRequestDispatcher = filterConfig.getServletContext().getNamedDispatcher("default");
        new Configuration();
    }

}

@@ -370,16 +370,101 @@
 ponse;%0A%0A
+import org.apache.logging.log4j.LogManager;%0Aimport org.apache.logging.log4j.Logger;%0A%0A
 public c
@@ -570,16 +570,93 @@
 patcher;
+%0A    private static Logger logger = LogManager.getLogger(StaticFilter.class);
 %0A%0A    @O
@@ -703,48 +703,47 @@
     
-throw new UnsupportedOperationException(
+logger.warn(%22StaticFilter is destroyed%22
 );%0A 

remove exceptions