Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Oracle/GenericOracleRunner.cpp @ 1792:373d7f7e796e
ICompositor::ComputeTextBoundingBox()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 17 May 2021 16:59:03 +0200 |
parents | e38b9875a969 |
children | 3889ae96d2e9 |
rev | line source |
---|---|
1077 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1624
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
1077 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
1077 | 9 * as published by the Free Software Foundation, either version 3 of |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
1077 | 20 **/ |
21 | |
22 | |
23 #include "GenericOracleRunner.h" | |
24 | |
1110
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
25 #if !defined(ORTHANC_ENABLE_DCMTK) |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
26 # error The macro ORTHANC_ENABLE_DCMTK must be defined |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
27 #endif |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
28 |
1077 | 29 #include "GetOrthancImageCommand.h" |
30 #include "GetOrthancWebViewerJpegCommand.h" | |
31 #include "HttpCommand.h" | |
32 #include "OracleCommandExceptionMessage.h" | |
33 #include "OrthancRestApiCommand.h" | |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
34 #include "ParseDicomFromFileCommand.h" |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
35 #include "ParseDicomFromWadoCommand.h" |
1104 | 36 #include "ReadFileCommand.h" |
1077 | 37 |
1110
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
38 #if ORTHANC_ENABLE_DCMTK == 1 |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
39 # include "ParseDicomSuccessMessage.h" |
1110
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
40 # include <dcmtk/dcmdata/dcdeftag.h> |
1153 | 41 # include <dcmtk/dcmdata/dcfilefo.h> |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
42 static unsigned int BUCKET_DICOMDIR = 0; |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
43 static unsigned int BUCKET_SOP = 1; |
1110
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
44 #endif |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
45 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1299
diff
changeset
|
46 #include <Compression/GzipCompressor.h> |
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1299
diff
changeset
|
47 #include <HttpClient.h> |
1624 | 48 #include <Logging.h> |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1299
diff
changeset
|
49 #include <OrthancException.h> |
1624 | 50 #include <SystemToolbox.h> |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1299
diff
changeset
|
51 #include <Toolbox.h> |
1104 | 52 |
53 #include <boost/filesystem.hpp> | |
1077 | 54 |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
55 |
1110
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
56 |
1077 | 57 namespace OrthancStone |
58 { | |
59 static void CopyHttpHeaders(Orthanc::HttpClient& client, | |
60 const Orthanc::HttpClient::HttpHeaders& headers) | |
61 { | |
62 for (Orthanc::HttpClient::HttpHeaders::const_iterator | |
1571 | 63 it = headers.begin(); it != headers.end(); ++it ) |
1077 | 64 { |
65 client.AddHeader(it->first, it->second); | |
66 } | |
67 } | |
68 | |
69 | |
70 static void DecodeAnswer(std::string& answer, | |
71 const Orthanc::HttpClient::HttpHeaders& headers) | |
72 { | |
73 Orthanc::HttpCompression contentEncoding = Orthanc::HttpCompression_None; | |
74 | |
75 for (Orthanc::HttpClient::HttpHeaders::const_iterator it = headers.begin(); | |
76 it != headers.end(); ++it) | |
77 { | |
78 std::string s; | |
79 Orthanc::Toolbox::ToLowerCase(s, it->first); | |
80 | |
81 if (s == "content-encoding") | |
82 { | |
83 if (it->second == "gzip") | |
84 { | |
85 contentEncoding = Orthanc::HttpCompression_Gzip; | |
86 } | |
87 else | |
88 { | |
89 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol, | |
90 "Unsupported HTTP Content-Encoding: " + it->second); | |
91 } | |
92 | |
93 break; | |
94 } | |
95 } | |
96 | |
97 if (contentEncoding == Orthanc::HttpCompression_Gzip) | |
98 { | |
99 std::string compressed; | |
100 answer.swap(compressed); | |
101 | |
102 Orthanc::GzipCompressor compressor; | |
103 compressor.Uncompress(answer, compressed.c_str(), compressed.size()); | |
104 | |
105 LOG(INFO) << "Uncompressing gzip Encoding: from " << compressed.size() | |
106 << " to " << answer.size() << " bytes"; | |
107 } | |
108 } | |
109 | |
110 | |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
111 static void RunHttpCommand(std::string& answer, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
112 Orthanc::HttpClient::HttpHeaders& answerHeaders, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
113 const HttpCommand& command) |
1077 | 114 { |
115 Orthanc::HttpClient client; | |
116 client.SetUrl(command.GetUrl()); | |
117 client.SetMethod(command.GetMethod()); | |
118 client.SetTimeout(command.GetTimeout()); | |
119 | |
120 CopyHttpHeaders(client, command.GetHttpHeaders()); | |
121 | |
1079
e6d2ff8f1ab4
credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1077
diff
changeset
|
122 if (command.HasCredentials()) |
e6d2ff8f1ab4
credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1077
diff
changeset
|
123 { |
e6d2ff8f1ab4
credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1077
diff
changeset
|
124 client.SetCredentials(command.GetUsername().c_str(), command.GetPassword().c_str()); |
e6d2ff8f1ab4
credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1077
diff
changeset
|
125 } |
e6d2ff8f1ab4
credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1077
diff
changeset
|
126 |
1077 | 127 if (command.GetMethod() == Orthanc::HttpMethod_Post || |
128 command.GetMethod() == Orthanc::HttpMethod_Put) | |
129 { | |
1760
e38b9875a969
adaptation to change in API of Orthanc::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
130 client.SetExternalBody(command.GetBody()); |
1077 | 131 } |
132 | |
133 client.ApplyAndThrowException(answer, answerHeaders); | |
1760
e38b9875a969
adaptation to change in API of Orthanc::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
134 client.ClearBody(); |
e38b9875a969
adaptation to change in API of Orthanc::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
135 |
1077 | 136 DecodeAnswer(answer, answerHeaders); |
137 } | |
138 | |
139 | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
140 static void RunInternal(boost::weak_ptr<IObserver> receiver, |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
141 IMessageEmitter& emitter, |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
142 const HttpCommand& command) |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
143 { |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
144 std::string answer; |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
145 Orthanc::HttpClient::HttpHeaders answerHeaders; |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
146 RunHttpCommand(answer, answerHeaders, command); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
147 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
148 HttpCommand::SuccessMessage message(command, answerHeaders, answer); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
149 emitter.EmitMessage(receiver, message); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
150 } |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
151 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
152 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
153 static void RunOrthancRestApiCommand(std::string& answer, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
154 Orthanc::HttpClient::HttpHeaders& answerHeaders, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
155 const Orthanc::WebServiceParameters& orthanc, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
156 const OrthancRestApiCommand& command) |
1077 | 157 { |
158 Orthanc::HttpClient client(orthanc, command.GetUri()); | |
1254
7a0460c5e98e
don't follow redirections if contacting the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1153
diff
changeset
|
159 client.SetRedirectionFollowed(false); |
1077 | 160 client.SetMethod(command.GetMethod()); |
161 client.SetTimeout(command.GetTimeout()); | |
162 | |
163 CopyHttpHeaders(client, command.GetHttpHeaders()); | |
164 | |
165 if (command.GetMethod() == Orthanc::HttpMethod_Post || | |
166 command.GetMethod() == Orthanc::HttpMethod_Put) | |
167 { | |
1760
e38b9875a969
adaptation to change in API of Orthanc::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
168 client.SetExternalBody(command.GetBody()); |
1077 | 169 } |
170 | |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
171 client.ApplyAndThrowException(answer, answerHeaders); |
1760
e38b9875a969
adaptation to change in API of Orthanc::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
172 client.ClearBody(); |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
173 DecodeAnswer(answer, answerHeaders); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
174 } |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
175 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
176 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
177 static void RunInternal(boost::weak_ptr<IObserver> receiver, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
178 IMessageEmitter& emitter, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
179 const Orthanc::WebServiceParameters& orthanc, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
180 const OrthancRestApiCommand& command) |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
181 { |
1077 | 182 std::string answer; |
183 Orthanc::HttpClient::HttpHeaders answerHeaders; | |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
184 RunOrthancRestApiCommand(answer, answerHeaders, orthanc, command); |
1077 | 185 |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
186 OrthancRestApiCommand::SuccessMessage message(command, answerHeaders, answer); |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
187 emitter.EmitMessage(receiver, message); |
1077 | 188 } |
189 | |
190 | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
191 static void RunInternal(boost::weak_ptr<IObserver> receiver, |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
192 IMessageEmitter& emitter, |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
193 const Orthanc::WebServiceParameters& orthanc, |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
194 const GetOrthancImageCommand& command) |
1077 | 195 { |
196 Orthanc::HttpClient client(orthanc, command.GetUri()); | |
1254
7a0460c5e98e
don't follow redirections if contacting the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1153
diff
changeset
|
197 client.SetRedirectionFollowed(false); |
1077 | 198 client.SetTimeout(command.GetTimeout()); |
199 | |
200 CopyHttpHeaders(client, command.GetHttpHeaders()); | |
201 | |
202 std::string answer; | |
203 Orthanc::HttpClient::HttpHeaders answerHeaders; | |
204 client.ApplyAndThrowException(answer, answerHeaders); | |
205 | |
206 DecodeAnswer(answer, answerHeaders); | |
207 | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
208 command.ProcessHttpAnswer(receiver, emitter, answer, answerHeaders); |
1077 | 209 } |
210 | |
211 | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
212 static void RunInternal(boost::weak_ptr<IObserver> receiver, |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
213 IMessageEmitter& emitter, |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
214 const Orthanc::WebServiceParameters& orthanc, |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
215 const GetOrthancWebViewerJpegCommand& command) |
1077 | 216 { |
217 Orthanc::HttpClient client(orthanc, command.GetUri()); | |
1254
7a0460c5e98e
don't follow redirections if contacting the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1153
diff
changeset
|
218 client.SetRedirectionFollowed(false); |
1077 | 219 client.SetTimeout(command.GetTimeout()); |
220 | |
221 CopyHttpHeaders(client, command.GetHttpHeaders()); | |
222 | |
223 std::string answer; | |
224 Orthanc::HttpClient::HttpHeaders answerHeaders; | |
225 client.ApplyAndThrowException(answer, answerHeaders); | |
226 | |
227 DecodeAnswer(answer, answerHeaders); | |
228 | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
229 command.ProcessHttpAnswer(receiver, emitter, answer); |
1077 | 230 } |
231 | |
232 | |
1110
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
233 static std::string GetPath(const std::string& root, |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
234 const std::string& file) |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
235 { |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
236 boost::filesystem::path a(root); |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
237 boost::filesystem::path b(file); |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
238 |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
239 boost::filesystem::path c; |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
240 if (b.is_absolute()) |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
241 { |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
242 c = b; |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
243 } |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
244 else |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
245 { |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
246 c = a / b; |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
247 } |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
248 |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
249 return c.string(); |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
250 } |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
251 |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
252 |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
253 static void RunInternal(boost::weak_ptr<IObserver> receiver, |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
254 IMessageEmitter& emitter, |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
255 const std::string& root, |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
256 const ReadFileCommand& command) |
1104 | 257 { |
1110
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
258 std::string path = GetPath(root, command.GetPath()); |
1149
2da8b4d6f8c1
renamed ParsedDicomFileCache as ParsedDicomCache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
259 LOG(TRACE) << "Oracle reading file: " << path; |
1110
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
260 |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
261 std::string content; |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
262 Orthanc::SystemToolbox::ReadFile(content, path, true /* log */); |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
263 |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
264 ReadFileCommand::SuccessMessage message(command, content); |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
265 emitter.EmitMessage(receiver, message); |
1110
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
266 } |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
267 |
1104 | 268 |
1110
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
269 #if ORTHANC_ENABLE_DCMTK == 1 |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
270 static Orthanc::ParsedDicomFile* ParseDicom(uint64_t& fileSize, /* OUT */ |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
271 const std::string& path, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
272 bool isPixelData) |
1110
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
273 { |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
274 if (!Orthanc::SystemToolbox::IsRegularFile(path)) |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
275 { |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
276 throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentFile); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
277 } |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
278 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
279 LOG(TRACE) << "Parsing DICOM file, " << (isPixelData ? "with" : "without") |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
280 << " pixel data: " << path; |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
281 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
282 boost::posix_time::ptime start = boost::posix_time::microsec_clock::local_time(); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
283 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
284 fileSize = Orthanc::SystemToolbox::GetFileSize(path); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
285 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
286 // Check for 32bit systems |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
287 if (fileSize != static_cast<uint64_t>(static_cast<size_t>(fileSize))) |
1104 | 288 { |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
289 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotEnoughMemory); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
290 } |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
291 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
292 DcmFileFormat dicom; |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
293 bool ok; |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
294 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
295 if (isPixelData) |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
296 { |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
297 ok = dicom.loadFile(path.c_str()).good(); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
298 } |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
299 else |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
300 { |
1136
42581a6182c8
reactivation of the cache of parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
301 #if DCMTK_VERSION_NUMBER >= 362 |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
302 /** |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
303 * NB : We could stop at (0x3007, 0x0000) instead of |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
304 * DCM_PixelData as the Stone framework does not use further |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
305 * tags (cf. the Orthanc::DICOM_TAG_* constants), but we still |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
306 * use "PixelData" as this does not change the runtime much, and |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
307 * as it is more explicit. |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
308 **/ |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
309 static const DcmTagKey STOP = DCM_PixelData; |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
310 //static const DcmTagKey STOP(0x3007, 0x0000); |
1148 | 311 |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
312 ok = dicom.loadFileUntilTag(path.c_str(), EXS_Unknown, EGL_noChange, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
313 DCM_MaxReadLength, ERM_autoDetect, STOP).good(); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
314 #else |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
315 // The primitive "loadFileUntilTag" was introduced in DCMTK 3.6.2 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
316 ok = dicom.loadFile(path.c_str()).good(); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
317 #endif |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
318 } |
1104 | 319 |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
320 if (ok) |
1110
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
321 { |
1299
c38c89684d83
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1271
diff
changeset
|
322 std::unique_ptr<Orthanc::ParsedDicomFile> result(new Orthanc::ParsedDicomFile(dicom)); |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
323 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
324 boost::posix_time::ptime end = boost::posix_time::microsec_clock::local_time(); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
325 LOG(TRACE) << path << ": parsed in " << (end-start).total_milliseconds() << " ms"; |
1136
42581a6182c8
reactivation of the cache of parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
326 |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
327 return result.release(); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
328 } |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
329 else |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
330 { |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
331 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
332 "Cannot parse file: " + path); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
333 } |
1104 | 334 } |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1116
diff
changeset
|
335 |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
336 |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
337 static void RunInternal(boost::weak_ptr<IObserver> receiver, |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
338 IMessageEmitter& emitter, |
1150 | 339 boost::shared_ptr<ParsedDicomCache> cache, |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
340 const std::string& root, |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
341 const ParseDicomFromFileCommand& command) |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1116
diff
changeset
|
342 { |
1137
cc029987b6dc
improved cache key
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1136
diff
changeset
|
343 const std::string path = GetPath(root, command.GetPath()); |
cc029987b6dc
improved cache key
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1136
diff
changeset
|
344 |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
345 if (cache) |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1116
diff
changeset
|
346 { |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
347 ParsedDicomCache::Reader reader(*cache, BUCKET_DICOMDIR, path); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
348 if (reader.IsValid() && |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
349 (!command.IsPixelDataIncluded() || |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
350 reader.HasPixelData())) |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1116
diff
changeset
|
351 { |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
352 // Reuse the DICOM file from the cache |
1484
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
353 ParseDicomSuccessMessage message(command, command.GetSource(), reader.GetDicom(), |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
354 reader.GetFileSize(), reader.HasPixelData()); |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
355 emitter.EmitMessage(receiver, message); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
356 return; |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1116
diff
changeset
|
357 } |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
358 } |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
359 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
360 uint64_t fileSize; |
1299
c38c89684d83
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1271
diff
changeset
|
361 std::unique_ptr<Orthanc::ParsedDicomFile> parsed(ParseDicom(fileSize, path, command.IsPixelDataIncluded())); |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
362 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
363 if (fileSize != static_cast<size_t>(fileSize)) |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
364 { |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
365 // Cannot load such a large file on 32-bit architecture |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
366 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotEnoughMemory); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
367 } |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
368 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
369 { |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
370 ParseDicomSuccessMessage message |
1484
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
371 (command, command.GetSource(), *parsed, |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
372 static_cast<size_t>(fileSize), command.IsPixelDataIncluded()); |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
373 emitter.EmitMessage(receiver, message); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
374 } |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
375 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
376 if (cache) |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
377 { |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
378 // Store it into the cache for future use |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1116
diff
changeset
|
379 |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
380 // Invalidate to overwrite DICOM instance that would already |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
381 // be stored without pixel data |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
382 cache->Invalidate(BUCKET_DICOMDIR, path); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
383 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
384 cache->Acquire(BUCKET_DICOMDIR, path, parsed.release(), |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
385 static_cast<size_t>(fileSize), command.IsPixelDataIncluded()); |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1116
diff
changeset
|
386 } |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
387 } |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
388 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
389 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
390 static void RunInternal(boost::weak_ptr<IObserver> receiver, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
391 IMessageEmitter& emitter, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
392 boost::shared_ptr<ParsedDicomCache> cache, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
393 const Orthanc::WebServiceParameters& orthanc, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
394 const ParseDicomFromWadoCommand& command) |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
395 { |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
396 if (cache) |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1116
diff
changeset
|
397 { |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
398 ParsedDicomCache::Reader reader(*cache, BUCKET_SOP, command.GetSopInstanceUid()); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
399 if (reader.IsValid() && |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
400 reader.HasPixelData()) |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
401 { |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
402 // Reuse the DICOM file from the cache |
1484
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
403 ParseDicomSuccessMessage message(command, command.GetSource(), reader.GetDicom(), |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
404 reader.GetFileSize(), reader.HasPixelData()); |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
405 emitter.EmitMessage(receiver, message); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
406 return; |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
407 } |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1116
diff
changeset
|
408 } |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
409 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
410 std::string answer; |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
411 Orthanc::HttpClient::HttpHeaders answerHeaders; |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
412 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
413 switch (command.GetRestCommand().GetType()) |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
414 { |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
415 case IOracleCommand::Type_Http: |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
416 RunHttpCommand(answer, answerHeaders, dynamic_cast<const HttpCommand&>(command.GetRestCommand())); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
417 break; |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
418 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
419 case IOracleCommand::Type_OrthancRestApi: |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
420 RunOrthancRestApiCommand(answer, answerHeaders, orthanc, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
421 dynamic_cast<const OrthancRestApiCommand&>(command.GetRestCommand())); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
422 break; |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
423 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
424 default: |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
425 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
426 } |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
427 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
428 size_t fileSize; |
1299
c38c89684d83
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1271
diff
changeset
|
429 std::unique_ptr<Orthanc::ParsedDicomFile> parsed(ParseDicomSuccessMessage::ParseWadoAnswer(fileSize, answer, answerHeaders)); |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
430 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
431 { |
1484
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
432 ParseDicomSuccessMessage message(command, command.GetSource(), *parsed, fileSize, |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
433 true /* pixel data always is included in WADO-RS */); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
434 emitter.EmitMessage(receiver, message); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
435 } |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
436 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
437 if (cache) |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
438 { |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
439 // Store it into the cache for future use |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
440 cache->Acquire(BUCKET_SOP, command.GetSopInstanceUid(), parsed.release(), fileSize, true); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
441 } |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1116
diff
changeset
|
442 } |
1110
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
443 #endif |
1104 | 444 |
445 | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
446 void GenericOracleRunner::Run(boost::weak_ptr<IObserver> receiver, |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
447 IMessageEmitter& emitter, |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
448 const IOracleCommand& command) |
1077 | 449 { |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
450 Orthanc::ErrorCode error = Orthanc::ErrorCode_Success; |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
451 |
1077 | 452 try |
453 { | |
454 switch (command.GetType()) | |
455 { | |
456 case IOracleCommand::Type_Sleep: | |
457 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadParameterType, | |
458 "Sleep command cannot be executed by the runner"); | |
459 | |
460 case IOracleCommand::Type_Http: | |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
461 RunInternal(receiver, emitter, dynamic_cast<const HttpCommand&>(command)); |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
462 break; |
1077 | 463 |
464 case IOracleCommand::Type_OrthancRestApi: | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
465 RunInternal(receiver, emitter, orthanc_, |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
466 dynamic_cast<const OrthancRestApiCommand&>(command)); |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
467 break; |
1077 | 468 |
469 case IOracleCommand::Type_GetOrthancImage: | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
470 RunInternal(receiver, emitter, orthanc_, |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
471 dynamic_cast<const GetOrthancImageCommand&>(command)); |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
472 break; |
1077 | 473 |
474 case IOracleCommand::Type_GetOrthancWebViewerJpeg: | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
475 RunInternal(receiver, emitter, orthanc_, |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
476 dynamic_cast<const GetOrthancWebViewerJpegCommand&>(command)); |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
477 break; |
1077 | 478 |
1104 | 479 case IOracleCommand::Type_ReadFile: |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
480 RunInternal(receiver, emitter, rootDirectory_, |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
481 dynamic_cast<const ReadFileCommand&>(command)); |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
482 break; |
1104 | 483 |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
484 case IOracleCommand::Type_ParseDicomFromFile: |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
485 case IOracleCommand::Type_ParseDicomFromWado: |
1110
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
486 #if ORTHANC_ENABLE_DCMTK == 1 |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
487 switch (command.GetType()) |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
488 { |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
489 case IOracleCommand::Type_ParseDicomFromFile: |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
490 RunInternal(receiver, emitter, dicomCache_, rootDirectory_, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
491 dynamic_cast<const ParseDicomFromFileCommand&>(command)); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
492 break; |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
493 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
494 case IOracleCommand::Type_ParseDicomFromWado: |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
495 RunInternal(receiver, emitter, dicomCache_, orthanc_, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
496 dynamic_cast<const ParseDicomFromWadoCommand&>(command)); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
497 break; |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
498 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
499 default: |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
500 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1150
diff
changeset
|
501 } |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
502 break; |
1110
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
503 #else |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
504 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented, |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
505 "DCMTK must be enabled to parse DICOM files"); |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
506 #endif |
b82b74d13830
ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1104
diff
changeset
|
507 |
1077 | 508 default: |
509 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
510 } | |
511 } | |
512 catch (Orthanc::OrthancException& e) | |
513 { | |
514 LOG(ERROR) << "Exception within the oracle: " << e.What(); | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
515 error = e.GetErrorCode(); |
1077 | 516 } |
517 catch (...) | |
518 { | |
519 LOG(ERROR) << "Threaded exception within the oracle"; | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
520 error = Orthanc::ErrorCode_InternalError; |
1077 | 521 } |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
522 |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
523 if (error != Orthanc::ErrorCode_Success) |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
524 { |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
525 OracleCommandExceptionMessage message(command, error); |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
526 emitter.EmitMessage(receiver, message); |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
527 } |
1077 | 528 } |
529 } |