Index: openacs-4/packages/acs-authentication/tcl/apm-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/apm-callback-procs.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/packages/acs-authentication/tcl/apm-callback-procs.tcl 24 Oct 2003 16:44:19 -0000 1.11 +++ openacs-4/packages/acs-authentication/tcl/apm-callback-procs.tcl 31 Oct 2003 10:29:19 -0000 1.12 @@ -32,6 +32,9 @@ # Register HTTP method for GetDocument auth::sync::get_doc::http::register_impl + # Register local file system method for GetDocument + auth::sync::get_doc::file::register_impl + # Register IMS Enterprise 1.1 ProcessDocument implementation auth::sync::process_doc::ims::register_impl } @@ -47,6 +50,9 @@ # Unregister HTTP method for GetDocument auth::sync::get_doc::http::unregister_impl + # Unregister local file system method for GetDocument + auth::sync::get_doc::file::unregister_impl + # Unregister local authentication implementations and update the local authority auth::local::uninstall Index: openacs-4/packages/acs-authentication/tcl/sync-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/sync-procs.tcl,v diff -u -r1.30 -r1.31 --- openacs-4/packages/acs-authentication/tcl/sync-procs.tcl 31 Oct 2003 09:29:15 -0000 1.30 +++ openacs-4/packages/acs-authentication/tcl/sync-procs.tcl 31 Oct 2003 10:29:19 -0000 1.31 @@ -11,6 +11,7 @@ namespace eval auth::sync::job {} namespace eval auth::sync::get_doc {} namespace eval auth::sync::get_doc::http {} +namespace eval auth::sync::get_doc::file {} namespace eval auth::sync::entry {} namespace eval auth::sync::process_doc {} namespace eval auth::sync::process_doc::ims {} @@ -747,6 +748,83 @@ ##### # +# auth::sync::get_doc::file namespace +# +##### + +ad_proc -private auth::sync::get_doc::file::register_impl {} { + Register this implementation +} { + set spec { + contract_name "auth_sync_retrieve" + owner "acs-authentication" + name "LocalFilesystem" + pretty_name "Local Filesystem" + aliases { + GetDocument auth::sync::get_doc::file::GetDocument + GetParameters auth::sync::get_doc::file::GetParameters + } + } + + return [acs_sc::impl::new_from_spec -spec $spec] + +} + +ad_proc -private auth::sync::get_doc::file::unregister_impl {} { + Unregister this implementation +} { + acs_sc::impl::delete -contract_name "auth_sync_retrieve" -impl_name "LocalFilesystem" +} + +ad_proc -private auth::sync::get_doc::file::GetParameters {} { + Parameters for FILE GetDocument implementation. +} { + return { + IncrementalPath {The path to the document for incremental update. Will retrieve this most of the time.} + SnapshotPath {The path to the document for snapshot update. If specified, will get this once per month.} + } +} + +ad_proc -private auth::sync::get_doc::file::GetDocument { + parameters +} { + Retrieve the document from local file system +} { + array set result { + doc_status failed_to_conntect + doc_message {} + document {} + snapshot_p f + } + + array set param $parameters + + if { (![empty_string_p $param(SnapshotPath)] && [string equal [clock format [clock seconds] -format "%d"] "01"]) || \ + [empty_string_p $param(IncrementalPath)] } { + + # On the first day of the month, we get a snapshot + set path $param(SnapshotPath) + set result(snapshot_p) "t" + } else { + # All the other days of the month, we get the incremental + set path $param(IncrementalPath) + } + + if { [empty_string_p $path] } { + error "You must specify at least one path to get." + } + + set result(document) [template::util::read_file $path] + + set result(doc_status) "ok" + + return [array get result] +} + + + +##### +# # auth::sync::process_doc::ims namespace # ##### Index: openacs-4/packages/acs-authentication/tcl/test/sync-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/test/sync-test-procs.tcl,v diff -u -r1.14 -r1.15 --- openacs-4/packages/acs-authentication/tcl/test/sync-test-procs.tcl 31 Oct 2003 09:29:17 -0000 1.14 +++ openacs-4/packages/acs-authentication/tcl/test/sync-test-procs.tcl 31 Oct 2003 10:29:19 -0000 1.15 @@ -960,3 +960,22 @@ aa_true "result.doc_message is empty" [empty_string_p $result(doc_message)] aa_equals "result.document is 'success'" $result(document) "success" } + +aa_register_case sync_file_get_document { + Test the HTTPGet implementation of GetDocument service contract. +} { + set path "[acs_root_dir]/www/SYSTEM/dbtest.tcl" + + aa_log "Getting path '$path'" + + array set result [acs_sc::invoke \ + -error \ + -contract "auth_sync_retrieve" \ + -impl "LocalFilesystem" \ + -operation "GetDocument" \ + -call_args [list [list SnapshotPath {} IncrementalPath $path]]] + + aa_equals "result.doc_status is ok" $result(doc_status) "ok" + aa_true "result.doc_message is empty" [empty_string_p $result(doc_message)] + aa_equals "result.document is 'success'" $result(document) [template::util::read_file $path] +}