oacs_dav::impl::content_revision::copy (private)
oacs_dav::impl::content_revision::copy
Defined in packages/oacs-dav/tcl/oacs-dav-procs.tcl
COPY DAV method for generic content revision
- Author:
- Dave Bauer
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: set package_id [oacs_dav::conn package_id] set user_id [oacs_dav::conn user_id] set peer_addr [oacs_dav::conn peeraddr] set uri [oacs_dav::conn uri] # check for write permission on target folder set target_uri [oacs_dav::conn oacs_destination] set copy_item_id [oacs_dav::conn item_id] set overwrite [oacs_dav::conn overwrite] set turlv [split [string trimright $target_uri "/"] "/"] set new_name [lindex $turlv end] set new_parent_folder_id [oacs_dav::conn dest_parent_id] if {$new_parent_folder_id eq ""} { return [list 409] } set dest_item_id [db_string get_dest_id "" -default ""] ns_log debug "\nDAV Revision Copy dest $target_uri parent_id $new_parent_folder_id" if {$dest_item_id ne ""} { ns_log debug "\n ----- \n DAV Revision Copy Folder Exists item_id $dest_item_id overwrite $overwrite \n ----- \n" if {![string equal -nocase $overwrite "T"]} { return [list 412] } elseif {![permission::permission_p -object_id $dest_item_id -party_id $user_id -privilege "write"]} { ns_returnunauthorized } # according to the spec copy with overwrite means # delete then copy ns_log debug "\noacs_dav::revision::copy checking for lock on target" if {"unlocked" ne [tdav::check_lock $target_uri] } { return [list 423] } db_exec_plsql delete_for_copy "" set response [list 204] ns_log debug "\n ----- \n CONTENT_REVISION::COPY OVERWRITING RETURNING 204 \n ----- \n" } else { set response [list 201] } set err_p 0 db_transaction { set item_id [db_exec_plsql copy_item ""] db_dml set_live_revision "" } on_error { set err_p 1 } if { $err_p } { return [list 500] } tdav::copy_props $uri $target_uri return $responseGeneric XQL file: <fullquery name="oacs_dav::impl::content_revision::copy.set_live_revision"> <querytext> update cr_items set live_revision=latest_revision where item_id=:item_id </querytext> </fullquery>packages/oacs-dav/tcl/oacs-dav-procs.xql
PostgreSQL XQL file: <fullquery name="oacs_dav::impl::content_revision::copy.copy_item"> <querytext> select content_item__copy ( :copy_item_id, :new_parent_folder_id, :user_id, :peer_addr, :new_name ) </querytext> </fullquery> <fullquery name="oacs_dav::impl::content_revision::copy.delete_for_copy"> <querytext> select content_item__delete(:dest_item_id) </querytext> </fullquery> <fullquery name="oacs_dav::impl::content_revision::copy.get_dest_id"> <querytext> select content_item__get_id(:new_name,:new_parent_folder_id,'f') </querytext> </fullquery>packages/oacs-dav/tcl/oacs-dav-procs-postgresql.xql
Oracle XQL file: <fullquery name="oacs_dav::impl::content_revision::copy.copy_item"> <querytext> begin :1 := content_item.copy2 ( item_id => :copy_item_id, target_folder_id => :new_parent_folder_id, creation_user => :user_id, creation_ip => :peer_addr, name => :new_name ); end; </querytext> </fullquery> <fullquery name="oacs_dav::impl::content_revision::copy.delete_for_copy"> <querytext> begin content_item.del( item_id => :dest_item_id ); end; </querytext> </fullquery> <fullquery name="oacs_dav::impl::content_revision::copy.get_dest_id"> <querytext> select content_item.get_id(:new_name,:new_parent_folder_id,'f') from dual </querytext> </fullquery>packages/oacs-dav/tcl/oacs-dav-procs-oracle.xql