-
Notifications
You must be signed in to change notification settings - Fork 211
/
gems.vsp
103 lines (96 loc) · 3.63 KB
/
gems.vsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?vsp
--
-- $Id$
--
-- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
-- project.
--
-- Copyright (C) 1998-2014 OpenLink Software
--
-- This project is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; only version 2 of the License, dated June 1991.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
set ISOLATION = 'Committed';
set http_charset = 'utf-8';
declare _domain_id, _user_id, _authorized integer;
declare _params, _gems, _user varchar;
_domain_id := AB.WA.session_domain (params);
if (_domain_id > 0)
{
_authorized := AB.WA.domain_is_public (_domain_id);
if (not _authorized)
{
_authorized := 1;
if (not ODS..ods_check_auth (_user, _domain_id, 'reader'))
_authorized := 0;
}
http_rewrite ();
if (not _authorized)
{
http_request_status ('HTTP/1.1 401 Unauthorized');
http_header ('WWW-Authenticate: Basic realm="wa"\r\n');
http('Unauthorized');
}
else
{
declare exit handler for sqlstate '*' { return;};
_gems := get_keyword('type', params);
if (_gems = 'AddressBook.ics')
{
http_request_status ('HTTP/1.1 200 OK');
http_header ('Content-Type: application/x-download\r\nContent-Disposition: inline; filename="AddressBook.ics"\r\n');
http (AB.WA.export_vcal (_domain_id));
}
else if (_gems in ('AddressBook.rss', 'AddressBook.atom', 'AddressBook.rdf', 'AddressBook.comment'))
{
declare _header, _links, _result, _path, _content, _type, _xslt any;
_user_id := AB.WA.domain_owner_id (_domain_id);
_path := AB.WA.dav_home (_user_id) || 'Gems/' || AB.WA.domain_name (_domain_id) || '/' || _gems;
_result := string_output ();
DB.DBA.DAV_RES_CONTENT_INT (DB.DBA.DAV_SEARCH_ID (_path, 'R'), _content, _type, 0, 0);
_params := null;
if (get_keyword (':id', params, '') <> '')
_params := vector (':id', get_keyword (':id', params));
xml_template (xml_tree_doc (xml_tree (_content)), _params, _result);
_result := xml_tree_doc (xml_tree (string_output_string (_result)));
if (_gems in ('AddressBook.atom', 'AddressBook.rdf'))
{
if (_gems = 'AddressBook.rdf')
{
_xslt := AB.WA.xslt_full ('rss2rdf.xsl');
}
else
{
_xslt := AB.WA.xslt_full ('rss2atom03.xsl');
if (AB.WA.settings_atomVersion (AB.WA.settings (_domain_id)) = '1.0')
{
_xslt := AB.WA.xslt_full ('rss2atom.xsl');
}
}
_result := xslt (_xslt, _result);
}
_header := case when (_gems like '%atom%') then 'Content-Type: application/atom+xml\r\n' else 'Content-Type: text/xml\r\n' end;
if (_gems in ('AddressBook.rss', 'AddressBook.atom'))
{
_links := ODS..PSH_HEADER_LINKS (_domain_id);
if (length (_links))
_header := _header || sprintf ('Link: %s\r\n', _links);
}
http_request_status ('HTTP/1.1 200 OK');
http_header (_header);
http_value (_result);
}
}
http_flush ();
}
?>