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();
}
}
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();
}
}
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;
}
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;
}
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;
}
Aggregations