| 4434 | } |
| 4435 | |
| 4436 | static int dav_method_make_workspace(request_rec *r) |
| 4437 | { |
| 4438 | dav_resource *resource; |
| 4439 | const dav_hooks_vsn *vsn_hooks = DAV_GET_HOOKS_VSN(r); |
| 4440 | dav_error *err; |
| 4441 | apr_xml_doc *doc; |
| 4442 | int result; |
| 4443 | |
| 4444 | /* if no versioning provider, or the provider does not support workspaces, |
| 4445 | * decline the request |
| 4446 | */ |
| 4447 | if (vsn_hooks == NULL || vsn_hooks->make_workspace == NULL) |
| 4448 | return DECLINED; |
| 4449 | |
| 4450 | /* ask repository module to resolve the resource */ |
| 4451 | err = dav_get_resource(r, 0 /* label_allowed */, 0 /* use_checked_in */, |
| 4452 | &resource); |
| 4453 | if (err != NULL) |
| 4454 | return dav_handle_err(r, err, NULL); |
| 4455 | |
| 4456 | /* parse the request body (must be a mkworkspace element) */ |
| 4457 | if ((result = ap_xml_parse_input(r, &doc)) != OK) { |
| 4458 | return result; |
| 4459 | } |
| 4460 | |
| 4461 | /* check for any method preconditions */ |
| 4462 | if (dav_run_method_precondition(r, resource, NULL, doc, &err) != DECLINED |
| 4463 | && err) { |
| 4464 | return dav_handle_err(r, err, NULL); |
| 4465 | } |
| 4466 | |
| 4467 | if (doc == NULL |
| 4468 | || !dav_validate_root(doc, "mkworkspace")) { |
| 4469 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00615) |
| 4470 | "The request body does not contain " |
| 4471 | "a \"mkworkspace\" element."); |
| 4472 | return HTTP_BAD_REQUEST; |
| 4473 | } |
| 4474 | |
| 4475 | /* Check request preconditions */ |
| 4476 | |
| 4477 | /* ### need a general mechanism for reporting precondition violations |
| 4478 | * ### (should be returning XML document for 403/409 responses) |
| 4479 | */ |
| 4480 | |
| 4481 | /* resource must not already exist */ |
| 4482 | if (resource->exists) { |
| 4483 | err = dav_new_error(r->pool, HTTP_CONFLICT, 0, 0, |
| 4484 | "<DAV:resource-must-be-null/>"); |
| 4485 | return dav_handle_err(r, err, NULL); |
| 4486 | } |
| 4487 | |
| 4488 | /* ### what about locking? */ |
| 4489 | |
| 4490 | /* attempt to create the workspace */ |
| 4491 | if ((err = (*vsn_hooks->make_workspace)(resource, doc)) != NULL) { |
| 4492 | err = dav_push_error(r->pool, err->status, 0, |
| 4493 | apr_psprintf(r->pool, |
no test coverage detected