annotate Core/RestApi/RestApiHierarchy.cpp @ 2154:5d8e6fab98dd

increased timeout for buildbot
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 16 Nov 2016 12:34:15 +0100
parents b1291df2f780
children a3a65de1840f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1063
diff changeset
4 * Department, University Hospital of Liege, Belgium
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * In addition, as a special exception, the copyright holders of this
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * program give permission to link the code of its release with the
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * the linked executables. You must obey the GNU General Public License
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * you do not wish to do so, delete this exception statement from your
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * version. If you delete this exception statement from all source files
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * in the program, then also delete it here.
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
1624
0a2ad4a6858f fix missing precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1444
diff changeset
33 #include "../PrecompiledHeaders.h"
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "RestApiHierarchy.h"
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
975
c550e99c452b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 974
diff changeset
36 #include "../OrthancException.h"
c550e99c452b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 974
diff changeset
37
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include <cassert>
1063
0332e6e8c679 Fix automated generation of the list of resource children in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 980
diff changeset
39 #include <stdio.h>
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 namespace Orthanc
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
43 RestApiHierarchy::Resource::Resource() :
972
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
44 getHandler_(NULL),
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
45 postHandler_(NULL),
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
46 putHandler_(NULL),
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
47 deleteHandler_(NULL)
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
48 {
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
49 }
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
50
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
51
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
52 bool RestApiHierarchy::Resource::HasHandler(HttpMethod method) const
972
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
53 {
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
54 switch (method)
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
55 {
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
56 case HttpMethod_Get:
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
57 return getHandler_ != NULL;
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
58
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
59 case HttpMethod_Post:
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
60 return postHandler_ != NULL;
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
61
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
62 case HttpMethod_Put:
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
63 return putHandler_ != NULL;
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
64
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
65 case HttpMethod_Delete:
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
66 return deleteHandler_ != NULL;
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
67
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
68 default:
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
69 throw OrthancException(ErrorCode_ParameterOutOfRange);
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
70 }
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
71 }
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
72
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
73
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
74 bool RestApiHierarchy::Resource::IsEmpty() const
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
972
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
76 return (getHandler_ == NULL &&
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
77 postHandler_ == NULL &&
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
78 putHandler_ == NULL &&
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
79 deleteHandler_ == NULL);
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
80 }
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
81
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
82
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 RestApiHierarchy& RestApiHierarchy::AddChild(Children& children,
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 const std::string& name)
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 Children::iterator it = children.find(name);
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 if (it == children.end())
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 // Create new child
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 RestApiHierarchy *child = new RestApiHierarchy;
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 children[name] = child;
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 return *child;
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 else
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 return *it->second;
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
102
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
103 bool RestApiHierarchy::Resource::Handle(RestApiGetCall& call) const
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
104 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
105 if (getHandler_ != NULL)
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
106 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
107 getHandler_(call);
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
108 return true;
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
109 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
110 else
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
111 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
112 return false;
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
113 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
114 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
115
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
116
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
117 bool RestApiHierarchy::Resource::Handle(RestApiPutCall& call) const
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
118 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
119 if (putHandler_ != NULL)
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
120 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
121 putHandler_(call);
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
122 return true;
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
123 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
124 else
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
125 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
126 return false;
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
127 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
128 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
129
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
130
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
131 bool RestApiHierarchy::Resource::Handle(RestApiPostCall& call) const
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
132 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
133 if (postHandler_ != NULL)
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
134 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
135 postHandler_(call);
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
136 return true;
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
137 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
138 else
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
139 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
140 return false;
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
141 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
142 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
143
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
144
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
145 bool RestApiHierarchy::Resource::Handle(RestApiDeleteCall& call) const
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
146 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
147 if (deleteHandler_ != NULL)
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
148 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
149 deleteHandler_(call);
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
150 return true;
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
151 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
152 else
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
153 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
154 return false;
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
155 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
156 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
157
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
158
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
159
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 void RestApiHierarchy::DeleteChildren(Children& children)
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 for (Children::iterator it = children.begin();
1303
bba8a47922d1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
163 it != children.end(); ++it)
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 delete it->second;
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 template <typename Handler>
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 void RestApiHierarchy::RegisterInternal(const RestApiPath& path,
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 Handler handler,
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 size_t level)
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 if (path.GetLevelCount() == level)
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 if (path.IsUniversalTrailing())
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 universalHandlers_.Register(handler);
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 else
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 handlers_.Register(handler);
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 else
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 RestApiHierarchy* child;
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 if (path.IsWildcardLevel(level))
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 child = &AddChild(wildcardChildren_, path.GetWildcardName(level));
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 else
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 child = &AddChild(children_, path.GetLevelName(level));
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 child->RegisterInternal(path, handler, level + 1);
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202
1441
f3672356c121 refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
203 bool RestApiHierarchy::LookupResource(IHttpHandler::Arguments& components,
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 const UriComponents& uri,
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
205 IVisitor& visitor,
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
206 size_t level)
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 {
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
208 if (uri.size() != 0 &&
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
209 level > uri.size())
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
210 {
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
211 return false;
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
212 }
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
213
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 UriComponents trailing;
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 // Look for an exact match on the resource of interest
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
217 if (uri.size() == 0 ||
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
218 level == uri.size())
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 if (!handlers_.IsEmpty() &&
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
221 visitor.Visit(handlers_, uri, components, trailing))
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 return true;
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
228 if (level < uri.size()) // A recursive call is possible
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 {
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
230 // Try and go down in the hierarchy, using an exact match for the child
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
231 Children::const_iterator child = children_.find(uri[level]);
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
232 if (child != children_.end())
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 {
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
234 if (child->second->LookupResource(components, uri, visitor, level + 1))
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
235 {
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
236 return true;
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
237 }
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
240 // Try and go down in the hierarchy, using wildcard rules for children
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
241 for (child = wildcardChildren_.begin();
1303
bba8a47922d1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
242 child != wildcardChildren_.end(); ++child)
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
243 {
1441
f3672356c121 refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
244 IHttpHandler::Arguments subComponents = components;
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
245 subComponents[child->first] = uri[level];
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
247 if (child->second->LookupResource(subComponents, uri, visitor, level + 1))
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
248 {
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
249 return true;
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
250 }
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
251 }
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 // As a last resort, call the universal handlers, if any
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 if (!universalHandlers_.IsEmpty())
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 trailing.resize(uri.size() - level);
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 size_t pos = 0;
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 for (size_t i = level; i < uri.size(); i++, pos++)
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 trailing[pos] = uri[i];
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 assert(pos == trailing.size());
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
267 if (visitor.Visit(universalHandlers_, uri, components, trailing))
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 return true;
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 return false;
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
277 bool RestApiHierarchy::CanGenerateDirectory() const
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
278 {
1063
0332e6e8c679 Fix automated generation of the list of resource children in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 980
diff changeset
279 return (universalHandlers_.IsEmpty() &&
1303
bba8a47922d1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
280 wildcardChildren_.empty());
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
281 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
282
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
283
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 bool RestApiHierarchy::GetDirectory(Json::Value& result,
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 const UriComponents& uri,
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 size_t level)
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 if (uri.size() == level)
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 {
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
290 if (CanGenerateDirectory())
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 result = Json::arrayValue;
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 for (Children::const_iterator it = children_.begin();
1303
bba8a47922d1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
295 it != children_.end(); ++it)
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 result.append(it->first);
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 return true;
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 else
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 return false;
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 Children::const_iterator child = children_.find(uri[level]);
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 if (child != children_.end())
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 if (child->second->GetDirectory(result, uri, level + 1))
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 return true;
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 for (child = wildcardChildren_.begin();
1303
bba8a47922d1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
318 child != wildcardChildren_.end(); ++child)
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 if (child->second->GetDirectory(result, uri, level + 1))
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 return true;
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 return false;
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 RestApiHierarchy::~RestApiHierarchy()
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 {
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 DeleteChildren(children_);
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 DeleteChildren(wildcardChildren_);
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335
970
1a3817d84f39 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 969
diff changeset
336 void RestApiHierarchy::Register(const std::string& uri,
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 972
diff changeset
337 RestApiGetCall::Handler handler)
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 {
970
1a3817d84f39 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 969
diff changeset
339 RestApiPath path(uri);
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 RegisterInternal(path, handler, 0);
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342
970
1a3817d84f39 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 969
diff changeset
343 void RestApiHierarchy::Register(const std::string& uri,
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 972
diff changeset
344 RestApiPutCall::Handler handler)
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 {
970
1a3817d84f39 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 969
diff changeset
346 RestApiPath path(uri);
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 RegisterInternal(path, handler, 0);
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349
970
1a3817d84f39 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 969
diff changeset
350 void RestApiHierarchy::Register(const std::string& uri,
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 972
diff changeset
351 RestApiPostCall::Handler handler)
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 {
970
1a3817d84f39 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 969
diff changeset
353 RestApiPath path(uri);
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 RegisterInternal(path, handler, 0);
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356
970
1a3817d84f39 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 969
diff changeset
357 void RestApiHierarchy::Register(const std::string& uri,
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 972
diff changeset
358 RestApiDeleteCall::Handler handler)
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359 {
970
1a3817d84f39 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 969
diff changeset
360 RestApiPath path(uri);
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 RegisterInternal(path, handler, 0);
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 void RestApiHierarchy::CreateSiteMap(Json::Value& target) const
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 {
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
366 target = Json::objectValue;
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
367
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
368 /*std::string s = " ";
972
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
369 if (handlers_.HasHandler(HttpMethod_Get))
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 {
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
371 s += "GET ";
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373
972
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
374 if (handlers_.HasHandler(HttpMethod_Post))
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 {
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
376 s += "POST ";
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378
972
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
379 if (handlers_.HasHandler(HttpMethod_Put))
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380 {
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
381 s += "PUT ";
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383
972
2047e6f033bd refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 970
diff changeset
384 if (handlers_.HasHandler(HttpMethod_Delete))
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 {
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
386 s += "DELETE ";
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
389 target = s;*/
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
390
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
391 for (Children::const_iterator it = children_.begin();
1303
bba8a47922d1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
392 it != children_.end(); ++it)
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393 {
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
394 it->second->CreateSiteMap(target[it->first]);
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
397 for (Children::const_iterator it = wildcardChildren_.begin();
1303
bba8a47922d1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
398 it != wildcardChildren_.end(); ++it)
980
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
399 {
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
400 it->second->CreateSiteMap(target["<" + it->first + ">"]);
f1ff2a2f06cd use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 978
diff changeset
401 }
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
404
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
405 bool RestApiHierarchy::LookupResource(const UriComponents& uri,
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
406 IVisitor& visitor)
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 {
1441
f3672356c121 refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
408 IHttpHandler::Arguments components;
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
409 return LookupResource(components, uri, visitor, 0);
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 }
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
412
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
413
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
414 namespace
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
415 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
416 // Anonymous namespace to avoid clashes between compilation modules
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
417
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
418 class AcceptedMethodsVisitor : public RestApiHierarchy::IVisitor
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
419 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
420 private:
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
421 std::set<HttpMethod>& methods_;
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
422
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
423 public:
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
424 AcceptedMethodsVisitor(std::set<HttpMethod>& methods) : methods_(methods)
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
425 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
426 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
427
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
428 virtual bool Visit(const RestApiHierarchy::Resource& resource,
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
429 const UriComponents& uri,
1441
f3672356c121 refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
430 const IHttpHandler::Arguments& components,
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
431 const UriComponents& trailing)
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
432 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
433 if (trailing.size() == 0) // Ignore universal handlers
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
434 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
435 if (resource.HasHandler(HttpMethod_Get))
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
436 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
437 methods_.insert(HttpMethod_Get);
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
438 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
439
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
440 if (resource.HasHandler(HttpMethod_Post))
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
441 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
442 methods_.insert(HttpMethod_Post);
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
443 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
444
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
445 if (resource.HasHandler(HttpMethod_Put))
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
446 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
447 methods_.insert(HttpMethod_Put);
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
448 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
449
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
450 if (resource.HasHandler(HttpMethod_Delete))
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
451 {
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
452 methods_.insert(HttpMethod_Delete);
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
453 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
454 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
455
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
456 return false; // Continue to check all the possible ways to access this URI
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
457 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
458 };
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
459 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
460
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
461 void RestApiHierarchy::GetAcceptedMethods(std::set<HttpMethod>& methods,
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
462 const UriComponents& uri)
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 {
1441
f3672356c121 refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
464 IHttpHandler::Arguments components;
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
465 AcceptedMethodsVisitor visitor(methods);
1444
b2b09a3dbd8e refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1441
diff changeset
466 if (LookupResource(components, uri, visitor, 0))
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
467 {
1444
b2b09a3dbd8e refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1441
diff changeset
468 Json::Value d;
b2b09a3dbd8e refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1441
diff changeset
469 if (GetDirectory(d, uri))
b2b09a3dbd8e refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1441
diff changeset
470 {
b2b09a3dbd8e refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1441
diff changeset
471 methods.insert(HttpMethod_Get);
b2b09a3dbd8e refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1441
diff changeset
472 }
978
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
473 }
ce3106e5843f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 975
diff changeset
474 }
969
3dce528b0cc2 RestApiHierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475 }