use of org.apache.jackrabbit.webdav.WebdavResponseImpl in project jackrabbit by apache.
the class AbstractWebdavServlet method service.
/**
* Service the given request.
*
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
WebdavRequest webdavRequest = new WebdavRequestImpl(request, getLocatorFactory(), isCreateAbsoluteURI());
// DeltaV requires 'Cache-Control' header for all methods except 'VERSION-CONTROL' and 'REPORT'.
int methodCode = DavMethods.getMethodCode(request.getMethod());
boolean noCache = DavMethods.isDeltaVMethod(webdavRequest) && !(DavMethods.DAV_VERSION_CONTROL == methodCode || DavMethods.DAV_REPORT == methodCode);
WebdavResponse webdavResponse = new WebdavResponseImpl(response, noCache);
try {
// make sure there is a authenticated user
if (!getDavSessionProvider().attachSession(webdavRequest)) {
return;
}
// perform referrer host checks if CSRF protection is enabled
if (!csrfUtil.isValidRequest(webdavRequest)) {
webdavResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
// check matching if=header for lock-token relevant operations
DavResource resource = getResourceFactory().createResource(webdavRequest.getRequestLocator(), webdavRequest, webdavResponse);
if (!isPreconditionValid(webdavRequest, resource)) {
webdavResponse.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
return;
}
if (!execute(webdavRequest, webdavResponse, methodCode, resource)) {
super.service(request, response);
}
} catch (DavException e) {
if (e.getErrorCode() == HttpServletResponse.SC_UNAUTHORIZED) {
sendUnauthorized(webdavRequest, webdavResponse, e);
} else {
webdavResponse.sendError(e);
}
} finally {
getDavSessionProvider().releaseSession(webdavRequest);
}
}
Aggregations