Index: openacs-4/packages/file-storage/file-storage.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/file-storage.info,v
diff -u -r1.39 -r1.40
--- openacs-4/packages/file-storage/file-storage.info 26 May 2005 08:28:44 -0000 1.39
+++ openacs-4/packages/file-storage/file-storage.info 29 Sep 2005 18:51:09 -0000 1.40
@@ -7,39 +7,41 @@
f
f
-
+
OpenACS
Collaborative document storage
- 2004-07-21
+ 2005-09-28
OpenACS
Provides a versioned document store with storage in the filesystem or database (depending on configuration). Documents and folders can be permissioned and folders downloaded.
+ 0
-
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
+
-
-
+
+
Index: openacs-4/packages/file-storage/sql/postgresql/file-storage-package-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/postgresql/file-storage-package-create.sql,v
diff -u -r1.22 -r1.23
--- openacs-4/packages/file-storage/sql/postgresql/file-storage-package-create.sql 26 May 2005 08:28:45 -0000 1.22
+++ openacs-4/packages/file-storage/sql/postgresql/file-storage-package-create.sql 29 Sep 2005 18:51:48 -0000 1.23
@@ -84,7 +84,8 @@
null, --folder_id
null, --creation_date
null, --creation_user
- null --creation_ip
+ null, --creation_ip
+ new_root_folder__package_id --package_id
);
insert into fs_root_folders
@@ -133,7 +134,8 @@
integer, -- acs_objects.creation_user%TYPE,
varchar, -- acs_objects.creation_ip%TYPE,
boolean, -- store in db?
- integer -- cr_items.item_id%TYPE,
+ integer, -- cr_items.item_id%TYPE,
+ integer -- apm_packages.package_id%TYPE
) returns integer as ' -- cr_items.item_id%TYPE
declare
new_file__name alias for $1;
@@ -142,6 +144,7 @@
new_file__creation_ip alias for $4;
new_file__indb_p alias for $5;
new_file__item_id alias for $6;
+ new_file__package_id alias for $7;
v_item_id integer;
begin
@@ -162,7 +165,8 @@
null, -- description
''text/plain'', -- mime_type (default)
null, -- nls_language (default)
- null -- data (default)
+ null, -- data (default)
+ new_file__package_id -- package_id
);
else
v_item_id := content_item__new (
@@ -181,7 +185,8 @@
''text/plain'', -- mime_type (default)
null, -- nls_language (default)
null, -- text (default)
- ''file'' -- storage_type
+ ''file'', -- storage_type
+ new_file__package_id -- package_id
);
end if;
@@ -198,23 +203,25 @@
integer, -- cr_items.parent_id%TYPE,
integer, -- acs_objects.creation_user%TYPE,
varchar, -- acs_objects.creation_ip%TYPE,
- boolean -- store in db?
+ boolean, -- store in db?
+ integer -- apm_packages.package_id%TYPE
) returns integer as ' -- cr_items.item_id%TYPE
declare
new_file__name alias for $1;
new_file__folder_id alias for $2;
new_file__user_id alias for $3;
new_file__creation_ip alias for $4;
new_file__indb_p alias for $5;
+ new_file__package_id alias for $6;
begin
-
return file_storage__new_file(
- new_file__name,
- new_file__folder_id,
- new_file__user_id,
- new_file__creation_ip,
- new_file__indb_p,
- null
+ new_file__name, -- name
+ new_file__folder_id, -- parent_id
+ new_file__user_id, -- creation_user
+ new_file__creation_ip, -- creation_ip
+ new_file__indb_p, -- storage_type
+ null, -- item_id
+ new_file__package_id -- pacakge_id
);
end;' language 'plpgsql';
Index: openacs-4/packages/file-storage/sql/postgresql/upgrade/upgrade-5.1.0a16-5.1.0a17.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/postgresql/upgrade/upgrade-5.1.0a16-5.1.0a17.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/file-storage/sql/postgresql/upgrade/upgrade-5.1.0a16-5.1.0a17.sql 29 Sep 2005 18:52:33 -0000 1.1
@@ -0,0 +1,199 @@
+--
+-- packages/file-storage/sql/postgresql/upgrade/upgrade-5.1.0a16-5.1.0a17.sql
+--
+-- @author Stan Kaufman (skaufman@epimetrics.com)
+-- @creation-date 2005-09-28
+-- @cvs-id $Id: upgrade-5.1.0a16-5.1.0a17.sql,v 1.1 2005/09/29 18:52:33 skaufman Exp $
+--
+
+-- add package_id to acs_objects for all objects in FS (see Tip 42)
+
+create or replace function file_storage__new_root_folder (
+ --
+ -- Creates a new root folder
+ --
+ --
+ -- A hackish function to get around the fact that we can not run
+ -- code automatically when a new package instance is created.
+ --
+ integer, -- apm_packages.package_id%TYPE
+ varchar, -- cr_folders.label%TYPE
+ varchar, -- cr_items.name%TYPE
+ varchar
+)
+returns integer as ' -- fs_root_folders.folder_id%TYPE
+declare
+ new_root_folder__package_id alias for $1;
+ new_root_folder__folder_name alias for $2;
+ new_root_folder__url alias for $3;
+ new_root_folder__description alias for $4;
+ v_folder_id fs_root_folders.folder_id%TYPE;
+begin
+
+
+ v_folder_id := content_folder__new (
+ new_root_folder__url, -- name
+ new_root_folder__folder_name, -- label
+ new_root_folder__description, -- description
+ null, -- parent_id (default)
+ new_root_folder__package_id, --context_id
+ null, --folder_id
+ null, --creation_date
+ null, --creation_user
+ null, --creation_ip
+ new_root_folder__package_id --package_id
+ );
+
+ insert into fs_root_folders
+ (package_id, folder_id)
+ values
+ (new_root_folder__package_id, v_folder_id);
+
+ -- allow child items to be added
+ -- JS: Note that we need to set include_subtypes to
+ -- JS: true since we created a new subtype.
+ PERFORM content_folder__register_content_type(
+ v_folder_id, -- folder_id
+ ''content_revision'', -- content_types
+ ''t'' -- include_subtypes
+ );
+ PERFORM content_folder__register_content_type(
+ v_folder_id, -- folder_id
+ ''content_folder'', -- content_types
+ ''t'' -- include_subtypes
+ );
+ PERFORM content_folder__register_content_type(
+ v_folder_id, -- folder_id
+ ''content_symlink'', -- content_types
+ ''t'' -- include_subtypes
+ );
+ PERFORM content_folder__register_content_type(
+ v_folder_id, -- folder_id
+ ''content_extlink'', -- content_types
+ ''t'' -- include_subtypes
+ );
+
+ return v_folder_id;
+
+end;' language 'plpgsql';
+
+create or replace function file_storage__new_file(
+ --
+ -- Create a file in CR in preparation for actual storage
+ -- Wrapper for content_item__new
+ --
+ -- DRB: I added this version to allow one to predefine item_id, among other things to
+ -- make it easier to use with ad_form
+ varchar, -- cr_items.name%TYPE,
+ integer, -- cr_items.parent_id%TYPE,
+ integer, -- acs_objects.creation_user%TYPE,
+ varchar, -- acs_objects.creation_ip%TYPE,
+ boolean, -- store in db?
+ integer, -- cr_items.item_id%TYPE,
+ integer -- apm_packages.package_id%TYPE
+) returns integer as ' -- cr_items.item_id%TYPE
+declare
+ new_file__name alias for $1;
+ new_file__folder_id alias for $2;
+ new_file__user_id alias for $3;
+ new_file__creation_ip alias for $4;
+ new_file__indb_p alias for $5;
+ new_file__item_id alias for $6;
+ new_file__package_id alias for $7;
+ v_item_id integer;
+begin
+
+ if new_file__indb_p
+ then
+ v_item_id := content_item__new (
+ new_file__name, -- name
+ new_file__folder_id, -- parent_id
+ new_file__item_id, -- item_id (default)
+ null, -- locale (default)
+ now(), -- creation_date (default)
+ new_file__user_id, -- creation_user
+ new_file__folder_id, -- context_id
+ new_file__creation_ip, -- creation_ip
+ ''content_item'', -- item_subtype (default)
+ ''file_storage_object'', -- content_type (needed by site-wide search)
+ null, -- title (default)
+ null, -- description
+ ''text/plain'', -- mime_type (default)
+ null, -- nls_language (default)
+ null, -- data (default)
+ new_file__package_id -- package_id
+ );
+ else
+ v_item_id := content_item__new (
+ new_file__name, -- name
+ new_file__folder_id, -- parent_id
+ new_file__item_id, -- item_id (default)
+ null, -- locale (default)
+ now(), -- creation_date (default)
+ new_file__user_id, -- creation_user
+ new_file__folder_id, -- context_id
+ new_file__creation_ip, -- creation_ip
+ ''content_item'', -- item_subtype (default)
+ ''file_storage_object'', -- content_type (needed by site-wide search)
+ null, -- title (default)
+ null, -- description
+ ''text/plain'', -- mime_type (default)
+ null, -- nls_language (default)
+ null, -- text (default)
+ ''file'', -- storage_type
+ new_file__package_id -- package_id
+ );
+
+ end if;
+
+ perform acs_object__update_last_modified(new_file__folder_id,new_file__user_id,new_file__creation_ip);
+
+ return v_item_id;
+
+end;' language 'plpgsql';
+
+
+create or replace function file_storage__new_file(
+ varchar, -- cr_items.name%TYPE,
+ integer, -- cr_items.parent_id%TYPE,
+ integer, -- acs_objects.creation_user%TYPE,
+ varchar, -- acs_objects.creation_ip%TYPE,
+ boolean, -- store in db?
+ integer -- apm_packages.package_id%TYPE
+) returns integer as ' -- cr_items.item_id%TYPE
+declare
+ new_file__name alias for $1;
+ new_file__folder_id alias for $2;
+ new_file__user_id alias for $3;
+ new_file__creation_ip alias for $4;
+ new_file__indb_p alias for $5;
+ new_file__package_id alias for $6;
+begin
+ return file_storage__new_file(
+ new_file__name, -- name
+ new_file__folder_id, -- parent_id
+ new_file__user_id, -- creation_user
+ new_file__creation_ip, -- creation_ip
+ new_file__indb_p, -- storage_type
+ null, -- item_id
+ new_file__package_id -- pacakge_id
+ );
+
+end;' language 'plpgsql';
+
+-- upgrade existing data
+-- do in transaction since we're bashing acs_objects in a major way
+begin;
+lock table acs_objects;
+
+-- prevent loss of last_modified dates in all objects
+drop trigger acs_objects_last_mod_update_tr on acs_objects;
+-- the FS root folders for each package instance
+update cr_folders set package_id = file_storage__get_package_id(folder_id) where folder_id in (select folder_id from fs_root_folders);
+-- all the rest of the FS objects
+update acs_objects set package_id = file_storage__get_package_id(object_id) where object_id in (select object_id from fs_objects);
+-- restart last_mod updating
+create trigger acs_objects_last_mod_update_tr before update on acs_objects for each row execute procedure acs_objects_last_mod_update_tr ();
+
+commit;
+
Index: openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql,v
diff -u -r1.42 -r1.43
--- openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql 1 Mar 2005 22:53:02 -0000 1.42
+++ openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql 29 Sep 2005 18:54:09 -0000 1.43
@@ -178,7 +178,8 @@
:creation_user,
:creation_ip,
:indbp,
- :item_id
+ :item_id,
+ :package_id
)
Index: openacs-4/packages/file-storage/tcl/file-storage-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs.tcl,v
diff -u -r1.49 -r1.50
--- openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 26 May 2005 08:28:45 -0000 1.49
+++ openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 29 Sep 2005 18:53:38 -0000 1.50
@@ -1096,6 +1096,24 @@
return [list $package_id $root_folder_id]
}
+ad_proc -public fs::get_file_package_id {
+ -file_id
+} {
+ Returns the package_id for a passed-in file_id. This is useful when
+ using symlinks to files whose real root_folder_id is not the root_folder_id
+ of the package the user is in.
+
+ @author Stan Kaufman (skaufman@epimetrics.com)
+ @creation-date 2005-09-07
+
+ @param file_id
+
+ @return package_id
+
+} {
+ return [db_string select_package_id {}]
+}
+
namespace eval fs::notification {}
ad_proc -public fs::notification::get_url {
Index: openacs-4/packages/file-storage/tcl/file-storage-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs.xql,v
diff -u -r1.16 -r1.17
--- openacs-4/packages/file-storage/tcl/file-storage-procs.xql 13 Jan 2005 13:58:12 -0000 1.16
+++ openacs-4/packages/file-storage/tcl/file-storage-procs.xql 29 Sep 2005 18:53:25 -0000 1.17
@@ -148,10 +148,18 @@
-
select storage_type from cr_items where item_id=:item_id
-
\ No newline at end of file
+
+
+
+ select package__id
+ from acs_objects
+ where object_id = :file_id
+
+
+
+