oacs_dav::impl::content_folder::move (private)

 oacs_dav::impl::content_folder::move

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

MOVE DAV method for generic content folder

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

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]
    set target_uri [oacs_dav::conn oacs_destination]
    set move_folder_id [oacs_dav::conn item_id]
    set item_name [oacs_dav::conn item_name]
    set new_parent_folder_id [oacs_dav::conn dest_parent_id]
    set cur_parent_folder_id [oacs_dav::item_parent_folder_id $uri]
    set turlv [split [string trimright $target_uri "/""/"]
    set new_name [lindex $turlv end]
    set overwrite [oacs_dav::conn overwrite]

    if {"unlocked" ne [tdav::check_lock $uri] } {
        return [list 423]
    }

    if {$new_parent_folder_id eq ""} {
        set response [list 412]
        return $response
    }

    set dest_item_id [db_string get_dest_id "" -default ""]
    ns_log debug "\n@DAV@@ folder move new_name $new_name dest_id $dest_item_id new_folder_id $new_parent_folder_id \n"

    if {$dest_item_id ne ""} {

        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 move with overwrite means
        # delete then move
        if {"unlocked" ne [tdav::check_lock $target_uri] } {
            return [list 423]
        }
        # TODO check if we have permission over everything inside
        set children_permission_p [oacs_dav::children_have_permission_p -item_id $move_folder_id -user_id $user_id -privilege "delete"]
        if {!$children_permission_p} {
            return [list 409]
        }
        db_exec_plsql delete_for_move ""
        set response [list 204]
        ns_log debug "\n ----- \n  CONTENT_FOLDER::MOVE OVERWRITING RETURNING 204  \n ----- \n"
    } else {
        set response [list 201]
    }

    # don't let anyone move root DAV folders in the
    # dav_site_node_folder_map
    if {[db_string site_node_folder ""] ne "0" } {
        return [list 403]
    }

    set err_p 0
    db_transaction {
        if {$cur_parent_folder_id ne $new_parent_folder_id } {
            ns_log debug "\n@@DAV@@ move folder $move_folder_id"
            db_exec_plsql move_folder ""
            # change label if name is different
            if {$new_name ne $item_name } {
                db_dml update_label ""
            }
        } elseif {$new_name ne ""} {
            ns_log debug "\n@@DAV@@ move folder rename $move_folder_id to $new_name"
            db_exec_plsql rename_folder ""
        }

    } 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_folder::move.site_node_folder">
    <querytext>
      select count(*) from dav_site_node_folder_map
      where folder_id=:move_folder_id
    </querytext>
</fullquery>

<fullquery name="oacs_dav::impl::content_folder::move.update_label">
    <querytext>
      update cr_folders 
	set label = :new_name
        where folder_id=:move_folder_id
    </querytext>
</fullquery>
packages/oacs-dav/tcl/oacs-dav-procs.xql

PostgreSQL XQL file:
<fullquery name="oacs_dav::impl::content_folder::move.move_folder">
    <querytext>
      select content_folder__move (
      :move_folder_id,
      :new_parent_folder_id,
      :new_name
      )
    </querytext>
</fullquery>

<fullquery name="oacs_dav::impl::content_folder::move.rename_folder">
    <querytext>
      select content_folder__edit_name (
      :move_folder_id,
      :new_name,
      :new_name,
      NULL
      )
    </querytext>
</fullquery>

<fullquery name="oacs_dav::impl::content_folder::move.get_dest_id">
    <querytext>
	select content_item__get_id(:new_name,:new_parent_folder_id,'f')
    </querytext>
</fullquery>

<fullquery name="oacs_dav::impl::content_folder::move.delete_for_move">
    <querytext>
      select content_folder__delete(:dest_item_id,'t');
    </querytext>
</fullquery>
packages/oacs-dav/tcl/oacs-dav-procs-postgresql.xql

Oracle XQL file:
<fullquery name="oacs_dav::impl::content_folder::move.move_folder">
    <querytext>
	begin
	      :1 := content_folder.move (
	              folder_id => :move_folder_id,
	              target_folder_id => :new_parent_folder_id,
	              name => :new_name
	      );
	end;
    </querytext>
</fullquery>

<fullquery name="oacs_dav::impl::content_folder::move.rename_folder">
    <querytext>
	begin
	      content_folder.edit_name (
	              folder_id => :move_folder_id,
	              name => :new_name,
	              label => :new_name,
	              description => NULL
	      );
	end;
    </querytext>
</fullquery>

<fullquery name="oacs_dav::impl::content_folder::move.get_dest_id">
    <querytext>
	select content_item.get_id(:new_name,:new_parent_folder_id,'f') from dual
    </querytext>
</fullquery>

<fullquery name="oacs_dav::impl::content_folder::move.delete_for_move">
    <querytext>
	begin
      		content_folder.del(
	              folder_id => :dest_item_id,
	              cascade_p => 't');
	end;
    </querytext>
</fullquery>
packages/oacs-dav/tcl/oacs-dav-procs-oracle.xql

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