file-storage-dav-procs.tcl

Procedures for DAV service contract implementations

Location:
packages/file-storage/tcl/file-storage-dav-procs.tcl
Created:
2003-11-09
Author:
Dave Bauer <dave@thedesignexperience.org>
CVS Identification:
$Id: file-storage-dav-procs.tcl,v 1.12.2.6 2023/02/20 09:55:55 antoniop Exp $

Procedures in this file

Detailed information

fs::dav::require (private)

 fs::dav::require

oacs-dav used to be a requirement for file-storage. We now made this optional, with the caveat that some operations need to happen only depending if the package is there or not.

Partial Call Graph (max 5 caller/called nodes):
%3 packages/file-storage/tcl/file-storage-init.tcl packages/file-storage/ tcl/file-storage-init.tcl fs::dav::require fs::dav::require packages/file-storage/tcl/file-storage-init.tcl->fs::dav::require apm_package_installed_p apm_package_installed_p (public) fs::dav::require->apm_package_installed_p db_0or1row db_0or1row (public) fs::dav::require->db_0or1row db_dml db_dml (public) fs::dav::require->db_dml db_table_exists db_table_exists (public) fs::dav::require->db_table_exists fs::install::register_implementation fs::install::register_implementation (private) fs::dav::require->fs::install::register_implementation

Testcases:
No testcase defined.

fs::impl::dav_mkcol_type::get_type (private)

 fs::impl::dav_mkcol_type::get_type

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.dav_mkcol_type.get_type.file_storage AcsSc.dav_mkcol_type.get_type.file_storage (private) fs::impl::dav_mkcol_type::get_type fs::impl::dav_mkcol_type::get_type AcsSc.dav_mkcol_type.get_type.file_storage->fs::impl::dav_mkcol_type::get_type

Testcases:
No testcase defined.

fs::impl::dav_put_type::get_type (private)

 fs::impl::dav_put_type::get_type

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.dav_put_type.get_type.file_storage AcsSc.dav_put_type.get_type.file_storage (private) fs::impl::dav_put_type::get_type fs::impl::dav_put_type::get_type AcsSc.dav_put_type.get_type.file_storage->fs::impl::dav_put_type::get_type

Testcases:
No testcase defined.

fs::impl::fs_object::copy (private)

 fs::impl::fs_object::copy

COPY method

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.dav.copy.file_storage_object AcsSc.dav.copy.file_storage_object (private) fs::impl::fs_object::copy fs::impl::fs_object::copy AcsSc.dav.copy.file_storage_object->fs::impl::fs_object::copy acs_sc::invoke acs_sc::invoke (public) fs::impl::fs_object::copy->acs_sc::invoke

Testcases:
No testcase defined.

fs::impl::fs_object::delete (private)

 fs::impl::fs_object::delete

DELETE method

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.dav.delete.file_storage_object AcsSc.dav.delete.file_storage_object (private) fs::impl::fs_object::delete fs::impl::fs_object::delete AcsSc.dav.delete.file_storage_object->fs::impl::fs_object::delete acs_sc::invoke acs_sc::invoke (public) fs::impl::fs_object::delete->acs_sc::invoke

Testcases:
No testcase defined.

fs::impl::fs_object::get (private)

 fs::impl::fs_object::get

GET method

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.dav.get.file_storage_object AcsSc.dav.get.file_storage_object (private) fs::impl::fs_object::get fs::impl::fs_object::get AcsSc.dav.get.file_storage_object->fs::impl::fs_object::get acs_sc::invoke acs_sc::invoke (public) fs::impl::fs_object::get->acs_sc::invoke

Testcases:
No testcase defined.

fs::impl::fs_object::head (private)

 fs::impl::fs_object::head

HEAD method

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.dav.head.file_storage_object AcsSc.dav.head.file_storage_object (private) fs::impl::fs_object::head fs::impl::fs_object::head AcsSc.dav.head.file_storage_object->fs::impl::fs_object::head acs_sc::invoke acs_sc::invoke (public) fs::impl::fs_object::head->acs_sc::invoke

Testcases:
No testcase defined.

fs::impl::fs_object::lock (private)

 fs::impl::fs_object::lock

LOCK method

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.dav.lock.file_storage_object AcsSc.dav.lock.file_storage_object (private) fs::impl::fs_object::lock fs::impl::fs_object::lock AcsSc.dav.lock.file_storage_object->fs::impl::fs_object::lock acs_sc::invoke acs_sc::invoke (public) fs::impl::fs_object::lock->acs_sc::invoke

Testcases:
No testcase defined.

fs::impl::fs_object::mkcol (private)

 fs::impl::fs_object::mkcol

