Index: openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl 21 Jun 2005 13:40:45 -0000 1.12 +++ openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl 31 May 2006 13:42:30 -0000 1.13 @@ -32,6 +32,7 @@ {-is_live ""} {-storage_type "file"} {-attributes ""} + {-tmp_filename ""} } { @author Dave Bauer (dave@thedesignexperience.org) @creation-date 2004-05-28 @@ -59,6 +60,7 @@ @param title - title of content_revision to be created @param description of content_revision to be created @param text - text of content revision to be created + @param tmp_filename file containing content to be added to new revision @param attributes - A list of lists ofpairs of additional attributes and their values to pass to the constructor. Each pair is a list of two elements: key => value such as @@ -106,7 +108,7 @@ # the content type is not the object type of the cr_item so we pass in # the cr_item subtype here and content_type as part of # var_list - + db_transaction { set item_id [package_exec_plsql \ -var_list $var_list \ content_item new] @@ -130,9 +132,10 @@ -content_type $content_type \ -is_live $is_live \ -package_id $package_id \ + -tmp_filename $tmp_filename \ -attributes $attributes } - + } return $item_id } @@ -268,7 +271,7 @@ # we have valid attributes, update them - set query_text "update cr_items set ${update_text}" + set query_text "update cr_items set ${update_text} where item_id=:item_id" db_dml item_update $query_text } } Index: openacs-4/packages/acs-content-repository/tcl/content-revision-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/content-revision-procs-oracle.xql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-content-repository/tcl/content-revision-procs-oracle.xql 24 Feb 2005 13:41:22 -0000 1.5 +++ openacs-4/packages/acs-content-repository/tcl/content-revision-procs-oracle.xql 31 May 2006 13:42:30 -0000 1.6 @@ -31,5 +31,33 @@ + + + select item_id + from cr_revisions + where revision_id = :revision_id + + + + + + + update cr_revisions + set content_length = lob_length(lob) + where revision_id = :revision_id + + + + + + + update cr_revisions + set filename = :filename, + mime_type = :mime_type, + content_length = :tmp_size + where revision_id = :revision_id + + + Index: openacs-4/packages/acs-content-repository/tcl/content-revision-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/content-revision-procs-postgresql.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-content-repository/tcl/content-revision-procs-postgresql.xql 10 Feb 2005 01:40:11 -0000 1.2 +++ openacs-4/packages/acs-content-repository/tcl/content-revision-procs-postgresql.xql 31 May 2006 13:42:30 -0000 1.3 @@ -21,4 +21,43 @@ + + + select item_id + from cr_revisions + where revision_id = :revision_id + + + + + + + update cr_revisions + set mime_type = :mime_type, + lob = [set __lob_id [db_string get_lob_id "select empty_lob()"]] + where revision_id = :revision_id + + + + + + + + update cr_revisions + set content_length = lob_length(lob) + where revision_id = :revision_id + + + + + + + update cr_revisions + set content = :filename, + mime_type = :mime_type, + content_length = :tmp_size + where revision_id = :revision_id + + + \ No newline at end of file Index: openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl 8 Jun 2005 20:59:19 -0000 1.11 +++ openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl 31 May 2006 13:42:30 -0000 1.12 @@ -28,6 +28,8 @@ {-package_id} {-attributes} {-is_live "f"} + {-tmp_filename ""} + {-storage_type ""} } { Adds a new revision of a content item. If content_type is not passed in, we determine it from the content item. This is needed @@ -60,11 +62,12 @@ @param creation_user @param creation_ip + + @param package_id Package_id content belongs to - @param package_id + @param is_live True is revision should be set live - @param is_live - + @param tmp_filename file containing content to be added to revision @param attributes A list of lists of pairs of additional attributes and their values to pass to the constructor. Each pair is a list of two elements: key => value such as @@ -86,6 +89,9 @@ if {![exists_and_not_null content_type]} { set content_type [::content::item::content_type -item_id $item_id] } + if {![exists_and_not_null storage_type]} { + set storage_type [db_string get_storage_type ""] + } if {![info exists package_id]} { set package_id [ad_conn package_id] } @@ -135,24 +141,37 @@ set revision_id [db_nextval "acs_object_id_seq"] } db_dml insert_revision $query_text - update_content \ + ::content::revision::update_content \ + -item_id $item_id \ -revision_id $revision_id \ - -content $content + -content $content \ + -tmp_filename $tmp_filename \ + -storage_type $storage_type \ + -mime_type $mime_type } if {[string is true $is_live]} { content::item::set_live_revision -revision_id $revision_id } return $revision_id } -ad_proc -public content::revision::update_content { +ad_proc -public ::content::revision::update_content { + -item_id -revision_id -content + -storage_type + -mime_type + {-tmp_filename ""} + } { Update content column seperately. Oracle does not allow insert into a BLOB. + This assumes that if storage type is lob and no file is specified + that the content is really text and store it in the text column + in PostgreSQL + @author Dave Bauer (dave@thedesignexperience.org) @creation-date 2005-02-09 @@ -164,7 +183,37 @@ @error } { - db_dml update_content "" -blobs [list $content] + + switch $storage_type { + file { + if {$tmp_filename eq ""} { + set tmp_filename [ns_mktemp /tmp/XXXXXX] + set fd [open $tmp_filename w] + puts $fd $content + close $fd + } + set tmp_size [file size $tmp_filename] + set filename [cr_create_content_file $item_id $revision_id $tmp_filename] + db_dml set_file_content "" + } + lob { + if {$tmp_filename ne ""} { + # handle file + set filename [cr_create_content_file $item_id $revision_id $tmp_filename] + db_dml set_lob_content "" -blob_files [list $tmp_filename] + db_dml set_lob_size "" + } else { + # handle blob + db_dml update_content "" -blobs [list $content] + } + } + default { + # HAM : 112505 + # I added a default switch because in some cases + # storage type is text and revision is not being updated + db_dml update_content "" -blobs [list $content] + } + } } ad_proc -public content::revision::content_copy { @@ -299,6 +348,17 @@ } +ad_proc -public content::revision::item_id { + -revision_id:required +} { + @param revision_id + + @return item_id +} { + return [db_string item_id {} -default ""] +} + + ad_proc -public content::revision::read_xml { -item_id:required -revision_id:required Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/acs-content-repository/tcl/content-revision-procs.xql'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/acs-content-repository/tcl/test/content-item-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/test/content-item-test-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-content-repository/tcl/test/content-item-test-procs.tcl 15 Feb 2005 17:27:06 -0000 1.3 +++ openacs-4/packages/acs-content-repository/tcl/test/content-item-test-procs.tcl 31 May 2006 13:42:30 -0000 1.4 @@ -208,7 +208,29 @@ ######################################################### #TODO + ######################################################### + # new from tmpfile + ######################################################### + set tmp_item_name [ns_mktemp "__content_item_test_XXXXXX"] + set tmp_item_id [content::item::new \ + -name $tmp_item_name \ + -title $tmp_item_name \ + -parent_id $first_folder_id \ + -tmp_filename [acs_root_dir]/packages/acs-content-repository/tcl/test/test.html] + + aa_true "Tmp_filename added cr_item exists" \ + [expr {[content::item::get_id \ + -item_path $tmp_item_name \ + -root_folder_id $first_folder_id] \ + eq $tmp_item_id}] + + latest_revision from cr_items where + item_id=:tmp_item_id" -default ""]' " + aa_true "Tmp_filename added cr_revision exists" \ + [expr {[content::item::get_latest_revision \ + -item_id $tmp_item_id] ne ""}] + ######################################################### # delete first folder and everything in it to clean up ######################################################### content::folder::delete \ Index: openacs-4/packages/acs-content-repository/tcl/test/test.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/test/test.html,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/tcl/test/test.html 31 May 2006 13:42:30 -0000 1.1 @@ -0,0 +1,11 @@ + + +this is a test + + +

+this is a test +

+ + +