MCPcopy Create free account
hub / github.com/apache/tomcat / doMkcol

Method doMkcol

java/org/apache/catalina/servlets/WebdavServlet.java:1264–1302  ·  view source on GitHub ↗

MKCOL Method. @param req The Servlet request @param resp The Servlet response @throws ServletException If an error occurs @throws IOException If an IO error occurs

(HttpServletRequest req, HttpServletResponse resp)

Source from the content-addressed store, hash-verified

1262 * @throws IOException If an IO error occurs
1263 */
1264 protected void doMkcol(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
1265
1266 String path = getRelativePath(req);
1267
1268 WebResource resource = resources.getResource(path);
1269 if (!checkIfHeaders(req, resp, resource)) {
1270 resp.setStatus(HttpServletResponse.SC_PRECONDITION_FAILED);
1271 return;
1272 }
1273
1274 // Can't create a collection if a resource already exists at the given
1275 // path
1276 if (resource.exists()) {
1277 sendNotAllowed(req, resp);
1278 return;
1279 }
1280
1281 if (isReadOnly()) {
1282 resp.sendError(WebdavStatus.SC_FORBIDDEN);
1283 return;
1284 }
1285
1286 if (isLocked(path, req)) {
1287 resp.sendError(WebdavStatus.SC_LOCKED);
1288 return;
1289 }
1290
1291 if (req.getContentLengthLong() > 0 || "chunked".equalsIgnoreCase(req.getHeader("Transfer-Encoding"))) {
1292 // No support for MKCOL bodies, which are non standard
1293 resp.sendError(WebdavStatus.SC_UNSUPPORTED_MEDIA_TYPE);
1294 return;
1295 }
1296
1297 if (resources.mkdir(path)) {
1298 resp.setStatus(WebdavStatus.SC_CREATED);
1299 } else {
1300 resp.sendError(WebdavStatus.SC_CONFLICT);
1301 }
1302 }
1303
1304
1305 @Override

Callers 1

serviceMethod · 0.95

Calls 13

getRelativePathMethod · 0.95
checkIfHeadersMethod · 0.95
existsMethod · 0.95
isLockedMethod · 0.95
sendNotAllowedMethod · 0.80
getResourceMethod · 0.65
setStatusMethod · 0.65
isReadOnlyMethod · 0.65
sendErrorMethod · 0.65
getContentLengthLongMethod · 0.65
getHeaderMethod · 0.65
mkdirMethod · 0.65

Tested by

no test coverage detected