Index: openacs-4/packages/oacs-dav/tcl/oacs-dav-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/oacs-dav/tcl/oacs-dav-procs-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/oacs-dav/tcl/oacs-dav-procs-postgresql.xql 16 Feb 2004 16:49:27 -0000 1.1 +++ openacs-4/packages/oacs-dav/tcl/oacs-dav-procs-postgresql.xql 30 Mar 2004 15:35:10 -0000 1.2 @@ -11,7 +11,7 @@ - select coalesce (cr.content_length,4096) as content_length, + select coalesce (cr.content_length,0) as content_length, coalesce(cr.mime_type,'*/*') as mime_type, to_char(timezone('GMT',o.creation_date) :: timestamptz ,'YYYY-MM-DD"T"HH:MM:SS.MS"Z"') as creation_date, to_char(timezone('GMT',o.last_modified) :: timestamptz ,'Dy, DD Mon YYYY HH:MM:SS TZ') as last_modified, Index: openacs-4/packages/oacs-dav/tcl/oacs-dav-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/oacs-dav/tcl/oacs-dav-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/oacs-dav/tcl/oacs-dav-procs.tcl 27 Mar 2004 01:09:42 -0000 1.5 +++ openacs-4/packages/oacs-dav/tcl/oacs-dav-procs.tcl 30 Mar 2004 15:35:10 -0000 1.6 @@ -136,14 +136,13 @@ copy - move { set authorized_p [expr [permission::permission_p \ - -object_id $item_id \ - -party_id $user_id \ - -privilege "read"] && \ - [permission::permission_p \ - -object_id [oacs_dav::conn dest_parent_id ] \ - -party_id $user_id \ - -privilege "create"]] - + -object_id $item_id \ + -party_id $user_id \ + -privilege "read"] \ + && [permission::permission_p \ + -object_id [oacs_dav::conn dest_parent_id ] \ + -party_id $user_id \ + -privilege "create"] ] } propfind - get { @@ -272,18 +271,18 @@ oacs_dav::conn -set uri $uri set method [ns_conn method] oacs_dav::set_user_id - ns_log notice "OACS-DAV conn_setup uri $uri method $method user_id [oacs_dav::conn user_id]" + ns_log debug "oacs_dav::conn_setup: uri $uri method $method user_id [oacs_dav::conn user_id]" array set sn [oacs_dav::request_site_node $uri] set node_id [oacs_dav::conn -set node_id $sn(node_id)] set package_id [oacs_dav::conn -set package_id $sn(package_id)] set folder_id [oacs_dav::conn -set folder_id [oacs_dav::request_folder_id [oacs_dav::conn node_id]]] set urlv [oacs_dav::conn -set urlv [split [string trimright $uri "/"] "/"]] if {[catch {[oacs_dav::conn destination]} destination]} { - set destination [oacs_dav::conn -set destination [ns_set iget [ns_conn headers] Destination]] + set destination [oacs_dav::conn -set destination [ns_urldecode [ns_set iget [ns_conn headers] Destination]]] } regsub {http://[^/]+/} $destination {/} dest - ns_log notice "DEST = $dest" + ns_log debug "oacs_dav::conn_setup destination = $dest" regsub $dav_url_regexp $dest {} dest oacs_dav::conn -set destination $dest if {![empty_string_p $dest]} { @@ -299,24 +298,24 @@ } else { set parent_url "/" } - ns_log debug "handle request parent_url $parent_url length urlv [llength $urlv] urlv $urlv" + ns_log debug "oacs_dav::conn_setup: handle request parent_url $parent_url length urlv [llength $urlv] urlv $urlv" set item_name [lindex $urlv end] if {[empty_string_p $item_name]} { # for propget etc we need the name of the folder # the last element in urlv for a folder is an empty string set item_name [lindex [split [string trimleft $parent_url "/"] "/"] end] } oacs_dav::conn -set item_name $item_name - ns_log debug "handle request parent_url $parent_url length urlv [llength $urlv] urlv $urlv item_name $item_name" + ns_log debug "oacs_dav::conn_setup: handle request parent_url $parent_url length urlv [llength $urlv] urlv $urlv item_name $item_name" set parent_id [oacs_dav::item_parent_folder_id $uri] set item_id [oacs_dav::conn -set item_id [db_exec_plsql get_item_id ""]] - ns_log notice "OACS-DAV uri $uri parent_url $parent_url folder_id $folder_id" + ns_log debug "oacs_dav::conn_setup: uri $uri parent_url $parent_url folder_id $folder_id" if {[string equal [string trimright $uri "/"] [string trimright $sn(url) "/"]]} { set item_id [oacs_dav::conn -set item_id $folder_id] } - ns_log notice "OACS-DAV setup conn item_id $item_id" + ns_log debug "oacs_dav::conn_setup: item_id $item_id" } ad_proc -public oacs_dav::handle_request { uri method args } { @@ -325,16 +324,16 @@ set uri [ns_conn url] set method [string tolower [ns_conn method]] -ns_log debug "oacs_dav::handle_request method=$method uri=$uri" + ns_log debug "oacs_dav::handle_request method=$method uri=$uri" set item_id [oacs_dav::conn item_id] set folder_id [oacs_dav::conn folder_id] set package_id [oacs_dav::conn package_id] set node_id [oacs_dav::conn node_id] set package_key [apm_package_key_from_id $package_id] - ns_log debug "DAV item_id is $item_id" + ns_log debug "oacs_dav::handle_request item_id is $item_id" if {[empty_string_p $item_id]} { - ns_log debug "DAV: item_id is empty" + ns_log debug "oacs_dav::handle_request item_id is empty" # set this to null if nothing exists, only valid on PUT or MKCOL # to create a new item, otherwise we bail # item for URI does not exist @@ -353,7 +352,7 @@ } default { # return a 404 or other error - ns_log notice "DAV:handle request Item not found method $method URI $uri" + ns_log notice "oacs_dav::handle_request: 404 handle request Item not found method $method URI $uri" ns_return 404 text/html "File Not Found" return } @@ -369,7 +368,7 @@ # i think we should walk up the object type hierarchy up to # content_revision if we don't find an implementation # implementation name is content_type - + if {![acs_sc_binding_exists_p dav $content_type]} { # go up content_type hierarchy # we do the query here to avoid running the query @@ -382,15 +381,15 @@ oacs_dav::conn -set content_type $content_type - # probably should catch this + # probably should catch this ns_log debug "oacs_dav::handle_request method $method uri $uri item_id $item_id folder_id $folder_id package_id $package_id node_id $node_id content_type $content_type args $args" set response [acs_sc_call dav $method "" $content_type] - + # here the sc impl might return us some data, # then we would probably have to send that to tDAV for processing - ns_log debug "DAV: response is $response" + ns_log debug "DAV: response is \"$response\"" if {![string equal -nocase "get" $method]} { tdav::respond $response @@ -754,7 +753,7 @@ if {![string equal "unlocked" [tdav::check_lock $uri]]} { return [list 423] } - + set tmp_filename [oacs_dav::conn tmpfile] set tmp_size [file size $tmp_filename] # authenticate that user has write privilege @@ -770,17 +769,17 @@ set response [list 409] return $response } - - ns_log debug "oacs_dav::impl::content_revision::put parent_id=$parent_id item_id=:item_id root_folder_id=:root_folder_id name=$name" + ns_log debug "oacs_dav::impl::content_revision::put parent_id=$parent_id item_id=$item_id root_folder_id=$root_folder_id name=$name tmp_filename=$tmp_filename" + # create new item if necessary db_transaction { set mime_type [cr_filename_to_mime_type $name] if {[empty_string_p $item_id]} { # this won't really work very nicely if we support # abstract url type names... maybe chop off the extension # when we name the object? - + set revision_id [cr_import_content \ -storage_type file \ $parent_id \ @@ -793,20 +792,21 @@ -item_id $item_id \ -storage_type file \ $parent_id \ - $tmp_size \ $tmp_filename \ + $tmp_size \ $mime_type \ $name] } db_dml set_live_revision "" set response [list 201] } on_error { - set response [list 500] + set response [list 500] + ns_log error "oacs_dav::impl::content_revision::put: $errmsg" } # at least we need to return the http_status - return $response + return $response } Index: openacs-4/packages/oacs-dav/tcl/tDAV-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/oacs-dav/tcl/tDAV-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/oacs-dav/tcl/tDAV-procs.tcl 1 Mar 2004 16:05:08 -0000 1.2 +++ openacs-4/packages/oacs-dav/tcl/tDAV-procs.tcl 30 Mar 2004 15:35:10 -0000 1.3 @@ -358,14 +358,16 @@ set token "" # add ? in the token re in case there is a conditional () # in the header - regexp {]+)>\s+\(<([^>]+)>\)} $hdr nil hdr_uri token + regexp {(]+)>\s+)?\(<([^>]+)>\)} $hdr nil maybe hdr_uri token set ftk [lindex [tdav::read_lock $uri] 3] - if {![string equal $token $ftk]} { + if {![info exists token] || ![string equal $token $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 } @@ -928,7 +930,7 @@ proc tdav::filter_webdav_copy {args} { set overwrite [tdav::conn -set overwrite [ns_set iget [ns_conn headers] Overwrite]] - set destination [encoding convertto utf-8 [ns_set iget [ns_conn headers] Destination]] + set destination [encoding convertto utf-8 [ns_urldecode [ns_set iget [ns_conn headers] Destination]]] regsub {http://[^/]+/} $destination {/} dest tdav::conn -set destination $dest ] return filter_ok @@ -985,7 +987,7 @@ proc tdav::filter_webdav_move {args} { set overwrite [tdav::conn -set overwrite [ns_set iget [ns_conn headers] Overwrite]] - set destination [encoding convertto utf-8 [ns_set iget [ns_conn headers] Destination]] + set destination [encoding convertto utf-8 [ns_urldecode [ns_set iget [ns_conn headers] Destination]]] regsub {http://[^/]+/} $destination {/} dest