comparison OrthancFramework/Sources/HttpServer/IWebDavBucket.cpp @ 4232:688435755466

added DELETE in WebDAV, first working virtual filesystem
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 07 Oct 2020 13:00:57 +0200
parents b313a0001893
children a38376b80cd1
comparison
equal deleted inserted replaced
4231:290ffcb0a147 4232:688435755466
89 hasModificationTime_ = true; 89 hasModificationTime_ = true;
90 } 90 }
91 91
92 92
93 void IWebDavBucket::Resource::Format(pugi::xml_node& node, 93 void IWebDavBucket::Resource::Format(pugi::xml_node& node,
94 const std::string& parentPath) const 94 const std::string& parentPath,
95 bool includeDisplayName) const
95 { 96 {
96 node.set_name("D:response"); 97 node.set_name("D:response");
97 98
98 std::string s = AddTrailingSlash(parentPath) + GetName(); 99 std::string s = AddTrailingSlash(parentPath) + GetName();
99 node.append_child("D:href").append_child(pugi::node_pcdata).set_value(s.c_str()); 100 node.append_child("D:href").append_child(pugi::node_pcdata).set_value(s.c_str());
146 } 147 }
147 148
148 SetNameInternal(name); 149 SetNameInternal(name);
149 } 150 }
150 151
151 152
152 void IWebDavBucket::File::Format(pugi::xml_node& node, 153 void IWebDavBucket::File::Format(pugi::xml_node& node,
153 const std::string& parentPath) const 154 const std::string& parentPath,
154 { 155 bool includeDisplayName) const
155 Resource::Format(node, parentPath); 156 {
157 Resource::Format(node, parentPath, includeDisplayName);
156 158
157 pugi::xml_node prop = node.first_element_by_path("D:propstat/D:prop"); 159 pugi::xml_node prop = node.first_element_by_path("D:propstat/D:prop");
158 prop.append_child("D:resourcetype"); 160 prop.append_child("D:resourcetype");
159 161
160 std::string s = boost::lexical_cast<std::string>(contentLength_); 162 std::string s = boost::lexical_cast<std::string>(contentLength_);
166 prop.append_child("D:displayname").append_child(pugi::node_pcdata).set_value(GetName().c_str()); 168 prop.append_child("D:displayname").append_child(pugi::node_pcdata).set_value(GetName().c_str());
167 } 169 }
168 170
169 171
170 void IWebDavBucket::Folder::Format(pugi::xml_node& node, 172 void IWebDavBucket::Folder::Format(pugi::xml_node& node,
171 const std::string& parentPath) const 173 const std::string& parentPath,
172 { 174 bool includeDisplayName) const
173 Resource::Format(node, parentPath); 175 {
176 Resource::Format(node, parentPath, includeDisplayName);
174 177
175 pugi::xml_node prop = node.first_element_by_path("D:propstat/D:prop"); 178 pugi::xml_node prop = node.first_element_by_path("D:propstat/D:prop");
176 prop.append_child("D:resourcetype").append_child("D:collection"); 179 prop.append_child("D:resourcetype").append_child("D:collection");
177 180
178 //prop.append_child("D:getcontenttype").append_child(pugi::node_pcdata).set_value("httpd/unix-directory"); 181 //prop.append_child("D:getcontenttype").append_child(pugi::node_pcdata).set_value("httpd/unix-directory");
204 } 207 }
205 } 208 }
206 209
207 210
208 void IWebDavBucket::Collection::Format(std::string& target, 211 void IWebDavBucket::Collection::Format(std::string& target,
209 const std::string& parentPath) const 212 const std::string& parentPath,
213 bool includeDisplayName) const
210 { 214 {
211 pugi::xml_document doc; 215 pugi::xml_document doc;
212 216
213 pugi::xml_node root = doc.append_child("D:multistatus"); 217 pugi::xml_node root = doc.append_child("D:multistatus");
214 root.append_attribute("xmlns:D").set_value("DAV:"); 218 root.append_attribute("xmlns:D").set_value("DAV:");
216 for (std::list<Resource*>::const_iterator 220 for (std::list<Resource*>::const_iterator
217 it = resources_.begin(); it != resources_.end(); ++it) 221 it = resources_.begin(); it != resources_.end(); ++it)
218 { 222 {
219 assert(*it != NULL); 223 assert(*it != NULL);
220 pugi::xml_node n = root.append_child(); 224 pugi::xml_node n = root.append_child();
221 (*it)->Format(n, parentPath); 225 (*it)->Format(n, parentPath, includeDisplayName);
222 } 226 }
223 227
224 pugi::xml_node decl = doc.prepend_child(pugi::node_declaration); 228 pugi::xml_node decl = doc.prepend_child(pugi::node_declaration);
225 decl.append_attribute("version").set_value("1.0"); 229 decl.append_attribute("version").set_value("1.0");
226 decl.append_attribute("encoding").set_value("UTF-8"); 230 decl.append_attribute("encoding").set_value("UTF-8");