tdav::check_lock (public)

 tdav::check_lock uri

Defined in packages/oacs-dav/tcl/tDAV-procs.tcl

Check whether the request may proceed under the resource's WebDAV lock. Remove an expired lock. If an active lock has no matching token in the If header, send HTTP 423.

Parameters:
uri (required)
Resource URI.
Returns:
unlocked if the request may proceed, or filter_return after HTTP 423.

Partial Call Graph (max 5 caller/called nodes):
fs::impl::fs_object::put fs::impl::fs_object::put (private) tdav::check_lock tdav::check_lock fs::impl::fs_object::put->tdav::check_lock oacs_dav::impl::content_folder::copy oacs_dav::impl::content_folder::copy (private) oacs_dav::impl::content_folder::copy->tdav::check_lock oacs_dav::impl::content_folder::delete oacs_dav::impl::content_folder::delete (private) oacs_dav::impl::content_folder::delete->tdav::check_lock oacs_dav::impl::content_folder::lock oacs_dav::impl::content_folder::lock (private) oacs_dav::impl::content_folder::lock->tdav::check_lock oacs_dav::impl::content_folder::move oacs_dav::impl::content_folder::move (private) oacs_dav::impl::content_folder::move->tdav::check_lock tdav::get_lock_file tdav::get_lock_file (public) tdav::check_lock->tdav::get_lock_file tdav::lock_timeout_left tdav::lock_timeout_left (private) tdav::check_lock->tdav::lock_timeout_left tdav::read_lock tdav::read_lock (private) tdav::check_lock->tdav::read_lock tdav::remove_lock tdav::remove_lock (public) tdav::check_lock->tdav::remove_lock

Testcases:
No testcase defined.
Source code:
    regsub {^/} $uri {} uri
    # if lock exists, work.  if not, just return.
    if {[file exists [tdav::get_lock_file $uri]]} {
        set lockinfo [tdav::read_lock $uri]

        # check if lock is expired
        if {[tdav::lock_timeout_left [lindex $lockinfo 4] [lindex $lockinfo 6]] == 0 } {
            tdav::remove_lock $uri
            return "unlocked"
        }
        set hdr [ns_set iget [ns_conn headers] If]

        # the If header exists, work, otherwise 423

        if {[info exists hdr] && [string length $hdr]} {
            set token ""
            # add ? in the token re in case there is a conditional ()
            # in the header
            regexp {(<https?://[^/]+([^>]+)>\s+)?\(<([^>]+)>\)} $hdr nil maybe hdr_uri token

            set ftk [lindex $lockinfo 3]
            if {![info exists token] || $token ne $ftk } {
                ns_log Debug "tdav::check_lock: token mismatch $ftk expected hdr: $hdr token: $token"
                ns_return 423 {text/plain} {}
                return filter_return
            }
        } else {
            ns_log Debug "tdav::check_lock: no \"If\" header found for request of $uri"
            ns_return 423 {text/plain} {}
            return filter_return
        }
        # also check for uri == hdr_uri
    }
    return unlocked
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: