Index: openacs-4/packages/file-storage/www/file-copy-2-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/file-copy-2-oracle.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/file-storage/www/file-copy-2-oracle.xql 4 Sep 2001 01:29:52 -0000 1.2 +++ openacs-4/packages/file-storage/www/file-copy-2-oracle.xql 22 Sep 2001 05:43:54 -0000 1.3 @@ -5,53 +5,17 @@ - - begin - :1 := content_item.new ( - parent_id => :parent_id, - context_id => :parent_id, - name => :name, - content_type => :content_type, + + begin + :1 := file_storage.copy_file( + file_id => :file_id, + target_folder_id => :parent_id, creation_user => :user_id, - creation_ip => :ip_address, - item_subtype => 'file_storage_item' -- needed by site-wide search - ); - end; + creation_ip => :ip_address + ); + end; - - - - - begin - select acs_object_id_seq.nextval into :1 from dual; - - insert into acs_objects - (object_id, object_type, context_id, security_inherit_p, - creation_user, creation_ip, last_modified, modifying_user, - modifying_ip) - (select :1, object_type, :new_file_id, security_inherit_p, - creation_user, creation_ip, last_modified, modifying_user, - modifying_ip - from acs_objects - where object_id = content_item.get_live_revision(:file_id)); - - insert into cr_revisions - (revision_id, title, description, publish_date, mime_type, - nls_language, content, item_id) - (select :1, title, description, publish_date, mime_type, - nls_language, content, :new_file_id - from cr_revisions - where revision_id = content_item.get_live_revision(:file_id)); - - content_item.set_live_revision(:1); - - end; - - - - - Index: openacs-4/packages/file-storage/www/file-copy-2-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/file-copy-2-postgresql.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/file-storage/www/file-copy-2-postgresql.xql 4 Sep 2001 01:30:06 -0000 1.3 +++ openacs-4/packages/file-storage/www/file-copy-2-postgresql.xql 22 Sep 2001 05:44:12 -0000 1.4 @@ -6,66 +6,16 @@ - select content_item__new ( - :name, -- name - :parent_id, -- parent_id - null, -- item_id (default) - null, -- locale (default) - now(), -- creation_date (default) + select file_storage__copy_file ( + :file_id, -- file_id + :parent_id, -- taget_folder_id :user_id, -- creation_user - :parent_id, -- context_id - :ip_address, -- creation_ip - 'file_storage_item', -- item_subtype (needed by site-wide search) - :content_type, -- content_type - null, -- title (default) - null, -- description - 'text/plain', -- mime_type (default) - null, -- nls_language (default) - null -- data (default) + :ip_address -- creation_ip ); - - - - - declare - v_object_id acs_objects.object_id%TYPE; - begin - - select acs_object_id_seq.nextval into v_object_id; - - insert into acs_objects - (object_id, object_type, context_id, security_inherit_p, - creation_user, creation_ip, last_modified, modifying_user, - modifying_ip) - (select v_object_id, object_type, :new_file_id, security_inherit_p, - creation_user, creation_ip, last_modified, modifying_user, - modifying_ip - from acs_objects - where object_id = content_item__get_live_revision(:file_id)); - - insert into cr_revisions - (revision_id, title, description, publish_date, mime_type, - nls_language, content, item_id) - (select v_object_id, title, description, publish_date, mime_type, - nls_language, content, :new_file_id - from cr_revisions - where revision_id = content_item__get_live_revision(:file_id)); - - PERFORM content_item__set_live_revision(v_object_id); - - return v_object_id; - - - end; - - - - - Index: openacs-4/packages/file-storage/www/file-copy-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/file-copy-2.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/file-storage/www/file-copy-2.tcl 4 Sep 2001 01:30:23 -0000 1.4 +++ openacs-4/packages/file-storage/www/file-copy-2.tcl 22 Sep 2001 05:44:40 -0000 1.5 @@ -35,63 +35,16 @@ db_transaction { - db_1row item_info " - select name, content_type from cr_items where item_id = :file_id" - - # I'd like to use content_item.copy but the current version (4.0.1) - # doesn't return the new item_id. This would be okay except that - # content_revision.copy doesn't set the context_id properly - # and we will have no way to fix it. Also, the live revision - # doesn't get set. - - # Post-4.0.1 revisions to the content repository add the function - # copy2 which does return the item_id, so ultimately a call to - # that function will replace all this. - - set new_file_id [db_exec_plsql file_copy " + db_exec_plsql file_copy " begin - :1 := content_item.new ( - parent_id => :parent_id, - context_id => :parent_id, - name => :name, - content_type => :content_type, + file_storage.copy_file( + item_id => :file_id + target_folder_id => :parent_id, creation_user => :user_id, - creation_ip => :ip_address, - item_subtype => 'file_storage_item' -- needed by site-wide search - ); - end;"] + creation_ip => :ip_address + ); + end;" - # We could use content_revision.copy, but we would have to - # fix up the context_id by hand, so we'll just keep this - # for the time being. - set new_version_id [db_exec_plsql revision_copy " - begin - select acs_object_id_seq.nextval into :1 from dual; - - insert into acs_objects - (object_id, object_type, context_id, security_inherit_p, - creation_user, creation_ip, last_modified, modifying_user, - modifying_ip) - (select - :1, object_type, :new_file_id, security_inherit_p, - creation_user, creation_ip, last_modified, modifying_user, - modifying_ip - from acs_objects - where object_id = content_item.get_live_revision(:file_id)); - - insert into cr_revisions - (revision_id, title, description, publish_date, mime_type, - nls_language, content, item_id) - (select - :1, title, description, publish_date, mime_type, - nls_language, content, :new_file_id - from cr_revisions - where revision_id = content_item.get_live_revision(:file_id)); - - content_item.set_live_revision(:1); - - end;"] - } on_error { ad_return_complaint 1 "We received an error from the database. Probably the folder you selected already contains a file with the same name. Index: openacs-4/packages/file-storage/www/file-copy.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/file-copy.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/file-storage/www/file-copy.xql 16 Aug 2001 20:29:20 -0000 1.1 +++ openacs-4/packages/file-storage/www/file-copy.xql 22 Sep 2001 05:45:52 -0000 1.2 @@ -4,11 +4,9 @@ - select title - from cr_revisions - where revision_id = (select live_revision - from cr_items - where item_id = :file_id) + select name as title + from cr_items + where item_id = :file_id