oacs_dav::impl::content_revision::move (private)

 oacs_dav::impl::content_revision::move

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

MOVE DAV method for generic content revision

Author:
Dave Bauer

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.dav.move.content_revision AcsSc.dav.move.content_revision (private) oacs_dav::impl::content_revision::move oacs_dav::impl::content_revision::move AcsSc.dav.move.content_revision->oacs_dav::impl::content_revision::move db_dml db_dml (public) oacs_dav::impl::content_revision::move->db_dml db_exec_plsql db_exec_plsql (public) oacs_dav::impl::content_revision::move->db_exec_plsql db_string db_string (public) oacs_dav::impl::content_revision::move->db_string db_transaction db_transaction (public) oacs_dav::impl::content_revision::move->db_transaction oacs_dav::conn oacs_dav::conn (public) oacs_dav::impl::content_revision::move->oacs_dav::conn

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 item_id [oacs_dav::conn item_id]
    set item_name [oacs_dav::conn item_name]
    set uri [oacs_dav::conn uri]
    set target_uri [oacs_dav::conn oacs_destination]
    set cur_parent_folder_id [oacs_dav::conn folder_id]
    set new_parent_folder_id [oacs_dav::conn dest_parent_id]
    set turlv [split [string trimright $target_uri "/""/"]
    set new_name [lindex $turlv end]
    set overwrite [oacs_dav::conn overwrite]
    if {$new_parent_folder_id eq ""} {
        return [list 409]
    }

    if {"unlocked" ne [tdav::check_lock $uri] } {
        return [list 423]
    }
ns_log debug "\nDAV Revision move dest $target_uri parent_id $new_parent_folder_id"
    set dest_item_id [db_string get_dest_id "" -default ""]
    if {$dest_item_id ne ""} {
        ns_log debug "\n ----- \n DAV Revision move 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"]} {
                return [list 401]
        }
        if {"unlocked" ne [tdav::check_lock $target_uri] } {
            return [list 423]
        }

        db_exec_plsql delete_for_move ""
        set response [list 204]
        ns_log debug "\n ----- \n  CONTENT_REVISION::MOVE OVERWRITING RETURNING 204  \n ----- \n"
    } else {
        set response [list 201]
    }

    set err_p 0
    db_transaction {
        if {$cur_parent_folder_id ne $new_parent_folder_id } {
                db_exec_plsql move_item ""

        } elseif {$new_name ne "" } {
            db_exec_plsql rename_item ""
        }
       if {$item_name ne $new_name } {
            db_dml update_title ""
        }
    } on_error {
        set err_p 1
    }

    if { $err_p } {
        return [list 500]
    }

    tdav::copy_props $uri $target_uri
    tdav::delete_props $uri
    tdav::remove_lock $uri
    return $response
Generic XQL file:
<fullquery name="oacs_dav::impl::content_revision::move.update_title">
    <querytext>
      update cr_revisions 
	set title = :new_name
        where revision_id = (select latest_revision from cr_items
				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::move.move_item">
    <querytext>
      select content_item__move (
      :item_id,
      :new_parent_folder_id,
      :new_name
      )
    </querytext>
</fullquery>

<fullquery name="oacs_dav::impl::content_revision::move.rename_item">
    <querytext>
      select content_item__edit_name (
      :item_id,
      :new_name
      )
    </querytext>
</fullquery>

<fullquery name="oacs_dav::impl::content_revision::move.delete_for_move">
    <querytext>
      select content_item__delete(:dest_item_id)
    </querytext>
</fullquery>

<fullquery name="oacs_dav::impl::content_revision::move.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::move.move_item">
    <querytext>
	begin
	      content_item.move (
	              item_id => :item_id,
	              target_folder_id => :new_parent_folder_id,
	              name => :new_name
	      );
	end;
    </querytext>
</fullquery>

<fullquery name="oacs_dav::impl::content_revision::move.rename_item">
    <querytext>
	begin
	      content_item.edit_name (
	              item_id => :item_id,
	              name => :new_name
	      );
	end;
    </querytext>
</fullquery>

<fullquery name="oacs_dav::impl::content_revision::move.delete_for_move">
    <querytext>
	begin
      		content_item.del(
	              item_id => :dest_item_id
	      	);
	end;
    </querytext>
</fullquery>

<fullquery name="oacs_dav::impl::content_revision::move.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

[ hide source ] | [ make this the default ]
Show another procedure: