filter-valve: use lambdas
[controller.git] / opendaylight / commons / filter-valve / src / main / java / org / opendaylight / controller / filtervalve / cors / model / FilterProcessor.java
index dc3e9dcd49201654866f6603dc0201cd38359bdd..2aa2301315f0cecc8b804af495ad733677c7555b 100644 (file)
@@ -14,8 +14,6 @@ import java.util.List;
 import java.util.ListIterator;
 import javax.servlet.FilterChain;
 import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 import org.opendaylight.controller.filtervalve.cors.jaxb.Context;
@@ -37,29 +35,26 @@ public class FilterProcessor {
             throws IOException, ServletException {
 
         String contextPath = request.getContext().getPath();
-        String pathInfo = request.getPathInfo();
+        String path = request.getDecodedRequestURI();
 
         Optional<Context> maybeContext = host.findContext(contextPath);
-        logger.trace("Processing context {} path {}, found {}", contextPath, pathInfo, maybeContext);
+        logger.trace("Processing context {} path {}, found {}", contextPath, path, maybeContext);
         if (maybeContext.isPresent()) {
             // process filters
             Context context = maybeContext.get();
-            List<Filter> matchingFilters = context.findMatchingFilters(pathInfo);
+            List<Filter> matchingFilters = context.findMatchingFilters(path);
             FilterChain fromLast = nextValveFilterChain;
             ListIterator<Filter> it = matchingFilters.listIterator(matchingFilters.size());
             final boolean trace = logger.isTraceEnabled();
             while (it.hasPrevious()) {
                 final Filter currentFilter = it.previous();
                 final FilterChain copy = fromLast;
-                fromLast = new FilterChain() {
-                    @Override
-                    public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
-                        if (trace) {
-                            logger.trace("Applying {}", currentFilter);
-                        }
-                        javax.servlet.Filter actualFilter = currentFilter.getActualFilter();
-                        actualFilter.doFilter(request, response, copy);
+                fromLast = (request1, response1) -> {
+                    if (trace) {
+                        logger.trace("Applying {}", currentFilter);
                     }
+                    javax.servlet.Filter actualFilter = currentFilter.getActualFilter();
+                    actualFilter.doFilter(request1, response1, copy);
                 };
             }
             // call first filter