caldav::CalDAV instproc generateResponse (public)
<instance of caldav::CalDAV> generateResponse \ -queryType queryType [ -user_id user_id ] \ [ -calendar_id calendar_id ] [ -cal_item cal_item ] node
Defined in /var/www/openacs.org/packages/caldav/tcl/caldav-procs.tcl
Return a <response> ... </response> entry for the URL specified in the ${:url} and for the query attributes specified in the tdom node. The attributes user_id, calendar_id, or cal_item have to be set according to the queryType.
- Switches:
- -queryType (required)
- is an abstraction of the query url and can be "calendar", "resource", "top", or "principal"
- -user_id (optional)
- -calendar_id (optional)
- -cal_item (optional)
- Parameters:
- node (required)
- Testcases:
- PROPFIND_ios, PROPFIND_android, Thunderbird_subscribe, macOS_subscribe
Source code: # @prop: requested properties as tdom nodes # generate xml for this resource #ns_log notice "generateResponse $queryType" set :queryType $queryType switch $queryType { "resource" { set href "${:url}calendar/[ns_urlencode [$cal_item cget -uid]].ics" set resource $cal_item } "calendar" { set href "${:url}calendar/" set resource $calendar_id } "top" { set href ${:url} set resource $user_id } "principal" { set href "${:url}principal" set resource "none" } "default" { error "invalid input" } } ns_log notice "generateResponse href=$href, resource=$resource child nodes [llength [$node childNodes]]" set not_found_props "" set found_props "" foreach childNode [$node childNodes] { lassign [:returnXMLelement $resource $childNode] returncode val if {$returncode} { append not_found_props $val \n } else { append found_props $val \n } } :debug "found_props $found_props, not_found_props $not_found_props" append result <d:response> \n <d:href>$href</d:href> \n if {$found_props ne ""} { # # return 200 for properties that were found # append result <d:propstat> \n <d:prop>$found_props</d:prop> \n "<d:status>HTTP/1.1 200 OK</d:status>" \n </d:propstat> } if {$not_found_props ne ""} { # # return 404 for properties that were not found # append result \n <d:propstat> \n <d:prop>$not_found_props</d:prop> \n "<d:status>HTTP/1.1 404 Not Found</d:status>" \n </d:propstat> } append result \n </d:response> return $resultXQL Not present: Generic, PostgreSQL, Oracle