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)
| 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 |
no test coverage detected