src/server/plugins/postgresql/webdav.c

Tue, 26 Apr 2022 14:33:58 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 26 Apr 2022 14:33:58 +0200
branch
webdav
changeset 315
b608b7aa43a6
parent 314
6b1a6066ee43
child 317
09676b559091
permissions
-rw-r--r--

fix sql query for selecting specific properties

299
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2022 Olaf Wintermann. All rights reserved.
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include "webdav.h"
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
30 #include "vfs.h"
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
31
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
32 #include "../../util/util.h"
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
33
315
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
34 #include <ucx/buffer.h>
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
35 #include <libxml/tree.h>
299
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 static WebdavBackend pg_webdav_backend = {
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 pg_dav_propfind_init,
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 pg_dav_propfind_do,
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 pg_dav_propfind_finish,
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 pg_dav_proppatch_do,
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 pg_dav_proppatch_finish,
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 NULL, // opt_mkcol
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 NULL, // opt_mkcol_finish
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 NULL, // opt_delete
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 NULL, // opt_delete_finish
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 0,
303
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
48 NULL,
299
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 NULL
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 };
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
52
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
53 /*
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
54 * SQL Queries
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
55 */
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
56
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
57 // propfind with depth = 0
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
58 // params: $1: resource_id
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
59 static const char *sql_propfind_allprop_depth0 = "\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
60 select\n\
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
61 $2::text as ppath,\n\
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
62 r.resource_id,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
63 r.parent_id,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
64 r.nodename,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
65 r.iscollection,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
66 r.lastmodified,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
67 r.creationdate,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
68 r.contentlength,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
69 p.xmlns,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
70 p.pname,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
71 p.pvalue\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
72 from Resource r\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
73 left join Property p on r.resource_id = p.resource_id\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
74 where r.resource_id = $1;";
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
75
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
76 // propfind with depth = 0 for specific properties
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
77 // params: $1: resource_id
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
78 static const char *sql_propfind_depth0 = "\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
79 select\n\
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
80 $2::text as ppath,\n\
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
81 r.resource_id,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
82 r.parent_id,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
83 r.nodename,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
84 r.iscollection,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
85 r.lastmodified,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
86 r.creationdate,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
87 r.contentlength,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
88 p.xmlns,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
89 p.pname,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
90 p.pvalue\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
91 from Resource r\n\
315
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
92 left join (\n\
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
93 select p.* from Property p\
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
94 inner join (select unnest($3::text[]) as xmlns, unnest($4::text[]) as pname) n\n\
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
95 on p.xmlns = n.xmlns and p.pname = n.pname\n\
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
96 ) p on r.resource_id = p.resource_id\n\
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
97 where r.resource_id = $1;";
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
98
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
99 // propfind with depth = 1
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
100 // params: $1: resource_id
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
101 static const char *sql_propfind_allprop_depth1 = "\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
102 select\n\
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
103 case when r.resource_id = $1 then $2\n\
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
104 else $2 || '/' || r.nodename\n\
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
105 end as ppath,\n\
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
106 r.resource_id,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
107 r.parent_id,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
108 r.nodename,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
109 r.iscollection,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
110 r.lastmodified,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
111 r.creationdate,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
112 r.contentlength,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
113 p.xmlns,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
114 p.pname,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
115 p.pvalue\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
116 from Resource r\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
117 left join Property p on r.resource_id = p.resource_id\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
118 where r.resource_id = $1 or r.parent_id = $1\n\
315
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
119 order by case when r.resource_id = $1 then 0 else 1 end, nodename, resource_id;";
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
120
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
121
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
122 // propfind with depth = 1 for specific properties
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
123 // params: $1: resource_id
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
124 static const char *sql_propfind_depth1 = "\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
125 select\n\
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
126 case when r.resource_id = $1 then $2\n\
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
127 else $2 || '/' || r.nodename\n\
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
128 end as ppath,\n\
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
129 r.resource_id,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
130 r.parent_id,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
131 r.nodename,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
132 r.iscollection,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
133 r.lastmodified,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
134 r.creationdate,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
135 r.contentlength,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
136 p.xmlns,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
137 p.pname,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
138 p.pvalue\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
139 from Resource r\n\
315
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
140 left join (\n\
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
141 select p.* from Property p\
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
142 inner join (select unnest($3::text[]) as xmlns, unnest($4::text[]) as pname) n\n\
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
143 on p.xmlns = n.xmlns and p.pname = n.pname\n\
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
144 ) p on r.resource_id = p.resource_id\n\
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
145 where r.resource_id = $1 or r.parent_id = $1\n\
315
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
146 order by case when r.resource_id = $1 then 0 else 1 end, nodename, resource_id;";
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
147
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
148 // recursive propfind
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
149 // params: $1: resource_id
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
150 static const char *sql_propfind_allprop_recursive = "\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
151 with recursive resolvepath as (\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
152 select\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
153 '' as ppath,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
154 *\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
155 from Resource\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
156 where resource_id = $1 \n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
157 union\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
158 select\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
159 p.ppath || '/' || r.nodename,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
160 r.*\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
161 from Resource r\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
162 inner join resolvepath p on r.parent_id = p.resource_id\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
163 )\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
164 select\n\
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
165 case when r.resource_id = $1 then $2\n\
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
166 else $2 || r.ppath\n\
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
167 end as ppath,\n\
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
168 r.resource_id,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
169 r.parent_id,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
170 r.nodename,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
171 r.iscollection,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
172 r.lastmodified,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
173 r.creationdate,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
174 r.contentlength,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
175 p.xmlns,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
176 p.pname,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
177 p.pvalue\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
178 from resolvepath r\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
179 left join Property p on r.resource_id = p.resource_id\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
180 order by replace(ppath, '/', chr(1)), resource_id;";
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
181
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
182 // recursive propfind for specific properties
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
183 // params: $1: resource_id
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
184 // $2: array of property xmlns
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
185 // $3: array of property names
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
186 static const char *sql_propfind_recursive = "\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
187 with recursive resolvepath as (\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
188 select\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
189 '' as ppath,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
190 *\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
191 from Resource\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
192 where resource_id = $1 \n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
193 union\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
194 select\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
195 p.ppath || '/' || r.nodename,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
196 r.*\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
197 from Resource r\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
198 inner join resolvepath p on r.parent_id = p.resource_id\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
199 )\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
200 select\n\
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
201 case when r.resource_id = $1 then $2\n\
315
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
202 else $2 || r.ppath\n\
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
203 end as ppath,\n\
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
204 r.resource_id,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
205 r.parent_id,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
206 r.nodename,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
207 r.iscollection,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
208 r.lastmodified,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
209 r.creationdate,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
210 r.contentlength,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
211 p.xmlns,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
212 p.pname,\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
213 p.pvalue\n\
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
214 from resolvepath r\n\
315
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
215 left join (\n\
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
216 select p.* from Property p\
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
217 inner join (select unnest($3::text[]) as xmlns, unnest($4::text[]) as pname) n\n\
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
218 on p.xmlns = n.xmlns and p.pname = n.pname\n\
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
219 ) p on r.resource_id = p.resource_id\n\
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
220 order by replace(ppath, '/', chr(1)), resource_id;";
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
221
303
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
222 WebdavBackend* pg_webdav_create(Session *sn, Request *rq, pblock *pb) {
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
223 // resourcepool is required
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
224 char *resource_pool = pblock_findval("resourcepool", pb);
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
225 if(!resource_pool) {
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
226 log_ereport(LOG_MISCONFIG, "pg_webdav_create: missing resourcepool parameter");
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
227 return NULL;
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
228 }
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
229
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
230 // get the resource first (should only fail in case of misconfig)
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
231 ResourceData *resdata = resourcepool_lookup(sn, rq, resource_pool, 0);
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
232 if(!resdata) {
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
233 log_ereport(LOG_MISCONFIG, "postgresql webdav: resource pool %s not found", resource_pool);
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
234 return NULL;
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
235 }
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
236
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
237 return pg_webdav_create_from_resdata(sn, rq, resdata);
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
238 }
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
239
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
240 WebdavBackend* pg_webdav_create_from_resdata(Session *sn, Request *rq, ResourceData *resdata) {
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
241 WebdavBackend *webdav = pool_malloc(sn->pool, sizeof(WebdavBackend));
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
242 if(!webdav) {
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
243 return NULL;
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
244 }
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
245 *webdav = pg_webdav_backend;
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
246
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
247 PgWebdavBackend *instance = pool_malloc(sn->pool, sizeof(PgWebdavBackend));
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
248 if(!instance) {
303
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
249 pool_free(sn->pool, webdav);
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
250 return NULL;
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
251 }
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
252 webdav->instance = instance;
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
253
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
254 instance->pg_resource = resdata;
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
255 instance->connection = resdata->data;
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
256
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
257 return webdav;
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
258 }
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
259
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
260 WebdavBackend* pg_webdav_prop_create(Session *sn, Request *rq, pblock *pb) {
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
261 return NULL;
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
262 }
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
263
315
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
264 /*
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
265 * adds str to the buffer
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
266 * some characters will be escaped: \,{}
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
267 */
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
268 static void buf_addstr_escaped(UcxBuffer *buf, const char *str) {
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
269 size_t len = strlen(str);
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
270 for(size_t i=0;i<len;i++) {
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
271 char c = str[i];
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
272 if(c == '{' || c == '}' || c == ',' || c == '\\') {
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
273 ucx_buffer_putc(buf, '\\');
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
274 }
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
275 ucx_buffer_putc(buf, c);
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
276 }
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
277 }
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
278
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
279 /*
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
280 * convert a property list to two pg array parameter strings
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
281 * array format: {elm1,elm2,elm3}
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
282 * xmlns: buffer for the xmlns array
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
283 * pname: buffer for the property name array
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
284 *
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
285 * returns 0 on success, 1 otherwise
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
286 */
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
287 int pg_create_property_param_arrays(WebdavPList *plist, UcxBuffer *xmlns, UcxBuffer *pname) {
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
288 ucx_buffer_putc(xmlns, '{');
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
289 ucx_buffer_putc(pname, '{');
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
290 while(plist) {
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
291 WebdavProperty *property = plist->property;
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
292 if(property && property->namespace && property->namespace->href && property->name) {
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
293 buf_addstr_escaped(xmlns, (const char*)property->namespace->href);
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
294 buf_addstr_escaped(pname, (const char*)property->name);
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
295 if(plist->next) {
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
296 ucx_buffer_putc(xmlns, ',');
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
297 ucx_buffer_putc(pname, ',');
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
298 }
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
299 }
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
300 plist = plist->next;
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
301 }
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
302 int r1 = ucx_buffer_write("}\0", 2, 1, xmlns) == 0;
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
303 int r2 = ucx_buffer_write("}\0", 2, 1, pname) == 0;
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
304 return r1+r2 != 0;
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
305 }
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
306
303
ad9ba51c8634 add pg webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
307
299
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
308 int pg_dav_propfind_init(
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
309 WebdavPropfindRequest *rq,
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
310 const char *path,
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
311 const char *href,
299
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
312 WebdavPList **outplist)
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
313 {
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
314 PgWebdavBackend *pgdav = rq->dav->instance;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
315
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
316 // check if the resource exists
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
317 int64_t parent_id;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
318 int64_t resource_id;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
319 const char *resourcename;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
320 WSBool iscollection;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
321 int res_errno = 0;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
322 int err = pg_resolve_path(
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
323 pgdav->connection,
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
324 path,
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
325 &parent_id,
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
326 &resource_id,
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
327 NULL, // OID
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
328 &resourcename,
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
329 &iscollection,
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
330 NULL, // stat
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
331 &res_errno);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
332
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
333 if(err) {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
334 if(res_errno == ENOENT) {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
335 protocol_status(rq->sn, rq->rq, PROTOCOL_NOT_FOUND, NULL);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
336 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
337 return 1;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
338 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
339
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
340 // choose sql query
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
341 const char *query = NULL;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
342 if(!iscollection || rq->depth == 0) {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
343 query = rq->allprop ? sql_propfind_allprop_depth0 : sql_propfind_depth0;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
344 } else if(rq->depth == 1) {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
345 query = rq->allprop ? sql_propfind_allprop_depth1 : sql_propfind_depth1;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
346 } else if(rq->depth == -1) {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
347 query = rq->allprop ? sql_propfind_allprop_recursive : sql_propfind_recursive;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
348 } else {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
349 log_ereport(LOG_FAILURE, "%s", "pg_dav_propfind_init: invalid depth");
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
350 return 1;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
351 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
352
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
353 // get all resources and properties
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
354 char resource_id_str[32];
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
355 snprintf(resource_id_str, 32, "%" PRId64, resource_id);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
356
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
357 size_t href_len = strlen(href);
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
358 char *href_param = pool_malloc(rq->sn->pool, href_len + 1);
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
359 memcpy(href_param, href, href_len);
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
360 if(href_param[href_len-1] == '/') {
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
361 href_len--;
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
362 }
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
363 href_param[href_len] = '\0';
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
364
315
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
365 // if allprop is false, create array pair for xmlns/property names
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
366 UcxBuffer *xmlns_buf = NULL;
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
367 UcxBuffer *pname_buf = NULL;
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
368 char *xmlns_param = NULL;
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
369 char *pname_param = NULL;
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
370 int nparam = 2;
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
371 if(!rq->allprop) {
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
372 size_t bufsize = rq->propcount < 200 ? 8 + rq->propcount * 32 : 4096;
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
373 xmlns_buf = ucx_buffer_new(NULL, bufsize, UCX_BUFFER_AUTOEXTEND);
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
374 if(!xmlns_buf) {
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
375 return 1;
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
376 }
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
377 pname_buf = ucx_buffer_new(NULL, bufsize, UCX_BUFFER_AUTOEXTEND);
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
378 if(!pname_buf) {
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
379 ucx_buffer_free(xmlns_buf);
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
380 return 1;
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
381 }
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
382 if(pg_create_property_param_arrays(rq->properties, xmlns_buf, pname_buf)) {
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
383 ucx_buffer_free(xmlns_buf);
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
384 ucx_buffer_free(pname_buf);
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
385 return 1;
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
386 }
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
387 xmlns_param = xmlns_buf->space;
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
388 pname_param = pname_buf->space;
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
389 nparam = 4;
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
390 }
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
391
315
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
392 const char* params[4] = { resource_id_str, href_param, xmlns_param, pname_param };
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
393 PGresult *result = PQexecParams(
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
394 pgdav->connection,
315
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
395 query,
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
396 nparam, // number of parameters
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
397 NULL,
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
398 params, // parameter value
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
399 NULL,
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
400 NULL,
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
401 0); // 0: result in text format
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
402 int nrows = PQntuples(result);
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
403 pool_free(rq->sn->pool, href_param);
315
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
404 if(xmlns_buf) {
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
405 ucx_buffer_free(xmlns_buf);
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
406 ucx_buffer_free(pname_buf);
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 314
diff changeset
407 }
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
408 if(nrows < 1) {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
409 PQclear(result);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
410 return 1;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
411 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
412
300
0e3f275b2492 add instance field to webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 299
diff changeset
413 PgPropfind *pg = pool_malloc(rq->sn->pool, sizeof(PgPropfind));
0e3f275b2492 add instance field to webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 299
diff changeset
414 rq->userdata = pg;
0e3f275b2492 add instance field to webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 299
diff changeset
415
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
416 pg->path = path;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
417 pg->resource_id = resource_id;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
418 pg->vfsproperties = webdav_vfs_properties(outplist, TRUE, 0);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
419 pg->result = result;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
420 pg->nrows = nrows;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
421
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
422 return 0;
299
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
423 }
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
424
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
425 int pg_dav_propfind_do(
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
426 WebdavPropfindRequest *rq,
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
427 WebdavResponse *response,
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
428 VFS_DIR parent,
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
429 WebdavResource *resource,
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
430 struct stat *s)
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
431 {
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
432 PgPropfind *pg = rq->userdata;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
433 pool_handle_t *pool = rq->sn->pool;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
434 PGresult *result = pg->result;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
435 WebdavVFSProperties vfsprops = pg->vfsproperties;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
436
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 312
diff changeset
437 WSBool vfsprops_set = 0; // are live properties added to the response?
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
438 int64_t current_resource_id = pg->resource_id;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
439 for(int r=0;r<pg->nrows;r++) {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
440 // columns:
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
441 // 0: path
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
442 // 1: resource_id
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
443 // 2: parent_id
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
444 // 3: nodename
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
445 // 4: iscollection
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
446 // 5: lastmodified
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
447 // 6: creationdate
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
448 // 7: contentlength
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
449 // 8: property xmlns
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
450 // 9: property name
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
451 // 10: property value
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
452
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
453 char *path = PQgetvalue(result, r, 0);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
454 char *res_id = PQgetvalue(result, r, 1);
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
455 char *iscollection_str = PQgetvalue(result, r, 4);
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
456 WSBool iscollection = iscollection_str && iscollection_str[0] == 't';
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
457 int64_t resource_id;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
458 if(!util_strtoint(res_id, &resource_id)) {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
459 log_ereport(LOG_FAILURE, "pg_dav_propfind_do: cannot convert resource_id '%s' to int", res_id);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
460 return 1;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
461 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
462
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
463 if(resource_id != current_resource_id) {
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
464 // create a href string for the new resource
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
465 // if the resource is a collection, it should have a trailing '/'
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
466 size_t pathlen = strlen(path);
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
467 if(pathlen == 0) {
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
468 log_ereport(LOG_FAILURE, "pg_dav_propfind_do: query returned invalid path");
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
469 return 1;
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
470 }
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
471 char *newres_href = pool_malloc(pool, pathlen+2);
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
472 memcpy(newres_href, path, pathlen);
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
473 if(iscollection && path[pathlen-1] != '/') {
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
474 newres_href[pathlen++] = '/';
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
475 }
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
476 newres_href[pathlen] = '\0';
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
477
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
478 // new resource
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
479 resource = response->addresource(response, newres_href);
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
480 vfsprops_set = FALSE;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
481 current_resource_id = resource_id;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
482 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
483
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 312
diff changeset
484 // standard webdav live properties
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
485 if(!vfsprops_set) {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
486 if(vfsprops.getresourcetype) {
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
487 if(iscollection) {
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
488 resource->addproperty(resource, webdav_resourcetype_collection(), 200);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
489 } else {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
490 resource->addproperty(resource, webdav_resourcetype_empty(), 200);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
491 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
492 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
493 if(vfsprops.getlastmodified) {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
494 char *lastmodified = PQgetvalue(result, r, 5);
311
e676ed461b5b implement pg getlastmodified propfind (and prepare creationdate)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 309
diff changeset
495 time_t t = pg_convert_timestamp(lastmodified);
e676ed461b5b implement pg getlastmodified propfind (and prepare creationdate)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 309
diff changeset
496 struct tm tm;
e676ed461b5b implement pg getlastmodified propfind (and prepare creationdate)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 309
diff changeset
497 gmtime_r(&t, &tm);
e676ed461b5b implement pg getlastmodified propfind (and prepare creationdate)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 309
diff changeset
498
e676ed461b5b implement pg getlastmodified propfind (and prepare creationdate)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 309
diff changeset
499 char buf[HTTP_DATE_LEN+1];
e676ed461b5b implement pg getlastmodified propfind (and prepare creationdate)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 309
diff changeset
500 strftime(buf, HTTP_DATE_LEN, HTTP_DATE_FMT, &tm);
314
6b1a6066ee43 fix pg propfind for getlastmodified property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
501 webdav_resource_add_dav_stringproperty(resource, pool, "getlastmodified", buf, strlen(buf));
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
502 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
503 if(vfsprops.creationdate) {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
504 char *creationdate = PQgetvalue(result, r, 6);
311
e676ed461b5b implement pg getlastmodified propfind (and prepare creationdate)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 309
diff changeset
505 webdav_resource_add_dav_stringproperty(resource, pool, "creationdate", creationdate, strlen(creationdate));
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
506 }
314
6b1a6066ee43 fix pg propfind for getlastmodified property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
507 if(vfsprops.getcontentlength && !iscollection) {
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
508 char *contentlength = PQgetvalue(result, r, 7);
309
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
509 webdav_resource_add_dav_stringproperty(resource, pool, "getcontentlength", contentlength, strlen(contentlength));
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
510 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
511 if(vfsprops.getetag) {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
512
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
513 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
514
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
515 vfsprops_set = TRUE;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
516 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
517
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
518 // dead properties
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
519 if(!PQgetisnull(result, r, 9)) {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
520 char *xmlns = PQgetvalue(result, r, 8);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
521 char *pname = PQgetvalue(result, r, 9);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
522 char *pvalue = PQgetvalue(result, r, 10);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
523
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
524 WebdavProperty *property = pool_malloc(pool, sizeof(WebdavProperty));
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
525 property->lang = NULL;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
526 property->name = pool_strdup(pool, pname);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
527
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
528 xmlNs *namespace = pool_malloc(pool, sizeof(xmlNs));
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
529 memset(namespace, 0, sizeof(struct _xmlNs));
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
530 namespace->href = (xmlChar*)pool_strdup(pool, xmlns);
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
531 namespace->prefix = (xmlChar*)"zx1"; // TODO
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
532 property->namespace = namespace;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
533
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
534 property->vtype = WS_VALUE_TEXT;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
535 property->value.text.str = pool_strdup(pool, pvalue);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
536 property->value.text.length = strlen(pvalue);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
537
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
538 resource->addproperty(resource, property, 200);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
539 }
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 312
diff changeset
540 }
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
541
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
542 return 0;
299
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
543 }
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
544
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
545 int pg_dav_propfind_finish(WebdavPropfindRequest *rq) {
312
f7544e220a0f add pg propfind cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 311
diff changeset
546 PgPropfind *pg = rq->userdata;
f7544e220a0f add pg propfind cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 311
diff changeset
547 pool_handle_t *pool = rq->sn->pool;
f7544e220a0f add pg propfind cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 311
diff changeset
548 PGresult *result = pg->result;
f7544e220a0f add pg propfind cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 311
diff changeset
549
f7544e220a0f add pg propfind cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 311
diff changeset
550 PQclear(result);
f7544e220a0f add pg propfind cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 311
diff changeset
551
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
552 return 0;
299
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
553 }
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
554
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
555 int pg_dav_proppatch_do(
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
556 WebdavProppatchRequest *request,
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
557 WebdavResource *response,
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
558 VFSFile *file,
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
559 WebdavPList **out_set,
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
560 WebdavPList **out_remove)
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
561 {
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
562 return 1;
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
563 }
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
564
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
565 int pg_dav_proppatch_finish(
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
566 WebdavProppatchRequest *request,
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
567 WebdavResource *response,
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
568 VFSFile *file,
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
569 WSBool commit)
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
570 {
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
571 return 1;
f927ef81a12b add empty pg webdav funcs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
572 }

mercurial