download_insert_revision (public)

 download_insert_revision upload_file tmpfile repository_id \
    archive_type_id archive_id version_name revision_id user_id \
    creation_ip approved_p metadata_array

Defined in packages/download/tcl/download-procs.tcl

Dummy comment.

Parameters:
upload_file
tmpfile
repository_id
archive_type_id
archive_id
version_name
revision_id
user_id
creation_ip
approved_p
metadata_array

Partial Call Graph (max 5 caller/called nodes):
%3 packages/download/www/archive-add-2.tcl packages/download/ www/archive-add-2.tcl download_insert_revision download_insert_revision packages/download/www/archive-add-2.tcl->download_insert_revision packages/download/www/archive-version-add-2.tcl packages/download/ www/archive-version-add-2.tcl packages/download/www/archive-version-add-2.tcl->download_insert_revision cr_filename_to_mime_type cr_filename_to_mime_type (public) download_insert_revision->cr_filename_to_mime_type db_dml db_dml (public) download_insert_revision->db_dml db_exec_plsql db_exec_plsql (public) download_insert_revision->db_exec_plsql download_insert_metadata download_insert_metadata (public) download_insert_revision->download_insert_metadata

Testcases:
No testcase defined.
Source code:
    # get the filename part of the upload file
    if {![regexp {[^//\\]+$} $upload_file filename]} {
        # no match
        set filename $upload_file
    }

    # get the file_size for the postgres version
    set file_size [file size $tmpfile]

    set mime_type [cr_filename_to_mime_type -create $upload_file]

    db_exec_plsql revision_new {
        declare
        v_revision_id integer;
        begin
        v_revision_id := content_revision.new(
                                              item_id => :archive_id,
                                              title => :filename,
                                              description => :version_name,
                                              revision_id => :revision_id,
                                              mime_type => :mime_type,
                                              creation_user => :user_id,
                                              creation_ip => :creation_ip
                                              );

        insert into download_archive_revisions (revision_id,    approved_p) values
        (v_revision_id, :approved_p);
        end;
    }

    db_dml content_add {
        update cr_revisions
        set    content = empty_blob()
        where  revision_id = :revision_id
        returning content into :1
    } -blob_files [list $tmpfile]

    db_exec_plsql make_live {
        begin
        content_item.set_live_revision(:revision_id);
        end;
    }

    download_insert_metadata $repository_id $archive_type_id $revision_id $metadata_array
Generic XQL file:
packages/download/tcl/download-procs.xql

PostgreSQL XQL file:
<fullquery name="download_insert_revision.revision_new">
    <querytext>

declare
  v_revision_id integer;
begin
  v_revision_id := content_revision__new(
    :filename,
    :version_name,
    now(),
    :mime_type,
    null,
    ' ',
    :archive_id,
    :revision_id,
    now(),
    :user_id,
    :creation_ip
   );

  insert into download_archive_revisions 
  (revision_id, approved_p, file_size) 
  values
  (v_revision_id, :approved_p, :file_size);

  return v_revision_id;
end;
    
</querytext>
</fullquery>

<fullquery name="download_insert_revision.content_add">
    <querytext>

update cr_revisions
set    content = '[cr_create_content_file $archive_id $revision_id $tmpfile]'
where  revision_id = :revision_id
    
</querytext>
</fullquery>

<fullquery name="download_insert_revision.make_live">
    <querytext>

select content_item__set_live_revision( :revision_id );
    
</querytext>
</fullquery>
packages/download/tcl/download-procs-postgresql.xql

Oracle XQL file:
<fullquery name="download_insert_revision.revision_new">
    <querytext>
      
        declare
          v_revision_id integer;
        begin
          v_revision_id := content_revision.new(
           item_id => :archive_id,
           title => :filename,
           description => :version_name,
           revision_id => :revision_id,
           mime_type => :mime_type,
           creation_user => :user_id,
           creation_ip => :creation_ip
          );

          insert into download_archive_revisions (revision_id,    approved_p) values
                                                 (v_revision_id, :approved_p);
        end;
    
      </querytext>
</fullquery>

<fullquery name="download_insert_revision.content_add">
    <querytext>
      
        update cr_revisions
        set    content = empty_blob()
        where  revision_id = :revision_id
        returning content into :1
    
      </querytext>
</fullquery>

<fullquery name="download_insert_revision.make_live">
    <querytext>
      
        begin
        content_item.set_live_revision(:revision_id);
        end;
    
      </querytext>
</fullquery>
packages/download/tcl/download-procs-oracle.xql

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