Mercurial > hg > orthanc
annotate OrthancServer/OrthancInitialization.cpp @ 2058:43cd2ab060c7
cont OrthancPluginCppWrapper
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 30 Jun 2016 08:20:23 +0200 |
parents | fefbe71c2272 |
children | fabf7820d1f1 0ad32aeae9f3 |
rev | line source |
---|---|
0 | 1 /** |
62 | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1275
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
0 | 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 | |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
33 #include "PrecompiledHeadersServer.h" |
62 | 34 #include "OrthancInitialization.h" |
0 | 35 |
476 | 36 #include "../Core/HttpClient.h" |
1485
27661b33f624
Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1429
diff
changeset
|
37 #include "../Core/Logging.h" |
62 | 38 #include "../Core/OrthancException.h" |
0 | 39 #include "../Core/Toolbox.h" |
1485
27661b33f624
Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1429
diff
changeset
|
40 #include "../Core/FileStorage/FilesystemStorage.h" |
27661b33f624
Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1429
diff
changeset
|
41 |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
42 #include "ServerEnumerations.h" |
1485
27661b33f624
Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1429
diff
changeset
|
43 #include "DatabaseWrapper.h" |
1656 | 44 #include "FromDcmtkBridge.h" |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1987
diff
changeset
|
45 #include "ToDcmtkBridge.h" |
0 | 46 |
47 #include <boost/lexical_cast.hpp> | |
48 #include <boost/filesystem.hpp> | |
49 #include <curl/curl.h> | |
50 #include <boost/thread.hpp> | |
1274 | 51 |
847
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
52 |
1526
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
53 #if ORTHANC_SSL_ENABLED == 1 |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
54 // For OpenSSL initialization and finalization |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
55 #include <openssl/conf.h> |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
56 #include <openssl/engine.h> |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
57 #include <openssl/err.h> |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
58 #include <openssl/evp.h> |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
59 #include <openssl/ssl.h> |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
60 #endif |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
61 |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
62 |
847
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
63 #if ORTHANC_JPEG_ENABLED == 1 |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
64 #include <dcmtk/dcmjpeg/djdecode.h> |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
65 #endif |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
66 |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
67 |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
68 #if ORTHANC_JPEG_LOSSLESS_ENABLED == 1 |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
69 #include <dcmtk/dcmjpls/djdecode.h> |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
70 #endif |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
71 |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
72 |
1927
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
73 #include <dcmtk/dcmnet/dul.h> |
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
74 |
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
75 |
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
76 |
62 | 77 namespace Orthanc |
0 | 78 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
79 static boost::recursive_mutex globalMutex_; |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
80 static Json::Value configuration_; |
394
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
81 static boost::filesystem::path defaultDirectory_; |
1145
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
82 static std::string configurationAbsolutePath_; |
1610
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
83 static FontRegistry fontRegistry_; |
2010
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
84 static const char* configurationFileArg_ = NULL; |
0 | 85 |
806 | 86 |
1533
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
87 static std::string GetGlobalStringParameterInternal(const std::string& parameter, |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
88 const std::string& defaultValue) |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
89 { |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
90 if (configuration_.isMember(parameter)) |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
91 { |
1592
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
92 if (configuration_[parameter].type() != Json::stringValue) |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
93 { |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
94 LOG(ERROR) << "The configuration option \"" << parameter << "\" must be a string"; |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
95 throw OrthancException(ErrorCode_BadParameterType); |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
96 } |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
97 else |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
98 { |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
99 return configuration_[parameter].asString(); |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
100 } |
1533
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
101 } |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
102 else |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
103 { |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
104 return defaultValue; |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
105 } |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
106 } |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
107 |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
108 |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
109 static bool GetGlobalBoolParameterInternal(const std::string& parameter, |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
110 bool defaultValue) |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
111 { |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
112 if (configuration_.isMember(parameter)) |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
113 { |
1592
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
114 if (configuration_[parameter].type() != Json::booleanValue) |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
115 { |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
116 LOG(ERROR) << "The configuration option \"" << parameter << "\" must be a Boolean (true or false)"; |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
117 throw OrthancException(ErrorCode_BadParameterType); |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
118 } |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
119 else |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
120 { |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
121 return configuration_[parameter].asBool(); |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
122 } |
1533
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
123 } |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
124 else |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
125 { |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
126 return defaultValue; |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
127 } |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
128 } |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
129 |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
130 |
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
131 |
2010
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
132 static void AddFileToConfiguration(Json::Value& target, |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
133 const boost::filesystem::path& path) |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
134 { |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
135 LOG(WARNING) << "Reading the configuration from: " << path; |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
136 |
1424
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
137 Json::Value config; |
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
138 |
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
139 { |
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
140 std::string content; |
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
141 Toolbox::ReadFile(content, path.string()); |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
142 |
1424
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
143 Json::Value tmp; |
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
144 Json::Reader reader; |
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
145 if (!reader.parse(content, tmp) || |
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
146 tmp.type() != Json::objectValue) |
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
147 { |
1596
f2e3d030ea59
BadJson error code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1592
diff
changeset
|
148 LOG(ERROR) << "The configuration file does not follow the JSON syntax: " << path; |
f2e3d030ea59
BadJson error code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1592
diff
changeset
|
149 throw OrthancException(ErrorCode_BadJson); |
1424
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
150 } |
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
151 |
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
152 Toolbox::CopyJsonWithoutComments(config, tmp); |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
153 } |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
154 |
2010
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
155 if (target.size() == 0) |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
156 { |
2010
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
157 target = config; |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
158 } |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
159 else |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
160 { |
1424
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
161 Json::Value::Members members = config.getMemberNames(); |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
162 for (Json::Value::ArrayIndex i = 0; i < members.size(); i++) |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
163 { |
2010
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
164 if (target.isMember(members[i])) |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
165 { |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
166 LOG(ERROR) << "The configuration section \"" << members[i] << "\" is defined in 2 different configuration files"; |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
167 throw OrthancException(ErrorCode_BadFileFormat); |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
168 } |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
169 else |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
170 { |
2010
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
171 target[members[i]] = config[members[i]]; |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
172 } |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
173 } |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
174 } |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
175 } |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
176 |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
177 |
2010
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
178 static void ScanFolderForConfiguration(Json::Value& target, |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
179 const char* folder) |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
180 { |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
181 using namespace boost::filesystem; |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
182 |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
183 LOG(WARNING) << "Scanning folder \"" << folder << "\" for configuration files"; |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
184 |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
185 directory_iterator end_it; // default construction yields past-the-end |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
186 for (directory_iterator it(folder); |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
187 it != end_it; |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
188 ++it) |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
189 { |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
190 if (!is_directory(it->status())) |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
191 { |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
192 std::string extension = boost::filesystem::extension(it->path()); |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
193 Toolbox::ToLowerCase(extension); |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
194 |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
195 if (extension == ".json") |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
196 { |
2010
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
197 AddFileToConfiguration(target, it->path().string()); |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
198 } |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
199 } |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
200 } |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
201 } |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
202 |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
203 |
2010
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
204 static void ReadConfiguration(Json::Value& target, |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
205 const char* configurationFile) |
0 | 206 { |
2010
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
207 target = Json::objectValue; |
0 | 208 |
209 if (configurationFile) | |
210 { | |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
211 if (!boost::filesystem::exists(configurationFile)) |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
212 { |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
213 LOG(ERROR) << "Inexistent path to configuration: " << configurationFile; |
1427
d710ea64f0fd
Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1424
diff
changeset
|
214 throw OrthancException(ErrorCode_InexistentFile); |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
215 } |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
216 |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
217 if (boost::filesystem::is_directory(configurationFile)) |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
218 { |
2010
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
219 ScanFolderForConfiguration(target, configurationFile); |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
220 } |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
221 else |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
222 { |
2010
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
223 AddFileToConfiguration(target, configurationFile); |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
224 } |
0 | 225 } |
226 else | |
227 { | |
660 | 228 #if ORTHANC_STANDALONE == 1 |
229 // No default path for the standalone configuration | |
230 LOG(WARNING) << "Using the default Orthanc configuration"; | |
231 return; | |
232 | |
233 #else | |
234 // In a non-standalone build, we use the | |
235 // "Resources/Configuration.json" from the Orthanc source code | |
236 | |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
237 boost::filesystem::path p = ORTHANC_PATH; |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
238 p /= "Resources"; |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
239 p /= "Configuration.json"; |
2010
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
240 |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
241 AddFileToConfiguration(target, p); |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
242 #endif |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
243 } |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
244 } |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
245 |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
246 |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
247 |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
248 static void ReadGlobalConfiguration(const char* configurationFile) |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
249 { |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
250 // Read the content of the configuration |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
251 configurationFileArg_ = configurationFile; |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
252 ReadConfiguration(configuration_, configurationFile); |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
253 |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
254 // Adapt the paths to the configurations |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
255 defaultDirectory_ = boost::filesystem::current_path(); |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
256 configurationAbsolutePath_ = ""; |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
257 |
2010
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
258 if (configurationFile) |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
259 { |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
260 if (boost::filesystem::is_directory(configurationFile)) |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
261 { |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
262 defaultDirectory_ = boost::filesystem::path(configurationFile); |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
263 configurationAbsolutePath_ = boost::filesystem::absolute(configurationFile).parent_path().string(); |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
264 } |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
265 else |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
266 { |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
267 defaultDirectory_ = boost::filesystem::path(configurationFile).parent_path(); |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
268 configurationAbsolutePath_ = boost::filesystem::absolute(configurationFile).string(); |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
269 } |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
270 } |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
271 else |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
272 { |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
273 #if ORTHANC_STANDALONE != 1 |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
274 // In a non-standalone build, we use the |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
275 // "Resources/Configuration.json" from the Orthanc source code |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
276 |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
277 boost::filesystem::path p = ORTHANC_PATH; |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
278 p /= "Resources"; |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
279 p /= "Configuration.json"; |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
280 configurationAbsolutePath_ = boost::filesystem::absolute(p).string(); |
87
8517e2c44283
path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
281 #endif |
0 | 282 } |
283 } | |
284 | |
285 | |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
286 static void ValidateGlobalConfiguration() |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
287 { |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
288 std::set<std::string> ids; |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
289 |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
290 Configuration::GetListOfOrthancPeers(ids); |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
291 for (std::set<std::string>::const_iterator it = ids.begin(); it != ids.end(); ++it) |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
292 { |
2020 | 293 WebServiceParameters peer; |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
294 Configuration::GetOrthancPeer(peer, *it); |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
295 } |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
296 |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
297 Configuration::GetListOfDicomModalities(ids); |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
298 for (std::set<std::string>::const_iterator it = ids.begin(); it != ids.end(); ++it) |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
299 { |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
300 RemoteModalityParameters modality; |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
301 Configuration::GetDicomModalityUsingSymbolicName(modality, *it); |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
302 } |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
303 } |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
304 |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
305 |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
306 static void RegisterUserMetadata() |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
307 { |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
308 if (configuration_.isMember("UserMetadata")) |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
309 { |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
310 const Json::Value& parameter = configuration_["UserMetadata"]; |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
311 |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
312 Json::Value::Members members = parameter.getMemberNames(); |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
313 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
|
314 { |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
315 const std::string& name = members[i]; |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
316 |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
317 if (!parameter[name].isInt()) |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
318 { |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
319 LOG(ERROR) << "Not a number in this user-defined metadata: " << name; |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
320 throw OrthancException(ErrorCode_BadParameterType); |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
321 } |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
322 |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
323 int metadata = parameter[name].asInt(); |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
324 |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
325 LOG(INFO) << "Registering user-defined metadata: " << name << " (index " |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
326 << metadata << ")"; |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
327 |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
328 try |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
329 { |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
330 RegisterUserMetadata(metadata, name); |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
331 } |
657
5425bb6f1ea5
further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
332 catch (OrthancException&) |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
333 { |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
334 LOG(ERROR) << "Cannot register this user-defined metadata: " << name; |
657
5425bb6f1ea5
further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
335 throw; |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
336 } |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
337 } |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
338 } |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
339 } |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
340 |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
341 |
696
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
342 static void RegisterUserContentType() |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
343 { |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
344 if (configuration_.isMember("UserContentType")) |
696
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
345 { |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
346 const Json::Value& parameter = configuration_["UserContentType"]; |
696
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
347 |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
348 Json::Value::Members members = parameter.getMemberNames(); |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
349 for (size_t i = 0; i < members.size(); i++) |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
350 { |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
351 const std::string& name = members[i]; |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
352 std::string mime = "application/octet-stream"; |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
353 |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
354 const Json::Value& value = parameter[name]; |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
355 int contentType; |
696
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
356 |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
357 if (value.isArray() && |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
358 value.size() == 2 && |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
359 value[0].isInt() && |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
360 value[1].isString()) |
696
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
361 { |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
362 contentType = value[0].asInt(); |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
363 mime = value[1].asString(); |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
364 } |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
365 else if (value.isInt()) |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
366 { |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
367 contentType = value.asInt(); |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
368 } |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
369 else |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
370 { |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
371 LOG(ERROR) << "Not a number in this user-defined attachment type: " << name; |
696
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
372 throw OrthancException(ErrorCode_BadParameterType); |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
373 } |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
374 |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
375 LOG(INFO) << "Registering user-defined attachment type: " << name << " (index " |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
376 << contentType << ") with MIME type \"" << mime << "\""; |
696
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
377 |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
378 try |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
379 { |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
380 RegisterUserContentType(contentType, name, mime); |
696
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
381 } |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
382 catch (OrthancException&) |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
383 { |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
384 throw; |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
385 } |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
386 } |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
387 } |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
388 } |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
389 |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
390 |
1765
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
391 static void LoadCustomDictionary(const Json::Value& configuration) |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
392 { |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
393 if (configuration.type() != Json::objectValue || |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
394 !configuration.isMember("Dictionary") || |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
395 configuration["Dictionary"].type() != Json::objectValue) |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
396 { |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
397 return; |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
398 } |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
399 |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
400 Json::Value::Members tags(configuration["Dictionary"].getMemberNames()); |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
401 |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
402 for (Json::Value::ArrayIndex i = 0; i < tags.size(); i++) |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
403 { |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
404 const Json::Value& content = configuration["Dictionary"][tags[i]]; |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
405 if (content.type() != Json::arrayValue || |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
406 content.size() < 2 || |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
407 content.size() > 4 || |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
408 content[0].type() != Json::stringValue || |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
409 content[1].type() != Json::stringValue || |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
410 (content.size() >= 3 && content[2].type() != Json::intValue) || |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
411 (content.size() >= 4 && content[3].type() != Json::intValue)) |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
412 { |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
413 throw OrthancException(ErrorCode_BadFileFormat); |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
414 } |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
415 |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
416 DicomTag tag(FromDcmtkBridge::ParseTag(tags[i])); |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1987
diff
changeset
|
417 ValueRepresentation vr = StringToValueRepresentation(content[0].asString(), true); |
1765
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
418 std::string name = content[1].asString(); |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
419 unsigned int minMultiplicity = (content.size() >= 2) ? content[2].asUInt() : 1; |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
420 unsigned int maxMultiplicity = (content.size() >= 3) ? content[3].asUInt() : 1; |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
421 |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
422 FromDcmtkBridge::RegisterDictionaryTag(tag, vr, name, minMultiplicity, maxMultiplicity); |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
423 } |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
424 } |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
425 |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
426 |
2022
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
427 static void ConfigurePkcs11(const Json::Value& config) |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
428 { |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
429 if (config.type() != Json::objectValue || |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
430 !config.isMember("Module") || |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
431 config["Module"].type() != Json::stringValue) |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
432 { |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
433 LOG(ERROR) << "No path to the PKCS#11 module (DLL or .so) is provided for HTTPS client authentication"; |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
434 throw OrthancException(ErrorCode_BadFileFormat); |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
435 } |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
436 |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
437 std::string pin; |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
438 if (config.isMember("Pin")) |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
439 { |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
440 if (config["Pin"].type() == Json::stringValue) |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
441 { |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
442 pin = config["Pin"].asString(); |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
443 } |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
444 else |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
445 { |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
446 LOG(ERROR) << "The PIN number in the PKCS#11 configuration must be a string"; |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
447 throw OrthancException(ErrorCode_BadFileFormat); |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
448 } |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
449 } |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
450 |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
451 bool verbose = false; |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
452 if (config.isMember("Verbose")) |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
453 { |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
454 if (config["Verbose"].type() == Json::booleanValue) |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
455 { |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
456 verbose = config["Verbose"].asBool(); |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
457 } |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
458 else |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
459 { |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
460 LOG(ERROR) << "The Verbose option in the PKCS#11 configuration must be a Boolean"; |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
461 throw OrthancException(ErrorCode_BadFileFormat); |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
462 } |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
463 } |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
464 |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
465 HttpClient::InitializePkcs11(config["Module"].asString(), pin, verbose); |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
466 } |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
467 |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
468 |
1656 | 469 |
62 | 470 void OrthancInitialize(const char* configurationFile) |
0 | 471 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
472 boost::recursive_mutex::scoped_lock lock(globalMutex_); |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
473 |
1526
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
474 #if ORTHANC_SSL_ENABLED == 1 |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
475 // https://wiki.openssl.org/index.php/Library_Initialization |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
476 SSL_library_init(); |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
477 SSL_load_error_strings(); |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
478 OpenSSL_add_all_algorithms(); |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
479 ERR_load_crypto_strings(); |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
480 #endif |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
481 |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
482 InitializeServerEnumerations(); |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
483 |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
484 // Read the user-provided configuration |
0 | 485 ReadGlobalConfiguration(configurationFile); |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
486 ValidateGlobalConfiguration(); |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
487 |
2022
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
488 if (configuration_.isMember("Pkcs11")) |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
489 { |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
490 ConfigurePkcs11(configuration_["Pkcs11"]); |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
491 } |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
492 |
1987
ce90d109bb64
new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1928
diff
changeset
|
493 HttpClient::GlobalInitialize(); |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
494 |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
495 RegisterUserMetadata(); |
696
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
496 RegisterUserContentType(); |
685
b01cc78caba4
possibility to disable the DICOM/HTTP servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
660
diff
changeset
|
497 |
1656 | 498 FromDcmtkBridge::InitializeDictionary(); |
1765
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
499 LoadCustomDictionary(configuration_); |
847
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
500 |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
501 #if ORTHANC_JPEG_LOSSLESS_ENABLED == 1 |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
502 LOG(WARNING) << "Registering JPEG Lossless codecs"; |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
503 DJLSDecoderRegistration::registerCodecs(); |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
504 #endif |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
505 |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
506 #if ORTHANC_JPEG_ENABLED == 1 |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
507 LOG(WARNING) << "Registering JPEG codecs"; |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
508 DJDecoderRegistration::registerCodecs(); |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
509 #endif |
1610
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
510 |
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
511 fontRegistry_.AddFromResource(EmbeddedResources::FONT_UBUNTU_MONO_BOLD_16); |
1927
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
512 |
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
513 /* Disable "gethostbyaddr" (which results in memory leaks) and use raw IP addresses */ |
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
514 dcmDisableGethostbyaddr.set(OFTrue); |
0 | 515 } |
516 | |
517 | |
518 | |
62 | 519 void OrthancFinalize() |
0 | 520 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
521 boost::recursive_mutex::scoped_lock lock(globalMutex_); |
457 | 522 HttpClient::GlobalFinalize(); |
847
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
523 |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
524 #if ORTHANC_JPEG_LOSSLESS_ENABLED == 1 |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
525 // Unregister JPEG-LS codecs |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
526 DJLSDecoderRegistration::cleanup(); |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
527 #endif |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
528 |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
529 #if ORTHANC_JPEG_ENABLED == 1 |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
530 // Unregister JPEG codecs |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
531 DJDecoderRegistration::cleanup(); |
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
532 #endif |
1526
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
533 |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
534 #if ORTHANC_SSL_ENABLED == 1 |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
535 // Finalize OpenSSL |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
536 // https://wiki.openssl.org/index.php/Library_Initialization#Cleanup |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
537 FIPS_mode_set(0); |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
538 ENGINE_cleanup(); |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
539 CONF_modules_unload(1); |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
540 EVP_cleanup(); |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
541 CRYPTO_cleanup_all_ex_data(); |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
542 ERR_remove_state(0); |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
543 ERR_free_strings(); |
096a8af528c9
fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1485
diff
changeset
|
544 #endif |
0 | 545 } |
546 | |
547 | |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
548 std::string Configuration::GetGlobalStringParameter(const std::string& parameter, |
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
549 const std::string& defaultValue) |
0 | 550 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
551 boost::recursive_mutex::scoped_lock lock(globalMutex_); |
1533
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
552 return GetGlobalStringParameterInternal(parameter, defaultValue); |
0 | 553 } |
554 | |
555 | |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
556 int Configuration::GetGlobalIntegerParameter(const std::string& parameter, |
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
557 int defaultValue) |
0 | 558 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
559 boost::recursive_mutex::scoped_lock lock(globalMutex_); |
0 | 560 |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
561 if (configuration_.isMember(parameter)) |
0 | 562 { |
1592
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
563 if (configuration_[parameter].type() != Json::intValue) |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
564 { |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
565 LOG(ERROR) << "The configuration option \"" << parameter << "\" must be an integer"; |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
566 throw OrthancException(ErrorCode_BadParameterType); |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
567 } |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
568 else |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
569 { |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
570 return configuration_[parameter].asInt(); |
d73124f6b439
configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
571 } |
0 | 572 } |
573 else | |
574 { | |
575 return defaultValue; | |
576 } | |
577 } | |
578 | |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
579 |
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
580 bool Configuration::GetGlobalBoolParameter(const std::string& parameter, |
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
581 bool defaultValue) |
23 | 582 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
583 boost::recursive_mutex::scoped_lock lock(globalMutex_); |
1533
0011cc99443c
improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1526
diff
changeset
|
584 return GetGlobalBoolParameterInternal(parameter, defaultValue); |
23 | 585 } |
586 | |
587 | |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
588 void Configuration::GetDicomModalityUsingSymbolicName(RemoteModalityParameters& modality, |
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
589 const std::string& name) |
0 | 590 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
591 boost::recursive_mutex::scoped_lock lock(globalMutex_); |
0 | 592 |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
593 if (!configuration_.isMember("DicomModalities")) |
0 | 594 { |
1422
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
595 LOG(ERROR) << "No modality with symbolic name: " << name; |
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
596 throw OrthancException(ErrorCode_InexistentItem); |
0 | 597 } |
598 | |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
599 const Json::Value& modalities = configuration_["DicomModalities"]; |
0 | 600 if (modalities.type() != Json::objectValue || |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
601 !modalities.isMember(name)) |
0 | 602 { |
1007
871c49c9b11d
lua routing is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
942
diff
changeset
|
603 LOG(ERROR) << "No modality with symbolic name: " << name; |
871c49c9b11d
lua routing is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
942
diff
changeset
|
604 throw OrthancException(ErrorCode_InexistentItem); |
0 | 605 } |
606 | |
607 try | |
608 { | |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
609 modality.FromJson(modalities[name]); |
0 | 610 } |
1545 | 611 catch (OrthancException&) |
0 | 612 { |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
613 LOG(ERROR) << "Syntax error in the definition of DICOM modality \"" << name |
752
45715eadc2e0
port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
725
diff
changeset
|
614 << "\". Please check your configuration file."; |
942
b3f6fb1130cd
fixes thanks to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
847
diff
changeset
|
615 throw; |
0 | 616 } |
617 } | |
618 | |
619 | |
620 | |
2020 | 621 void Configuration::GetOrthancPeer(WebServiceParameters& peer, |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
622 const std::string& name) |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
623 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
624 boost::recursive_mutex::scoped_lock lock(globalMutex_); |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
625 |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
626 if (!configuration_.isMember("OrthancPeers")) |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
627 { |
1422
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
628 LOG(ERROR) << "No peer with symbolic name: " << name; |
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
629 throw OrthancException(ErrorCode_InexistentItem); |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
630 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
631 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
632 try |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
633 { |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
634 const Json::Value& modalities = configuration_["OrthancPeers"]; |
752
45715eadc2e0
port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
725
diff
changeset
|
635 if (modalities.type() != Json::objectValue || |
45715eadc2e0
port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
725
diff
changeset
|
636 !modalities.isMember(name)) |
485
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
637 { |
1007
871c49c9b11d
lua routing is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
942
diff
changeset
|
638 LOG(ERROR) << "No peer with symbolic name: " << name; |
871c49c9b11d
lua routing is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
942
diff
changeset
|
639 throw OrthancException(ErrorCode_InexistentItem); |
485
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
640 } |
752
45715eadc2e0
port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
725
diff
changeset
|
641 |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
642 peer.FromJson(modalities[name]); |
485
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
643 } |
1545 | 644 catch (OrthancException&) |
485
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
645 { |
752
45715eadc2e0
port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
725
diff
changeset
|
646 LOG(ERROR) << "Syntax error in the definition of peer \"" << name |
45715eadc2e0
port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
725
diff
changeset
|
647 << "\". Please check your configuration file."; |
942
b3f6fb1130cd
fixes thanks to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
847
diff
changeset
|
648 throw; |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
649 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
650 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
651 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
652 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
653 static bool ReadKeys(std::set<std::string>& target, |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
654 const char* parameter, |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
655 bool onlyAlphanumeric) |
0 | 656 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
657 boost::recursive_mutex::scoped_lock lock(globalMutex_); |
0 | 658 |
659 target.clear(); | |
660 | |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
661 if (!configuration_.isMember(parameter)) |
0 | 662 { |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
663 return true; |
0 | 664 } |
665 | |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
666 const Json::Value& modalities = configuration_[parameter]; |
0 | 667 if (modalities.type() != Json::objectValue) |
668 { | |
1422
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
669 LOG(ERROR) << "Bad format of the \"DicomModalities\" configuration section"; |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
670 throw OrthancException(ErrorCode_BadFileFormat); |
0 | 671 } |
672 | |
673 Json::Value::Members members = modalities.getMemberNames(); | |
674 for (size_t i = 0; i < members.size(); i++) | |
675 { | |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
676 if (onlyAlphanumeric) |
0 | 677 { |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
678 for (size_t j = 0; j < members[i].size(); j++) |
0 | 679 { |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
680 if (!isalnum(members[i][j]) && members[i][j] != '-') |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
681 { |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
682 return false; |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
683 } |
0 | 684 } |
685 } | |
686 | |
687 target.insert(members[i]); | |
688 } | |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
689 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
690 return true; |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
691 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
692 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
693 |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
694 void Configuration::GetListOfDicomModalities(std::set<std::string>& target) |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
695 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
696 target.clear(); |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
697 |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
698 if (!ReadKeys(target, "DicomModalities", true)) |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
699 { |
1422
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
700 LOG(ERROR) << "Only alphanumeric and dash characters are allowed in the names of the modalities"; |
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
701 throw OrthancException(ErrorCode_BadFileFormat); |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
702 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
703 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
704 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
705 |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
706 void Configuration::GetListOfOrthancPeers(std::set<std::string>& target) |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
707 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
708 target.clear(); |
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
709 |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
710 if (!ReadKeys(target, "OrthancPeers", true)) |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
711 { |
1422
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
712 LOG(ERROR) << "Only alphanumeric and dash characters are allowed in the names of Orthanc peers"; |
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
713 throw OrthancException(ErrorCode_BadFileFormat); |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
714 } |
0 | 715 } |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
716 |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
717 |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
718 |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
719 void Configuration::SetupRegisteredUsers(MongooseServer& httpServer) |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
720 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
721 boost::recursive_mutex::scoped_lock lock(globalMutex_); |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
722 |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
723 httpServer.ClearUsers(); |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
724 |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
725 if (!configuration_.isMember("RegisteredUsers")) |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
726 { |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
727 return; |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
728 } |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
729 |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
730 const Json::Value& users = configuration_["RegisteredUsers"]; |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
731 if (users.type() != Json::objectValue) |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
732 { |
1422
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
733 LOG(ERROR) << "Badly formatted list of users"; |
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
734 throw OrthancException(ErrorCode_BadFileFormat); |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
735 } |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
736 |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
737 Json::Value::Members usernames = users.getMemberNames(); |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
738 for (size_t i = 0; i < usernames.size(); i++) |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
739 { |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
740 const std::string& username = usernames[i]; |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
741 std::string password = users[username].asString(); |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
742 httpServer.RegisterUser(username.c_str(), password.c_str()); |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
743 } |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
744 } |
394
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
745 |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
746 |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
747 std::string Configuration::InterpretRelativePath(const std::string& baseDirectory, |
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
748 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
|
749 { |
429
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
750 boost::filesystem::path base(baseDirectory); |
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
751 boost::filesystem::path relative(relativePath); |
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
752 |
428 | 753 /** |
754 The following lines should be equivalent to this one: | |
755 | |
429
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
756 return (base / relative).string(); |
428 | 757 |
758 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
|
759 make the proper path resolution when "baseDirectory" is an |
428 | 760 absolute path. So, a hack is used below. |
752
45715eadc2e0
port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
725
diff
changeset
|
761 **/ |
428 | 762 |
429
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
763 if (relative.is_absolute()) |
427 | 764 { |
429
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
765 return relative.string(); |
427 | 766 } |
767 else | |
768 { | |
429
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
769 return (base / relative).string(); |
427 | 770 } |
394
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
771 } |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
772 |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
773 std::string Configuration::InterpretStringParameterAsPath(const std::string& parameter) |
429
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
774 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
775 boost::recursive_mutex::scoped_lock lock(globalMutex_); |
429
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
776 return InterpretRelativePath(defaultDirectory_.string(), parameter); |
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
777 } |
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
428
diff
changeset
|
778 |
394
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
779 |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
780 void Configuration::GetGlobalListOfStringsParameter(std::list<std::string>& target, |
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
781 const std::string& key) |
394
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
782 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
783 boost::recursive_mutex::scoped_lock lock(globalMutex_); |
394
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
784 |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
785 target.clear(); |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
786 |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
787 if (!configuration_.isMember(key)) |
394
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
788 { |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
789 return; |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
790 } |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
791 |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
792 const Json::Value& lst = configuration_[key]; |
394
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
793 |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
794 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
|
795 { |
1422
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
796 LOG(ERROR) << "Badly formatted list of strings"; |
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
797 throw OrthancException(ErrorCode_BadFileFormat); |
394
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
798 } |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
799 |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
800 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
|
801 { |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
802 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
|
803 } |
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
804 } |
613 | 805 |
806 | |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
807 bool Configuration::IsSameAETitle(const std::string& aet1, |
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
808 const std::string& aet2) |
690
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
809 { |
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
810 if (GetGlobalBoolParameter("StrictAetComparison", false)) |
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
811 { |
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
812 // Case-sensitive matching |
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
813 return aet1 == aet2; |
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
814 } |
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
815 else |
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
816 { |
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
817 // Case-insensitive matching (default) |
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
818 std::string tmp1, tmp2; |
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
819 Toolbox::ToLowerCase(tmp1, aet1); |
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
820 Toolbox::ToLowerCase(tmp2, aet2); |
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
821 return tmp1 == tmp2; |
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
822 } |
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
823 } |
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
824 |
2e67366aab83
case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
825 |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
826 bool Configuration::LookupDicomModalityUsingAETitle(RemoteModalityParameters& modality, |
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
827 const std::string& aet) |
613 | 828 { |
829 std::set<std::string> modalities; | |
830 GetListOfDicomModalities(modalities); | |
831 | |
832 for (std::set<std::string>::const_iterator | |
656 | 833 it = modalities.begin(); it != modalities.end(); ++it) |
613 | 834 { |
835 try | |
836 { | |
806 | 837 GetDicomModalityUsingSymbolicName(modality, *it); |
725 | 838 |
806 | 839 if (IsSameAETitle(aet, modality.GetApplicationEntityTitle())) |
613 | 840 { |
617 | 841 return true; |
613 | 842 } |
843 } | |
844 catch (OrthancException&) | |
845 { | |
846 } | |
847 } | |
848 | |
617 | 849 return false; |
850 } | |
851 | |
852 | |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
853 bool Configuration::IsKnownAETitle(const std::string& aet) |
617 | 854 { |
806 | 855 RemoteModalityParameters modality; |
856 return LookupDicomModalityUsingAETitle(modality, aet); | |
617 | 857 } |
772
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
771
diff
changeset
|
858 |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
771
diff
changeset
|
859 |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
860 RemoteModalityParameters Configuration::GetModalityUsingSymbolicName(const std::string& name) |
772
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
771
diff
changeset
|
861 { |
806 | 862 RemoteModalityParameters modality; |
863 GetDicomModalityUsingSymbolicName(modality, name); | |
772
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
771
diff
changeset
|
864 |
806 | 865 return modality; |
772
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
771
diff
changeset
|
866 } |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
771
diff
changeset
|
867 |
773 | 868 |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
869 RemoteModalityParameters Configuration::GetModalityUsingAet(const std::string& aet) |
772
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
771
diff
changeset
|
870 { |
806 | 871 RemoteModalityParameters modality; |
772
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
771
diff
changeset
|
872 |
806 | 873 if (LookupDicomModalityUsingAETitle(modality, aet)) |
772
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
771
diff
changeset
|
874 { |
806 | 875 return modality; |
772
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
771
diff
changeset
|
876 } |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
771
diff
changeset
|
877 else |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
771
diff
changeset
|
878 { |
1422
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
879 LOG(ERROR) << "Unknown modality for AET: " << aet; |
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
880 throw OrthancException(ErrorCode_InexistentItem); |
772
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
771
diff
changeset
|
881 } |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
771
diff
changeset
|
882 } |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
883 |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
884 |
812 | 885 void Configuration::UpdateModality(const std::string& symbolicName, |
886 const RemoteModalityParameters& modality) | |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
887 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
888 boost::recursive_mutex::scoped_lock lock(globalMutex_); |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
889 |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
890 if (!configuration_.isMember("DicomModalities")) |
1366 | 891 { |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
892 configuration_["DicomModalities"] = Json::objectValue; |
1366 | 893 } |
894 | |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
895 Json::Value& modalities = configuration_["DicomModalities"]; |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
896 if (modalities.type() != Json::objectValue) |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
897 { |
1422
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
898 LOG(ERROR) << "Bad file format for modality: " << symbolicName; |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
899 throw OrthancException(ErrorCode_BadFileFormat); |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
900 } |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
901 |
812 | 902 modalities.removeMember(symbolicName); |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
903 |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
904 Json::Value v; |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
905 modality.ToJson(v); |
812 | 906 modalities[symbolicName] = v; |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
907 } |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
908 |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
909 |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
910 void Configuration::RemoveModality(const std::string& symbolicName) |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
911 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
912 boost::recursive_mutex::scoped_lock lock(globalMutex_); |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
913 |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
914 if (!configuration_.isMember("DicomModalities")) |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
915 { |
1422
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
916 LOG(ERROR) << "No modality with symbolic name: " << symbolicName; |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
917 throw OrthancException(ErrorCode_BadFileFormat); |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
918 } |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
919 |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
920 Json::Value& modalities = configuration_["DicomModalities"]; |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
921 if (modalities.type() != Json::objectValue) |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
922 { |
1422
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
923 LOG(ERROR) << "Bad file format for the \"DicomModalities\" configuration section"; |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
924 throw OrthancException(ErrorCode_BadFileFormat); |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
925 } |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
926 |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
927 modalities.removeMember(symbolicName.c_str()); |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
928 } |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
929 |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
930 |
812 | 931 void Configuration::UpdatePeer(const std::string& symbolicName, |
2020 | 932 const WebServiceParameters& peer) |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
933 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
934 boost::recursive_mutex::scoped_lock lock(globalMutex_); |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
935 |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
936 if (!configuration_.isMember("OrthancPeers")) |
1366 | 937 { |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
938 LOG(ERROR) << "No peer with symbolic name: " << symbolicName; |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
939 configuration_["OrthancPeers"] = Json::objectValue; |
1366 | 940 } |
941 | |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
942 Json::Value& peers = configuration_["OrthancPeers"]; |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
943 if (peers.type() != Json::objectValue) |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
944 { |
1422
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
945 LOG(ERROR) << "Bad file format for the \"OrthancPeers\" configuration section"; |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
946 throw OrthancException(ErrorCode_BadFileFormat); |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
947 } |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
948 |
812 | 949 peers.removeMember(symbolicName); |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
950 |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
951 Json::Value v; |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
952 peer.ToJson(v); |
812 | 953 peers[symbolicName] = v; |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
954 } |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
955 |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
956 |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
808
diff
changeset
|
957 void Configuration::RemovePeer(const std::string& symbolicName) |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
958 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
959 boost::recursive_mutex::scoped_lock lock(globalMutex_); |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
960 |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
961 if (!configuration_.isMember("OrthancPeers")) |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
962 { |
1422
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
963 LOG(ERROR) << "No peer with symbolic name: " << symbolicName; |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
964 throw OrthancException(ErrorCode_BadFileFormat); |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
965 } |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
966 |
1423
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
967 Json::Value& peers = configuration_["OrthancPeers"]; |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
968 if (peers.type() != Json::objectValue) |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
969 { |
1422
52b2070fc8f1
improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1366
diff
changeset
|
970 LOG(ERROR) << "Bad file format for the \"OrthancPeers\" configuration section"; |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
971 throw OrthancException(ErrorCode_BadFileFormat); |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
972 } |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
973 |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
974 peers.removeMember(symbolicName.c_str()); |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
975 } |
1145
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
976 |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
977 |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
978 |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
979 const std::string& Configuration::GetConfigurationAbsolutePath() |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
980 { |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
981 return configurationAbsolutePath_; |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
982 } |
1274 | 983 |
984 | |
985 static IDatabaseWrapper* CreateSQLiteWrapper() | |
986 { | |
987 std::string storageDirectoryStr = Configuration::GetGlobalStringParameter("StorageDirectory", "OrthancStorage"); | |
988 | |
989 // Open the database | |
990 boost::filesystem::path indexDirectory = Configuration::InterpretStringParameterAsPath( | |
991 Configuration::GetGlobalStringParameter("IndexDirectory", storageDirectoryStr)); | |
992 | |
993 LOG(WARNING) << "SQLite index directory: " << indexDirectory; | |
994 | |
995 try | |
996 { | |
997 boost::filesystem::create_directories(indexDirectory); | |
998 } | |
999 catch (boost::filesystem::filesystem_error) | |
1000 { | |
1001 } | |
1002 | |
1003 return new DatabaseWrapper(indexDirectory.string() + "/index"); | |
1004 } | |
1005 | |
1006 | |
1007 namespace | |
1008 { | |
1009 // Anonymous namespace to avoid clashes between compilation modules | |
1010 | |
1011 class FilesystemStorageWithoutDicom : public IStorageArea | |
1012 { | |
1013 private: | |
1014 FilesystemStorage storage_; | |
1015 | |
1016 public: | |
1017 FilesystemStorageWithoutDicom(const std::string& path) : storage_(path) | |
1018 { | |
1019 } | |
1020 | |
1021 virtual void Create(const std::string& uuid, | |
1022 const void* content, | |
1023 size_t size, | |
1024 FileContentType type) | |
1025 { | |
1026 if (type != FileContentType_Dicom) | |
1027 { | |
1028 storage_.Create(uuid, content, size, type); | |
1029 } | |
1030 } | |
1031 | |
1032 virtual void Read(std::string& content, | |
1033 const std::string& uuid, | |
1034 FileContentType type) | |
1035 { | |
1036 if (type != FileContentType_Dicom) | |
1037 { | |
1038 storage_.Read(content, uuid, type); | |
1039 } | |
1040 else | |
1041 { | |
1042 throw OrthancException(ErrorCode_UnknownResource); | |
1043 } | |
1044 } | |
1045 | |
1046 virtual void Remove(const std::string& uuid, | |
1047 FileContentType type) | |
1048 { | |
1049 if (type != FileContentType_Dicom) | |
1050 { | |
1051 storage_.Remove(uuid, type); | |
1052 } | |
1053 } | |
1054 }; | |
1055 } | |
1056 | |
1057 | |
1058 static IStorageArea* CreateFilesystemStorage() | |
1059 { | |
1060 std::string storageDirectoryStr = Configuration::GetGlobalStringParameter("StorageDirectory", "OrthancStorage"); | |
1061 | |
1062 boost::filesystem::path storageDirectory = Configuration::InterpretStringParameterAsPath(storageDirectoryStr); | |
1063 LOG(WARNING) << "Storage directory: " << storageDirectory; | |
1064 | |
1065 if (Configuration::GetGlobalBoolParameter("StoreDicom", true)) | |
1066 { | |
1067 return new FilesystemStorage(storageDirectory.string()); | |
1068 } | |
1069 else | |
1070 { | |
1071 LOG(WARNING) << "The DICOM files will not be stored, Orthanc running in index-only mode"; | |
1072 return new FilesystemStorageWithoutDicom(storageDirectory.string()); | |
1073 } | |
1074 } | |
1075 | |
1076 | |
1077 IDatabaseWrapper* Configuration::CreateDatabaseWrapper() | |
1078 { | |
1079 return CreateSQLiteWrapper(); | |
1080 } | |
1081 | |
1082 | |
1083 IStorageArea* Configuration::CreateStorageArea() | |
1084 { | |
1085 return CreateFilesystemStorage(); | |
1086 } | |
1424
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
1087 |
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
1088 |
1587
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
1089 void Configuration::GetConfiguration(Json::Value& result) |
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
1090 { |
1892
0001f8cd7849
Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
1091 boost::recursive_mutex::scoped_lock lock(globalMutex_); |
1587
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
1092 result = configuration_; |
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
1093 } |
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
1094 |
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
1095 |
1424
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
1096 void Configuration::FormatConfiguration(std::string& result) |
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
1097 { |
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
1098 Json::Value config; |
1587
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
1099 GetConfiguration(config); |
1424
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
1100 |
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
1101 Json::StyledWriter w; |
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
1102 result = w.write(config); |
fe384a9d3b51
OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1423
diff
changeset
|
1103 } |
1610
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
1104 |
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
1105 |
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
1106 const FontRegistry& Configuration::GetFontRegistry() |
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
1107 { |
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
1108 return fontRegistry_; |
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
1109 } |
1928
84c7eaeb5244
Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1927
diff
changeset
|
1110 |
84c7eaeb5244
Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1927
diff
changeset
|
1111 |
84c7eaeb5244
Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1927
diff
changeset
|
1112 Encoding Configuration::GetDefaultEncoding() |
84c7eaeb5244
Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1927
diff
changeset
|
1113 { |
84c7eaeb5244
Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1927
diff
changeset
|
1114 std::string s = GetGlobalStringParameter("DefaultEncoding", "Latin1"); |
84c7eaeb5244
Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1927
diff
changeset
|
1115 |
84c7eaeb5244
Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1927
diff
changeset
|
1116 // By default, Latin1 encoding is assumed |
84c7eaeb5244
Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1927
diff
changeset
|
1117 return s.empty() ? Encoding_Latin1 : StringToEncoding(s.c_str()); |
84c7eaeb5244
Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1927
diff
changeset
|
1118 } |
2010
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1119 |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1120 |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1121 bool Configuration::HasConfigurationChanged() |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1122 { |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1123 Json::Value starting; |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1124 GetConfiguration(starting); |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1125 |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1126 Json::Value current; |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1127 ReadConfiguration(current, configurationFileArg_); |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1128 |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1129 Json::FastWriter writer; |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1130 std::string a = writer.write(starting); |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1131 std::string b = writer.write(current); |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1132 |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1133 return a != b; |
4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1134 } |
0 | 1135 } |