handle the CHECKIN method */
| 3871 | |
| 3872 | /* handle the CHECKIN method */ |
| 3873 | static int dav_method_checkin(request_rec *r) |
| 3874 | { |
| 3875 | dav_resource *resource; |
| 3876 | dav_resource *new_version; |
| 3877 | const dav_hooks_vsn *vsn_hooks = DAV_GET_HOOKS_VSN(r); |
| 3878 | dav_error *err; |
| 3879 | int result; |
| 3880 | apr_xml_doc *doc; |
| 3881 | int keep_checked_out = 0; |
| 3882 | |
| 3883 | /* If no versioning provider, decline the request */ |
| 3884 | if (vsn_hooks == NULL) |
| 3885 | return DECLINED; |
| 3886 | |
| 3887 | if ((result = ap_xml_parse_input(r, &doc)) != OK) |
| 3888 | return result; |
| 3889 | |
| 3890 | if (doc != NULL) { |
| 3891 | if (!dav_validate_root(doc, "checkin")) { |
| 3892 | /* This supplies additional information for the default msg. */ |
| 3893 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00603) |
| 3894 | "The request body, if present, must be a " |
| 3895 | "DAV:checkin element."); |
| 3896 | return HTTP_BAD_REQUEST; |
| 3897 | } |
| 3898 | |
| 3899 | keep_checked_out = dav_find_child(doc->root, "keep-checked-out") != NULL; |
| 3900 | } |
| 3901 | |
| 3902 | /* Ask repository module to resolve the resource */ |
| 3903 | err = dav_get_resource(r, 0 /* label_allowed */, 0 /* use_checked_in */, |
| 3904 | &resource); |
| 3905 | if (err != NULL) |
| 3906 | return dav_handle_err(r, err, NULL); |
| 3907 | |
| 3908 | /* check for any method preconditions */ |
| 3909 | if (dav_run_method_precondition(r, resource, NULL, doc, &err) != DECLINED |
| 3910 | && err) { |
| 3911 | return dav_handle_err(r, err, NULL); |
| 3912 | } |
| 3913 | |
| 3914 | if (!resource->exists) { |
| 3915 | /* Apache will supply a default error for this. */ |
| 3916 | return HTTP_NOT_FOUND; |
| 3917 | } |
| 3918 | |
| 3919 | /* Check the state of the resource: must be a file or collection, |
| 3920 | * must be versioned, and must be checked out. |
| 3921 | */ |
| 3922 | if (resource->type != DAV_RESOURCE_TYPE_REGULAR) { |
| 3923 | return dav_error_response(r, HTTP_CONFLICT, |
| 3924 | "Cannot checkin this type of resource."); |
| 3925 | } |
| 3926 | |
| 3927 | if (!resource->versioned) { |
| 3928 | return dav_error_response(r, HTTP_CONFLICT, |
| 3929 | "Cannot checkin unversioned resource."); |
| 3930 | } |
no test coverage detected