Mercurial > hg > orthanc
annotate OrthancFramework/Sources/HttpServer/IWebDavBucket.cpp @ 5640:f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 30 May 2024 21:19:57 +0200 |
parents | 48b8dae6dc77 |
children |
rev | line source |
---|---|
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * This program is free software: you can redistribute it and/or |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * modify it under the terms of the GNU Lesser General Public License |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * as published by the Free Software Foundation, either version 3 of |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * the License, or (at your option) any later version. |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * This program is distributed in the hope that it will be useful, but |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * Lesser General Public License for more details. |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * You should have received a copy of the GNU Lesser General Public |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * License along with this program. If not, see |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 * <http://www.gnu.org/licenses/>. |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 **/ |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include "../PrecompiledHeaders.h" |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 #include "IWebDavBucket.h" |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
4228
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
28 #include "HttpOutput.h" |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 #include "../OrthancException.h" |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 #include "../Toolbox.h" |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 static boost::posix_time::ptime GetNow() |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 return boost::posix_time::second_clock::universal_time(); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 static std::string AddTrailingSlash(const std::string& s) |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 if (s.empty() || |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 s[s.size() - 1] != '/') |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 return s + '/'; |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 else |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 return s; |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 namespace Orthanc |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 { |
4252 | 55 IWebDavBucket::Resource::Resource(const std::string& displayName) : |
56 displayName_(displayName), | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 hasModificationTime_(false), |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 creationTime_(GetNow()), |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 modificationTime_(GetNow()) |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 { |
4252 | 61 if (displayName.empty() || |
62 displayName.find('/') != std::string::npos || | |
63 displayName.find('\\') != std::string::npos || | |
64 displayName.find('\0') != std::string::npos) | |
65 { | |
66 throw OrthancException(ErrorCode_ParameterOutOfRange, | |
67 "Bad resource name for WebDAV: " + displayName); | |
68 } | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 void IWebDavBucket::Resource::SetCreationTime(const boost::posix_time::ptime& t) |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 { |
4246 | 74 if (t.is_special()) |
75 { | |
76 throw OrthancException(ErrorCode_ParameterOutOfRange, "Not a valid date-time"); | |
77 } | |
78 else | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 { |
4246 | 80 creationTime_ = t; |
81 | |
82 if (!hasModificationTime_) | |
83 { | |
84 modificationTime_ = t; | |
85 } | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 void IWebDavBucket::Resource::SetModificationTime(const boost::posix_time::ptime& t) |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 { |
4246 | 92 if (t.is_special()) |
93 { | |
94 throw OrthancException(ErrorCode_ParameterOutOfRange, "Not a valid date-time"); | |
95 } | |
96 else | |
97 { | |
98 modificationTime_ = t; | |
99 hasModificationTime_ = true; | |
100 } | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 |
4246 | 104 static void FormatInternal(pugi::xml_node& node, |
105 const std::string& href, | |
106 const std::string& displayName, | |
107 const boost::posix_time::ptime& creationTime, | |
108 const boost::posix_time::ptime& modificationTime) | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 node.set_name("D:response"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 |
4246 | 112 node.append_child("D:href").append_child(pugi::node_pcdata).set_value(href.c_str()); |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 pugi::xml_node propstat = node.append_child("D:propstat"); |
4228
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
115 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
116 static const HttpStatus status = HttpStatus_200_Ok; |
4246 | 117 std::string s = ("HTTP/1.1 " + boost::lexical_cast<std::string>(status) + " " + |
118 std::string(EnumerationToString(status))); | |
4228
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
119 propstat.append_child("D:status").append_child(pugi::node_pcdata).set_value(s.c_str()); |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 pugi::xml_node prop = propstat.append_child("D:prop"); |
4246 | 122 prop.append_child("D:displayname").append_child(pugi::node_pcdata).set_value(displayName.c_str()); |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 |
4247 | 124 // IMPORTANT: Adding the "Z" suffix is mandatory on Windows >= 7 (it indicates UTC) |
125 assert(!creationTime.is_special()); | |
4246 | 126 s = boost::posix_time::to_iso_extended_string(creationTime) + "Z"; |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 prop.append_child("D:creationdate").append_child(pugi::node_pcdata).set_value(s.c_str()); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 |
4247 | 129 assert(!modificationTime.is_special()); |
4246 | 130 s = boost::posix_time::to_iso_extended_string(modificationTime) + "Z"; |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 prop.append_child("D:getlastmodified").append_child(pugi::node_pcdata).set_value(s.c_str()); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 #if 0 |
4228
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
134 // Maybe used by davfs2 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
135 prop.append_child("D:quota-available-bytes"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
136 prop.append_child("D:quota-used-bytes"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
137 #endif |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
138 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
139 #if 0 |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 prop.append_child("D:lockdiscovery"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 pugi::xml_node lock = prop.append_child("D:supportedlock"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 pugi::xml_node lockentry = lock.append_child("D:lockentry"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 lockentry.append_child("D:lockscope").append_child("D:exclusive"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 lockentry.append_child("D:locktype").append_child("D:write"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 lockentry = lock.append_child("D:lockentry"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 lockentry.append_child("D:lockscope").append_child("D:shared"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 lockentry.append_child("D:locktype").append_child("D:write"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 #endif |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 |
4246 | 153 |
4252 | 154 IWebDavBucket::File::File(const std::string& displayName) : |
155 Resource(displayName), | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 contentLength_(0), |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 mime_(MimeType_Binary) |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 |
4232
688435755466
added DELETE in WebDAV, first working virtual filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4230
diff
changeset
|
161 |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 void IWebDavBucket::File::Format(pugi::xml_node& node, |
4246 | 163 const std::string& parentPath) const |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 { |
4246 | 165 std::string href; |
4252 | 166 Toolbox::UriEncode(href, AddTrailingSlash(parentPath) + GetDisplayName()); |
167 FormatInternal(node, href, GetDisplayName(), GetCreationTime(), GetModificationTime()); | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 pugi::xml_node prop = node.first_element_by_path("D:propstat/D:prop"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 prop.append_child("D:resourcetype"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 std::string s = boost::lexical_cast<std::string>(contentLength_); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 prop.append_child("D:getcontentlength").append_child(pugi::node_pcdata).set_value(s.c_str()); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 s = EnumerationToString(mime_); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 prop.append_child("D:getcontenttype").append_child(pugi::node_pcdata).set_value(s.c_str()); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 void IWebDavBucket::Folder::Format(pugi::xml_node& node, |
4246 | 181 const std::string& parentPath) const |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 { |
4246 | 183 std::string href; |
4252 | 184 Toolbox::UriEncode(href, AddTrailingSlash(parentPath) + GetDisplayName()); |
185 FormatInternal(node, href, GetDisplayName(), GetCreationTime(), GetModificationTime()); | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 pugi::xml_node prop = node.first_element_by_path("D:propstat/D:prop"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 prop.append_child("D:resourcetype").append_child("D:collection"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 //prop.append_child("D:getcontenttype").append_child(pugi::node_pcdata).set_value("httpd/unix-directory"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 IWebDavBucket::Collection::~Collection() |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 for (std::list<Resource*>::iterator it = resources_.begin(); it != resources_.end(); ++it) |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 assert(*it != NULL); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 delete(*it); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 void IWebDavBucket::Collection::AddResource(Resource* resource) // Takes ownership |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 if (resource == NULL) |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 throw OrthancException(ErrorCode_NullPointer); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 else |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 resources_.push_back(resource); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 |
4252 | 217 void IWebDavBucket::Collection::ListDisplayNames(std::set<std::string>& target) |
218 { | |
219 for (std::list<Resource*>::iterator it = resources_.begin(); it != resources_.end(); ++it) | |
220 { | |
221 assert(*it != NULL); | |
222 target.insert((*it)->GetDisplayName()); | |
223 } | |
224 } | |
225 | |
226 | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 void IWebDavBucket::Collection::Format(std::string& target, |
4246 | 228 const std::string& parentPath) const |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 pugi::xml_document doc; |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 pugi::xml_node root = doc.append_child("D:multistatus"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 root.append_attribute("xmlns:D").set_value("DAV:"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 |
4246 | 235 { |
236 pugi::xml_node self = root.append_child(); | |
237 | |
4252 | 238 std::vector<std::string> tokens; |
239 Toolbox::SplitUriComponents(tokens, parentPath); | |
240 | |
4246 | 241 std::string folder; |
4252 | 242 if (!tokens.empty()) |
4246 | 243 { |
4252 | 244 folder = tokens.back(); |
4246 | 245 } |
4252 | 246 |
4246 | 247 std::string href; |
4252 | 248 Toolbox::UriEncode(href, Toolbox::FlattenUri(tokens) + "/"); |
4247 | 249 |
250 boost::posix_time::ptime now = GetNow(); | |
251 FormatInternal(self, href, folder, now, now); | |
4246 | 252 |
253 pugi::xml_node prop = self.first_element_by_path("D:propstat/D:prop"); | |
254 prop.append_child("D:resourcetype").append_child("D:collection"); | |
255 } | |
256 | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 for (std::list<Resource*>::const_iterator |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
258 it = resources_.begin(); it != resources_.end(); ++it) |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
260 assert(*it != NULL); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
261 pugi::xml_node n = root.append_child(); |
4246 | 262 (*it)->Format(n, parentPath); |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 pugi::xml_node decl = doc.prepend_child(pugi::node_declaration); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
266 decl.append_attribute("version").set_value("1.0"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
267 decl.append_attribute("encoding").set_value("UTF-8"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
268 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
269 Toolbox::XmlToString(target, doc); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 } |
4228
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
271 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
272 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
273 void IWebDavBucket::AnswerFakedProppatch(HttpOutput& output, |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
274 const std::string& uri) |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
275 { |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
276 /** |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
277 * This is a fake implementation. The goal is to make happy the |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
278 * WebDAV clients that set properties (such as Windows >= 7). |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
279 **/ |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
280 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
281 pugi::xml_document doc; |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
282 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
283 pugi::xml_node root = doc.append_child("D:multistatus"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
284 root.append_attribute("xmlns:D").set_value("DAV:"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
285 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
286 pugi::xml_node response = root.append_child("D:response"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
287 response.append_child("D:href").append_child(pugi::node_pcdata).set_value(uri.c_str()); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
288 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
289 response.append_child("D:propstat"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
290 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
291 pugi::xml_node decl = doc.prepend_child(pugi::node_declaration); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
292 decl.append_attribute("version").set_value("1.0"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
293 decl.append_attribute("encoding").set_value("UTF-8"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
294 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
295 std::string s; |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
296 Toolbox::XmlToString(s, doc); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
297 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
298 output.AddHeader("Content-Type", "application/xml"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
299 output.SendStatus(HttpStatus_207_MultiStatus, s); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
300 } |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
301 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
302 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
303 void IWebDavBucket::AnswerFakedLock(HttpOutput& output, |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
304 const std::string& uri) |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
305 { |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
306 /** |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
307 * This is a fake implementation. No lock is actually |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
308 * created. The goal is to make happy the WebDAV clients |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
309 * that use locking (such as Windows >= 7). |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
310 **/ |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
311 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
312 pugi::xml_document doc; |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
313 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
314 pugi::xml_node root = doc.append_child("D:prop"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
315 root.append_attribute("xmlns:D").set_value("DAV:"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
316 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
317 pugi::xml_node activelock = root.append_child("D:lockdiscovery").append_child("D:activelock"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
318 activelock.append_child("D:locktype").append_child("D:write"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
319 activelock.append_child("D:lockscope").append_child("D:exclusive"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
320 activelock.append_child("D:depth").append_child(pugi::node_pcdata).set_value("0"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
321 activelock.append_child("D:timeout").append_child(pugi::node_pcdata).set_value("Second-3599"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
322 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
323 activelock.append_child("D:lockroot").append_child("D:href") |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
324 .append_child(pugi::node_pcdata).set_value(uri.c_str()); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
325 activelock.append_child("D:owner"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
326 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
327 std::string token = Toolbox::GenerateUuid(); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
328 boost::erase_all(token, "-"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
329 token = "opaquelocktoken:0x" + token; |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
330 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
331 activelock.append_child("D:locktoken").append_child("D:href"). |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
332 append_child(pugi::node_pcdata).set_value(token.c_str()); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
333 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
334 pugi::xml_node decl = doc.prepend_child(pugi::node_declaration); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
335 decl.append_attribute("version").set_value("1.0"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
336 decl.append_attribute("encoding").set_value("UTF-8"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
337 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
338 std::string s; |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
339 Toolbox::XmlToString(s, doc); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
340 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
341 output.AddHeader("Lock-Token", token); // Necessary for davfs2 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
342 output.AddHeader("Content-Type", "application/xml"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
343 output.SendStatus(HttpStatus_201_Created, s); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
344 } |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
345 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
346 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
347 void IWebDavBucket::AnswerFakedUnlock(HttpOutput& output) |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
348 { |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
349 output.SendStatus(HttpStatus_204_NoContent); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
350 } |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
351 } |