annotate OrthancServer/Sources/OrthancWebDav.h @ 4344:25112063257b

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 05 Dec 2020 17:09:58 +0100
parents 64f57c9d5f79
children d9473bd5ed43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4240
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #pragma once
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include "../../OrthancFramework/Sources/HttpServer/WebDavStorage.h"
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../../OrthancFramework/Sources/MultiThreading/SharedMessageQueue.h"
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include "../../OrthancFramework/Sources/Toolbox.h"
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 namespace Orthanc
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 class ServerContext;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 class OrthancWebDav : public IWebDavBucket
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 {
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 private:
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 typedef std::map<ResourceType, std::string> Templates;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
4242
5cfa6ba75dfc deleting resources from Orthanc WebDAV
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4240
diff changeset
50 class DicomDeleteVisitor;
4240
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 class DicomFileVisitor;
4242
5cfa6ba75dfc deleting resources from Orthanc WebDAV
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4240
diff changeset
52 class DicomIdentifiersVisitor;
4240
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 class InstancesOfSeries;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 class InternalNode;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 class ListOfResources;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 class ListOfStudiesByDate;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 class ListOfStudiesByMonth;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 class ListOfStudiesByYear;
4242
5cfa6ba75dfc deleting resources from Orthanc WebDAV
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4240
diff changeset
59 class OrthancJsonVisitor;
4240
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 class ResourcesIndex;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 class RootNode;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 class SingleDicomResource;
4242
5cfa6ba75dfc deleting resources from Orthanc WebDAV
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4240
diff changeset
63
4240
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 class INode : public boost::noncopyable
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 {
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 public:
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 virtual ~INode()
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 {
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 }
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 virtual bool ListCollection(IWebDavBucket::Collection& target,
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 const UriComponents& path) = 0;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 virtual bool GetFileContent(MimeType& mime,
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 std::string& content,
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 boost::posix_time::ptime& time,
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 const UriComponents& path) = 0;
4242
5cfa6ba75dfc deleting resources from Orthanc WebDAV
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4240
diff changeset
78
5cfa6ba75dfc deleting resources from Orthanc WebDAV
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4240
diff changeset
79 virtual bool DeleteItem(const UriComponents& path) = 0;
4240
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 };
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 void AddVirtualFile(Collection& collection,
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 const UriComponents& path,
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 const std::string& filename);
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 static void UploadWorker(OrthancWebDav* that);
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 void Upload(const std::string& path);
4242
5cfa6ba75dfc deleting resources from Orthanc WebDAV
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4240
diff changeset
90
5cfa6ba75dfc deleting resources from Orthanc WebDAV
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4240
diff changeset
91 INode& GetRootNode(const std::string& rootPath);
4240
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 ServerContext& context_;
4242
5cfa6ba75dfc deleting resources from Orthanc WebDAV
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4240
diff changeset
94 bool allowDicomDelete_;
4243
64f57c9d5f79 configuration options for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4242
diff changeset
95 bool allowUpload_;
4240
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 std::unique_ptr<INode> patients_;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 std::unique_ptr<INode> studies_;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 std::unique_ptr<INode> dates_;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 Templates patientsTemplates_;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 Templates studiesTemplates_;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 WebDavStorage uploads_;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 SharedMessageQueue uploadQueue_;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 boost::thread uploadThread_;
4243
64f57c9d5f79 configuration options for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4242
diff changeset
104 bool uploadRunning_;
4240
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 public:
4242
5cfa6ba75dfc deleting resources from Orthanc WebDAV
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4240
diff changeset
107 OrthancWebDav(ServerContext& context,
4243
64f57c9d5f79 configuration options for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4242
diff changeset
108 bool allowDicomDelete,
64f57c9d5f79 configuration options for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4242
diff changeset
109 bool allowUpload);
4240
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 virtual ~OrthancWebDav()
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 {
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 Stop();
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 }
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 virtual bool IsExistingFolder(const UriComponents& path) ORTHANC_OVERRIDE;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 virtual bool ListCollection(Collection& collection,
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 const UriComponents& path) ORTHANC_OVERRIDE;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 virtual bool GetFileContent(MimeType& mime,
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 std::string& content,
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 boost::posix_time::ptime& modificationTime,
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 const UriComponents& path) ORTHANC_OVERRIDE;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 virtual bool StoreFile(const std::string& content,
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 const UriComponents& path) ORTHANC_OVERRIDE;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 virtual bool CreateFolder(const UriComponents& path) ORTHANC_OVERRIDE;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 virtual bool DeleteItem(const std::vector<std::string>& path) ORTHANC_OVERRIDE;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 virtual void Start() ORTHANC_OVERRIDE;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 virtual void Stop() ORTHANC_OVERRIDE;
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 };
799c0c527ced reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 }