package fr.synchrotron.soleil.ica.proxy.utilities;

import org.apache.commons.httpclient.HttpStatus;
import org.vertx.java.core.Handler;
import org.vertx.java.core.http.HttpServerRequest;
import org.vertx.java.core.http.RouteMatcher;
import org.vertx.java.core.logging.Logger;
import org.vertx.java.core.logging.impl.LoggerFactory;

/**
 * @author Gregory Boissinot
 */
public class RequestHandlerWrapper implements Handler<HttpServerRequest> {

    private static final Logger LOG = LoggerFactory.getLogger(RequestHandlerWrapper.class);
    private final RouteMatcher routeMatcher;

    public RequestHandlerWrapper(RouteMatcher routeMatcher) {
        this.routeMatcher = routeMatcher;
    }

    @Override
    public void handle(final HttpServerRequest request) {

        if (LOG.isDebugEnabled()) {
            LOG.debug("Incoming request : " + request.method() + " " + request.uri());
        }

        request.exceptionHandler(new Handler<Throwable>() {
            @Override
            public void handle(Throwable t) {
                LOG.error("Severe error during request processing :", t);
                request.response().setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
                request.response().end();
            }
        });

        try {
            routeMatcher.handle(request);
        } catch (Throwable t) {
            LOG.error("The routeMatcher throw an error", t);
            LOG.error("Severe error during request processing :", t);
            request.response().setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
            request.response().end();
        }
    }

}

@@ -56,42 +56,48 @@
 ort 
-org.apache.commons.httpclient.Http
+io.netty.handler.codec.http.HttpResponse
 Stat
@@ -1152,34 +1152,39 @@
 tusCode(Http
+Response
 Status.
-SC_
 INTERNAL_SER
@@ -1184,32 +1184,39 @@
 NAL_SERVER_ERROR
+.code()
 );%0A             
@@ -1543,18 +1543,23 @@
 Http
+Response
 Status.
-SC_
 INTE
@@ -1575,16 +1575,23 @@
 ER_ERROR
+.code()
 );%0A     

use vertx api