Index: openacs-4/packages/file-storage/tcl/file-storage-dav-install-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/Attic/file-storage-dav-install-procs.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/file-storage/tcl/file-storage-dav-install-procs.tcl 9 Nov 2003 20:56:45 -0000 1.1.2.1
@@ -0,0 +1,94 @@
+#
+
+ad_library {
+
+ Sets up WebDAV support service contracts
+
+ @author Dave Bauer (dave@thedesignexperience.org)
+ @creation-date 2003-11-09
+ @cvs-id $Id: file-storage-dav-install-procs.tcl,v 1.1.2.1 2003/11/09 20:56:45 daveb Exp $
+
+}
+
+
+namespace eval fs::install {}
+
+ad_proc -private fs::install::package_install {} {
+ setup DAV service contracts
+} {
+ db_transaction {
+ register_implementation
+ }
+}
+
+ad_proc -private fs::install::package_uninstall {} {
+ clean up for package uninstall
+} {
+ db_transaction {
+ unregister_implementation
+ }
+}
+
+
+ad_proc -private fs::install::register_implementation {
+} {
+ add file-storage repository service contract
+ implementation
+} {
+
+ set spec {
+ name "file_storage_object"
+ aliases {
+ get fs::impl::fs_object::get
+ put fs::impl::fs_object::put
+ propfind fs::impl::fs_object::propfind
+ delete fs::impl::fs_object::delete
+ mkcol fs::impl::fs_object::mkcol
+ proppatch fs::impl::fs_object::proppatch
+ copy fs::impl::fs_object::copy
+ move fs::impl::fs_object::move
+ }
+ contract_name {dav}
+ owner "file-storage"
+ }
+
+ acs_sc::impl::new_from_spec -spec $spec
+
+ set spec {
+ name "file-storage"
+ aliases {
+ get_type fs::impl::dav_put_type::get_type
+ }
+ contract_name {dav_put_type}
+ owner "file-storage"
+ }
+
+ acs_sc::impl::new_from_spec -spec $spec
+
+}
+
+
+ad_proc -private fs::install::unregister_implementation {
+} {
+ remove file-storage service contract implementation
+} {
+ acs_sc::impl::delete -contract_name dav -impl_name file_storage_object
+}
+
+ad_proc -private fs::install::upgrade {
+ -from_version_name
+ -to_version_name
+} {
+ Install new DAV service contracts
+} {
+ apm_upgrade_logic \
+ -from_version_name $from_version_name \
+ -to_version_name $to_version_name \
+ -spec {
+ 4.6.2 4.6.4 {
+ fs::install::package_install
+ }
+
+ }
+
+}
\ No newline at end of file
Index: openacs-4/packages/file-storage/tcl/file-storage-dav-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-dav-procs.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/file-storage/tcl/file-storage-dav-procs.tcl 9 Nov 2003 20:56:45 -0000 1.1.2.1
@@ -0,0 +1,123 @@
+#
+
+ad_library {
+
+ Procedures for DAV service contract implementations
+
+ @author Dave Bauer (dave@thedesignexperience.org)
+ @creation-date 2003-11-09
+ @cvs-id $Id: file-storage-dav-procs.tcl,v 1.1.2.1 2003/11/09 20:56:45 daveb Exp $
+
+}
+
+namespace eval fs::impl::fs_object {}
+
+ad_proc fs::impl::fs_object::get {} {
+ GET method
+} {
+ return [oacs_dav::impl::content_revision::get]
+}
+
+ad_proc fs::impl::fs_object::put {} {
+ PUT method
+} {
+ set user_id [oacs_dav::conn user_id]
+ set item_id [oacs_dav::conn item_id]
+ set root_folder_id [oacs_dav::conn folder_id]
+ set uri [oacs_dav::conn url]
+
+ set tmp_filename [oacs_dav::conn tmpfile]
+ set tmp_size [file size $tmp_filename]
+ # authenticate that user has write privilege
+
+ # we need to calculate parent_id from the URI
+ # it might not be the root DAV folder for the package
+ # check for folder or not
+
+ set name [oacs_dav::conn item_name]
+ set parent_id [oacs_dav::item_parent_folder_id $uri]
+ array set sn [site_node::get -url $uri]
+ set package_id $sn(package_id)
+ if {[empty_string_p $parent_id]} {
+ set response [list 409]
+ return $response
+ }
+
+ if { ! [permission::permission_p \
+ -object_id $parent_id \
+ -party_id $user_id \
+ -privilege "create"
+ ]} {
+ return [list 401]
+ }
+
+ if {![empty_string_p $item_id]} {
+ if {![permission::permission_p \
+ -object_id $item_id \
+ -party_id $user_id \
+ -privilege "write"
+ ]} {
+ return [list 401]
+ }
+ }
+
+ fs::add_file \
+ -package_id $package_id \
+ -name $name \
+ -item_id $item_id \
+ -parent_id $parent_id \
+ -tmp_filename $tmp_filename \
+ -creation_user $user_id \
+ -creation_ip [ad_conn peeraddr] \
+
+ set response [list 201]
+
+ return $response
+
+}
+
+ad_proc fs::impl::fs_object::propfind {} {
+ PROPFIND method
+} {
+ return [oacs_dav::impl::content_revision::propfind]
+}
+
+ad_proc fs::impl::fs_object::delete {} {
+ DELETE method
+} {
+ return [oacs_dav::impl::content_revision::delete]
+}
+
+ad_proc fs::impl::fs_object::mkcol {} {
+ MKCOL method
+ not valid for resource
+} {
+ return [list 409]
+}
+
+ad_proc fs::impl::fs_object::proppatch {} {
+ PROPPATCH method
+} {
+ # this is handled in tDAV for now
+ return [list 201]
+}
+
+ad_proc fs::impl::fs_object::copy {} {
+ COPY method
+} {
+ return [oacs_dav::impl::content_revision::copy]
+}
+
+ad_proc fs::impl::fs_object::move {} {
+ MOVE method
+} {
+ return [oacs_dav::impl::content_revision::move]
+}
+
+namespace eval fs::impl::dav_put_type {}
+
+ad_proc fs::impl::dav_put_type::get_type {} {
+
+} {
+ return "file_storage_object"
+}
\ No newline at end of file
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 -N -r1.29.2.5 -r1.29.2.6
--- openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql 9 Nov 2003 03:36:56 -0000 1.29.2.5
+++ openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql 9 Nov 2003 20:56:45 -0000 1.29.2.6
@@ -143,4 +143,30 @@
+
+
+
+ select file_storage__new_file (
+ :name,
+ :parent_id,
+ :creation_user,
+ :creation_ip,
+ :indbp,
+ :item_id
+ )
+
+
+
+
+
+ begin
+ perform acs_object__update_last_modified
+ (:parent_id,:creation_user,:creation_ip);
+ perform
+ acs_object__update_last_modified(:item_id,:creation_user,:creation_ip);
+ return null;
+ end;
+
+
+
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 -N -r1.25.2.6 -r1.25.2.7
--- openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 9 Nov 2003 03:36:56 -0000 1.25.2.6
+++ openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 9 Nov 2003 20:56:45 -0000 1.25.2.7
@@ -599,3 +599,61 @@
}
return [db_exec_plsql get_item_id ""]
}
+
+ad_proc -public fs::add_file {
+ -name
+ -parent_id
+ -tmp_filename
+ -package_id
+ {-item_id ""}
+ {-creation_user ""}
+ {-creation_ip ""}
+ {-title ""}
+ {-description ""}
+} {
+ Create a new file storage item or add a new revision if
+ an item with the same name and parent folder already exists
+
+ @returns revision_id
+} {
+
+ if {[ad_parameter "StoreFilesInDatabaseP" -package_id $package_id]} {
+ set indbp "t"
+ set storage_type "lob"
+ } else {
+ set indpb "f"
+ set storage_type "file"
+ }
+
+ set mime_type [cr_filename_to_mime_type -create $name]
+ set tmp_size [file size $tmp_filename]
+ db_transaction {
+ if {[empty_string_p $item_id] || ![db_string item_exists ""]} {
+ set item_id [db_exec_plsql create_item ""]
+ }
+
+ set revision_id [cr_import_content \
+ -item_id $item_id \
+ -storage_type $storage_type \
+ -creation_user $creation_user \
+ -creation_ip $creation_ip \
+ -other_type "file_storage_object" \
+ -title $title \
+ -description $description \
+ $parent_id \
+ $tmp_filename \
+ $tmp_size \
+ $mime_type \
+ $name]
+
+ db_dml set_live_revision ""
+ db_exec_plsql update_last_modified ""
+
+ if {![empty_string_p $creation_user]} {
+ permission::grant -party_id $creation_user -object_id $item_id -privilege admin
+ }
+ } on_error {
+ error $errmsg
+ }
+ return $revision_id
+}
\ No newline at end of file
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 -N -r1.10.2.4 -r1.10.2.5
--- openacs-4/packages/file-storage/tcl/file-storage-procs.xql 20 Mar 2003 22:13:59 -0000 1.10.2.4
+++ openacs-4/packages/file-storage/tcl/file-storage-procs.xql 9 Nov 2003 20:56:45 -0000 1.10.2.5
@@ -117,4 +117,19 @@
+
+
+ select count(*) from cr_items
+ where name=:name
+ and parent_id=:parent_id
+
+
+
+
+
+ update cr_items set live_revision=:revision_id
+ where item_id=:item_id
+
+
+