| 3460 | } |
| 3461 | |
| 3462 | static int dav_method_vsn_control(request_rec *r) |
| 3463 | { |
| 3464 | dav_resource *resource; |
| 3465 | int resource_state; |
| 3466 | dav_auto_version_info av_info; |
| 3467 | const dav_hooks_locks *locks_hooks = DAV_GET_HOOKS_LOCKS(r); |
| 3468 | const dav_hooks_vsn *vsn_hooks = DAV_GET_HOOKS_VSN(r); |
| 3469 | dav_error *err; |
| 3470 | apr_xml_doc *doc; |
| 3471 | const char *target = NULL; |
| 3472 | int result; |
| 3473 | |
| 3474 | /* if no versioning provider, decline the request */ |
| 3475 | if (vsn_hooks == NULL) |
| 3476 | return DECLINED; |
| 3477 | |
| 3478 | /* ask repository module to resolve the resource */ |
| 3479 | err = dav_get_resource(r, 0 /* label_allowed */, 0 /* use_checked_in */, |
| 3480 | &resource); |
| 3481 | if (err != NULL) |
| 3482 | return dav_handle_err(r, err, NULL); |
| 3483 | |
| 3484 | /* parse the request body (may be a version-control element) */ |
| 3485 | if ((result = ap_xml_parse_input(r, &doc)) != OK) { |
| 3486 | return result; |
| 3487 | } |
| 3488 | /* note: doc == NULL if no request body */ |
| 3489 | |
| 3490 | /* check for any method preconditions */ |
| 3491 | if (dav_run_method_precondition(r, resource, NULL, doc, &err) != DECLINED |
| 3492 | && err) { |
| 3493 | return dav_handle_err(r, err, NULL); |
| 3494 | } |
| 3495 | |
| 3496 | /* remember the pre-creation resource state */ |
| 3497 | resource_state = dav_get_resource_state(r, resource); |
| 3498 | |
| 3499 | if (doc != NULL) { |
| 3500 | const apr_xml_elem *child; |
| 3501 | apr_size_t tsize; |
| 3502 | |
| 3503 | if (!dav_validate_root(doc, "version-control")) { |
| 3504 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00597) |
| 3505 | "The request body does not contain " |
| 3506 | "a \"version-control\" element."); |
| 3507 | return HTTP_BAD_REQUEST; |
| 3508 | } |
| 3509 | |
| 3510 | /* get the version URI */ |
| 3511 | if ((child = dav_find_child(doc->root, "version")) == NULL) { |
| 3512 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00598) |
| 3513 | "The \"version-control\" element does not contain " |
| 3514 | "a \"version\" element."); |
| 3515 | return HTTP_BAD_REQUEST; |
| 3516 | } |
| 3517 | |
| 3518 | if ((child = dav_find_child(child, "href")) == NULL) { |
| 3519 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00599) |
no test coverage detected