src/server/plugins/postgresql/webdav.c

branch
webdav
changeset 317
09676b559091
parent 315
b608b7aa43a6
child 318
60870dbac94f
equal deleted inserted replaced
316:4090fc1b1c52 317:09676b559091
64 r.nodename,\n\ 64 r.nodename,\n\
65 r.iscollection,\n\ 65 r.iscollection,\n\
66 r.lastmodified,\n\ 66 r.lastmodified,\n\
67 r.creationdate,\n\ 67 r.creationdate,\n\
68 r.contentlength,\n\ 68 r.contentlength,\n\
69 p.prefix,\n\
69 p.xmlns,\n\ 70 p.xmlns,\n\
70 p.pname,\n\ 71 p.pname,\n\
72 p.lang,\n\
73 p.nsdeflist,\n\
71 p.pvalue\n\ 74 p.pvalue\n\
72 from Resource r\n\ 75 from Resource r\n\
73 left join Property p on r.resource_id = p.resource_id\n\ 76 left join Property p on r.resource_id = p.resource_id\n\
74 where r.resource_id = $1;"; 77 where r.resource_id = $1;";
75 78
83 r.nodename,\n\ 86 r.nodename,\n\
84 r.iscollection,\n\ 87 r.iscollection,\n\
85 r.lastmodified,\n\ 88 r.lastmodified,\n\
86 r.creationdate,\n\ 89 r.creationdate,\n\
87 r.contentlength,\n\ 90 r.contentlength,\n\
91 p.prefix,\n\
88 p.xmlns,\n\ 92 p.xmlns,\n\
89 p.pname,\n\ 93 p.pname,\n\
94 p.lang,\n\
95 p.nsdeflist,\n\
90 p.pvalue\n\ 96 p.pvalue\n\
91 from Resource r\n\ 97 from Resource r\n\
92 left join (\n\ 98 left join (\n\
93 select p.* from Property p\ 99 select p.* from Property p\
94 inner join (select unnest($3::text[]) as xmlns, unnest($4::text[]) as pname) n\n\ 100 inner join (select unnest($3::text[]) as xmlns, unnest($4::text[]) as pname) n\n\
108 r.nodename,\n\ 114 r.nodename,\n\
109 r.iscollection,\n\ 115 r.iscollection,\n\
110 r.lastmodified,\n\ 116 r.lastmodified,\n\
111 r.creationdate,\n\ 117 r.creationdate,\n\
112 r.contentlength,\n\ 118 r.contentlength,\n\
119 p.prefix,\n\
113 p.xmlns,\n\ 120 p.xmlns,\n\
114 p.pname,\n\ 121 p.pname,\n\
122 p.lang,\n\
123 p.nsdeflist,\n\
115 p.pvalue\n\ 124 p.pvalue\n\
116 from Resource r\n\ 125 from Resource r\n\
117 left join Property p on r.resource_id = p.resource_id\n\ 126 left join Property p on r.resource_id = p.resource_id\n\
118 where r.resource_id = $1 or r.parent_id = $1\n\ 127 where r.resource_id = $1 or r.parent_id = $1\n\
119 order by case when r.resource_id = $1 then 0 else 1 end, nodename, resource_id;"; 128 order by case when r.resource_id = $1 then 0 else 1 end, nodename, resource_id;";
131 r.nodename,\n\ 140 r.nodename,\n\
132 r.iscollection,\n\ 141 r.iscollection,\n\
133 r.lastmodified,\n\ 142 r.lastmodified,\n\
134 r.creationdate,\n\ 143 r.creationdate,\n\
135 r.contentlength,\n\ 144 r.contentlength,\n\
145 p.prefix,\n\
136 p.xmlns,\n\ 146 p.xmlns,\n\
137 p.pname,\n\ 147 p.pname,\n\
148 p.lang,\n\
149 p.nsdeflist,\n\
138 p.pvalue\n\ 150 p.pvalue\n\
139 from Resource r\n\ 151 from Resource r\n\
140 left join (\n\ 152 left join (\n\
141 select p.* from Property p\ 153 select p.* from Property p\
142 inner join (select unnest($3::text[]) as xmlns, unnest($4::text[]) as pname) n\n\ 154 inner join (select unnest($3::text[]) as xmlns, unnest($4::text[]) as pname) n\n\
170 r.nodename,\n\ 182 r.nodename,\n\
171 r.iscollection,\n\ 183 r.iscollection,\n\
172 r.lastmodified,\n\ 184 r.lastmodified,\n\
173 r.creationdate,\n\ 185 r.creationdate,\n\
174 r.contentlength,\n\ 186 r.contentlength,\n\
187 p.prefix,\n\
175 p.xmlns,\n\ 188 p.xmlns,\n\
176 p.pname,\n\ 189 p.pname,\n\
190 p.lang,\n\
191 p.nsdeflist,\n\
177 p.pvalue\n\ 192 p.pvalue\n\
178 from resolvepath r\n\ 193 from resolvepath r\n\
179 left join Property p on r.resource_id = p.resource_id\n\ 194 left join Property p on r.resource_id = p.resource_id\n\
180 order by replace(ppath, '/', chr(1)), resource_id;"; 195 order by replace(ppath, '/', chr(1)), resource_id;";
181 196
206 r.nodename,\n\ 221 r.nodename,\n\
207 r.iscollection,\n\ 222 r.iscollection,\n\
208 r.lastmodified,\n\ 223 r.lastmodified,\n\
209 r.creationdate,\n\ 224 r.creationdate,\n\
210 r.contentlength,\n\ 225 r.contentlength,\n\
226 p.prefix,\n\
211 p.xmlns,\n\ 227 p.xmlns,\n\
212 p.pname,\n\ 228 p.pname,\n\
229 p.lang,\n\
230 p.nsdeflist,\n\
213 p.pvalue\n\ 231 p.pvalue\n\
214 from resolvepath r\n\ 232 from resolvepath r\n\
215 left join (\n\ 233 left join (\n\
216 select p.* from Property p\ 234 select p.* from Property p\
217 inner join (select unnest($3::text[]) as xmlns, unnest($4::text[]) as pname) n\n\ 235 inner join (select unnest($3::text[]) as xmlns, unnest($4::text[]) as pname) n\n\
444 // 3: nodename 462 // 3: nodename
445 // 4: iscollection 463 // 4: iscollection
446 // 5: lastmodified 464 // 5: lastmodified
447 // 6: creationdate 465 // 6: creationdate
448 // 7: contentlength 466 // 7: contentlength
449 // 8: property xmlns 467 // 8: property prefix
450 // 9: property name 468 // 9: property xmlns
451 // 10: property value 469 // 10: property name
470 // 11: property lang
471 // 12: property nsdeflist
472 // 13: property value
452 473
453 char *path = PQgetvalue(result, r, 0); 474 char *path = PQgetvalue(result, r, 0);
454 char *res_id = PQgetvalue(result, r, 1); 475 char *res_id = PQgetvalue(result, r, 1);
455 char *iscollection_str = PQgetvalue(result, r, 4); 476 char *iscollection_str = PQgetvalue(result, r, 4);
456 WSBool iscollection = iscollection_str && iscollection_str[0] == 't'; 477 WSBool iscollection = iscollection_str && iscollection_str[0] == 't';
515 vfsprops_set = TRUE; 536 vfsprops_set = TRUE;
516 } 537 }
517 538
518 // dead properties 539 // dead properties
519 if(!PQgetisnull(result, r, 9)) { 540 if(!PQgetisnull(result, r, 9)) {
520 char *xmlns = PQgetvalue(result, r, 8); 541 char *prefix = PQgetvalue(result, r, 8);
521 char *pname = PQgetvalue(result, r, 9); 542 char *xmlns = PQgetvalue(result, r, 9);
522 char *pvalue = PQgetvalue(result, r, 10); 543 char *pname = PQgetvalue(result, r, 10);
544 char *lang = PQgetvalue(result, r, 11);
545 char *nsdef = PQgetvalue(result, r, 12);
546 char *pvalue = PQgetvalue(result, r, 13);
547
548 int pvalue_len = PQgetlength(result, r, 13);
549 WSBool lang_isnull = PQgetisnull(result, r, 11);
550 WSBool nsdef_isnull = PQgetisnull(result, r, 12);
551 WSBool pvalue_isnull = PQgetisnull(result, r, 13);
523 552
524 WebdavProperty *property = pool_malloc(pool, sizeof(WebdavProperty)); 553 WebdavProperty *property = pool_malloc(pool, sizeof(WebdavProperty));
525 property->lang = NULL; 554 property->lang = NULL;
526 property->name = pool_strdup(pool, pname); 555 property->name = pool_strdup(pool, pname);
527 556
528 xmlNs *namespace = pool_malloc(pool, sizeof(xmlNs)); 557 xmlNs *namespace = pool_malloc(pool, sizeof(xmlNs));
529 memset(namespace, 0, sizeof(struct _xmlNs)); 558 memset(namespace, 0, sizeof(struct _xmlNs));
530 namespace->href = (xmlChar*)pool_strdup(pool, xmlns); 559 namespace->href = (xmlChar*)pool_strdup(pool, xmlns);
531 namespace->prefix = (xmlChar*)"zx1"; // TODO 560 namespace->prefix = (xmlChar*)pool_strdup(pool, prefix);
532 property->namespace = namespace; 561 property->namespace = namespace;
533 562
534 property->vtype = WS_VALUE_TEXT; 563 if(!lang_isnull) {
535 property->value.text.str = pool_strdup(pool, pvalue); 564 property->lang = (xmlChar*)pool_strdup(pool, lang);
536 property->value.text.length = strlen(pvalue); 565 }
566
567 if(!pvalue_isnull) {
568 char *content = pool_malloc(pool, pvalue_len+1);
569 memcpy(content, pvalue, pvalue_len);
570 content[pvalue_len] = '\0';
571
572 if(nsdef_isnull) {
573 property->vtype = WS_VALUE_TEXT;
574 property->value.text.str = content;
575 property->value.text.length = pvalue_len;
576 } else {
577 // TODO
578 }
579 }
537 580
538 resource->addproperty(resource, property, 200); 581 resource->addproperty(resource, property, 200);
539 } 582 }
540 } 583 }
541 584

mercurial