annotate OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 1486:f967bdf8534e

refactoring to Logging.h
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 04 Aug 2015 10:01:31 +0200
parents 8dc80ba768aa
children 0586ed8897f1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1281
diff changeset
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1281
diff changeset
4 * Department, University Hospital of Liege, Belgium
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * In addition, as a special exception, the copyright holders of this
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * program give permission to link the code of its release with the
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * the linked executables. You must obey the GNU General Public License
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
5197fd35333c refactoring of OrthancRestApi
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * you do not wish to do so, delete this exception statement from your
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * version. If you delete this exception statement from all source files
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * in the program, then also delete it here.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
33 #include "../PrecompiledHeadersServer.h"
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "OrthancRestApi.h"
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
1486
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
36 #include "../../Core/Logging.h"
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../ServerToolbox.h"
795
d466b3606aca refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
38 #include "../FromDcmtkBridge.h"
1358
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1356
diff changeset
39 #include "../ResourceFinder.h"
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
40 #include "../DicomFindQuery.h"
1437
02f5a3f5c0a0 access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1385
diff changeset
41 #include "../ServerContext.h"
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 namespace Orthanc
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 // List all the patients, studies, series or instances ----------------------
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
1354
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
48 static void AnswerListOfResources(RestApiOutput& output,
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
49 ServerIndex& index,
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
50 const std::list<std::string>& resources,
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
51 ResourceType level,
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
52 bool expand)
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
53 {
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
54 Json::Value answer = Json::arrayValue;
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
55
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
56 for (std::list<std::string>::const_iterator
1384
d6971e18a324 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1374
diff changeset
57 resource = resources.begin(); resource != resources.end(); ++resource)
1354
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
58 {
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
59 if (expand)
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
60 {
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
61 Json::Value item;
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
62 if (index.LookupResource(item, *resource, level))
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
63 {
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
64 answer.append(item);
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
65 }
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
66 }
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
67 else
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
68 {
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
69 answer.append(*resource);
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
70 }
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
71 }
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
72
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
73 output.AnswerJson(answer);
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
74 }
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
75
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
76
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 template <enum ResourceType resourceType>
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
78 static void ListResources(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 {
1342
9ec7ac03152d "?expand" flag for URIs "/patients", "/studies" and "/series"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
80 ServerIndex& index = OrthancRestApi::GetIndex(call);
9ec7ac03152d "?expand" flag for URIs "/patients", "/studies" and "/series"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
81
1354
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
82 std::list<std::string> result;
1342
9ec7ac03152d "?expand" flag for URIs "/patients", "/studies" and "/series"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
83 index.GetAllUuids(result, resourceType);
9ec7ac03152d "?expand" flag for URIs "/patients", "/studies" and "/series"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
84
1354
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
85 AnswerListOfResources(call.GetOutput(), index, result, resourceType, call.HasArgument("expand"));
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 template <enum ResourceType resourceType>
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
89 static void GetSingleResource(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 Json::Value result;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 if (OrthancRestApi::GetIndex(call).LookupResource(result, call.GetUriComponent("id", ""), resourceType))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 template <enum ResourceType resourceType>
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
99 static void DeleteSingleResource(RestApiDeleteCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 Json::Value result;
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1140
diff changeset
102 if (OrthancRestApi::GetContext(call).DeleteResource(result, call.GetUriComponent("id", ""), resourceType))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 // Get information about a single patient -----------------------------------
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
111 static void IsProtectedPatient(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 bool isProtected = OrthancRestApi::GetIndex(call).IsProtectedPatient(publicId);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 call.GetOutput().AnswerBuffer(isProtected ? "1" : "0", "text/plain");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
119 static void SetPatientProtection(RestApiPutCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
125 std::string body;
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
126 call.BodyToString(body);
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
127 body = Toolbox::StripSpaces(body);
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
128
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
129 if (body == "0")
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 context.GetIndex().SetProtectedPatient(publicId, false);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 call.GetOutput().AnswerBuffer("", "text/plain");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 }
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
134 else if (body == "1")
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 context.GetIndex().SetProtectedPatient(publicId, true);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 call.GetOutput().AnswerBuffer("", "text/plain");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 else
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 // Bad request
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 // Get information about a single instance ----------------------------------
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
148 static void GetInstanceFile(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 std::string publicId = call.GetUriComponent("id", "");
1146
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
153 context.AnswerAttachment(call.GetOutput(), publicId, FileContentType_Dicom);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
157 static void ExportInstanceFile(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 std::string dicom;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 context.ReadFile(dicom, publicId, FileContentType_Dicom);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
166 std::string target;
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
167 call.BodyToString(target);
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
168 Toolbox::WriteFile(dicom, target);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 call.GetOutput().AnswerBuffer("{}", "application/json");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 template <bool simplify>
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
175 static void GetInstanceTags(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 if (simplify)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 {
1146
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
183 Json::Value full;
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
184 context.ReadJson(full, publicId);
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
185
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 Json::Value simplified;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 SimplifyTags(simplified, full);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 call.GetOutput().AnswerJson(simplified);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 else
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 {
1146
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
192 context.AnswerAttachment(call.GetOutput(), publicId, FileContentType_DicomAsJson);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195
964
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
196
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
197 static void GetInstanceTagsBis(RestApiGetCall& call)
964
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
198 {
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
199 bool simplify = call.HasArgument("simplify");
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
200
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
201 if (simplify)
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
202 {
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
203 GetInstanceTags<true>(call);
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
204 }
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
205 else
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
206 {
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
207 GetInstanceTags<false>(call);
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
208 }
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
209 }
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
210
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
212 static void ListFrames(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 Json::Value instance;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 if (OrthancRestApi::GetIndex(call).LookupResource(instance, call.GetUriComponent("id", ""), ResourceType_Instance))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 unsigned int numberOfFrames = 1;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 try
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 Json::Value tmp = instance["MainDicomTags"]["NumberOfFrames"];
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 numberOfFrames = boost::lexical_cast<unsigned int>(tmp.asString());
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 catch (...)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 Json::Value result = Json::arrayValue;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 for (unsigned int i = 0; i < numberOfFrames; i++)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 result.append(i);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 template <enum ImageExtractionMode mode>
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
240 static void GetImage(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 std::string frameId = call.GetUriComponent("frame", "0");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 unsigned int frame;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 try
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 frame = boost::lexical_cast<unsigned int>(frameId);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 catch (boost::bad_lexical_cast)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 std::string dicomContent, png;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 context.ReadFile(dicomContent, publicId, FileContentType_Dicom);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259
874
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
260 ParsedDicomFile dicom(dicomContent);
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
261
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 try
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 {
874
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
264 dicom.ExtractPngImage(png, frame, mode);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 call.GetOutput().AnswerBuffer(png, "image/png");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 catch (OrthancException& e)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 if (e.GetErrorCode() == ErrorCode_ParameterOutOfRange)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 // The frame number is out of the range for this DICOM
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 // instance, the resource is not existent
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 else
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 std::string root = "";
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 for (size_t i = 1; i < call.GetFullUri().size(); i++)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 root += "../";
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 call.GetOutput().Redirect(root + "app/images/unsupported.png");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
288 static void GetMatlabImage(RestApiGetCall& call)
874
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
289 {
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
290 ServerContext& context = OrthancRestApi::GetContext(call);
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
291
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
292 std::string frameId = call.GetUriComponent("frame", "0");
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
293
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
294 unsigned int frame;
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
295 try
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
296 {
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
297 frame = boost::lexical_cast<unsigned int>(frameId);
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
298 }
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
299 catch (boost::bad_lexical_cast)
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
300 {
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
301 return;
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
302 }
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
303
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
304 std::string publicId = call.GetUriComponent("id", "");
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
305 std::string dicomContent;
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
306 context.ReadFile(dicomContent, publicId, FileContentType_Dicom);
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
307
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
308 ParsedDicomFile dicom(dicomContent);
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
309 ImageBuffer buffer;
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
310 dicom.ExtractImage(buffer, frame);
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
311
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
312 ImageAccessor accessor(buffer.GetConstAccessor());
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
313
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
314 std::string result;
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
315 accessor.ToMatlabString(result);
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
316
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
317 call.GetOutput().AnswerBuffer(result, "text/plain");
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
318 }
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
319
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
320
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
322 static void GetResourceStatistics(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 Json::Value result;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 OrthancRestApi::GetIndex(call).GetStatistics(result, publicId);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 // Handling of metadata -----------------------------------------------------
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
334 static void CheckValidResourceType(RestApiCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 std::string resourceType = call.GetUriComponent("resourceType", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 StringToResourceType(resourceType.c_str());
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
341 static void ListMetadata(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 CheckValidResourceType(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346 std::list<MetadataType> metadata;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348 OrthancRestApi::GetIndex(call).ListAvailableMetadata(metadata, publicId);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 Json::Value result = Json::arrayValue;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 for (std::list<MetadataType>::const_iterator
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 it = metadata.begin(); it != metadata.end(); ++it)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 result.append(EnumerationToString(*it));
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
361 static void GetMetadata(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 CheckValidResourceType(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 std::string name = call.GetUriComponent("name", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 MetadataType metadata = StringToMetadata(name);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 std::string value;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 if (OrthancRestApi::GetIndex(call).LookupMetadata(value, publicId, metadata))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 call.GetOutput().AnswerBuffer(value, "text/plain");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
377 static void DeleteMetadata(RestApiDeleteCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379 CheckValidResourceType(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 std::string name = call.GetUriComponent("name", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 MetadataType metadata = StringToMetadata(name);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 if (metadata >= MetadataType_StartUser &&
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 metadata <= MetadataType_EndUser)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 // It is forbidden to modify internal metadata
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 OrthancRestApi::GetIndex(call).DeleteMetadata(publicId, metadata);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390 call.GetOutput().AnswerBuffer("", "text/plain");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
395 static void SetMetadata(RestApiPutCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 CheckValidResourceType(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400 std::string name = call.GetUriComponent("name", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 MetadataType metadata = StringToMetadata(name);
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
402
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
403 std::string value;
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
404 call.BodyToString(value);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406 if (metadata >= MetadataType_StartUser &&
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 metadata <= MetadataType_EndUser)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 // It is forbidden to modify internal metadata
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 OrthancRestApi::GetIndex(call).SetMetadata(publicId, metadata, value);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 call.GetOutput().AnswerBuffer("", "text/plain");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 // Handling of attached files -----------------------------------------------
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
420 static void ListAttachments(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 std::string resourceType = call.GetUriComponent("resourceType", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 std::list<FileContentType> attachments;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 OrthancRestApi::GetIndex(call).ListAvailableAttachments(attachments, publicId, StringToResourceType(resourceType.c_str()));
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 Json::Value result = Json::arrayValue;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 for (std::list<FileContentType>::const_iterator
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 it = attachments.begin(); it != attachments.end(); ++it)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 result.append(EnumerationToString(*it));
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
439 static bool GetAttachmentInfo(FileInfo& info, RestApiCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441 CheckValidResourceType(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 std::string name = call.GetUriComponent("name", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 FileContentType contentType = StringToContentType(name);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447 return OrthancRestApi::GetIndex(call).LookupAttachment(info, publicId, contentType);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
449
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
451 static void GetAttachmentOperations(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 FileInfo info;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 if (GetAttachmentInfo(info, call))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456 Json::Value operations = Json::arrayValue;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 operations.append("compressed-data");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 if (info.GetCompressedMD5() != "")
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462 operations.append("compressed-md5");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 operations.append("compressed-size");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 operations.append("data");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468 if (info.GetUncompressedMD5() != "")
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470 operations.append("md5");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 operations.append("size");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475 if (info.GetCompressedMD5() != "" &&
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
476 info.GetUncompressedMD5() != "")
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 operations.append("verify-md5");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 call.GetOutput().AnswerJson(operations);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486 template <int uncompress>
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
487 static void GetAttachmentData(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
489 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491 CheckValidResourceType(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493 std::string publicId = call.GetUriComponent("id", "");
1146
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
494 FileContentType type = StringToContentType(call.GetUriComponent("name", ""));
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495
1146
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
496 if (uncompress)
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
497 {
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
498 context.AnswerAttachment(call.GetOutput(), publicId, type);
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
499 }
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
500 else
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
501 {
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
502 // Return the raw data (possibly compressed), as stored on the filesystem
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
503 std::string content;
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
504 context.ReadFile(content, publicId, type, false);
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
505 call.GetOutput().AnswerBuffer(content, "application/octet-stream");
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
506 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
510 static void GetAttachmentSize(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512 FileInfo info;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513 if (GetAttachmentInfo(info, call))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515 call.GetOutput().AnswerBuffer(boost::lexical_cast<std::string>(info.GetUncompressedSize()), "text/plain");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
520 static void GetAttachmentCompressedSize(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
521 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
522 FileInfo info;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
523 if (GetAttachmentInfo(info, call))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
524 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525 call.GetOutput().AnswerBuffer(boost::lexical_cast<std::string>(info.GetCompressedSize()), "text/plain");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
526 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
527 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
528
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
530 static void GetAttachmentMD5(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
531 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532 FileInfo info;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
533 if (GetAttachmentInfo(info, call) &&
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
534 info.GetUncompressedMD5() != "")
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536 call.GetOutput().AnswerBuffer(boost::lexical_cast<std::string>(info.GetUncompressedMD5()), "text/plain");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
538 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
540
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
541 static void GetAttachmentCompressedMD5(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
543 FileInfo info;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
544 if (GetAttachmentInfo(info, call) &&
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
545 info.GetCompressedMD5() != "")
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
547 call.GetOutput().AnswerBuffer(boost::lexical_cast<std::string>(info.GetCompressedMD5()), "text/plain");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
548 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
550
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
551
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
552 static void VerifyAttachment(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555 CheckValidResourceType(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558 std::string name = call.GetUriComponent("name", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
559
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560 FileInfo info;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
561 if (!GetAttachmentInfo(info, call) ||
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562 info.GetCompressedMD5() == "" ||
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
563 info.GetUncompressedMD5() == "")
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
564 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565 // Inexistent resource, or no MD5 available
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
566 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
567 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569 bool ok = false;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
571 // First check whether the compressed data is correctly stored in the disk
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
572 std::string data;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
573 context.ReadFile(data, publicId, StringToContentType(name), false);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
574
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
575 std::string actualMD5;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
576 Toolbox::ComputeMD5(actualMD5, data);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
577
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
578 if (actualMD5 == info.GetCompressedMD5())
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580 // The compressed data is OK. If a compression algorithm was
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581 // applied to it, now check the MD5 of the uncompressed data.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
582 if (info.GetCompressionType() == CompressionType_None)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584 ok = true;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586 else
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
587 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
588 context.ReadFile(data, publicId, StringToContentType(name), true);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
589 Toolbox::ComputeMD5(actualMD5, data);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
590 ok = (actualMD5 == info.GetUncompressedMD5());
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
592 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
593
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594 if (ok)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
595 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
596 LOG(INFO) << "The attachment " << name << " of resource " << publicId << " has the right MD5";
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
597 call.GetOutput().AnswerBuffer("{}", "application/json");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
598 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
599 else
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601 LOG(INFO) << "The attachment " << name << " of resource " << publicId << " has bad MD5!";
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
602 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
606 static void UploadAttachment(RestApiPutCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
607 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
608 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
609 CheckValidResourceType(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
610
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
611 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
612 std::string name = call.GetUriComponent("name", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
613
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
614 FileContentType contentType = StringToContentType(name);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
615 if (contentType >= FileContentType_StartUser && // It is forbidden to modify internal attachments
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616 contentType <= FileContentType_EndUser &&
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
617 context.AddAttachment(publicId, StringToContentType(name), call.GetBodyData(), call.GetBodySize()))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
618 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
619 call.GetOutput().AnswerBuffer("{}", "application/json");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
620 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
621 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
622
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
623
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
624 static void DeleteAttachment(RestApiDeleteCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
625 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
626 CheckValidResourceType(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
627
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
628 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
629 std::string name = call.GetUriComponent("name", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
630 FileContentType contentType = StringToContentType(name);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
631
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
632 if (contentType >= FileContentType_StartUser &&
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
633 contentType <= FileContentType_EndUser)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
634 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
635 // It is forbidden to delete internal attachments
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
636 OrthancRestApi::GetIndex(call).DeleteAttachment(publicId, contentType);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
637 call.GetOutput().AnswerBuffer("{}", "application/json");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
638 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
640
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
641
782
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
642 // Raw access to the DICOM tags of an instance ------------------------------
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
643
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
644 static void GetRawContent(RestApiGetCall& call)
782
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
645 {
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
646 std::string id = call.GetUriComponent("id", "");
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
647
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
648 ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), id);
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
649
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
650 locker.GetDicom().SendPathValue(call.GetOutput(), call.GetTrailingUri());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
651 }
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
652
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
653
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
654
960
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
655 static bool ExtractSharedTags(Json::Value& shared,
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
656 ServerContext& context,
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
657 const std::string& publicId)
958
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
658 {
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
659 // Retrieve all the instances of this patient/study/series
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
660 typedef std::list<std::string> Instances;
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
661 Instances instances;
959
bd5659f2a50a fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 958
diff changeset
662 context.GetIndex().GetChildInstances(instances, publicId); // (*)
958
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
663
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
664 // Loop over the instances
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
665 bool isFirst = true;
960
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
666 shared = Json::objectValue;
958
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
667
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
668 for (Instances::const_iterator it = instances.begin();
1303
bba8a47922d1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
669 it != instances.end(); ++it)
958
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
670 {
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
671 // Get the tags of the current instance, in the simplified format
960
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
672 Json::Value tags;
959
bd5659f2a50a fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 958
diff changeset
673
bd5659f2a50a fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 958
diff changeset
674 try
bd5659f2a50a fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 958
diff changeset
675 {
960
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
676 context.ReadJson(tags, *it);
959
bd5659f2a50a fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 958
diff changeset
677 }
bd5659f2a50a fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 958
diff changeset
678 catch (OrthancException&)
bd5659f2a50a fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 958
diff changeset
679 {
bd5659f2a50a fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 958
diff changeset
680 // Race condition: This instance has been removed since
bd5659f2a50a fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 958
diff changeset
681 // (*). Ignore this instance.
bd5659f2a50a fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 958
diff changeset
682 continue;
bd5659f2a50a fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 958
diff changeset
683 }
bd5659f2a50a fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 958
diff changeset
684
960
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
685 if (tags.type() != Json::objectValue)
958
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
686 {
960
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
687 return false; // Error
958
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
688 }
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
689
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
690 // Only keep the tags that are mapped to a string
960
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
691 Json::Value::Members members = tags.getMemberNames();
958
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
692 for (size_t i = 0; i < members.size(); i++)
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
693 {
960
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
694 const Json::Value& tag = tags[members[i]];
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
695 if (tag.type() != Json::objectValue ||
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
696 tag["Type"].type() != Json::stringValue ||
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
697 tag["Type"].asString() != "String")
958
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
698 {
960
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
699 tags.removeMember(members[i]);
958
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
700 }
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
701 }
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
702
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
703 if (isFirst)
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
704 {
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
705 // This is the first instance, keep its tags as such
960
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
706 shared = tags;
958
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
707 isFirst = false;
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
708 }
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
709 else
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
710 {
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
711 // Loop over all the members of the shared tags extracted so
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
712 // far. If the value of one of these tags does not match its
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
713 // value in the current instance, remove it.
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
714 members = shared.getMemberNames();
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
715 for (size_t i = 0; i < members.size(); i++)
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
716 {
960
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
717 if (!tags.isMember(members[i]) ||
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
718 tags[members[i]]["Value"].asString() != shared[members[i]]["Value"].asString())
958
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
719 {
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
720 shared.removeMember(members[i]);
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
721 }
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
722 }
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
723 }
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
724 }
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
725
960
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
726 return true;
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
727 }
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
728
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
729
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 964
diff changeset
730 static void GetSharedTags(RestApiGetCall& call)
960
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
731 {
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
732 ServerContext& context = OrthancRestApi::GetContext(call);
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
733 std::string publicId = call.GetUriComponent("id", "");
964
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
734 bool simplify = call.HasArgument("simplify");
960
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
735
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
736 Json::Value sharedTags;
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
737 if (ExtractSharedTags(sharedTags, context, publicId))
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
738 {
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
739 // Success: Send the value of the shared tags
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
740 if (simplify)
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
741 {
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
742 Json::Value simplified;
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
743 SimplifyTags(simplified, sharedTags);
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
744 call.GetOutput().AnswerJson(simplified);
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
745 }
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
746 else
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
747 {
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
748 call.GetOutput().AnswerJson(sharedTags);
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
749 }
abac5c83134f simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 959
diff changeset
750 }
958
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
751 }
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
752
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
753
1054
1701dcb6f554 Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 974
diff changeset
754 static void GetModuleInternal(RestApiGetCall& call,
1701dcb6f554 Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 974
diff changeset
755 ResourceType resourceType,
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
756 DicomModule module)
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
757 {
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
758 if (!((resourceType == ResourceType_Patient && module == DicomModule_Patient) ||
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
759 (resourceType == ResourceType_Study && module == DicomModule_Patient) ||
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
760 (resourceType == ResourceType_Study && module == DicomModule_Study) ||
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
761 (resourceType == ResourceType_Series && module == DicomModule_Series) ||
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
762 (resourceType == ResourceType_Instance && module == DicomModule_Instance) ||
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
763 (resourceType == ResourceType_Instance && module == DicomModule_Image)))
1054
1701dcb6f554 Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 974
diff changeset
764 {
1701dcb6f554 Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 974
diff changeset
765 throw OrthancException(ErrorCode_NotImplemented);
1701dcb6f554 Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 974
diff changeset
766 }
1701dcb6f554 Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 974
diff changeset
767
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
768 ServerContext& context = OrthancRestApi::GetContext(call);
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
769 std::string publicId = call.GetUriComponent("id", "");
964
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
770 bool simplify = call.HasArgument("simplify");
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
771
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
772 typedef std::set<DicomTag> ModuleTags;
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
773 ModuleTags moduleTags;
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1361
diff changeset
774 DicomTag::AddTagsForModule(moduleTags, module);
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
775
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
776 Json::Value tags;
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
777
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
778 if (resourceType != ResourceType_Instance)
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
779 {
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
780 // Retrieve all the instances of this patient/study/series
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
781 typedef std::list<std::string> Instances;
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
782 Instances instances;
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
783 context.GetIndex().GetChildInstances(instances, publicId);
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
784
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
785 if (instances.empty())
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
786 {
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
787 return; // Error: No instance (should never happen)
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
788 }
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
789
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
790 // Select one child instance
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
791 publicId = instances.front();
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
792 }
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
793
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
794 context.ReadJson(tags, publicId);
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
795
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
796 // Filter the tags of the instance according to the module
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
797 Json::Value result = Json::objectValue;
1303
bba8a47922d1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
798 for (ModuleTags::const_iterator tag = moduleTags.begin(); tag != moduleTags.end(); ++tag)
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
799 {
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
800 std::string s = tag->Format();
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
801 if (tags.isMember(s))
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
802 {
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
803 result[s] = tags[s];
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
804 }
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
805 }
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
806
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
807 if (simplify)
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
808 {
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
809 Json::Value simplified;
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
810 SimplifyTags(simplified, result);
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
811 call.GetOutput().AnswerJson(simplified);
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
812 }
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
813 else
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
814 {
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
815 call.GetOutput().AnswerJson(result);
1054
1701dcb6f554 Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 974
diff changeset
816 }
1701dcb6f554 Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 974
diff changeset
817 }
1701dcb6f554 Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 974
diff changeset
818
1701dcb6f554 Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 974
diff changeset
819
1701dcb6f554 Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 974
diff changeset
820
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
821 template <enum ResourceType resourceType,
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
822 enum DicomModule module>
1054
1701dcb6f554 Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 974
diff changeset
823 static void GetModule(RestApiGetCall& call)
1701dcb6f554 Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 974
diff changeset
824 {
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
825 GetModuleInternal(call, resourceType, module);
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
826 }
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
827
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
828
1139
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
829 static void Lookup(RestApiPostCall& call)
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
830 {
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
831 typedef std::list< std::pair<ResourceType, std::string> > Resources;
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
832
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
833 std::string tag;
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
834 call.BodyToString(tag);
1139
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
835 Resources resources;
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
836
1162
1ea4094d077c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
837 OrthancRestApi::GetIndex(call).LookupIdentifier(resources, tag);
1139
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
838
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
839 Json::Value result = Json::arrayValue;
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
840
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
841 for (Resources::const_iterator it = resources.begin();
1303
bba8a47922d1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
842 it != resources.end(); ++it)
1139
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
843 {
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
844 ResourceType type = it->first;
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
845 const std::string& id = it->second;
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
846
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
847 Json::Value item = Json::objectValue;
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
848 item["Type"] = EnumerationToString(type);
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
849 item["ID"] = id;
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
850 item["Path"] = GetBasePath(type, id);
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
851
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
852 result.append(item);
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
853 }
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
854
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
855 call.GetOutput().AnswerJson(result);
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
856 }
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
857
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
858
1354
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
859 static void Find(RestApiPostCall& call)
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
860 {
1358
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1356
diff changeset
861 ServerContext& context = OrthancRestApi::GetContext(call);
1354
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
862
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
863 Json::Value request;
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
864 if (call.ParseJsonRequest(request) &&
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
865 request.type() == Json::objectValue &&
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
866 request.isMember("Level") &&
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
867 request.isMember("Query") &&
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
868 request["Level"].type() == Json::stringValue &&
1374
a1745d9be6e9 CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1361
diff changeset
869 request["Query"].type() == Json::objectValue &&
a1745d9be6e9 CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1361
diff changeset
870 (!request.isMember("CaseSensitive") || request["CaseSensitive"].type() == Json::booleanValue))
1354
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
871 {
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
872 bool expand = false;
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
873 if (request.isMember("Expand"))
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
874 {
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
875 expand = request["Expand"].asBool();
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
876 }
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
877
1374
a1745d9be6e9 CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1361
diff changeset
878 bool caseSensitive = false;
a1745d9be6e9 CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1361
diff changeset
879 if (request.isMember("CaseSensitive"))
a1745d9be6e9 CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1361
diff changeset
880 {
a1745d9be6e9 CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1361
diff changeset
881 caseSensitive = request["CaseSensitive"].asBool();
a1745d9be6e9 CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1361
diff changeset
882 }
a1745d9be6e9 CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1361
diff changeset
883
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1358
diff changeset
884 std::string level = request["Level"].asString();
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1358
diff changeset
885
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
886 DicomFindQuery query;
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
887 query.SetLevel(StringToResourceType(level.c_str()));
1358
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1356
diff changeset
888
1354
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
889 Json::Value::Members members = request["Query"].getMemberNames();
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
890 for (size_t i = 0; i < members.size(); i++)
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
891 {
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
892 if (request["Query"][members[i]].type() != Json::stringValue)
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
893 {
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
894 throw OrthancException(ErrorCode_BadRequest);
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
895 }
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
896
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
897 query.SetConstraint(FromDcmtkBridge::ParseTag(members[i]),
1374
a1745d9be6e9 CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1361
diff changeset
898 request["Query"][members[i]].asString(),
a1745d9be6e9 CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1361
diff changeset
899 caseSensitive);
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
900 }
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
901
1354
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
902 std::list<std::string> resources;
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
903 ResourceFinder finder(context);
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
904 finder.Apply(resources, query);
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
905 AnswerListOfResources(call.GetOutput(), context.GetIndex(), resources, query.GetLevel(), expand);
1354
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
906 }
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
907 else
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
908 {
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
909 throw OrthancException(ErrorCode_BadRequest);
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
910 }
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
911 }
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
912
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
913
1140
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
914 template <enum ResourceType start,
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
915 enum ResourceType end>
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
916 static void GetChildResources(RestApiGetCall& call)
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
917 {
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
918 ServerIndex& index = OrthancRestApi::GetIndex(call);
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
919
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
920 std::list<std::string> a, b, c;
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
921 a.push_back(call.GetUriComponent("id", ""));
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
922
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
923 ResourceType type = start;
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
924 while (type != end)
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
925 {
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
926 b.clear();
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
927
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
928 for (std::list<std::string>::const_iterator
1303
bba8a47922d1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
929 it = a.begin(); it != a.end(); ++it)
1140
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
930 {
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
931 index.GetChildren(c, *it);
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
932 b.splice(b.begin(), c);
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
933 }
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
934
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
935 switch (type)
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
936 {
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
937 case ResourceType_Patient:
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
938 type = ResourceType_Study;
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
939 break;
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
940
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
941 case ResourceType_Study:
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
942 type = ResourceType_Series;
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
943 break;
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
944
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
945 case ResourceType_Series:
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
946 type = ResourceType_Instance;
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
947 break;
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
948
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
949 default:
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
950 throw OrthancException(ErrorCode_InternalError);
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
951 }
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
952
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
953 a.clear();
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
954 a.splice(a.begin(), b);
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
955 }
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
956
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
957 Json::Value result = Json::arrayValue;
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
958
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
959 for (std::list<std::string>::const_iterator
1303
bba8a47922d1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
960 it = a.begin(); it != a.end(); ++it)
1140
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
961 {
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
962 Json::Value item;
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
963
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
964 if (OrthancRestApi::GetIndex(call).LookupResource(item, *it, end))
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
965 {
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
966 result.append(item);
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
967 }
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
968 }
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
969
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
970 call.GetOutput().AnswerJson(result);
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
971 }
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
972
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
973
1166
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
974 static void GetChildInstancesTags(RestApiGetCall& call)
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
975 {
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
976 ServerContext& context = OrthancRestApi::GetContext(call);
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
977 std::string publicId = call.GetUriComponent("id", "");
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
978 bool simplify = call.HasArgument("simplify");
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
979
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
980 // Retrieve all the instances of this patient/study/series
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
981 typedef std::list<std::string> Instances;
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
982 Instances instances;
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
983
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
984 context.GetIndex().GetChildInstances(instances, publicId); // (*)
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
985
1201
09aa7c126be9 URIs 'instance-tags' now indexed by the instance IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1172
diff changeset
986 Json::Value result = Json::objectValue;
1166
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
987
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
988 for (Instances::const_iterator it = instances.begin();
1303
bba8a47922d1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
989 it != instances.end(); ++it)
1166
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
990 {
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
991 Json::Value full;
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
992 context.ReadJson(full, *it);
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
993
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
994 if (simplify)
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
995 {
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
996 Json::Value simplified;
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
997 SimplifyTags(simplified, full);
1201
09aa7c126be9 URIs 'instance-tags' now indexed by the instance IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1172
diff changeset
998 result[*it] = simplified;
1166
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
999 }
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
1000 else
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
1001 {
1201
09aa7c126be9 URIs 'instance-tags' now indexed by the instance IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1172
diff changeset
1002 result[*it] = full;
1166
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
1003 }
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
1004 }
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
1005
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
1006 call.GetOutput().AnswerJson(result);
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
1007 }
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
1008
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
1009
1140
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
1010
1281
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1011 template <enum ResourceType start,
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1012 enum ResourceType end>
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1013 static void GetParentResource(RestApiGetCall& call)
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1014 {
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1015 assert(start > end);
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1016
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1017 ServerIndex& index = OrthancRestApi::GetIndex(call);
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1018
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1019 std::string current = call.GetUriComponent("id", "");
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1020 ResourceType currentType = start;
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1021 while (currentType > end)
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1022 {
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1023 std::string parent;
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1024 if (!index.LookupParent(parent, current))
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1025 {
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1026 // Error that could happen if the resource gets deleted by
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1027 // another concurrent call
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1028 return;
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1029 }
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1030
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1031 current = parent;
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1032 switch (currentType)
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1033 {
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1034 case ResourceType_Instance: currentType = ResourceType_Series; break;
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1035 case ResourceType_Series: currentType = ResourceType_Study; break;
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1036 case ResourceType_Study: currentType = ResourceType_Patient; break;
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1037 default: throw OrthancException(ErrorCode_InternalError);
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1038 }
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1039 }
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1040
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1041 assert(currentType == end);
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1042
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1043 Json::Value result;
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1044 if (index.LookupResource(result, current, end))
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1045 {
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1046 call.GetOutput().AnswerJson(result);
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1047 }
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1048 }
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1049
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1050
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1051
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1052 void OrthancRestApi::RegisterResources()
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1053 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1054 Register("/instances", ListResources<ResourceType_Instance>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1055 Register("/patients", ListResources<ResourceType_Patient>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1056 Register("/series", ListResources<ResourceType_Series>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1057 Register("/studies", ListResources<ResourceType_Study>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1058
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1059 Register("/instances/{id}", DeleteSingleResource<ResourceType_Instance>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1060 Register("/instances/{id}", GetSingleResource<ResourceType_Instance>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1061 Register("/patients/{id}", DeleteSingleResource<ResourceType_Patient>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1062 Register("/patients/{id}", GetSingleResource<ResourceType_Patient>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1063 Register("/series/{id}", DeleteSingleResource<ResourceType_Series>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1064 Register("/series/{id}", GetSingleResource<ResourceType_Series>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1065 Register("/studies/{id}", DeleteSingleResource<ResourceType_Study>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1066 Register("/studies/{id}", GetSingleResource<ResourceType_Study>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1067
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1068 Register("/instances/{id}/statistics", GetResourceStatistics);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1069 Register("/patients/{id}/statistics", GetResourceStatistics);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1070 Register("/studies/{id}/statistics", GetResourceStatistics);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1071 Register("/series/{id}/statistics", GetResourceStatistics);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1072
964
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
1073 Register("/patients/{id}/shared-tags", GetSharedTags);
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
1074 Register("/series/{id}/shared-tags", GetSharedTags);
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
1075 Register("/studies/{id}/shared-tags", GetSharedTags);
958
1fbe89dc18b5 extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
1076
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
1077 Register("/instances/{id}/module", GetModule<ResourceType_Instance, DicomModule_Instance>);
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
1078 Register("/patients/{id}/module", GetModule<ResourceType_Patient, DicomModule_Patient>);
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
1079 Register("/series/{id}/module", GetModule<ResourceType_Series, DicomModule_Series>);
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
1080 Register("/studies/{id}/module", GetModule<ResourceType_Study, DicomModule_Study>);
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1201
diff changeset
1081 Register("/studies/{id}/module-patient", GetModule<ResourceType_Study, DicomModule_Patient>);
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 960
diff changeset
1082
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1083 Register("/instances/{id}/file", GetInstanceFile);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1084 Register("/instances/{id}/export", ExportInstanceFile);
964
cc7a4ae474c1 simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 963
diff changeset
1085 Register("/instances/{id}/tags", GetInstanceTagsBis);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1086 Register("/instances/{id}/simplified-tags", GetInstanceTags<true>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1087 Register("/instances/{id}/frames", ListFrames);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1088
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1089 Register("/instances/{id}/frames/{frame}/preview", GetImage<ImageExtractionMode_Preview>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1090 Register("/instances/{id}/frames/{frame}/image-uint8", GetImage<ImageExtractionMode_UInt8>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1091 Register("/instances/{id}/frames/{frame}/image-uint16", GetImage<ImageExtractionMode_UInt16>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1092 Register("/instances/{id}/frames/{frame}/image-int16", GetImage<ImageExtractionMode_Int16>);
874
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1093 Register("/instances/{id}/frames/{frame}/matlab", GetMatlabImage);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1094 Register("/instances/{id}/preview", GetImage<ImageExtractionMode_Preview>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1095 Register("/instances/{id}/image-uint8", GetImage<ImageExtractionMode_UInt8>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1096 Register("/instances/{id}/image-uint16", GetImage<ImageExtractionMode_UInt16>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1097 Register("/instances/{id}/image-int16", GetImage<ImageExtractionMode_Int16>);
874
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1098 Register("/instances/{id}/matlab", GetMatlabImage);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1099
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1100 Register("/patients/{id}/protected", IsProtectedPatient);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1101 Register("/patients/{id}/protected", SetPatientProtection);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1102
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1103 Register("/{resourceType}/{id}/metadata", ListMetadata);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1104 Register("/{resourceType}/{id}/metadata/{name}", DeleteMetadata);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1105 Register("/{resourceType}/{id}/metadata/{name}", GetMetadata);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1106 Register("/{resourceType}/{id}/metadata/{name}", SetMetadata);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1107
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1108 Register("/{resourceType}/{id}/attachments", ListAttachments);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1109 Register("/{resourceType}/{id}/attachments/{name}", DeleteAttachment);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1110 Register("/{resourceType}/{id}/attachments/{name}", GetAttachmentOperations);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1111 Register("/{resourceType}/{id}/attachments/{name}/compressed-data", GetAttachmentData<0>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1112 Register("/{resourceType}/{id}/attachments/{name}/compressed-md5", GetAttachmentCompressedMD5);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1113 Register("/{resourceType}/{id}/attachments/{name}/compressed-size", GetAttachmentCompressedSize);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1114 Register("/{resourceType}/{id}/attachments/{name}/data", GetAttachmentData<1>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1115 Register("/{resourceType}/{id}/attachments/{name}/md5", GetAttachmentMD5);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1116 Register("/{resourceType}/{id}/attachments/{name}/size", GetAttachmentSize);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1117 Register("/{resourceType}/{id}/attachments/{name}/verify-md5", VerifyAttachment);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1118 Register("/{resourceType}/{id}/attachments/{name}", UploadAttachment);
782
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
1119
1139
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
1120 Register("/tools/lookup", Lookup);
1354
3dd494f201a1 ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1342
diff changeset
1121 Register("/tools/find", Find);
1139
f167b672db94 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1054
diff changeset
1122
1140
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
1123 Register("/patients/{id}/studies", GetChildResources<ResourceType_Patient, ResourceType_Study>);
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
1124 Register("/patients/{id}/series", GetChildResources<ResourceType_Patient, ResourceType_Series>);
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
1125 Register("/patients/{id}/instances", GetChildResources<ResourceType_Patient, ResourceType_Instance>);
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
1126 Register("/studies/{id}/series", GetChildResources<ResourceType_Study, ResourceType_Series>);
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
1127 Register("/studies/{id}/instances", GetChildResources<ResourceType_Study, ResourceType_Instance>);
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
1128 Register("/series/{id}/instances", GetChildResources<ResourceType_Series, ResourceType_Instance>);
94c5f6623b3a URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1139
diff changeset
1129
1281
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1130 Register("/studies/{id}/patient", GetParentResource<ResourceType_Study, ResourceType_Patient>);
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1131 Register("/series/{id}/patient", GetParentResource<ResourceType_Series, ResourceType_Patient>);
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1132 Register("/series/{id}/study", GetParentResource<ResourceType_Series, ResourceType_Study>);
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1133 Register("/instances/{id}/patient", GetParentResource<ResourceType_Instance, ResourceType_Patient>);
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1134 Register("/instances/{id}/study", GetParentResource<ResourceType_Instance, ResourceType_Study>);
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1135 Register("/instances/{id}/series", GetParentResource<ResourceType_Instance, ResourceType_Series>);
8dac11c78d71 URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
1136
1166
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
1137 Register("/patients/{id}/instances-tags", GetChildInstancesTags);
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
1138 Register("/studies/{id}/instances-tags", GetChildInstancesTags);
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
1139 Register("/series/{id}/instances-tags", GetChildInstancesTags);
a921e3b5e763 bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1146
diff changeset
1140
782
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
1141 Register("/instances/{id}/content/*", GetRawContent);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1142 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1143 }