MKCOL method

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.dav.mkcol.file_storage_object AcsSc.dav.mkcol.file_storage_object (private) fs::impl::fs_object::mkcol fs::impl::fs_object::mkcol AcsSc.dav.mkcol.file_storage_object->fs::impl::fs_object::mkcol fs::new_folder fs::new_folder (public) fs::impl::fs_object::mkcol->fs::new_folder oacs_dav::conn oacs_dav::conn (public) fs::impl::fs_object::mkcol->oacs_dav::conn oacs_dav::item_parent_folder_id oacs_dav::item_parent_folder_id (public) fs::impl::fs_object::mkcol->oacs_dav::item_parent_folder_id

Testcases:
No testcase defined.

fs::impl::fs_object::move (private)

 fs::impl::fs_object::move

MOVE method

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.dav.move.file_storage_object AcsSc.dav.move.file_storage_object (private) fs::impl::fs_object::move fs::impl::fs_object::move AcsSc.dav.move.file_storage_object->fs::impl::fs_object::move acs_sc::invoke acs_sc::invoke (public) fs::impl::fs_object::move->acs_sc::invoke

Testcases:
No testcase defined.

fs::impl::fs_object::propfind (private)

 fs::impl::fs_object::propfind

PROPFIND method

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.dav.propfind.file_storage_object AcsSc.dav.propfind.file_storage_object (private) fs::impl::fs_object::propfind fs::impl::fs_object::propfind AcsSc.dav.propfind.file_storage_object->fs::impl::fs_object::propfind acs_sc::invoke acs_sc::invoke (public) fs::impl::fs_object::propfind->acs_sc::invoke

Testcases:
No testcase defined.

fs::impl::fs_object::proppatch (private)

 fs::impl::fs_object::proppatch

PROPPATCH method

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.dav.proppatch.file_storage_object AcsSc.dav.proppatch.file_storage_object (private) fs::impl::fs_object::proppatch fs::impl::fs_object::proppatch AcsSc.dav.proppatch.file_storage_object->fs::impl::fs_object::proppatch acs_sc::invoke acs_sc::invoke (public) fs::impl::fs_object::proppatch->acs_sc::invoke

Testcases:
No testcase defined.

fs::impl::fs_object::put (private)

 fs::impl::fs_object::put

PUT method

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.dav.put.file_storage_object AcsSc.dav.put.file_storage_object (private) fs::impl::fs_object::put fs::impl::fs_object::put AcsSc.dav.put.file_storage_object->fs::impl::fs_object::put ad_conn ad_conn (public) fs::impl::fs_object::put->ad_conn ad_file ad_file (public) fs::impl::fs_object::put->ad_file fs::add_file fs::add_file (public) fs::impl::fs_object::put->fs::add_file fs::add_version fs::add_version (public) fs::impl::fs_object::put->fs::add_version oacs_dav::conn oacs_dav::conn (public) fs::impl::fs_object::put->oacs_dav::conn

Testcases:
No testcase defined.

fs::impl::fs_object::unlock (private)

 fs::impl::fs_object::unlock

UNLOCK method

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.dav.unlock.file_storage_object AcsSc.dav.unlock.file_storage_object (private) fs::impl::fs_object::unlock fs::impl::fs_object::unlock AcsSc.dav.unlock.file_storage_object->fs::impl::fs_object::unlock acs_sc::invoke acs_sc::invoke (public) fs::impl::fs_object::unlock->acs_sc::invoke

Testcases:
No testcase defined.
[ hide source ] | [ make this the default ]

Content File Source

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.12.2.6 2023/02/20 09:55:55 antoniop Exp $

}

namespace eval fs::dav {}

ad_proc -private fs::dav::require {} {
    oacs-dav used to be a requirement for file-storage. We now made
    this optional, with the caveat that some operations need to happen
    only depending if the package is there or not.
} {
    if { ![apm_package_installed_p oacs-dav] } {
        #
        # Delete the Service Contract implementation if they existed.
        #
        fs::install::unregister_implementation

        if { [db_table_exists dav_site_node_folder_map] } {
            #
            # oacs-dav registers folders for access after mount. We remove
            # this registration.
            #
            db_dml unregister_folders {
                delete from dav_site_node_folder_map
                where folder_id in (select folder_id from fs_root_folders)
            }
        }

        #
        # We do not need to define the DAV callbacks, exit now.
        #
        return

    } elseif { ![db_0or1row implementation_exists {
        select 1 from acs_sc_impls
         where impl_owner_name = 'file-storage'
           and impl_contract_name = 'dav'
         fetch first 1 rows only
    }] } {
        #
        # Check at load time whether the Service Contract implementations
        # exist and register them on the fly in case.
        #
        fs::install::register_implementation

        #
        # Map the root folder of all mounted file-storage instances. Do
        # not do anything if the DAV folders table has already tuples.
        #
        db_dml register_folders {
            insert into dav_site_node_folder_map
            select n.node_id, f.folder_id, true as enabled_p
            from fs_root_folders f,
                 site_nodes n
            where n.object_id = f.package_id
              and not exists (select 1 from dav_site_node_folder_map)
        }
    }
}

