annotate OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 794:437c4a83d2cc

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 06 May 2014 10:52:20 +0200
parents a60040857ce6
children d466b3606aca
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege,
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Belgium
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #include "OrthancRestApi.h"
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "../ServerToolbox.h"
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include <glog/logging.h>
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 namespace Orthanc
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 // List all the patients, studies, series or instances ----------------------
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 template <enum ResourceType resourceType>
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 static void ListResources(RestApi::GetCall& call)
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 Json::Value result;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 OrthancRestApi::GetIndex(call).GetAllUuids(result, resourceType);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 template <enum ResourceType resourceType>
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 static void GetSingleResource(RestApi::GetCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 Json::Value result;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 if (OrthancRestApi::GetIndex(call).LookupResource(result, call.GetUriComponent("id", ""), resourceType))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 template <enum ResourceType resourceType>
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 static void DeleteSingleResource(RestApi::DeleteCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 Json::Value result;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 if (OrthancRestApi::GetIndex(call).DeleteResource(result, call.GetUriComponent("id", ""), resourceType))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 // Get information about a single patient -----------------------------------
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 static void IsProtectedPatient(RestApi::GetCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 bool isProtected = OrthancRestApi::GetIndex(call).IsProtectedPatient(publicId);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 call.GetOutput().AnswerBuffer(isProtected ? "1" : "0", "text/plain");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 static void SetPatientProtection(RestApi::PutCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 std::string s = Toolbox::StripSpaces(call.GetPutBody());
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 if (s == "0")
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 context.GetIndex().SetProtectedPatient(publicId, false);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 call.GetOutput().AnswerBuffer("", "text/plain");
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 else if (s == "1")
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 context.GetIndex().SetProtectedPatient(publicId, true);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 call.GetOutput().AnswerBuffer("", "text/plain");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 else
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 // Bad request
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }
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
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 // Get information about a single instance ----------------------------------
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 static void GetInstanceFile(RestApi::GetCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 context.AnswerDicomFile(call.GetOutput(), publicId, FileContentType_Dicom);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115
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 static void ExportInstanceFile(RestApi::PostCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 ServerContext& context = OrthancRestApi::GetContext(call);
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 std::string publicId = call.GetUriComponent("id", "");
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 dicom;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 context.ReadFile(dicom, publicId, FileContentType_Dicom);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 Toolbox::WriteFile(dicom, call.GetPostBody());
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 call.GetOutput().AnswerBuffer("{}", "application/json");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 template <bool simplify>
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 static void GetInstanceTags(RestApi::GetCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 std::string publicId = call.GetUriComponent("id", "");
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 Json::Value full;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 context.ReadJson(full, publicId);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 if (simplify)
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 Json::Value simplified;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 SimplifyTags(simplified, full);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 call.GetOutput().AnswerJson(simplified);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 else
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 call.GetOutput().AnswerJson(full);
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 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153
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 static void ListFrames(RestApi::GetCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 Json::Value instance;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 if (OrthancRestApi::GetIndex(call).LookupResource(instance, call.GetUriComponent("id", ""), ResourceType_Instance))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 unsigned int numberOfFrames = 1;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 try
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 Json::Value tmp = instance["MainDicomTags"]["NumberOfFrames"];
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 numberOfFrames = boost::lexical_cast<unsigned int>(tmp.asString());
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 catch (...)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 {
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 Json::Value result = Json::arrayValue;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 for (unsigned int i = 0; i < numberOfFrames; i++)
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 result.append(i);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 }
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 call.GetOutput().AnswerJson(result);
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 }
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 template <enum ImageExtractionMode mode>
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 static void GetImage(RestApi::GetCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 std::string frameId = call.GetUriComponent("frame", "0");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 unsigned int frame;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 try
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 frame = boost::lexical_cast<unsigned int>(frameId);
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 catch (boost::bad_lexical_cast)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 std::string dicomContent, png;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 context.ReadFile(dicomContent, publicId, FileContentType_Dicom);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 try
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 FromDcmtkBridge::ExtractPngImage(png, dicomContent, frame, mode);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 call.GetOutput().AnswerBuffer(png, "image/png");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 catch (OrthancException& e)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 if (e.GetErrorCode() == ErrorCode_ParameterOutOfRange)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 // The frame number is out of the range for this DICOM
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 // instance, the resource is not existent
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 else
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 std::string root = "";
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 for (size_t i = 1; i < call.GetFullUri().size(); i++)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 root += "../";
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 call.GetOutput().Redirect(root + "app/images/unsupported.png");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 }
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 static void GetResourceStatistics(RestApi::GetCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 Json::Value result;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 OrthancRestApi::GetIndex(call).GetStatistics(result, publicId);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 call.GetOutput().AnswerJson(result);
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 // Handling of metadata -----------------------------------------------------
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 static void CheckValidResourceType(RestApi::Call& 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 resourceType = call.GetUriComponent("resourceType", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 StringToResourceType(resourceType.c_str());
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247
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 static void ListMetadata(RestApi::GetCall& call)
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 CheckValidResourceType(call);
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 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 std::list<MetadataType> metadata;
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 OrthancRestApi::GetIndex(call).ListAvailableMetadata(metadata, publicId);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 Json::Value result = Json::arrayValue;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 for (std::list<MetadataType>::const_iterator
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 it = metadata.begin(); it != metadata.end(); ++it)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 result.append(EnumerationToString(*it));
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 call.GetOutput().AnswerJson(result);
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
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 static void GetMetadata(RestApi::GetCall& call)
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 CheckValidResourceType(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 std::string name = call.GetUriComponent("name", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 MetadataType metadata = StringToMetadata(name);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 std::string value;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 if (OrthancRestApi::GetIndex(call).LookupMetadata(value, publicId, metadata))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 call.GetOutput().AnswerBuffer(value, "text/plain");
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 }
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 static void DeleteMetadata(RestApi::DeleteCall& call)
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 CheckValidResourceType(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 std::string name = call.GetUriComponent("name", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 MetadataType metadata = StringToMetadata(name);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 if (metadata >= MetadataType_StartUser &&
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 metadata <= MetadataType_EndUser)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 // It is forbidden to modify internal metadata
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 OrthancRestApi::GetIndex(call).DeleteMetadata(publicId, metadata);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 call.GetOutput().AnswerBuffer("", "text/plain");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 static void SetMetadata(RestApi::PutCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 CheckValidResourceType(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 std::string name = call.GetUriComponent("name", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 MetadataType metadata = StringToMetadata(name);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 std::string value = call.GetPutBody();
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 if (metadata >= MetadataType_StartUser &&
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 metadata <= MetadataType_EndUser)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 // It is forbidden to modify internal metadata
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 OrthancRestApi::GetIndex(call).SetMetadata(publicId, metadata, value);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 call.GetOutput().AnswerBuffer("", "text/plain");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322
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 // Handling of attached files -----------------------------------------------
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 static void ListAttachments(RestApi::GetCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 std::string resourceType = call.GetUriComponent("resourceType", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 std::list<FileContentType> attachments;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 OrthancRestApi::GetIndex(call).ListAvailableAttachments(attachments, publicId, StringToResourceType(resourceType.c_str()));
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 Json::Value result = Json::arrayValue;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 for (std::list<FileContentType>::const_iterator
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 it = attachments.begin(); it != attachments.end(); ++it)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 result.append(EnumerationToString(*it));
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 call.GetOutput().AnswerJson(result);
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
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 static bool GetAttachmentInfo(FileInfo& info, RestApi::Call& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 CheckValidResourceType(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 std::string name = call.GetUriComponent("name", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 FileContentType contentType = StringToContentType(name);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 return OrthancRestApi::GetIndex(call).LookupAttachment(info, publicId, contentType);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 }
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 static void GetAttachmentOperations(RestApi::GetCall& call)
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 FileInfo info;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 if (GetAttachmentInfo(info, call))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 Json::Value operations = Json::arrayValue;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 operations.append("compressed-data");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 if (info.GetCompressedMD5() != "")
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 operations.append("compressed-md5");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 operations.append("compressed-size");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 operations.append("data");
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 if (info.GetUncompressedMD5() != "")
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 operations.append("md5");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 }
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 operations.append("size");
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 if (info.GetCompressedMD5() != "" &&
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 info.GetUncompressedMD5() != "")
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 operations.append("verify-md5");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 call.GetOutput().AnswerJson(operations);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390
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 template <int uncompress>
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393 static void GetAttachmentData(RestApi::GetCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 ServerContext& context = OrthancRestApi::GetContext(call);
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 std::string content;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403 context.ReadFile(content, publicId, StringToContentType(name),
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 (uncompress == 1));
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 call.GetOutput().AnswerBuffer(content, "application/octet-stream");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 }
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 static void GetAttachmentSize(RestApi::GetCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 FileInfo info;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 if (GetAttachmentInfo(info, call))
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 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
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 static void GetAttachmentCompressedSize(RestApi::GetCall& call)
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 FileInfo info;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 if (GetAttachmentInfo(info, call))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 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
426 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 }
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 static void GetAttachmentMD5(RestApi::GetCall& call)
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 FileInfo info;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433 if (GetAttachmentInfo(info, call) &&
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434 info.GetUncompressedMD5() != "")
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 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
437 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439
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 static void GetAttachmentCompressedMD5(RestApi::GetCall& 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 FileInfo info;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 if (GetAttachmentInfo(info, call) &&
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 info.GetCompressedMD5() != "")
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 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
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
451
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452 static void VerifyAttachment(RestApi::PostCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 CheckValidResourceType(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 std::string name = call.GetUriComponent("name", "");
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 FileInfo info;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461 if (!GetAttachmentInfo(info, call) ||
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462 info.GetCompressedMD5() == "" ||
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 info.GetUncompressedMD5() == "")
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 // Inexistent resource, or no MD5 available
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 return;
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469 bool ok = false;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 // 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
472 std::string data;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 context.ReadFile(data, publicId, StringToContentType(name), false);
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 std::string actualMD5;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
476 Toolbox::ComputeMD5(actualMD5, data);
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 if (actualMD5 == info.GetCompressedMD5())
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 // The compressed data is OK. If a compression algorithm was
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 // applied to it, now check the MD5 of the uncompressed data.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482 if (info.GetCompressionType() == CompressionType_None)
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 ok = true;
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 else
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
487 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488 context.ReadFile(data, publicId, StringToContentType(name), true);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
489 Toolbox::ComputeMD5(actualMD5, data);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490 ok = (actualMD5 == info.GetUncompressedMD5());
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491 }
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494 if (ok)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 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
497 call.GetOutput().AnswerBuffer("{}", "application/json");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499 else
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501 LOG(INFO) << "The attachment " << name << " of resource " << publicId << " has bad MD5!";
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
502 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506 static void UploadAttachment(RestApi::PutCall& call)
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 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509 CheckValidResourceType(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
510
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512 std::string name = call.GetUriComponent("name", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514 const void* data = call.GetPutBody().size() ? &call.GetPutBody()[0] : NULL;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 FileContentType contentType = StringToContentType(name);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517 if (contentType >= FileContentType_StartUser && // It is forbidden to modify internal attachments
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518 contentType <= FileContentType_EndUser &&
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519 context.AddAttachment(publicId, StringToContentType(name), data, call.GetPutBody().size()))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
521 call.GetOutput().AnswerBuffer("{}", "application/json");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
522 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
523 }
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
526 static void DeleteAttachment(RestApi::DeleteCall& call)
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 CheckValidResourceType(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530 std::string publicId = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
531 std::string name = call.GetUriComponent("name", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532 FileContentType contentType = StringToContentType(name);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
533
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
534 if (contentType >= FileContentType_StartUser &&
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535 contentType <= FileContentType_EndUser)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537 // It is forbidden to delete internal attachments
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
538 OrthancRestApi::GetIndex(call).DeleteAttachment(publicId, contentType);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539 call.GetOutput().AnswerBuffer("{}", "application/json");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
540 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541 }
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
782
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
544 // Raw access to the DICOM tags of an instance ------------------------------
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
545
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
546 static void GetRawContent(RestApi::GetCall& call)
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
547 {
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
548 std::string id = call.GetUriComponent("id", "");
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
549
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
550 ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), id);
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
551
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
552 locker.GetDicom().SendPathValue(call.GetOutput(), call.GetTrailingUri());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
553 }
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
554
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555
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 void OrthancRestApi::RegisterResources()
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
559 Register("/instances", ListResources<ResourceType_Instance>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560 Register("/patients", ListResources<ResourceType_Patient>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
561 Register("/series", ListResources<ResourceType_Series>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562 Register("/studies", ListResources<ResourceType_Study>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
563
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
564 Register("/instances/{id}", DeleteSingleResource<ResourceType_Instance>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565 Register("/instances/{id}", GetSingleResource<ResourceType_Instance>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
566 Register("/patients/{id}", DeleteSingleResource<ResourceType_Patient>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
567 Register("/patients/{id}", GetSingleResource<ResourceType_Patient>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568 Register("/series/{id}", DeleteSingleResource<ResourceType_Series>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569 Register("/series/{id}", GetSingleResource<ResourceType_Series>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570 Register("/studies/{id}", DeleteSingleResource<ResourceType_Study>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
571 Register("/studies/{id}", GetSingleResource<ResourceType_Study>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
572
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
573 Register("/instances/{id}/statistics", GetResourceStatistics);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
574 Register("/patients/{id}/statistics", GetResourceStatistics);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
575 Register("/studies/{id}/statistics", GetResourceStatistics);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
576 Register("/series/{id}/statistics", GetResourceStatistics);
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 Register("/instances/{id}/file", GetInstanceFile);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579 Register("/instances/{id}/export", ExportInstanceFile);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580 Register("/instances/{id}/tags", GetInstanceTags<false>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581 Register("/instances/{id}/simplified-tags", GetInstanceTags<true>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
582 Register("/instances/{id}/frames", ListFrames);
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 Register("/instances/{id}/frames/{frame}/preview", GetImage<ImageExtractionMode_Preview>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585 Register("/instances/{id}/frames/{frame}/image-uint8", GetImage<ImageExtractionMode_UInt8>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586 Register("/instances/{id}/frames/{frame}/image-uint16", GetImage<ImageExtractionMode_UInt16>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
587 Register("/instances/{id}/frames/{frame}/image-int16", GetImage<ImageExtractionMode_Int16>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
588 Register("/instances/{id}/preview", GetImage<ImageExtractionMode_Preview>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
589 Register("/instances/{id}/image-uint8", GetImage<ImageExtractionMode_UInt8>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
590 Register("/instances/{id}/image-uint16", GetImage<ImageExtractionMode_UInt16>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591 Register("/instances/{id}/image-int16", GetImage<ImageExtractionMode_Int16>);
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 Register("/patients/{id}/protected", IsProtectedPatient);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594 Register("/patients/{id}/protected", SetPatientProtection);
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 Register("/{resourceType}/{id}/metadata", ListMetadata);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
597 Register("/{resourceType}/{id}/metadata/{name}", DeleteMetadata);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
598 Register("/{resourceType}/{id}/metadata/{name}", GetMetadata);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
599 Register("/{resourceType}/{id}/metadata/{name}", SetMetadata);
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 Register("/{resourceType}/{id}/attachments", ListAttachments);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
602 Register("/{resourceType}/{id}/attachments/{name}", DeleteAttachment);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603 Register("/{resourceType}/{id}/attachments/{name}", GetAttachmentOperations);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604 Register("/{resourceType}/{id}/attachments/{name}/compressed-data", GetAttachmentData<0>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605 Register("/{resourceType}/{id}/attachments/{name}/compressed-md5", GetAttachmentCompressedMD5);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
606 Register("/{resourceType}/{id}/attachments/{name}/compressed-size", GetAttachmentCompressedSize);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
607 Register("/{resourceType}/{id}/attachments/{name}/data", GetAttachmentData<1>);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
608 Register("/{resourceType}/{id}/attachments/{name}/md5", GetAttachmentMD5);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
609 Register("/{resourceType}/{id}/attachments/{name}/size", GetAttachmentSize);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
610 Register("/{resourceType}/{id}/attachments/{name}/verify-md5", VerifyAttachment);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
611 Register("/{resourceType}/{id}/attachments/{name}", UploadAttachment);
782
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
612
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
613 Register("/instances/{id}/content/*", GetRawContent);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
614 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
615 }