Index: openacs-4/packages/acs-admin/www/apm/index-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/index-oracle.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-admin/www/apm/index-oracle.xql 29 Apr 2001 02:29:15 -0000 1.2 +++ openacs-4/packages/acs-admin/www/apm/index-oracle.xql 5 May 2001 17:39:19 -0000 1.3 @@ -20,7 +20,9 @@ where v2.package_key = v.package_key and v2.installed_p = 't' and apm_package_version.sortable_version_name(v2.version_name) > apm_package_version.sortable_version_name(v.version_name)) as superseded_p, - (select count(*) from dual where distribution_tarball is not null) as tarball_p + (select count(*) + from cr_revisions + where revision_id = content_item.get_latest_revision(item_id)) as tarball_p from apm_package_versions v, apm_package_types t where t.package_key = v.package_key [ad_dimensional_sql $dimensional_list where and] Index: openacs-4/packages/acs-admin/www/apm/index-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/index-postgresql.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-admin/www/apm/index-postgresql.xql 4 May 2001 06:04:28 -0000 1.2 +++ openacs-4/packages/acs-admin/www/apm/index-postgresql.xql 5 May 2001 17:39:19 -0000 1.3 @@ -13,7 +13,9 @@ and v2.installed_p and apm_package_version__sortable_version_name(v2.version_name) > apm_package_version__sortable_version_name(v.version_name)) as superseded_p, - (select count(*) where item_id is not null) as tarball_p + (select count(*) + from cr_revisions + where revision_id = content_item__get_latest_revision(item_id)) as tarball_p from apm_package_versions v, apm_package_types t where t.package_key = v.package_key [ad_dimensional_sql $dimensional_list where and] Index: openacs-4/packages/acs-admin/www/apm/packages/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/packages/index.vuh,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-admin/www/apm/packages/index.vuh 13 Mar 2001 22:59:26 -0000 1.1 +++ openacs-4/packages/acs-admin/www/apm/packages/index.vuh 5 May 2001 17:39:19 -0000 1.2 @@ -1,6 +1,7 @@ ad_page_contract { This page serves .APM tarballs of packages. + Modified to serve tarballs from content repository (Openacs - DanW) @author Bryan Quinn (bquinn@arsdigita.com) @creation-date 29 September 2000 @@ -10,16 +11,21 @@ } if { [db_string apm_archive_exist_p { - select count(*) from apm_package_versions - where version_id = :version_id - and distribution_tarball is not null + select count(*) + from cr_revisions + where revision_id = (select content_item.get_latest_revision(item_id) + from apm_package_versions + where version_id = :version_id) } -default 0] } { set file [ns_tmpnam] db_blob_get_file apm_archive_serve " - select distribution_tarball from apm_package_versions - where version_id = $version_id + select content + from cr_revisions + where revision_id = (select content_item.get_latest_revision(item_id) + from apm_package_versions + where version_id = :version_id) " -file $file db_release_unused_handles ns_returnfile 200 application/octet-stream $file Index: openacs-4/packages/acs-kernel/sql/oracle/apm-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/apm-create.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-kernel/sql/oracle/apm-create.sql 5 Apr 2001 18:23:38 -0000 1.2 +++ openacs-4/packages/acs-kernel/sql/oracle/apm-create.sql 5 May 2001 17:39:19 -0000 1.3 @@ -212,7 +212,9 @@ cvs_import_results clob, activation_date date, deactivation_date date, - distribution_tarball blob, + -- distribution_tarball blob, + item_id integer, + content_length integer, distribution_uri varchar2(1500), distribution_date date, constraint apm_package_vers_id_name_un unique(package_key, version_name) @@ -477,17 +479,19 @@ -- Ths view faciliates accessing information about package versions by joining -- the apm_package_types information and acs_object_types information (which is -- invariant across versions) with the specific version information. + +-- DCW - 2001-05-04, converted tarball storage to use content repository. create or replace view apm_package_version_info as select v.package_key, t.package_uri, t.pretty_name, v.version_id, v.version_name, v.version_uri, v.summary, v.description_format, v.description, v.release_date, v.vendor, v.vendor_uri, v.enabled_p, v.installed_p, v.tagged_p, v.imported_p, v.data_model_loaded_p, v.activation_date, v.deactivation_date, - dbms_lob.getlength(distribution_tarball) tarball_length, + -- dbms_lob.getlength(distribution_tarball) tarball_length, + nvl(v.content_length,0) as tarball_length, distribution_uri, distribution_date from apm_package_types t, apm_package_versions v where v.package_key = t.package_key; - -- A useful view for simply determining which packages are eanbled. create or replace view apm_enabled_package_versions as select * from apm_package_version_info Index: openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql,v diff -u -r1.15 -r1.16 --- openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql 4 May 2001 06:04:28 -0000 1.15 +++ openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql 5 May 2001 17:39:19 -0000 1.16 @@ -264,10 +264,11 @@ -- FIXME: store the tarball in the content-repository -- distribution_tarball blob, item_id integer, - -- This constraint can't be adde yet, as the cr_items table + -- This constraint can't be added yet, as the cr_items table -- has not been created yet. -- constraint apm_package_ver_item_id_fk -- references cr_items(item_id), + content_length integer, distribution_uri varchar(1500), distribution_date timestamp, constraint apm_package_vers_id_name_un unique(package_key, version_name) @@ -645,16 +646,17 @@ -- Ths view faciliates accessing information about package versions by joining -- the apm_package_types information and acs_object_types information (which is -- invariant across versions) with the specific version information. + +-- DCW - 2001-05-04, converted tarball storage to use content repository. create view apm_package_version_info as select v.package_key, t.package_uri, t.pretty_name, v.version_id, v.version_name, v.version_uri, v.summary, v.description_format, v.description, v.release_date, v.vendor, v.vendor_uri, v.enabled_p, v.installed_p, v.tagged_p, v.imported_p, v.data_model_loaded_p, v.activation_date, v.deactivation_date, -- dbms_lob.getlength(distribution_tarball) tarball_length, --- FIXME: - case when item_id is not null then 1 else 0 end as tarball_length, + coalesce(v.content_length,0) as tarball_length, distribution_uri, distribution_date - from apm_package_types t, apm_package_versions v + from apm_package_types t, apm_package_versions v where v.package_key = t.package_key; Index: openacs-4/packages/acs-tcl/tcl/apm-file-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-file-procs-oracle.xql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-tcl/tcl/apm-file-procs-oracle.xql 4 May 2001 06:04:28 -0000 1.4 +++ openacs-4/packages/acs-tcl/tcl/apm-file-procs-oracle.xql 5 May 2001 17:39:19 -0000 1.5 @@ -7,7 +7,7 @@ begin - :1 := content_item.new(name => 'tarball-for-package-version-${version_id}', + :1 := content_item.new(name => :name, creation_ip => :creation_ip ); end; @@ -19,10 +19,10 @@ begin - :1 := content_revision.new(title => '${package_key}-tarball', + :1 := content_revision.new(title => :title, description => 'gzipped tarfile', text => 'not_important', - mime_type => 'application/x-compressed', + mime_type => 'text/plain', item_id => :item_id, creation_user => :user_id, creation_ip => :creation_ip @@ -47,7 +47,19 @@ + + + update apm_package_versions + set content_length = (select dbms_lob.getlength(content) + from cr_revisons + where revision_id = :revision_id) + where version_id = :version_id + + + + + @@ -59,21 +71,7 @@ - - - - update apm_package_versions - set distribution_tarball = empty_blob(), - distribution_uri = null, - distribution_date = sysdate - where version_id = :version_id - returning distribution_tarball into :1 - - - - - @@ -104,5 +102,5 @@ - + Index: openacs-4/packages/acs-tcl/tcl/apm-file-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-file-procs-postgresql.xql,v diff -u -r1.8 -r1.9 --- openacs-4/packages/acs-tcl/tcl/apm-file-procs-postgresql.xql 4 May 2001 06:04:28 -0000 1.8 +++ openacs-4/packages/acs-tcl/tcl/apm-file-procs-postgresql.xql 5 May 2001 17:39:19 -0000 1.9 @@ -7,7 +7,7 @@ select content_item__new( - 'tarball-for-package-version-${version_id}', + :name, null, null, null, @@ -36,7 +36,7 @@ begin v_revision_id := content_revision__new( - '${package_key}-tarball', + :title, 'gzipped tarfile', now(), 'text/plain', @@ -64,12 +64,22 @@ update cr_revisions - set content = '[cr_create_content_file $item_id $revision_id $tmpfile]' + set content = '[set content_file [cr_create_content_file $item_id $revision_id $tmpfile]]' where revision_id = :revision_id - + + + + + update apm_package_versions + set content_length = [file size [cr_fs_path]$content_file] + where version_id = :version_id + + + + Index: openacs-4/packages/acs-tcl/tcl/apm-file-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-file-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-tcl/tcl/apm-file-procs.tcl 4 May 2001 06:04:28 -0000 1.5 +++ openacs-4/packages/acs-tcl/tcl/apm-file-procs.tcl 5 May 2001 17:39:19 -0000 1.6 @@ -102,6 +102,7 @@ Extracts a distribution tarball into a particular directory, overwriting any existing files. + DCW - 2001-05-03, modified to extract tarball from content repository. } { @@ -115,9 +116,6 @@ where version_id = :version_id) } $apm_file - - #db_blob_get_file distribution_tar_ball_select "select distribution_tarball from apm_package_versions where version_id = :version_id" $apm_file - file mkdir $dir # cd, gunzip, and untar all in the same subprocess (to avoid having to # chdir first). @@ -132,11 +130,14 @@ DCW - 2001-05-03, change to use the content repository for tarball storage. } { - set files [apm_version_file_list $version_id] - + set files [apm_version_file_list $version_id] set tmpfile [ns_tmpnam] - db_1row package_key_select "select package_key from apm_package_version_info where version_id = :version_id" + db_1row package_key_select { + select package_key + from apm_package_version_info + where version_id = :version_id + } # Generate a command like: # @@ -157,21 +158,24 @@ lappend cmd "|" [apm_gzip_cmd] -c ">" $tmpfile eval $cmd - # At this point, the APM tarball is sitting in $tmpfile. Save it in the database. + # At this point, the APM tarball is sitting in $tmpfile. Save it in + # the database. set creation_ip [ad_conn peeraddr] set user_id [ad_verify_and_get_user_id] + set name "tarball-for-package-version-${version_id}" + set title "${package_key}-tarball" set create_item " begin - :1 := content_item.new(name => 'tarball-for-package-version-${version_id}', + :1 := content_item.new(name => :name, creation_ip => :creation_ip ); end;" set create_revision " begin - :1 := content_revision.new(title => '${package_key}-tarball', + :1 := content_revision.new(title => :title, description => 'gzipped tarfile', text => 'not_important', mime_type => 'text/plain', @@ -185,45 +189,45 @@ where item_id = :item_id; end;" - set update_tarball " - update cr_revisions - set content = empty_blob() - where revision_id = :revision_id - returning content into :1" + db_1row item_exists_p {select case when item_id is null + then 0 + else item_id + end as item_id + from apm_package_versions + where version_id = :version_id} - db_1row item_exists_p {select case when item_id is null then 0 else item_id end as item_id - from apm_package_versions - where version_id = :version_id} - if {!$item_id} { - # content item hasen't been created yet - create one. + # content item hasen't been created yet - create one. + set item_id [db_exec_plsql create_item $create_item] + db_dml set_item_id "update apm_package_versions + set item_id = :item_id + where version_id = :version_id" + set revision_id [db_exec_plsql create_revision $create_revision] - set item_id [db_exec_plsql create_item $create_item] - db_dml set_item_id "update apm_package_versions - set item_id = :item_id - where version_id = :version_id" - set revision_id [db_exec_plsql create_revision $create_revision] - db_dml update_tarball $update_tarball -blob_files [list $tmpfile] - } else { #tarball exists, so all we have to do is to make a new revision for it #Let's check if a current revision exists: if {![db_0or1row get_revision_id "select live_revision as revision_id from cr_items where item_id = :item_id"] || [empty_string_p $revision_id]} { - # It's an insert rather than an update - - set revision_id [db_exec_plsql create_revision $create_revision] - db_dml update_tarball $update_tarball -blob_files [list $tmpfile] - - } else { - # it's merely an update - - db_dml update_tarball $update_tarball -blob_files [list $tmpfile] - + # It's an insert rather than an update + set revision_id [db_exec_plsql create_revision $create_revision] } } + db_dml update_tarball {update cr_revisions + set content = empty_blob() + where revision_id = :revision_id + returning content into :1} -blob_files [list $tmpfile] + + db_dml update_content_length { + update apm_package_versions + set content_length = (select dbms_lob.getlength(content) + from cr_revisons + where revision_id = :revision_id) + where version_id = :version_id + } + file delete $tmpfile }