Mercurial > hg > orthanc
annotate OrthancServer/OrthancInitialization.cpp @ 689:2d0a347e8cfc
switch to 2014
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 03 Feb 2014 16:06:58 +0100 |
parents | b01cc78caba4 |
children | 2e67366aab83 |
rev | line source |
---|---|
0 | 1 /** |
62 | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
689 | 3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, |
0 | 4 * Belgium |
5 * | |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
136 | 10 * |
11 * In addition, as a special exception, the copyright holders of this | |
12 * program give permission to link the code of its release with the | |
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
14 * that use the same license as the "OpenSSL" library), and distribute | |
15 * the linked executables. You must obey the GNU General Public License | |
16 * in all respects for all of the code used other than "OpenSSL". If you | |
17 * modify file(s) with this exception, you may extend this exception to | |
18 * your version of the file(s), but you are not obligated to do so. If | |
19 * you do not wish to do so, delete this exception statement from your | |
20 * version. If you delete this exception statement from all source files | |
21 * in the program, then also delete it here. | |
0 | 22 * |
23 * This program is distributed in the hope that it will be useful, but | |
24 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
26 * General Public License for more details. | |
27 * | |
28 * You should have received a copy of the GNU General Public License | |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
30 **/ | |
31 | |
32 | |
62 | 33 #include "OrthancInitialization.h" |
0 | 34 |
476 | 35 #include "../Core/HttpClient.h" |
62 | 36 #include "../Core/OrthancException.h" |
0 | 37 #include "../Core/Toolbox.h" |
685
b01cc78caba4
possibility to disable the DICOM/HTTP servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
660
diff
changeset
|
38 #include "DicomProtocol/DicomServer.h" |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
39 #include "ServerEnumerations.h" |
0 | 40 |
41 #include <boost/lexical_cast.hpp> | |
42 #include <boost/filesystem.hpp> | |
43 #include <curl/curl.h> | |
44 #include <boost/thread.hpp> | |
108 | 45 #include <glog/logging.h> |
0 | 46 |
62 | 47 namespace Orthanc |
0 | 48 { |
49 static boost::mutex globalMutex_; | |
50 static std::auto_ptr<Json::Value> configuration_; | |
394
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
51 static boost::filesystem::path defaultDirectory_; |
0 | 52 |
53 static void ReadGlobalConfiguration(const char* configurationFile) | |
54 { | |
55 configuration_.reset(new Json::Value); | |
56 | |
57 std::string content; | |
58 | |
59 if (configurationFile) | |
60 { | |
61 Toolbox::ReadFile(content, configurationFile); | |
394
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
62 defaultDirectory_ = boost::filesystem::path(configurationFile).parent_path(); |
660 | 63 LOG(WARNING) << "Using the configuration from: " << configurationFile; |
0 | 64 } |
65 else | |
66 { | |
660 | 67 #if ORTHANC_STANDALONE == 1 |
68 // No default path for the standalone configuration | |
69 LOG(WARNING) << "Using the default Orthanc configuration"; | |
70 return; | |
71 | |
72 #else | |
73 // In a non-standalone build, we use the | |
74 // "Resources/Configuration.json" from the Orthanc source code | |
75 | |
19 | 76 try |
77 { | |
660 | 78 boost::filesystem::path p = ORTHANC_PATH; |
79 p /= "Resources"; | |
80 p /= "Configuration.json"; | |
87
8517e2c44283
path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
81 Toolbox::ReadFile(content, p.string()); |
660 | 82 LOG(WARNING) << "Using the configuration from: " << p.string(); |
87
8517e2c44283
path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
83 } |
8517e2c44283
path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
84 catch (OrthancException&) |
8517e2c44283
path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
85 { |
8517e2c44283
path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
86 // No configuration file found, give up with empty configuration |
660 | 87 LOG(WARNING) << "Using the default Orthanc configuration"; |
19 | 88 return; |
89 } | |
87
8517e2c44283
path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
90 #endif |
0 | 91 } |
92 | |
93 Json::Reader reader; | |
94 if (!reader.parse(content, *configuration_)) | |
95 { | |
62 | 96 throw OrthancException("Unable to read the configuration file"); |
0 | 97 } |
98 } | |
99 | |
100 | |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
101 static void RegisterUserMetadata() |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
102 { |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
103 if (configuration_->isMember("UserMetadata")) |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
104 { |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
105 const Json::Value& parameter = (*configuration_) ["UserMetadata"]; |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
106 |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
107 Json::Value::Members members = parameter.getMemberNames(); |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
108 for (size_t i = 0; i < members.size(); i++) |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
109 { |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
110 std::string info = "\"" + members[i] + "\" = " + parameter[members[i]].toStyledString(); |
660 | 111 LOG(WARNING) << "Registering user-defined metadata: " << info; |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
112 |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
113 if (!parameter[members[i]].asBool()) |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
114 { |
439 | 115 LOG(ERROR) << "Not a number in this user-defined metadata: " << info; |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
116 throw OrthancException(ErrorCode_BadParameterType); |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
117 } |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
118 |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
119 int metadata = parameter[members[i]].asInt(); |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
120 |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
121 try |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
122 { |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
123 RegisterUserMetadata(metadata, members[i]); |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
124 } |
657
5425bb6f1ea5
further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
125 catch (OrthancException&) |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
126 { |
439 | 127 LOG(ERROR) << "Cannot register this user-defined metadata: " << info; |
657
5425bb6f1ea5
further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
128 throw; |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
129 } |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
130 } |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
131 } |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
132 } |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
133 |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
134 |
62 | 135 void OrthancInitialize(const char* configurationFile) |
0 | 136 { |
137 boost::mutex::scoped_lock lock(globalMutex_); | |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
138 |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
139 InitializeServerEnumerations(); |
394
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
140 defaultDirectory_ = boost::filesystem::current_path(); |
0 | 141 ReadGlobalConfiguration(configurationFile); |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
142 |
457 | 143 HttpClient::GlobalInitialize(); |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
144 |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
145 RegisterUserMetadata(); |
685
b01cc78caba4
possibility to disable the DICOM/HTTP servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
660
diff
changeset
|
146 |
b01cc78caba4
possibility to disable the DICOM/HTTP servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
660
diff
changeset
|
147 DicomServer::InitializeDictionary(); |
0 | 148 } |
149 | |
150 | |
151 | |
62 | 152 void OrthancFinalize() |
0 | 153 { |
154 boost::mutex::scoped_lock lock(globalMutex_); | |
457 | 155 HttpClient::GlobalFinalize(); |
0 | 156 configuration_.reset(NULL); |
157 } | |
158 | |
159 | |
160 | |
161 std::string GetGlobalStringParameter(const std::string& parameter, | |
162 const std::string& defaultValue) | |
163 { | |
164 boost::mutex::scoped_lock lock(globalMutex_); | |
165 | |
166 if (configuration_->isMember(parameter)) | |
167 { | |
168 return (*configuration_) [parameter].asString(); | |
169 } | |
170 else | |
171 { | |
172 return defaultValue; | |
173 } | |
174 } | |
175 | |
176 | |
177 int GetGlobalIntegerParameter(const std::string& parameter, | |
178 int defaultValue) | |
179 { | |
180 boost::mutex::scoped_lock lock(globalMutex_); | |
181 | |
182 if (configuration_->isMember(parameter)) | |
183 { | |
184 return (*configuration_) [parameter].asInt(); | |
185 } | |
186 else | |
187 { | |
188 return defaultValue; | |
189 } | |
190 } | |
191 | |
23 | 192 bool GetGlobalBoolParameter(const std::string& parameter, |
193 bool defaultValue) | |
194 { | |
195 boost::mutex::scoped_lock lock(globalMutex_); | |
196 | |
197 if (configuration_->isMember(parameter)) | |
198 { | |
199 return (*configuration_) [parameter].asBool(); | |
200 } | |
201 else | |
202 { | |
203 return defaultValue; | |
204 } | |
205 } | |
206 | |
207 | |
0 | 208 |
209 | |
617 | 210 void GetDicomModalityUsingSymbolicName(const std::string& name, |
211 std::string& aet, | |
212 std::string& address, | |
213 int& port, | |
214 ModalityManufacturer& manufacturer) | |
0 | 215 { |
216 boost::mutex::scoped_lock lock(globalMutex_); | |
217 | |
218 if (!configuration_->isMember("DicomModalities")) | |
219 { | |
62 | 220 throw OrthancException(""); |
0 | 221 } |
222 | |
223 const Json::Value& modalities = (*configuration_) ["DicomModalities"]; | |
224 if (modalities.type() != Json::objectValue || | |
519
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
485
diff
changeset
|
225 !modalities.isMember(name) || |
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
485
diff
changeset
|
226 (modalities[name].size() != 3 && modalities[name].size() != 4)) |
0 | 227 { |
62 | 228 throw OrthancException(""); |
0 | 229 } |
230 | |
231 try | |
232 { | |
233 aet = modalities[name].get(0u, "").asString(); | |
234 address = modalities[name].get(1u, "").asString(); | |
235 port = modalities[name].get(2u, "").asInt(); | |
519
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
485
diff
changeset
|
236 |
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
485
diff
changeset
|
237 if (modalities[name].size() == 4) |
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
485
diff
changeset
|
238 { |
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
485
diff
changeset
|
239 manufacturer = StringToModalityManufacturer(modalities[name].get(3u, "").asString()); |
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
485
diff
changeset
|
240 } |
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
485
diff
changeset
|
241 else |
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
485
diff
changeset
|
242 { |
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
485
diff
changeset
|
243 manufacturer = ModalityManufacturer_Generic; |
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
485
diff
changeset
|
244 } |
0 | 245 } |
246 catch (...) | |
247 { | |
62 | 248 throw OrthancException("Badly formatted DICOM modality"); |
0 | 249 } |
250 } | |
251 | |
252 | |
253 | |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
254 void GetOrthancPeer(const std::string& name, |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
255 std::string& url, |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
256 std::string& username, |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
257 std::string& password) |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
258 { |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
259 boost::mutex::scoped_lock lock(globalMutex_); |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
260 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
261 if (!configuration_->isMember("OrthancPeers")) |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
262 { |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
263 throw OrthancException(""); |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
264 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
265 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
266 const Json::Value& modalities = (*configuration_) ["OrthancPeers"]; |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
267 if (modalities.type() != Json::objectValue || |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
268 !modalities.isMember(name)) |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
269 { |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
270 throw OrthancException(""); |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
271 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
272 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
273 try |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
274 { |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
275 url = modalities[name].get(0u, "").asString(); |
485
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
276 |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
277 if (modalities[name].size() == 1) |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
278 { |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
279 username = ""; |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
280 password = ""; |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
281 } |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
282 else if (modalities[name].size() == 3) |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
283 { |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
284 username = modalities[name].get(1u, "").asString(); |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
285 password = modalities[name].get(2u, "").asString(); |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
286 } |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
287 else |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
288 { |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
289 throw OrthancException(ErrorCode_BadFileFormat); |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
290 } |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
291 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
292 catch (...) |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
293 { |
485
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
294 throw OrthancException(ErrorCode_BadFileFormat); |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
295 } |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
296 |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
297 if (url.size() != 0 && url[url.size() - 1] != '/') |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
298 { |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
299 url += '/'; |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
300 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
301 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
302 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
303 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
304 static bool ReadKeys(std::set<std::string>& target, |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
305 const char* parameter, |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
306 bool onlyAlphanumeric) |
0 | 307 { |
308 boost::mutex::scoped_lock lock(globalMutex_); | |
309 | |
310 target.clear(); | |
311 | |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
312 if (!configuration_->isMember(parameter)) |
0 | 313 { |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
314 return true; |
0 | 315 } |
316 | |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
317 const Json::Value& modalities = (*configuration_) [parameter]; |
0 | 318 if (modalities.type() != Json::objectValue) |
319 { | |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
320 throw OrthancException(ErrorCode_BadFileFormat); |
0 | 321 } |
322 | |
323 Json::Value::Members members = modalities.getMemberNames(); | |
324 for (size_t i = 0; i < members.size(); i++) | |
325 { | |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
326 if (onlyAlphanumeric) |
0 | 327 { |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
328 for (size_t j = 0; j < members[i].size(); j++) |
0 | 329 { |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
330 if (!isalnum(members[i][j]) && members[i][j] != '-') |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
331 { |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
332 return false; |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
333 } |
0 | 334 } |
335 } | |
336 | |
337 target.insert(members[i]); | |
338 } | |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
339 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
340 return true; |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
341 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
342 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
343 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
344 void GetListOfDicomModalities(std::set<std::string>& target) |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
345 { |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
346 if (!ReadKeys(target, "DicomModalities", true)) |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
347 { |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
348 throw OrthancException("Only alphanumeric and dash characters are allowed in the names of the modalities"); |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
349 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
350 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
351 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
352 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
353 void GetListOfOrthancPeers(std::set<std::string>& target) |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
354 { |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
355 if (!ReadKeys(target, "OrthancPeers", true)) |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
356 { |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
357 throw OrthancException("Only alphanumeric and dash characters are allowed in the names of Orthanc peers"); |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
358 } |
0 | 359 } |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
360 |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
361 |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
362 |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
363 void SetupRegisteredUsers(MongooseServer& httpServer) |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
364 { |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
365 boost::mutex::scoped_lock lock(globalMutex_); |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
366 |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
367 httpServer.ClearUsers(); |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
368 |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
369 if (!configuration_->isMember("RegisteredUsers")) |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
370 { |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
371 return; |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
372 } |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
373 |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
374 const Json::Value& users = (*configuration_) ["RegisteredUsers"]; |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
375 if (users.type() != Json::objectValue) |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
376 { |
62 | 377 throw OrthancException("Badly formatted list of users"); |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
378 } |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
379 |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
380 Json::Value::Members usernames = users.getMemberNames(); |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
381 for (size_t i = 0; i < usernames.size(); i++) |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
382 { |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
383 const std::string& username = usernames[i]; |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
384 std::string password = users[username].asString(); |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
385 httpServer.RegisterUser(username.c_str(), password.c_str()); |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
386 } |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
387 } |
394
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
388 |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
389 |
429
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
390 std::string InterpretRelativePath(const std::string& baseDirectory, |
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
391 const std::string& relativePath) |
394
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
392 { |
429
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
393 boost::filesystem::path base(baseDirectory); |
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
394 boost::filesystem::path relative(relativePath); |
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
395 |
428 | 396 /** |
397 The following lines should be equivalent to this one: | |
398 | |
429
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
399 return (base / relative).string(); |
428 | 400 |
401 However, for some unknown reason, some versions of Boost do not | |
429
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
402 make the proper path resolution when "baseDirectory" is an |
428 | 403 absolute path. So, a hack is used below. |
404 **/ | |
405 | |
429
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
406 if (relative.is_absolute()) |
427 | 407 { |
429
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
408 return relative.string(); |
427 | 409 } |
410 else | |
411 { | |
429
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
412 return (base / relative).string(); |
427 | 413 } |
394
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
414 } |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
415 |
429
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
416 std::string InterpretStringParameterAsPath(const std::string& parameter) |
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
417 { |
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
418 boost::mutex::scoped_lock lock(globalMutex_); |
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
419 return InterpretRelativePath(defaultDirectory_.string(), parameter); |
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
420 } |
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
421 |
394
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
422 |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
423 void GetGlobalListOfStringsParameter(std::list<std::string>& target, |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
424 const std::string& key) |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
425 { |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
426 boost::mutex::scoped_lock lock(globalMutex_); |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
427 |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
428 target.clear(); |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
429 |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
430 if (!configuration_->isMember(key)) |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
431 { |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
432 return; |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
433 } |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
434 |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
435 const Json::Value& lst = (*configuration_) [key]; |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
436 |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
437 if (lst.type() != Json::arrayValue) |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
438 { |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
439 throw OrthancException("Badly formatted list of strings"); |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
440 } |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
441 |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
442 for (Json::Value::ArrayIndex i = 0; i < lst.size(); i++) |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
443 { |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
444 target.push_back(lst[i].asString()); |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
445 } |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
446 } |
613 | 447 |
448 | |
449 void ConnectToModalityUsingSymbolicName(DicomUserConnection& connection, | |
450 const std::string& name) | |
451 { | |
452 std::string aet, address; | |
453 int port; | |
454 ModalityManufacturer manufacturer; | |
617 | 455 GetDicomModalityUsingSymbolicName(name, aet, address, port, manufacturer); |
613 | 456 |
457 LOG(WARNING) << "Connecting to remote DICOM modality: AET=" << aet << ", address=" << address << ", port=" << port; | |
458 | |
459 connection.SetLocalApplicationEntityTitle(GetGlobalStringParameter("DicomAet", "ORTHANC")); | |
460 connection.SetDistantApplicationEntityTitle(aet); | |
461 connection.SetDistantHost(address); | |
462 connection.SetDistantPort(port); | |
463 connection.SetDistantManufacturer(manufacturer); | |
464 connection.Open(); | |
465 } | |
466 | |
467 | |
617 | 468 bool LookupDicomModalityUsingAETitle(const std::string& aet, |
469 std::string& symbolicName, | |
470 std::string& address, | |
471 int& port, | |
472 ModalityManufacturer& manufacturer) | |
613 | 473 { |
474 std::set<std::string> modalities; | |
475 GetListOfDicomModalities(modalities); | |
476 | |
477 for (std::set<std::string>::const_iterator | |
656 | 478 it = modalities.begin(); it != modalities.end(); ++it) |
613 | 479 { |
480 try | |
481 { | |
482 std::string thisAet; | |
617 | 483 GetDicomModalityUsingSymbolicName(*it, thisAet, address, port, manufacturer); |
613 | 484 |
485 if (aet == thisAet) | |
486 { | |
617 | 487 return true; |
613 | 488 } |
489 } | |
490 catch (OrthancException&) | |
491 { | |
492 } | |
493 } | |
494 | |
617 | 495 return false; |
496 } | |
497 | |
498 | |
499 bool IsKnownAETitle(const std::string& aet) | |
500 { | |
501 std::string symbolicName, address; | |
502 int port; | |
503 ModalityManufacturer manufacturer; | |
504 | |
505 return LookupDicomModalityUsingAETitle(aet, symbolicName, address, port, manufacturer); | |
506 } | |
507 | |
508 | |
509 void ConnectToModalityUsingAETitle(DicomUserConnection& connection, | |
510 const std::string& aet) | |
511 { | |
512 std::string symbolicName, address; | |
513 int port; | |
514 ModalityManufacturer manufacturer; | |
515 | |
516 if (!LookupDicomModalityUsingAETitle(aet, symbolicName, address, port, manufacturer)) | |
613 | 517 { |
518 throw OrthancException("Unknown modality: " + aet); | |
519 } | |
520 | |
521 LOG(WARNING) << "Connecting to remote DICOM modality: AET=" << aet << ", address=" << address << ", port=" << port; | |
522 | |
523 connection.SetLocalApplicationEntityTitle(GetGlobalStringParameter("DicomAet", "ORTHANC")); | |
524 connection.SetDistantApplicationEntityTitle(aet); | |
525 connection.SetDistantHost(address); | |
526 connection.SetDistantPort(port); | |
527 connection.SetDistantManufacturer(manufacturer); | |
528 connection.Open(); | |
529 } | |
0 | 530 } |