if { ![apm_package_installed_p oacs-dav] } {
    ns_log notice "oacs-dav not installed, fs::impl::fs_object callbacks won't be loaded"
    return
}

namespace eval fs::impl::fs_object {}

ad_proc -private fs::impl::fs_object::get {} {
    GET method
} {
    acs_sc::invoke \
        -contract dav \
        -operation get \
        -impl content_revision
}

ad_proc -private fs::impl::fs_object::head {} {
    HEAD method
} {
    acs_sc::invoke \
        -contract dav \
        -operation head \
        -impl content_revision
}

ad_proc -private 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 uri]

    if {"unlocked" ne [tdav::check_lock $uri] } {
    return [list 423]
    }

    set tmp_filename [oacs_dav::conn tmpfile]
    set tmp_size [ad_file size $tmp_filename]

    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)
    ns_log debug "\n ----- \n file_storage::dav::put package_id $package_id \n parent_id $parent_id \n uri $uri \n ----- \n "
    if {$parent_id eq ""} {
    set response [list 409]
    return $response
    }

    if {$item_id eq ""} {
        fs::add_file \
            -package_id $package_id \
            -name $name \
            -title $name \
            -item_id $item_id \
            -parent_id $parent_id \
            -tmp_filename $tmp_filename \
            -creation_user $user_id \
            -creation_ip [ad_conn peeraddr] \

    if {[file exists [tdav::get_lock_file $uri]]} {
        # if there is a null lock use 204
        set response [list 204]
    } else {
        set response [list 201]
    }
    } else {
    fs::add_version \
        -name $name\
            -title $name \
        -tmp_filename $tmp_filename\
        -item_id $item_id \
        -creation_user $user_id \
        -package_id $package_id

    set response [list 204]
    }
    file delete -- $tmp_filename
    return $response

}

ad_proc -private fs::impl::fs_object::propfind {} {
    PROPFIND method
} {
    acs_sc::invoke \
        -contract dav \
        -operation propfind \
        -impl content_revision
}

ad_proc -private fs::impl::fs_object::delete {} {
    DELETE method
} {
    acs_sc::invoke \
        -contract dav \
        -operation delete \
        -impl content_revision
}

ad_proc -private fs::impl::fs_object::mkcol {} {
    MKCOL method
} {
    set uri [oacs_dav::conn uri]
    set user_id [oacs_dav::conn user_id]
    set peer_addr [oacs_dav::conn peeraddr]
    set item_id [oacs_dav::conn item_id]
    set fname [oacs_dav::conn item_name]
    set parent_id [oacs_dav::item_parent_folder_id $uri]
    if {$parent_id eq ""} {
    return [list 409]
    }
    if { $item_id ne ""} {
    return [list 405]
    }

    if { [catch {
    fs::new_folder \
        -name $fname \
        -pretty_name $fname \
        -parent_id $parent_id \
        -creation_user $user_id \
        -creation_ip $peer_addr \
        } ]} {
    return [list 500]
    }

    return [list 201]
}

ad_proc -private fs::impl::fs_object::proppatch {} {
    PROPPATCH method
} {
    acs_sc::invoke \
        -contract dav \
        -operation proppatch \
        -impl content_revision
}

ad_proc -private fs::impl::fs_object::copy {} {
    COPY method
} {
    acs_sc::invoke \
        -contract dav \
        -operation copy \
        -impl content_revision
}

ad_proc -private fs::impl::fs_object::move {} {
    MOVE method
} {
    acs_sc::invoke \
        -contract dav \
        -operation move \
        -impl content_revision
}


ad_proc -private fs::impl::fs_object::lock {} {
    LOCK method
} {
    acs_sc::invoke \
        -contract dav \
        -operation lock \
        -impl content_revision
}

ad_proc -private fs::impl::fs_object::unlock {} {
    UNLOCK method
} {
    acs_sc::invoke \
        -contract dav \
        -operation unlock \
        -impl content_revision
}

namespace eval fs::impl::dav_put_type {}

ad_proc -private fs::impl::dav_put_type::get_type {} {

} {
    return "file_storage_object"
}

namespace eval fs::impl::dav_mkcol_type {}

ad_proc -private fs::impl::dav_mkcol_type::get_type {} {

} {
    return "file_storage_object"
}


# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: