Search in sources :

Example 1 with Request

use of io.milton.http.Request in project lobcder by skoulouzis.

the class SpringAwareMiltonServlet method service.

@Override
public void service(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse) throws ServletException, IOException {
    HttpServletRequest req = (HttpServletRequest) servletRequest;
    HttpServletResponse resp = (HttpServletResponse) servletResponse;
    try {
        originalRequest.set(req);
        originalResponse.set(resp);
        Request request = new ServletRequest(req, servletContext);
        Response response = new ServletResponse(resp);
        httpManager.process(request, response);
    } finally {
        originalRequest.remove();
        originalResponse.remove();
        servletResponse.getOutputStream().flush();
        servletResponse.flushBuffer();
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(io.milton.http.Response) HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) Request(io.milton.http.Request) HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse)

Example 2 with Request

use of io.milton.http.Request in project lobcder by skoulouzis.

the class SpringMiltonFilter method doMiltonProcessing.

private void doMiltonProcessing(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    try {
        MiltonServlet.setThreadlocals(req, resp);
        Request request = new io.milton.servlet.ServletRequest(req, servletContext);
        Response response = new io.milton.servlet.ServletResponse(resp);
        httpManager.process(request, response);
    } finally {
        MiltonServlet.clearThreadlocals();
        resp.getOutputStream().flush();
        resp.flushBuffer();
    }
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) ServletResponse(javax.servlet.ServletResponse) Response(io.milton.http.Response) HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequest(javax.servlet.ServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) ServletResponse(javax.servlet.ServletResponse) HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequest(javax.servlet.ServletRequest) Request(io.milton.http.Request)

Example 3 with Request

use of io.milton.http.Request in project lobcder by skoulouzis.

the class AnnoResource method processForm.

@Override
public String processForm(Map<String, String> parameters, Map<String, FileItem> files) throws BadRequestException, NotAuthorizedException, ConflictException {
    Request request = HttpManager.request();
    Object result = annoFactory.postAnnotationHandler.execute(this, request, parameters);
    if (result instanceof String) {
        String redirect = (String) result;
        return redirect;
    } else if (result instanceof JsonResult) {
        jsonResult = (JsonResult) result;
    } else {
        jsonResult = JsonResult.returnData(getHref(), result);
    }
    return null;
}
Also used : Request(io.milton.http.Request) JsonResult(io.milton.common.JsonResult)

Example 4 with Request

use of io.milton.http.Request in project lobcder by skoulouzis.

the class AbstractAnnotationHandler method isCompatible.

@Override
public boolean isCompatible(Object source) {
    String contentType = null;
    Map<String, String> params = null;
    Request req = HttpManager.request();
    if (req != null) {
        contentType = req.getContentTypeHeader();
        params = req.getParams();
    }
    ControllerMethod m = getBestMethod(source.getClass(), contentType, params, null);
    return m != null;
}
Also used : Request(io.milton.http.Request)

Example 5 with Request

use of io.milton.http.Request in project lobcder by skoulouzis.

the class JsonResourceFactory method getResource.

@Override
public Resource getResource(String host, String sPath) throws NotAuthorizedException, BadRequestException {
    LogUtils.trace(log, "getResource", host, sPath);
    Path path = Path.path(sPath);
    Path parent = path.getParent();
    Request request = HttpManager.request();
    String encodedPath = request.getAbsolutePath();
    if (isMatchingPath(parent)) {
        log.trace("getResource: is matching path");
        Path resourcePath = parent.getParent();
        if (resourcePath != null) {
            String method = path.getName();
            Resource wrappedResource = wrapped.getResource(host, resourcePath.toString());
            if (wrappedResource != null) {
                Resource r = wrapResource(host, wrappedResource, method, encodedPath);
                LogUtils.trace(log, "returning a", r.getClass());
                return r;
            }
        }
    } else if (isAjaxLoginPath(sPath)) {
        Resource h = wrapped.getResource(host, "/");
        if (h == null) {
            log.info("Found a login path, but couldnt get a root resource to delegate login to");
            return null;
        } else {
            return new AjaxLoginResource(sPath, h);
        }
    } else {
        log.trace("getResource: not matching path");
        return wrapped.getResource(host, sPath);
    }
    return null;
}
Also used : Path(io.milton.common.Path) Request(io.milton.http.Request)

Aggregations

Request (io.milton.http.Request)12 Response (io.milton.http.Response)7 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 ServletRequest (javax.servlet.ServletRequest)2 ServletResponse (javax.servlet.ServletResponse)2 AccessControlList (io.milton.annotations.AccessControlList)1 JsonResult (io.milton.common.JsonResult)1 Path (io.milton.common.Path)1 Auth (io.milton.http.Auth)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 javax.servlet (javax.servlet)1 Timer (org.polymap.core.runtime.Timer)1 DefaultSessionContextProvider (org.polymap.core.runtime.session.DefaultSessionContextProvider)1 ContentManager (org.polymap.service.fs.ContentManager)1 IContentNode (org.polymap.service.fs.spi.IContentNode)1