see mod_dav.h for docco */
| 1959 | |
| 1960 | /* see mod_dav.h for docco */ |
| 1961 | DAV_DECLARE(dav_error *) dav_auto_checkout( |
| 1962 | request_rec *r, |
| 1963 | dav_resource *resource, |
| 1964 | int parent_only, |
| 1965 | dav_auto_version_info *av_info) |
| 1966 | { |
| 1967 | const dav_hooks_vsn *vsn_hooks = DAV_GET_HOOKS_VSN(r); |
| 1968 | dav_lockdb *lockdb = NULL; |
| 1969 | dav_error *err = NULL; |
| 1970 | |
| 1971 | /* Initialize results */ |
| 1972 | memset(av_info, 0, sizeof(*av_info)); |
| 1973 | |
| 1974 | /* if no versioning provider, just return */ |
| 1975 | if (vsn_hooks == NULL) |
| 1976 | return NULL; |
| 1977 | |
| 1978 | /* check parent resource if requested or if resource must be created */ |
| 1979 | if (!resource->exists || parent_only) { |
| 1980 | dav_resource *parent; |
| 1981 | |
| 1982 | if ((err = (*resource->hooks->get_parent_resource)(resource, |
| 1983 | &parent)) != NULL) |
| 1984 | goto done; |
| 1985 | |
| 1986 | if (parent == NULL || !parent->exists) { |
| 1987 | err = dav_new_error(r->pool, HTTP_CONFLICT, 0, 0, |
| 1988 | apr_psprintf(r->pool, |
| 1989 | "Missing one or more intermediate " |
| 1990 | "collections. Cannot create resource %s.", |
| 1991 | ap_escape_html(r->pool, resource->uri))); |
| 1992 | goto done; |
| 1993 | } |
| 1994 | |
| 1995 | av_info->parent_resource = parent; |
| 1996 | |
| 1997 | /* if parent versioned and not checked out, see if it can be */ |
| 1998 | if (parent->versioned && !parent->working) { |
| 1999 | int checkout_parent; |
| 2000 | |
| 2001 | if ((err = dav_can_auto_checkout(r, parent, |
| 2002 | (*vsn_hooks->auto_versionable)(parent), |
| 2003 | &lockdb, &checkout_parent)) |
| 2004 | != NULL) { |
| 2005 | goto done; |
| 2006 | } |
| 2007 | |
| 2008 | if (!checkout_parent) { |
| 2009 | err = dav_new_error(r->pool, HTTP_CONFLICT, 0, 0, |
| 2010 | "<DAV:cannot-modify-checked-in-parent>"); |
| 2011 | goto done; |
| 2012 | } |
| 2013 | |
| 2014 | /* Try to checkout the parent collection. |
| 2015 | * Note that auto-versioning can only be applied to a version selector, |
| 2016 | * so no separate working resource will be created. |
| 2017 | */ |
| 2018 | if ((err = (*vsn_hooks->checkout)(parent, 1 /*auto_checkout*/, |
no test coverage detected