annotate OrthancServer/OrthancInitialization.cpp @ 2244:a3a65de1840f

shared copyright with osimis
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 04 Jan 2017 12:09:40 +0100
parents 4f39ab2cb453
children 423d3b692bb9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1892
diff changeset
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
2244
a3a65de1840f shared copyright with osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2217
diff changeset
5 * Copyright (C) 2017 Osimis, Belgium
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
136
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
11 *
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
12 * In addition, as a special exception, the copyright holders of this
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
13 * program give permission to link the code of its release with the
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
16 * the linked executables. You must obey the GNU General Public License
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
20 * you do not wish to do so, delete this exception statement from your
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
21 * version. If you delete this exception statement from all source files
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
22 * in the program, then also delete it here.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
34 #include "PrecompiledHeadersServer.h"
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
35 #include "OrthancInitialization.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
476
4aae0261515e move HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 457
diff changeset
37 #include "../Core/HttpClient.h"
1485
27661b33f624 Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1429
diff changeset
38 #include "../Core/Logging.h"
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
39 #include "../Core/OrthancException.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 #include "../Core/Toolbox.h"
1485
27661b33f624 Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1429
diff changeset
41 #include "../Core/FileStorage/FilesystemStorage.h"
27661b33f624 Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1429
diff changeset
42
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
43 #include "ServerEnumerations.h"
1485
27661b33f624 Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1429
diff changeset
44 #include "DatabaseWrapper.h"
1656
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
45 #include "FromDcmtkBridge.h"
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
46 #include "ToDcmtkBridge.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 #include <boost/lexical_cast.hpp>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 #include <boost/filesystem.hpp>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 #include <curl/curl.h>
2217
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
51 #include <boost/thread/recursive_mutex.hpp>
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
52
847
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
53
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
54 #if ORTHANC_ENABLE_JPEG == 1
2099
bcbc9137a535 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2071
diff changeset
55 # include <dcmtk/dcmjpeg/djdecode.h>
847
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
56 #endif
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
57
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
58
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
59 #if ORTHANC_ENABLE_JPEG_LOSSLESS == 1
2099
bcbc9137a535 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2071
diff changeset
60 # include <dcmtk/dcmjpls/djdecode.h>
847
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
61 #endif
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
62
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
63
1927
b60f27664b8f simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
64 #include <dcmtk/dcmnet/dul.h>
b60f27664b8f simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
65
b60f27664b8f simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
66
b60f27664b8f simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
67
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
68 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
70 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
71 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
72 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
73 static std::string configurationAbsolutePath_;
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
74 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
75 static const char* configurationFileArg_ = NULL;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
77
1533
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
78 static std::string GetGlobalStringParameterInternal(const std::string& parameter,
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
79 const std::string& defaultValue)
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
80 {
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
81 if (configuration_.isMember(parameter))
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
82 {
1592
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
83 if (configuration_[parameter].type() != Json::stringValue)
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
84 {
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
85 LOG(ERROR) << "The configuration option \"" << parameter << "\" must be a string";
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
86 throw OrthancException(ErrorCode_BadParameterType);
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
87 }
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
88 else
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
89 {
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
90 return configuration_[parameter].asString();
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
91 }
1533
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
92 }
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
93 else
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
94 {
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
95 return defaultValue;
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
96 }
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
97 }
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
98
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
99
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
100 static bool GetGlobalBoolParameterInternal(const std::string& parameter,
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
101 bool defaultValue)
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
102 {
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
103 if (configuration_.isMember(parameter))
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
104 {
1592
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
105 if (configuration_[parameter].type() != Json::booleanValue)
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
106 {
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
107 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
108 throw OrthancException(ErrorCode_BadParameterType);
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
109 }
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
110 else
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
111 {
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
112 return configuration_[parameter].asBool();
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
113 }
1533
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
114 }
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
115 else
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
116 {
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
117 return defaultValue;
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
118 }
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
119 }
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
120
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
121
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
122
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
123 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
124 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
125 {
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
126 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
127
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
128 Json::Value config;
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
129
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
130 {
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
131 std::string content;
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2136
diff changeset
132 SystemToolbox::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
133
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
134 Json::Value tmp;
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
135 Json::Reader reader;
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
136 if (!reader.parse(content, tmp) ||
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
137 tmp.type() != Json::objectValue)
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
138 {
1596
f2e3d030ea59 BadJson error code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1592
diff changeset
139 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
140 throw OrthancException(ErrorCode_BadJson);
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
141 }
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
142
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
143 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
144 }
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
145
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
146 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
147 {
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
148 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
149 }
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
150 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
151 {
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
152 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
153 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
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.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
156 {
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
157 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
158 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
159 }
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 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
161 {
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
162 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
163 }
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
164 }
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 }
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
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
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
169 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
170 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
171 {
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 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
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 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
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 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
177 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
178 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
179 ++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
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 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
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 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
184 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
185
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 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
187 {
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
188 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
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 }
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 }
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
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
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
195 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
196 const char* configurationFile)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 {
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
198 target = Json::objectValue;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 if (configurationFile)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 {
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
202 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
203 {
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
204 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
205 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
206 }
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
207
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
208 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
209 {
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
210 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
211 }
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 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
213 {
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
214 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
215 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 {
660
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
219 #if ORTHANC_STANDALONE == 1
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
220 // No default path for the standalone configuration
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
221 LOG(WARNING) << "Using the default Orthanc configuration";
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
222 return;
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
223
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
224 #else
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
225 // In a non-standalone build, we use the
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
226 // "Resources/Configuration.json" from the Orthanc source code
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
227
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
228 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
229 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
230 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
231
4dafe2a0d3ab Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
232 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
233 #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
234 }
4dafe2a0d3ab Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
235 }
4dafe2a0d3ab Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
236
4dafe2a0d3ab Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
237
4dafe2a0d3ab Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
238
4dafe2a0d3ab Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
239 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
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 // 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
242 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
243 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
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 // 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
246 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
247 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
248
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
249 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
250 {
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 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
252 {
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 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
254 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
255 }
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 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
257 {
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 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
259 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
260 }
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 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
263 {
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 #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
265 // 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
266 // "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
267
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 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
269 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
270 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
271 configurationAbsolutePath_ = boost::filesystem::absolute(p).string();
87
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
272 #endif
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
277 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
278 {
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
279 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
280
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
281 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
282 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
283 {
2020
a0bd8cd55da7 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2010
diff changeset
284 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
285 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
286 }
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 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
289 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
290 {
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
291 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
292 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
293 }
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
294 }
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
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
297 static void RegisterUserMetadata()
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
298 {
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
299 if (configuration_.isMember("UserMetadata"))
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
300 {
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
301 const Json::Value& parameter = configuration_["UserMetadata"];
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
302
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
303 Json::Value::Members members = parameter.getMemberNames();
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
304 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
305 {
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
306 const std::string& name = members[i];
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
307
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
308 if (!parameter[name].isInt())
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
309 {
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
310 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
311 throw OrthancException(ErrorCode_BadParameterType);
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
312 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
313
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
314 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
315
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
316 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
317 << metadata << ")";
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
318
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
319 try
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
320 {
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
321 RegisterUserMetadata(metadata, name);
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
322 }
657
5425bb6f1ea5 further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
323 catch (OrthancException&)
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
324 {
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
325 LOG(ERROR) << "Cannot register this user-defined metadata: " << name;
657
5425bb6f1ea5 further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
326 throw;
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 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
329 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
330 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
331
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
332
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
333 static void RegisterUserContentType()
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
334 {
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
335 if (configuration_.isMember("UserContentType"))
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
336 {
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
337 const Json::Value& parameter = configuration_["UserContentType"];
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
338
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
339 Json::Value::Members members = parameter.getMemberNames();
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
340 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
341 {
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
342 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
343 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
344
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
345 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
346 int contentType;
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
347
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
348 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
349 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
350 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
351 value[1].isString())
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
352 {
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
353 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
354 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
355 }
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
356 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
357 {
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
358 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
359 }
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
360 else
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
361 {
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
362 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
363 throw OrthancException(ErrorCode_BadParameterType);
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
364 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
365
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
366 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
367 << contentType << ") with MIME type \"" << mime << "\"";
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
368
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
369 try
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
370 {
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
371 RegisterUserContentType(contentType, name, mime);
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
372 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
373 catch (OrthancException&)
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
374 {
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
375 throw;
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
376 }
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 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
379 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
380
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
381
1765
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
382 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
383 {
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
384 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
385 !configuration.isMember("Dictionary") ||
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
386 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
387 {
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
388 return;
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
389 }
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
390
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
391 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
392
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
393 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
394 {
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
395 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
396 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
397 content.size() < 2 ||
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2099
diff changeset
398 content.size() > 5 ||
1765
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
399 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
400 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
401 (content.size() >= 3 && content[2].type() != Json::intValue) ||
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2099
diff changeset
402 (content.size() >= 4 && content[3].type() != Json::intValue) ||
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2099
diff changeset
403 (content.size() >= 5 && content[4].type() != Json::stringValue))
1765
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
404 {
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
405 throw OrthancException(ErrorCode_BadFileFormat);
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
406 }
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
407
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
408 DicomTag tag(FromDcmtkBridge::ParseTag(tags[i]));
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
409 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
410 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
411 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
412 unsigned int maxMultiplicity = (content.size() >= 3) ? content[3].asUInt() : 1;
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2099
diff changeset
413 std::string privateCreator = (content.size() >= 4) ? content[4].asString() : "";
1765
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
414
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2099
diff changeset
415 FromDcmtkBridge::RegisterDictionaryTag(tag, vr, name, minMultiplicity, maxMultiplicity, privateCreator);
1765
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
416 }
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
417 }
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
418
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
419
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
420 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
421 {
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
422 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
423 !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
424 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
425 {
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
426 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
427 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
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
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 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
431 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
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 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
434 {
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 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
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 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
438 {
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 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
440 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
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 }
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 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
445 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
446 {
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 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
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 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
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 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
452 {
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 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
454 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
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 }
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 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
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
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
1656
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
462
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
463 void OrthancInitialize(const char* configurationFile)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
465 boost::recursive_mutex::scoped_lock lock(globalMutex_);
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
466
2099
bcbc9137a535 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2071
diff changeset
467 HttpClient::InitializeOpenSsl();
1526
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
468
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
469 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
470
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
471 // Read the user-provided configuration
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 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
473 ValidateGlobalConfiguration();
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
474
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
475 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
476 {
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
477 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
478 }
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
479
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1928
diff changeset
480 HttpClient::GlobalInitialize();
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
481
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
482 RegisterUserMetadata();
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
483 RegisterUserContentType();
685
b01cc78caba4 possibility to disable the DICOM/HTTP servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 660
diff changeset
484
2151
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2140
diff changeset
485 FromDcmtkBridge::InitializeDictionary(GetGlobalBoolParameterInternal("LoadPrivateDictionary", true));
1765
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
486 LoadCustomDictionary(configuration_);
847
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
487
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
488 #if ORTHANC_ENABLE_JPEG_LOSSLESS == 1
847
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
489 LOG(WARNING) << "Registering JPEG Lossless codecs";
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
490 DJLSDecoderRegistration::registerCodecs();
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
491 #endif
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
492
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
493 #if ORTHANC_ENABLE_JPEG == 1
847
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
494 LOG(WARNING) << "Registering JPEG codecs";
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
495 DJDecoderRegistration::registerCodecs();
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
496 #endif
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
497
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
498 fontRegistry_.AddFromResource(EmbeddedResources::FONT_UBUNTU_MONO_BOLD_16);
1927
b60f27664b8f simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
499
b60f27664b8f simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
500 /* 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
501 dcmDisableGethostbyaddr.set(OFTrue);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
502 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
506 void OrthancFinalize()
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
508 boost::recursive_mutex::scoped_lock lock(globalMutex_);
457
997282a61ff8 cleaner names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
509 HttpClient::GlobalFinalize();
847
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
510
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
511 #if ORTHANC_ENABLE_JPEG_LOSSLESS == 1
847
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
512 // Unregister JPEG-LS codecs
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
513 DJLSDecoderRegistration::cleanup();
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
514 #endif
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
515
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
516 #if ORTHANC_ENABLE_JPEG == 1
847
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
517 // Unregister JPEG codecs
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
518 DJDecoderRegistration::cleanup();
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
519 #endif
1526
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
520
2099
bcbc9137a535 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2071
diff changeset
521 HttpClient::FinalizeOpenSsl();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
522 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
523
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
524
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
525 std::string Configuration::GetGlobalStringParameter(const std::string& parameter,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
526 const std::string& defaultValue)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
527 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
528 boost::recursive_mutex::scoped_lock lock(globalMutex_);
1533
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
529 return GetGlobalStringParameterInternal(parameter, defaultValue);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
531
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
533 int Configuration::GetGlobalIntegerParameter(const std::string& parameter,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
534 int defaultValue)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
536 boost::recursive_mutex::scoped_lock lock(globalMutex_);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537
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
538 if (configuration_.isMember(parameter))
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539 {
1592
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
540 if (configuration_[parameter].type() != Json::intValue)
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
541 {
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
542 LOG(ERROR) << "The configuration option \"" << parameter << "\" must be an integer";
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
543 throw OrthancException(ErrorCode_BadParameterType);
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
544 }
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
545 else
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
546 {
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
547 return configuration_[parameter].asInt();
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
548 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
550 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
551 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
552 return defaultValue;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
556
2069
fabf7820d1f1 New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2022
diff changeset
557 unsigned int Configuration::GetGlobalUnsignedIntegerParameter(const std::string& parameter,
fabf7820d1f1 New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2022
diff changeset
558 unsigned int defaultValue)
fabf7820d1f1 New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2022
diff changeset
559 {
fabf7820d1f1 New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2022
diff changeset
560 int v = GetGlobalIntegerParameter(parameter, defaultValue);
fabf7820d1f1 New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2022
diff changeset
561
fabf7820d1f1 New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2022
diff changeset
562 if (v < 0)
fabf7820d1f1 New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2022
diff changeset
563 {
fabf7820d1f1 New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2022
diff changeset
564 LOG(ERROR) << "The configuration option \"" << parameter << "\" must be a positive integer";
2071
27fd34970c52 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2069
diff changeset
565 throw OrthancException(ErrorCode_ParameterOutOfRange);
2069
fabf7820d1f1 New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2022
diff changeset
566 }
fabf7820d1f1 New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2022
diff changeset
567 else
fabf7820d1f1 New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2022
diff changeset
568 {
fabf7820d1f1 New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2022
diff changeset
569 return static_cast<unsigned int>(v);
fabf7820d1f1 New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2022
diff changeset
570 }
fabf7820d1f1 New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2022
diff changeset
571 }
fabf7820d1f1 New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2022
diff changeset
572
fabf7820d1f1 New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2022
diff changeset
573
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
574 bool Configuration::GetGlobalBoolParameter(const std::string& parameter,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
575 bool defaultValue)
23
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
576 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
577 boost::recursive_mutex::scoped_lock lock(globalMutex_);
1533
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
578 return GetGlobalBoolParameterInternal(parameter, defaultValue);
23
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
579 }
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
580
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
581
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
582 void Configuration::GetDicomModalityUsingSymbolicName(RemoteModalityParameters& modality,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
583 const std::string& name)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
585 boost::recursive_mutex::scoped_lock lock(globalMutex_);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586
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
587 if (!configuration_.isMember("DicomModalities"))
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
588 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
589 LOG(ERROR) << "No modality with symbolic name: " << name;
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
590 throw OrthancException(ErrorCode_InexistentItem);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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 const Json::Value& modalities = configuration_["DicomModalities"];
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594 if (modalities.type() != Json::objectValue ||
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
595 !modalities.isMember(name))
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
596 {
1007
871c49c9b11d lua routing is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 942
diff changeset
597 LOG(ERROR) << "No modality with symbolic name: " << name;
871c49c9b11d lua routing is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 942
diff changeset
598 throw OrthancException(ErrorCode_InexistentItem);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
599 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601 try
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
602 {
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
603 modality.FromJson(modalities[name]);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604 }
1545
33d34bc4ac15 fix msvc warnings
jodogne
parents: 1534
diff changeset
605 catch (OrthancException&)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
606 {
1429
7366a0bdda6a attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
607 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
608 << "\". Please check your configuration file.";
942
b3f6fb1130cd fixes thanks to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 847
diff changeset
609 throw;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
610 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
611 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
612
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
613
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
614
2020
a0bd8cd55da7 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2010
diff changeset
615 void Configuration::GetOrthancPeer(WebServiceParameters& peer,
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
616 const std::string& name)
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
617 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
618 boost::recursive_mutex::scoped_lock lock(globalMutex_);
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
619
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
620 if (!configuration_.isMember("OrthancPeers"))
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
621 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
622 LOG(ERROR) << "No peer with symbolic name: " << name;
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
623 throw OrthancException(ErrorCode_InexistentItem);
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
624 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
625
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
626 try
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
627 {
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
628 const Json::Value& modalities = configuration_["OrthancPeers"];
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
629 if (modalities.type() != Json::objectValue ||
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
630 !modalities.isMember(name))
485
bdbde1fbfab3 send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 484
diff changeset
631 {
1007
871c49c9b11d lua routing is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 942
diff changeset
632 LOG(ERROR) << "No peer with symbolic name: " << name;
871c49c9b11d lua routing is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 942
diff changeset
633 throw OrthancException(ErrorCode_InexistentItem);
485
bdbde1fbfab3 send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 484
diff changeset
634 }
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
635
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
636 peer.FromJson(modalities[name]);
485
bdbde1fbfab3 send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 484
diff changeset
637 }
1545
33d34bc4ac15 fix msvc warnings
jodogne
parents: 1534
diff changeset
638 catch (OrthancException&)
485
bdbde1fbfab3 send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 484
diff changeset
639 {
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
640 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
641 << "\". Please check your configuration file.";
942
b3f6fb1130cd fixes thanks to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 847
diff changeset
642 throw;
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
643 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
644 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
645
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
646
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
647 static bool ReadKeys(std::set<std::string>& target,
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
648 const char* parameter,
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
649 bool onlyAlphanumeric)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
650 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
651 boost::recursive_mutex::scoped_lock lock(globalMutex_);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
652
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
653 target.clear();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
654
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
655 if (!configuration_.isMember(parameter))
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
656 {
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
657 return true;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
658 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
659
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
660 const Json::Value& modalities = configuration_[parameter];
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
661 if (modalities.type() != Json::objectValue)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
662 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
663 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
664 throw OrthancException(ErrorCode_BadFileFormat);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
665 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
666
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
667 Json::Value::Members members = modalities.getMemberNames();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
668 for (size_t i = 0; i < members.size(); i++)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
669 {
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
670 if (onlyAlphanumeric)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
671 {
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
672 for (size_t j = 0; j < members[i].size(); j++)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
673 {
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
674 if (!isalnum(members[i][j]) && members[i][j] != '-')
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
675 {
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
676 return false;
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
677 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
678 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
679 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
680
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
681 target.insert(members[i]);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
682 }
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
683
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
684 return true;
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
685 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
686
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
687
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
688 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
689 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
690 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
691
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
692 if (!ReadKeys(target, "DicomModalities", true))
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
693 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
694 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
695 throw OrthancException(ErrorCode_BadFileFormat);
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
696 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
697 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
698
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
699
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
700 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
701 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
702 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
703
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
704 if (!ReadKeys(target, "OrthancPeers", true))
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
705 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
706 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
707 throw OrthancException(ErrorCode_BadFileFormat);
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
708 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
709 }
25
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
710
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
711
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
712
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
713 void Configuration::SetupRegisteredUsers(MongooseServer& httpServer)
25
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
714 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
715 boost::recursive_mutex::scoped_lock lock(globalMutex_);
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 httpServer.ClearUsers();
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
718
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
719 if (!configuration_.isMember("RegisteredUsers"))
25
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
720 {
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
721 return;
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
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
724 const Json::Value& users = configuration_["RegisteredUsers"];
25
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
725 if (users.type() != Json::objectValue)
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
726 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
727 LOG(ERROR) << "Badly formatted list of users";
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
728 throw OrthancException(ErrorCode_BadFileFormat);
25
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
729 }
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
730
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
731 Json::Value::Members usernames = users.getMemberNames();
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
732 for (size_t i = 0; i < usernames.size(); i++)
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
733 {
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
734 const std::string& username = usernames[i];
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
735 std::string password = users[username].asString();
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
736 httpServer.RegisterUser(username.c_str(), password.c_str());
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
737 }
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
738 }
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
739
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
740
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
741 std::string Configuration::InterpretRelativePath(const std::string& baseDirectory,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
742 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
743 {
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
744 boost::filesystem::path base(baseDirectory);
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
745 boost::filesystem::path relative(relativePath);
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
746
428
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
747 /**
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
748 The following lines should be equivalent to this one:
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
749
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
750 return (base / relative).string();
428
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
751
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
752 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
753 make the proper path resolution when "baseDirectory" is an
428
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
754 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
755 **/
428
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
756
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
757 if (relative.is_absolute())
427
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
758 {
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
759 return relative.string();
427
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
760 }
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
761 else
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
762 {
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
763 return (base / relative).string();
427
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
764 }
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
765 }
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
766
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
767 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
768 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
769 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
770 return InterpretRelativePath(defaultDirectory_.string(), parameter);
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
771 }
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
772
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
773
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
774 void Configuration::GetGlobalListOfStringsParameter(std::list<std::string>& target,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
775 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
776 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
777 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
778
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
779 target.clear();
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
780
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
781 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
782 {
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
783 return;
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
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
786 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
787
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
788 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
789 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
790 LOG(ERROR) << "Badly formatted list of strings";
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
791 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
792 }
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 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
795 {
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
796 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
797 }
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
798 }
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
799
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
800
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
801 bool Configuration::IsSameAETitle(const std::string& aet1,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
802 const std::string& aet2)
690
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
803 {
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
804 if (GetGlobalBoolParameter("StrictAetComparison", false))
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
805 {
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
806 // Case-sensitive matching
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
807 return aet1 == aet2;
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
808 }
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
809 else
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
810 {
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
811 // Case-insensitive matching (default)
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
812 std::string tmp1, tmp2;
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
813 Toolbox::ToLowerCase(tmp1, aet1);
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
814 Toolbox::ToLowerCase(tmp2, aet2);
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
815 return tmp1 == tmp2;
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 }
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
818
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
819
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
820 bool Configuration::LookupDicomModalityUsingAETitle(RemoteModalityParameters& modality,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
821 const std::string& aet)
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
822 {
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
823 std::set<std::string> modalities;
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
824 GetListOfDicomModalities(modalities);
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
825
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
826 for (std::set<std::string>::const_iterator
656
08eca5d86aad fixes to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
827 it = modalities.begin(); it != modalities.end(); ++it)
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
828 {
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
829 try
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
830 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
831 GetDicomModalityUsingSymbolicName(modality, *it);
725
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 696
diff changeset
832
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
833 if (IsSameAETitle(aet, modality.GetApplicationEntityTitle()))
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
834 {
617
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
835 return true;
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
836 }
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
837 }
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
838 catch (OrthancException&)
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
839 {
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
840 }
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
841 }
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
842
617
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
843 return false;
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
844 }
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
845
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
846
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
847 bool Configuration::IsKnownAETitle(const std::string& aet)
617
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
848 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
849 RemoteModalityParameters modality;
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
850 return LookupDicomModalityUsingAETitle(modality, aet);
617
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
851 }
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
852
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
853
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
854 RemoteModalityParameters Configuration::GetModalityUsingSymbolicName(const std::string& name)
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
855 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
856 RemoteModalityParameters modality;
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
857 GetDicomModalityUsingSymbolicName(modality, name);
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
858
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
859 return modality;
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
860 }
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
861
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 772
diff changeset
862
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
863 RemoteModalityParameters Configuration::GetModalityUsingAet(const std::string& aet)
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
864 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
865 RemoteModalityParameters modality;
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
866
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
867 if (LookupDicomModalityUsingAETitle(modality, aet))
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
868 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
869 return modality;
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
870 }
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
871 else
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
872 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
873 LOG(ERROR) << "Unknown modality for AET: " << aet;
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
874 throw OrthancException(ErrorCode_InexistentItem);
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
875 }
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
876 }
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
877
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
878
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
879 void Configuration::UpdateModality(const std::string& symbolicName,
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
880 const RemoteModalityParameters& modality)
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
881 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
882 boost::recursive_mutex::scoped_lock lock(globalMutex_);
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
883
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
884 if (!configuration_.isMember("DicomModalities"))
1366
a3559b66fba7 move primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1326
diff changeset
885 {
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
886 configuration_["DicomModalities"] = Json::objectValue;
1366
a3559b66fba7 move primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1326
diff changeset
887 }
a3559b66fba7 move primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1326
diff changeset
888
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
889 Json::Value& modalities = configuration_["DicomModalities"];
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
890 if (modalities.type() != Json::objectValue)
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
891 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
892 LOG(ERROR) << "Bad file format for modality: " << symbolicName;
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
893 throw OrthancException(ErrorCode_BadFileFormat);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
894 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
895
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
896 modalities.removeMember(symbolicName);
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
897
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
898 Json::Value v;
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
899 modality.ToJson(v);
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
900 modalities[symbolicName] = v;
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
901 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
902
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
903
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
904 void Configuration::RemoveModality(const std::string& symbolicName)
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
905 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
906 boost::recursive_mutex::scoped_lock lock(globalMutex_);
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
907
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
908 if (!configuration_.isMember("DicomModalities"))
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
909 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
910 LOG(ERROR) << "No modality with symbolic name: " << symbolicName;
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
911 throw OrthancException(ErrorCode_BadFileFormat);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
912 }
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 Json::Value& modalities = configuration_["DicomModalities"];
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
915 if (modalities.type() != Json::objectValue)
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
916 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
917 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
918 throw OrthancException(ErrorCode_BadFileFormat);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
919 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
920
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
921 modalities.removeMember(symbolicName.c_str());
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
922 }
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
923
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
924
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
925 void Configuration::UpdatePeer(const std::string& symbolicName,
2020
a0bd8cd55da7 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2010
diff changeset
926 const WebServiceParameters& peer)
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
927 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
928 boost::recursive_mutex::scoped_lock lock(globalMutex_);
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
929
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
930 if (!configuration_.isMember("OrthancPeers"))
1366
a3559b66fba7 move primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1326
diff changeset
931 {
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
932 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
933 configuration_["OrthancPeers"] = Json::objectValue;
1366
a3559b66fba7 move primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1326
diff changeset
934 }
a3559b66fba7 move primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1326
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 Json::Value& peers = configuration_["OrthancPeers"];
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
937 if (peers.type() != Json::objectValue)
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
938 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
939 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
940 throw OrthancException(ErrorCode_BadFileFormat);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
941 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
942
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
943 peers.removeMember(symbolicName);
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
944
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
945 Json::Value v;
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
946 peer.ToJson(v);
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
947 peers[symbolicName] = v;
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
948 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
949
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
950
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
951 void Configuration::RemovePeer(const std::string& symbolicName)
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
952 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
953 boost::recursive_mutex::scoped_lock lock(globalMutex_);
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
954
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
955 if (!configuration_.isMember("OrthancPeers"))
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
956 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
957 LOG(ERROR) << "No peer with symbolic name: " << symbolicName;
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
958 throw OrthancException(ErrorCode_BadFileFormat);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
959 }
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 Json::Value& peers = configuration_["OrthancPeers"];
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
962 if (peers.type() != Json::objectValue)
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
963 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
964 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
965 throw OrthancException(ErrorCode_BadFileFormat);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
966 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
967
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
968 peers.removeMember(symbolicName.c_str());
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
969 }
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
970
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
971
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
972
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
973 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
974 {
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
975 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
976 }
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
977
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
978
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
979 static IDatabaseWrapper* CreateSQLiteWrapper()
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
980 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
981 std::string storageDirectoryStr = Configuration::GetGlobalStringParameter("StorageDirectory", "OrthancStorage");
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
982
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
983 // Open the database
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
984 boost::filesystem::path indexDirectory = Configuration::InterpretStringParameterAsPath(
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
985 Configuration::GetGlobalStringParameter("IndexDirectory", storageDirectoryStr));
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
986
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
987 LOG(WARNING) << "SQLite index directory: " << indexDirectory;
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
988
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
989 try
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
990 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
991 boost::filesystem::create_directories(indexDirectory);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
992 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
993 catch (boost::filesystem::filesystem_error)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
994 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
995 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
996
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
997 return new DatabaseWrapper(indexDirectory.string() + "/index");
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
998 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
999
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1000
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1001 namespace
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1002 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1003 // Anonymous namespace to avoid clashes between compilation modules
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1004
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1005 class FilesystemStorageWithoutDicom : public IStorageArea
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1006 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1007 private:
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1008 FilesystemStorage storage_;
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1009
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1010 public:
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1011 FilesystemStorageWithoutDicom(const std::string& path) : storage_(path)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1012 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1013 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1014
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1015 virtual void Create(const std::string& uuid,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1016 const void* content,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1017 size_t size,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1018 FileContentType type)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1019 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1020 if (type != FileContentType_Dicom)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1021 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1022 storage_.Create(uuid, content, size, type);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1023 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1024 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1025
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1026 virtual void Read(std::string& content,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1027 const std::string& uuid,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1028 FileContentType type)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1029 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1030 if (type != FileContentType_Dicom)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1031 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1032 storage_.Read(content, uuid, type);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1033 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1034 else
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1035 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1036 throw OrthancException(ErrorCode_UnknownResource);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1037 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1038 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1039
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1040 virtual void Remove(const std::string& uuid,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1041 FileContentType type)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1042 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1043 if (type != FileContentType_Dicom)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1044 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1045 storage_.Remove(uuid, type);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1046 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1047 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1048 };
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1049 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1050
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1051
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1052 static IStorageArea* CreateFilesystemStorage()
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1053 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1054 std::string storageDirectoryStr = Configuration::GetGlobalStringParameter("StorageDirectory", "OrthancStorage");
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1055
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1056 boost::filesystem::path storageDirectory = Configuration::InterpretStringParameterAsPath(storageDirectoryStr);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1057 LOG(WARNING) << "Storage directory: " << storageDirectory;
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1058
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1059 if (Configuration::GetGlobalBoolParameter("StoreDicom", true))
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1060 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1061 return new FilesystemStorage(storageDirectory.string());
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1062 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1063 else
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1064 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1065 LOG(WARNING) << "The DICOM files will not be stored, Orthanc running in index-only mode";
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1066 return new FilesystemStorageWithoutDicom(storageDirectory.string());
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1067 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1068 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1069
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1070
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1071 IDatabaseWrapper* Configuration::CreateDatabaseWrapper()
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1072 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1073 return CreateSQLiteWrapper();
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1074 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1075
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1076
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1077 IStorageArea* Configuration::CreateStorageArea()
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1078 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1079 return CreateFilesystemStorage();
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
1080 }
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
1081
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
1082
1587
d7e569640d09 New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1083 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
1084 {
1892
0001f8cd7849 Warn about badly formatted modality/peer definitions in configuration file at startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1772
diff changeset
1085 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
1086 result = configuration_;
d7e569640d09 New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1087 }
d7e569640d09 New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1088
d7e569640d09 New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1089
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
1090 void Configuration::FormatConfiguration(std::string& result)
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
1091 {
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
1092 Json::Value config;
1587
d7e569640d09 New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1093 GetConfiguration(config);
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
1094
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
1095 Json::StyledWriter w;
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
1096 result = w.write(config);
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
1097 }
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1098
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1099
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1100 const FontRegistry& Configuration::GetFontRegistry()
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1101 {
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1102 return fontRegistry_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1103 }
1928
84c7eaeb5244 Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1927
diff changeset
1104
84c7eaeb5244 Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1927
diff changeset
1105
84c7eaeb5244 Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1927
diff changeset
1106 Encoding Configuration::GetDefaultEncoding()
84c7eaeb5244 Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1927
diff changeset
1107 {
84c7eaeb5244 Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1927
diff changeset
1108 std::string s = GetGlobalStringParameter("DefaultEncoding", "Latin1");
84c7eaeb5244 Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1927
diff changeset
1109
84c7eaeb5244 Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1927
diff changeset
1110 // By default, Latin1 encoding is assumed
84c7eaeb5244 Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1927
diff changeset
1111 return s.empty() ? Encoding_Latin1 : StringToEncoding(s.c_str());
84c7eaeb5244 Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1927
diff changeset
1112 }
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
1113
4dafe2a0d3ab Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
1114
2202
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2151
diff changeset
1115 void Configuration::SetDefaultEncoding(Encoding encoding)
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2151
diff changeset
1116 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2151
diff changeset
1117 std::string name = EnumerationToString(encoding);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2151
diff changeset
1118
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2151
diff changeset
1119 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2151
diff changeset
1120 boost::recursive_mutex::scoped_lock lock(globalMutex_);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2151
diff changeset
1121 configuration_["DefaultEncoding"] = name;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2151
diff changeset
1122 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2151
diff changeset
1123
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2151
diff changeset
1124 LOG(INFO) << "Default encoding was changed to: " << name;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2151
diff changeset
1125 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2151
diff changeset
1126
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2151
diff changeset
1127
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
1128 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
1129 {
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 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
1131 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
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 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
1134 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
1135
4dafe2a0d3ab Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
1136 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
1137 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
1138 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
1139
4dafe2a0d3ab Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
1140 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
1141 }
2131
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1142
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1143
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1144 void Configuration::ExtractDicomSummary(DicomMap& target,
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1145 DcmItem& dataset)
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1146 {
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1147 FromDcmtkBridge::ExtractDicomSummary(target, dataset,
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1148 ORTHANC_MAXIMUM_TAG_LENGTH, GetDefaultEncoding());
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1149 }
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1150
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1151
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1152 void Configuration::ExtractDicomAsJson(Json::Value& target,
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1153 DcmDataset& dataset)
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1154 {
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1155 FromDcmtkBridge::ExtractDicomAsJson(target, dataset,
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1156 DicomToJsonFormat_Full, DicomToJsonFlags_Default,
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1157 ORTHANC_MAXIMUM_TAG_LENGTH, GetDefaultEncoding());
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1158 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1159 }