oacs_dav::impl::content_folder::copy (private)

 oacs_dav::impl::content_folder::copy

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

COPY DAV method for generic content folder

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.dav.copy.content_folder AcsSc.dav.copy.content_folder (private) oacs_dav::impl::content_folder::copy oacs_dav::impl::content_folder::copy AcsSc.dav.copy.content_folder->oacs_dav::impl::content_folder::copy db_dml db_dml (public) oacs_dav::impl::content_folder::copy->db_dml db_exec_plsql db_exec_plsql (public) oacs_dav::impl::content_folder::copy->db_exec_plsql db_string db_string (public) oacs_dav::impl::content_folder::copy->db_string db_transaction db_transaction (public) oacs_dav::impl::content_folder::copy->db_transaction oacs_dav::children_have_permission_p oacs_dav::children_have_permission_p (public) oacs_dav::impl::content_folder::copy->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 copy_folder_id [oacs_dav::conn item_id]
    set overwrite [oacs_dav::conn overwrite]
    set target_uri [oacs_dav::conn oacs_destination]
    set new_parent_folder_id [oacs_dav::conn dest_parent_id]
    set durlv [split [string trimright $target_uri "/""/"]
    set new_name [lindex $durlv end]
    set uri [oacs_dav::conn uri]
    # check that destination exists and is WebDAV enabled
    # when depth is 0 copy just the folder
    # when depth is 1 copy contents
    ns_log debug "\nDAV Folder Copy dest $target_uri parent_id $new_parent_folder_id"
    if {$new_parent_folder_id eq ""} {
        return [list 409]
    }

    set dest_item_id [db_string get_dest_id "" -default ""]
    if {$dest_item_id ne ""} {
        ns_log debug "\n ----- \n DAV Folder 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
        set children_permission_p [oacs_dav::children_have_permission_p -item_id $copy_folder_id -user_id $user_id -privilege "delete"]
        if {!$children_permission_p} {
            return [list 409]
        }
        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_FOLDER::COPY OVERWRITING RETURNING 204  \n ----- \n"
    } else {
        set response [list 201]
    }
    set err_p 0
    db_transaction {
        db_exec_plsql copy_folder ""
        # we need to do this because in oracle content_folder__copy
        # is a procedure and does not return the new folder_id
        set new_folder_id [db_string get_new_folder_id ""]
        # update all child items revisions to live revision
        db_dml update_child_revisions ""
    } on_error {
        set err_p 1
    }

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

    tdav::copy_props $uri $target_uri
    return $response
Generic XQL file:
<fullquery name="oacs_dav::impl::content_folder::copy.get_new_folder_id">
    <querytext>
      select item_id 
      from cr_items
      where name = :new_name
      and parent_id = :new_parent_folder_id
    </querytext>
</fullquery>

<fullquery name="oacs_dav::impl::content_folder::copy.update_child_revisions">
    <querytext>
	update cr_items 
	set live_revision=latest_revision
	where exists (
		select 1 
		from
		(select ci1.item_id as child_item_id 
                from cr_items ci1, cr_items ci2
		where ci2.item_id=:new_folder_id
	        and ci1.tree_sortkey 
	        between ci2.tree_sortkey and tree_right(ci2.tree_sortkey)
                ) children 
                where item_id=child_item_id 
                      )
      </querytext>
</fullquery>
packages/oacs-dav/tcl/oacs-dav-procs.xql

PostgreSQL XQL file:
<fullquery name="oacs_dav::impl::content_folder::copy.copy_folder">
    <querytext>
      select content_folder__copy (
      :copy_folder_id,
      :new_parent_folder_id,
      :user_id,
      :peer_addr,
      :new_name
      )
    </querytext>
</fullquery>

<fullquery name="oacs_dav::impl::content_folder::copy.update_child_revisions">
    <querytext>
	update cr_items 
	set live_revision = latest_revision
	where exists (
		select 1 
		from
		(select ci1.item_id as child_item_id 
                from cr_items ci1, cr_items ci2
		where ci2.item_id=:new_folder_id
	        and ci1.tree_sortkey 
	        between ci2.tree_sortkey and tree_right(ci2.tree_sortkey)
                ) children 
                where item_id=children.child_item_id 
                      )
      </querytext>
</fullquery>

<fullquery name="oacs_dav::impl::content_folder::copy.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::copy.delete_for_copy">
    <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::copy.copy_folder">
    <querytext>
	begin
	      content_folder.copy (
	              folder_id => :copy_folder_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_folder::copy.update_child_revisions">
    <querytext>
	update cr_items 
	set live_revision=latest_revision
	where exists (
		select 1 
		from
		(select ci1.item_id as child_item_id 
                from cr_items ci1
	        connect by prior item_id = parent_id
                start with item_id = :folder_id
                ) children 
                where item_id=children.child_item_id 
                      )
      </querytext>
</fullquery>

<fullquery name="oacs_dav::impl::content_folder::copy.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::copy.delete_for_copy">
    <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: