annotate OrthancServer/OrthancInitialization.cpp @ 1592:d73124f6b439

configuration option HttpDescribeErrors
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 27 Aug 2015 11:35:16 +0200
parents d7e569640d09
children f2e3d030ea59
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
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1275
diff changeset
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1275
diff changeset
4 * Department, University Hospital of Liege, Belgium
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
136
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
10 *
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
11 * In addition, as a special exception, the copyright holders of this
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
12 * 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
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
15 * the linked executables. You must obey the GNU General Public License
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
16 * 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
17 * 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
18 * 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
19 * 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
20 * version. If you delete this exception statement from all source files
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
21 * in the program, then also delete it here.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * 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
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
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
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
33 #include "PrecompiledHeadersServer.h"
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
34 #include "OrthancInitialization.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
476
4aae0261515e move HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 457
diff changeset
36 #include "../Core/HttpClient.h"
1485
27661b33f624 Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1429
diff changeset
37 #include "../Core/Logging.h"
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
38 #include "../Core/OrthancException.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 #include "../Core/Toolbox.h"
1485
27661b33f624 Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1429
diff changeset
40 #include "../Core/FileStorage/FilesystemStorage.h"
27661b33f624 Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1429
diff changeset
41
685
b01cc78caba4 possibility to disable the DICOM/HTTP servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 660
diff changeset
42 #include "DicomProtocol/DicomServer.h"
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"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 #include <boost/lexical_cast.hpp>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 #include <boost/filesystem.hpp>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 #include <curl/curl.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 #include <boost/thread.hpp>
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
50
847
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
51
1526
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
52 #if ORTHANC_SSL_ENABLED == 1
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
53 // For OpenSSL initialization and finalization
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
54 #include <openssl/conf.h>
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
55 #include <openssl/engine.h>
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
56 #include <openssl/err.h>
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
57 #include <openssl/evp.h>
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
58 #include <openssl/ssl.h>
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
59 #endif
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
60
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
61
847
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
62 #if ORTHANC_JPEG_ENABLED == 1
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
63 #include <dcmtk/dcmjpeg/djdecode.h>
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
64 #endif
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
65
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
66
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
67 #if ORTHANC_JPEG_LOSSLESS_ENABLED == 1
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
68 #include <dcmtk/dcmjpls/djdecode.h>
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
69 #endif
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
70
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
71
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
72 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 static boost::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
75 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
76 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
77 static std::string configurationAbsolutePath_;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
79
1533
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
80 static std::string GetGlobalStringParameterInternal(const std::string& parameter,
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
81 const std::string& defaultValue)
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
82 {
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
83 if (configuration_.isMember(parameter))
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
84 {
1592
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
85 if (configuration_[parameter].type() != Json::stringValue)
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
86 {
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
87 LOG(ERROR) << "The configuration option \"" << parameter << "\" must be a string";
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
88 throw OrthancException(ErrorCode_BadParameterType);
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 else
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
91 {
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
92 return configuration_[parameter].asString();
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
93 }
1533
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 else
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 return defaultValue;
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
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
101
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
102 static bool GetGlobalBoolParameterInternal(const std::string& parameter,
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
103 bool defaultValue)
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
104 {
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
105 if (configuration_.isMember(parameter))
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
106 {
1592
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
107 if (configuration_[parameter].type() != Json::booleanValue)
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
108 {
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
109 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
110 throw OrthancException(ErrorCode_BadParameterType);
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 else
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
113 {
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
114 return configuration_[parameter].asBool();
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
115 }
1533
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 else
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 return defaultValue;
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
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
123
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
124
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 static void AddFileToConfiguration(const boost::filesystem::path& 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
126 {
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 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
128
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
129 Json::Value config;
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 {
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
132 std::string content;
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
133 Toolbox::ReadFile(content, path.string());
1423
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
134
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
135 Json::Value tmp;
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
136 Json::Reader reader;
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
137 if (!reader.parse(content, tmp) ||
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
138 tmp.type() != Json::objectValue)
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
139 {
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
140 LOG(ERROR) << "Bad file format for this configuration file: " << path;
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
141 throw OrthancException(ErrorCode_BadFileFormat);
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
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
144 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
145 }
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
146
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 if (configuration_.size() == 0)
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
148 {
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
149 configuration_ = 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
150 }
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 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
152 {
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
153 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
154 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
155 {
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 if (configuration_.isMember(members[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
157 {
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 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
159 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
160 }
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 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
162 {
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
163 configuration_[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
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
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
169
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
170 static void ScanFolderForConfiguration(const char* 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
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 {
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
188 AddFileToConfiguration(it->path().string());
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
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 static void ReadGlobalConfiguration(const char* configurationFile)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 {
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
197 // Prepare the default configuration
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
198 defaultDirectory_ = boost::filesystem::current_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
199 configuration_ = Json::objectValue;
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
200 configurationAbsolutePath_ = "";
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 if (configurationFile)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 {
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
204 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
205 {
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 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
207 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
208 }
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
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
210 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
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 defaultDirectory_ = boost::filesystem::path(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
213 configurationAbsolutePath_ = boost::filesystem::absolute(configurationFile).parent_path().string();
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
214 ScanFolderForConfiguration(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
215 }
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
216 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
217 {
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
218 defaultDirectory_ = boost::filesystem::path(configurationFile).parent_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
219 configurationAbsolutePath_ = boost::filesystem::absolute(configurationFile).string();
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
220 AddFileToConfiguration(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
221 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 {
660
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
225 #if ORTHANC_STANDALONE == 1
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
226 // No default path for the standalone configuration
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
227 LOG(WARNING) << "Using the default Orthanc configuration";
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
228 return;
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
229
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
230 #else
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
231 // In a non-standalone build, we use the
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
232 // "Resources/Configuration.json" from the Orthanc source code
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
233
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
234 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
235 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
236 p /= "Configuration.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
237 configurationAbsolutePath_ = boost::filesystem::absolute(p).string();
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
238
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
239 AddFileToConfiguration(p);
87
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
240 #endif
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
245 static void RegisterUserMetadata()
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
246 {
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
247 if (configuration_.isMember("UserMetadata"))
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
248 {
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
249 const Json::Value& parameter = configuration_["UserMetadata"];
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
250
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
251 Json::Value::Members members = parameter.getMemberNames();
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
252 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
253 {
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
254 std::string info = "\"" + members[i] + "\" = " + parameter[members[i]].toStyledString();
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
255 LOG(INFO) << "Registering user-defined metadata: " << info;
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
256
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
257 if (!parameter[members[i]].asBool())
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
258 {
439
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
259 LOG(ERROR) << "Not a number in this user-defined metadata: " << info;
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
260 throw OrthancException(ErrorCode_BadParameterType);
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
261 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
262
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
263 int metadata = parameter[members[i]].asInt();
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
264
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
265 try
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
266 {
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
267 RegisterUserMetadata(metadata, members[i]);
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
268 }
657
5425bb6f1ea5 further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
269 catch (OrthancException&)
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
270 {
439
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
271 LOG(ERROR) << "Cannot register this user-defined metadata: " << info;
657
5425bb6f1ea5 further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
272 throw;
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
273 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
274 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
275 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
276 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
277
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
278
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
279 static void RegisterUserContentType()
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
280 {
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
281 if (configuration_.isMember("UserContentType"))
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
282 {
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
283 const Json::Value& parameter = configuration_["UserContentType"];
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
284
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
285 Json::Value::Members members = parameter.getMemberNames();
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
286 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
287 {
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
288 std::string info = "\"" + members[i] + "\" = " + parameter[members[i]].toStyledString();
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
289 LOG(INFO) << "Registering user-defined attachment type: " << info;
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
290
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
291 if (!parameter[members[i]].asBool())
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
292 {
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
293 LOG(ERROR) << "Not a number in this user-defined attachment type: " << info;
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
294 throw OrthancException(ErrorCode_BadParameterType);
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
295 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
296
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
297 int contentType = parameter[members[i]].asInt();
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
298
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
299 try
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
300 {
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
301 RegisterUserContentType(contentType, members[i]);
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
302 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
303 catch (OrthancException&)
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
304 {
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
305 LOG(ERROR) << "Cannot register this user-defined attachment type: " << info;
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
306 throw;
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
307 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
308 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
309 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
310 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
311
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
312
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
313 void OrthancInitialize(const char* configurationFile)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 boost::mutex::scoped_lock lock(globalMutex_);
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
316
1526
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
317 #if ORTHANC_SSL_ENABLED == 1
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
318 // https://wiki.openssl.org/index.php/Library_Initialization
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
319 SSL_library_init();
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
320 SSL_load_error_strings();
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
321 OpenSSL_add_all_algorithms();
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
322 ERR_load_crypto_strings();
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
323
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
324 curl_global_init(CURL_GLOBAL_ALL);
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
325 #else
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
326 curl_global_init(CURL_GLOBAL_ALL & ~CURL_GLOBAL_SSL);
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
327 #endif
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
328
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
329 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
330
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
331 // Read the user-provided configuration
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 ReadGlobalConfiguration(configurationFile);
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
333
1533
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
334 HttpClient::GlobalInitialize(GetGlobalBoolParameterInternal("HttpsVerifyPeers", true),
1534
95b3b0260240 Options to validate peers against CA certificates in HTTPS requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1533
diff changeset
335 GetGlobalStringParameterInternal("HttpsCACertificates", ""));
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
336
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
337 RegisterUserMetadata();
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
338 RegisterUserContentType();
685
b01cc78caba4 possibility to disable the DICOM/HTTP servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 660
diff changeset
339
b01cc78caba4 possibility to disable the DICOM/HTTP servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 660
diff changeset
340 DicomServer::InitializeDictionary();
847
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
341
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
342 #if ORTHANC_JPEG_LOSSLESS_ENABLED == 1
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
343 LOG(WARNING) << "Registering JPEG Lossless codecs";
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
344 DJLSDecoderRegistration::registerCodecs();
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
345 #endif
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
346
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
347 #if ORTHANC_JPEG_ENABLED == 1
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
348 LOG(WARNING) << "Registering JPEG codecs";
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
349 DJDecoderRegistration::registerCodecs();
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
350 #endif
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
355 void OrthancFinalize()
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 boost::mutex::scoped_lock lock(globalMutex_);
457
997282a61ff8 cleaner names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
358 HttpClient::GlobalFinalize();
847
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
359
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
360 #if ORTHANC_JPEG_LOSSLESS_ENABLED == 1
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
361 // Unregister JPEG-LS codecs
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
362 DJLSDecoderRegistration::cleanup();
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
363 #endif
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
364
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
365 #if ORTHANC_JPEG_ENABLED == 1
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
366 // Unregister JPEG codecs
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
367 DJDecoderRegistration::cleanup();
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
368 #endif
1526
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
369
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
370 curl_global_cleanup();
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
371
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
372 #if ORTHANC_SSL_ENABLED == 1
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
373 // Finalize OpenSSL
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
374 // https://wiki.openssl.org/index.php/Library_Initialization#Cleanup
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
375 FIPS_mode_set(0);
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
376 ENGINE_cleanup();
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
377 CONF_modules_unload(1);
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
378 EVP_cleanup();
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
379 CRYPTO_cleanup_all_ex_data();
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
380 ERR_remove_state(0);
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
381 ERR_free_strings();
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
382 #endif
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
386 std::string Configuration::GetGlobalStringParameter(const std::string& parameter,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
387 const std::string& defaultValue)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 boost::mutex::scoped_lock lock(globalMutex_);
1533
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
390 return GetGlobalStringParameterInternal(parameter, defaultValue);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
394 int Configuration::GetGlobalIntegerParameter(const std::string& parameter,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
395 int defaultValue)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 boost::mutex::scoped_lock lock(globalMutex_);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398
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
399 if (configuration_.isMember(parameter))
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400 {
1592
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
401 if (configuration_[parameter].type() != Json::intValue)
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
402 {
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
403 LOG(ERROR) << "The configuration option \"" << parameter << "\" must be an integer";
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
404 throw OrthancException(ErrorCode_BadParameterType);
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
405 }
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
406 else
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
407 {
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
408 return configuration_[parameter].asInt();
d73124f6b439 configuration option HttpDescribeErrors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
409 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 return defaultValue;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
417
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
418 bool Configuration::GetGlobalBoolParameter(const std::string& parameter,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
419 bool defaultValue)
23
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
420 {
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
421 boost::mutex::scoped_lock lock(globalMutex_);
1533
0011cc99443c improving HTTPS support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1526
diff changeset
422 return GetGlobalBoolParameterInternal(parameter, defaultValue);
23
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
423 }
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
424
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
425
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
426 void Configuration::GetDicomModalityUsingSymbolicName(RemoteModalityParameters& modality,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
427 const std::string& name)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 boost::mutex::scoped_lock lock(globalMutex_);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430
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
431 if (!configuration_.isMember("DicomModalities"))
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
433 LOG(ERROR) << "No modality with symbolic name: " << name;
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
434 throw OrthancException(ErrorCode_InexistentItem);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436
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
437 const Json::Value& modalities = configuration_["DicomModalities"];
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 if (modalities.type() != Json::objectValue ||
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
439 !modalities.isMember(name))
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440 {
1007
871c49c9b11d lua routing is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 942
diff changeset
441 LOG(ERROR) << "No modality with symbolic name: " << name;
871c49c9b11d lua routing is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 942
diff changeset
442 throw OrthancException(ErrorCode_InexistentItem);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 try
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446 {
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
447 modality.FromJson(modalities[name]);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 }
1545
33d34bc4ac15 fix msvc warnings
jodogne
parents: 1534
diff changeset
449 catch (OrthancException&)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450 {
1429
7366a0bdda6a attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
451 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
452 << "\". Please check your configuration file.";
942
b3f6fb1130cd fixes thanks to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 847
diff changeset
453 throw;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
459 void Configuration::GetOrthancPeer(OrthancPeerParameters& peer,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
460 const std::string& name)
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
461 {
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
462 boost::mutex::scoped_lock lock(globalMutex_);
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
463
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
464 if (!configuration_.isMember("OrthancPeers"))
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
465 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
466 LOG(ERROR) << "No peer with symbolic name: " << name;
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
467 throw OrthancException(ErrorCode_InexistentItem);
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
468 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
469
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
470 try
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
471 {
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
472 const Json::Value& modalities = configuration_["OrthancPeers"];
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
473 if (modalities.type() != Json::objectValue ||
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
474 !modalities.isMember(name))
485
bdbde1fbfab3 send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 484
diff changeset
475 {
1007
871c49c9b11d lua routing is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 942
diff changeset
476 LOG(ERROR) << "No peer with symbolic name: " << name;
871c49c9b11d lua routing is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 942
diff changeset
477 throw OrthancException(ErrorCode_InexistentItem);
485
bdbde1fbfab3 send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 484
diff changeset
478 }
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
479
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
480 peer.FromJson(modalities[name]);
485
bdbde1fbfab3 send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 484
diff changeset
481 }
1545
33d34bc4ac15 fix msvc warnings
jodogne
parents: 1534
diff changeset
482 catch (OrthancException&)
485
bdbde1fbfab3 send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 484
diff changeset
483 {
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
484 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
485 << "\". Please check your configuration file.";
942
b3f6fb1130cd fixes thanks to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 847
diff changeset
486 throw;
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
487 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
488 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
489
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
490
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
491 static bool ReadKeys(std::set<std::string>& target,
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
492 const char* parameter,
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
493 bool onlyAlphanumeric)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495 boost::mutex::scoped_lock lock(globalMutex_);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497 target.clear();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498
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
499 if (!configuration_.isMember(parameter))
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 {
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
501 return true;
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
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
504 const Json::Value& modalities = configuration_[parameter];
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 if (modalities.type() != Json::objectValue)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
507 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
508 throw OrthancException(ErrorCode_BadFileFormat);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
510
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511 Json::Value::Members members = modalities.getMemberNames();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512 for (size_t i = 0; i < members.size(); i++)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513 {
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
514 if (onlyAlphanumeric)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515 {
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
516 for (size_t j = 0; j < members[i].size(); j++)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517 {
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
518 if (!isalnum(members[i][j]) && members[i][j] != '-')
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
519 {
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
520 return false;
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
521 }
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
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525 target.insert(members[i]);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
526 }
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
527
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
528 return true;
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
529 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
530
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
531
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
532 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
533 {
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
534 if (!ReadKeys(target, "DicomModalities", true))
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
535 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
536 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
537 throw OrthancException(ErrorCode_BadFileFormat);
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
538 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
539 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
540
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
541
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
542 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
543 {
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
544 if (!ReadKeys(target, "OrthancPeers", true))
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
545 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
546 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
547 throw OrthancException(ErrorCode_BadFileFormat);
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
548 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549 }
25
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
550
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
551
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
552
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
553 void Configuration::SetupRegisteredUsers(MongooseServer& httpServer)
25
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
554 {
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
555 boost::mutex::scoped_lock lock(globalMutex_);
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
556
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
557 httpServer.ClearUsers();
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
558
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
559 if (!configuration_.isMember("RegisteredUsers"))
25
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
560 {
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
561 return;
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
562 }
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
563
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
564 const Json::Value& users = configuration_["RegisteredUsers"];
25
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
565 if (users.type() != Json::objectValue)
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
566 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
567 LOG(ERROR) << "Badly formatted list of users";
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
568 throw OrthancException(ErrorCode_BadFileFormat);
25
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
569 }
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
570
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
571 Json::Value::Members usernames = users.getMemberNames();
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
572 for (size_t i = 0; i < usernames.size(); i++)
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
573 {
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
574 const std::string& username = usernames[i];
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
575 std::string password = users[username].asString();
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
576 httpServer.RegisterUser(username.c_str(), password.c_str());
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
577 }
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
578 }
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
579
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
580
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
581 std::string Configuration::InterpretRelativePath(const std::string& baseDirectory,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
582 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
583 {
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
584 boost::filesystem::path base(baseDirectory);
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
585 boost::filesystem::path relative(relativePath);
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
586
428
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
587 /**
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
588 The following lines should be equivalent to this one:
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
589
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
590 return (base / relative).string();
428
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
591
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
592 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
593 make the proper path resolution when "baseDirectory" is an
428
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
594 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
595 **/
428
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
596
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
597 if (relative.is_absolute())
427
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
598 {
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
599 return relative.string();
427
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
600 }
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
601 else
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
602 {
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
603 return (base / relative).string();
427
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
604 }
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
605 }
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
606
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
607 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
608 {
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
609 boost::mutex::scoped_lock lock(globalMutex_);
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
610 return InterpretRelativePath(defaultDirectory_.string(), parameter);
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
611 }
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
612
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
613
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
614 void Configuration::GetGlobalListOfStringsParameter(std::list<std::string>& target,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
615 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
616 {
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
617 boost::mutex::scoped_lock lock(globalMutex_);
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
618
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
619 target.clear();
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
620
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
621 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
622 {
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
623 return;
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
624 }
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
625
1423
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
626 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
627
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
628 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
629 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
630 LOG(ERROR) << "Badly formatted list of strings";
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
631 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
632 }
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
633
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
634 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
635 {
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
636 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
637 }
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
638 }
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
639
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
640
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
641 bool Configuration::IsSameAETitle(const std::string& aet1,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
642 const std::string& aet2)
690
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
643 {
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
644 if (GetGlobalBoolParameter("StrictAetComparison", false))
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
645 {
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
646 // Case-sensitive matching
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
647 return aet1 == aet2;
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
648 }
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
649 else
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
650 {
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
651 // Case-insensitive matching (default)
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
652 std::string tmp1, tmp2;
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
653 Toolbox::ToLowerCase(tmp1, aet1);
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
654 Toolbox::ToLowerCase(tmp2, aet2);
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
655 return tmp1 == tmp2;
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
656 }
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
657 }
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
658
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
659
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
660 bool Configuration::LookupDicomModalityUsingAETitle(RemoteModalityParameters& modality,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
661 const std::string& aet)
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
662 {
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
663 std::set<std::string> modalities;
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
664 GetListOfDicomModalities(modalities);
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
665
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
666 for (std::set<std::string>::const_iterator
656
08eca5d86aad fixes to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
667 it = modalities.begin(); it != modalities.end(); ++it)
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
668 {
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
669 try
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
670 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
671 GetDicomModalityUsingSymbolicName(modality, *it);
725
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 696
diff changeset
672
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
673 if (IsSameAETitle(aet, modality.GetApplicationEntityTitle()))
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
674 {
617
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
675 return true;
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
676 }
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
677 }
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
678 catch (OrthancException&)
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
679 {
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
680 }
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
681 }
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
682
617
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
683 return false;
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
684 }
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
685
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
686
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
687 bool Configuration::IsKnownAETitle(const std::string& aet)
617
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
688 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
689 RemoteModalityParameters modality;
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
690 return LookupDicomModalityUsingAETitle(modality, aet);
617
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
691 }
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
692
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
693
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
694 RemoteModalityParameters Configuration::GetModalityUsingSymbolicName(const std::string& name)
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
695 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
696 RemoteModalityParameters modality;
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
697 GetDicomModalityUsingSymbolicName(modality, name);
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
698
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
699 return modality;
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
700 }
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
701
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 772
diff changeset
702
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
703 RemoteModalityParameters Configuration::GetModalityUsingAet(const std::string& aet)
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
704 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
705 RemoteModalityParameters modality;
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
706
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
707 if (LookupDicomModalityUsingAETitle(modality, aet))
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
708 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
709 return modality;
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
710 }
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
711 else
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
712 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
713 LOG(ERROR) << "Unknown modality for AET: " << aet;
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
714 throw OrthancException(ErrorCode_InexistentItem);
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
715 }
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
716 }
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
717
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
718
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
719 void Configuration::UpdateModality(const std::string& symbolicName,
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
720 const RemoteModalityParameters& modality)
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
721 {
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
722 boost::mutex::scoped_lock lock(globalMutex_);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
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 if (!configuration_.isMember("DicomModalities"))
1366
a3559b66fba7 move primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1326
diff changeset
725 {
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
726 configuration_["DicomModalities"] = Json::objectValue;
1366
a3559b66fba7 move primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1326
diff changeset
727 }
a3559b66fba7 move primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1326
diff changeset
728
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
729 Json::Value& modalities = configuration_["DicomModalities"];
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
730 if (modalities.type() != Json::objectValue)
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
731 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
732 LOG(ERROR) << "Bad file format for modality: " << symbolicName;
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
733 throw OrthancException(ErrorCode_BadFileFormat);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
734 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
735
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
736 modalities.removeMember(symbolicName);
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
737
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
738 Json::Value v;
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
739 modality.ToJson(v);
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
740 modalities[symbolicName] = v;
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
741 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
742
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
743
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
744 void Configuration::RemoveModality(const std::string& symbolicName)
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
745 {
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
746 boost::mutex::scoped_lock lock(globalMutex_);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
747
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
748 if (!configuration_.isMember("DicomModalities"))
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
749 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
750 LOG(ERROR) << "No modality with symbolic name: " << symbolicName;
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
751 throw OrthancException(ErrorCode_BadFileFormat);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
752 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
753
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
754 Json::Value& modalities = configuration_["DicomModalities"];
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
755 if (modalities.type() != Json::objectValue)
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
756 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
757 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
758 throw OrthancException(ErrorCode_BadFileFormat);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
759 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
760
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
761 modalities.removeMember(symbolicName.c_str());
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
762 }
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
763
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
764
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
765 void Configuration::UpdatePeer(const std::string& symbolicName,
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
766 const OrthancPeerParameters& peer)
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
767 {
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
768 boost::mutex::scoped_lock lock(globalMutex_);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
769
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
770 if (!configuration_.isMember("OrthancPeers"))
1366
a3559b66fba7 move primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1326
diff changeset
771 {
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
772 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
773 configuration_["OrthancPeers"] = Json::objectValue;
1366
a3559b66fba7 move primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1326
diff changeset
774 }
a3559b66fba7 move primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1326
diff changeset
775
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
776 Json::Value& peers = configuration_["OrthancPeers"];
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
777 if (peers.type() != Json::objectValue)
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
778 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
779 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
780 throw OrthancException(ErrorCode_BadFileFormat);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
781 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
782
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
783 peers.removeMember(symbolicName);
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
784
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
785 Json::Value v;
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
786 peer.ToJson(v);
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
787 peers[symbolicName] = v;
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
788 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
789
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
790
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
791 void Configuration::RemovePeer(const std::string& symbolicName)
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
792 {
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
793 boost::mutex::scoped_lock lock(globalMutex_);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
794
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
795 if (!configuration_.isMember("OrthancPeers"))
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
796 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
797 LOG(ERROR) << "No peer with symbolic name: " << symbolicName;
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
798 throw OrthancException(ErrorCode_BadFileFormat);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
799 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
800
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
801 Json::Value& peers = configuration_["OrthancPeers"];
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
802 if (peers.type() != Json::objectValue)
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
803 {
1422
52b2070fc8f1 improvements to the logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1366
diff changeset
804 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
805 throw OrthancException(ErrorCode_BadFileFormat);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
806 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
807
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
808 peers.removeMember(symbolicName.c_str());
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
809 }
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
810
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
811
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
812
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
813 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
814 {
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
815 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
816 }
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
817
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
818
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
819 static IDatabaseWrapper* CreateSQLiteWrapper()
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
820 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
821 std::string storageDirectoryStr = Configuration::GetGlobalStringParameter("StorageDirectory", "OrthancStorage");
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
822
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
823 // Open the database
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
824 boost::filesystem::path indexDirectory = Configuration::InterpretStringParameterAsPath(
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
825 Configuration::GetGlobalStringParameter("IndexDirectory", storageDirectoryStr));
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
826
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
827 LOG(WARNING) << "SQLite index directory: " << indexDirectory;
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
828
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
829 try
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
830 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
831 boost::filesystem::create_directories(indexDirectory);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
832 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
833 catch (boost::filesystem::filesystem_error)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
834 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
835 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
836
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
837 return new DatabaseWrapper(indexDirectory.string() + "/index");
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
838 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
839
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
840
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
841 namespace
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
842 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
843 // Anonymous namespace to avoid clashes between compilation modules
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
844
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
845 class FilesystemStorageWithoutDicom : public IStorageArea
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
846 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
847 private:
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
848 FilesystemStorage storage_;
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
849
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
850 public:
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
851 FilesystemStorageWithoutDicom(const std::string& path) : storage_(path)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
852 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
853 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
854
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
855 virtual void Create(const std::string& uuid,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
856 const void* content,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
857 size_t size,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
858 FileContentType type)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
859 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
860 if (type != FileContentType_Dicom)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
861 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
862 storage_.Create(uuid, content, size, type);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
863 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
864 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
865
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
866 virtual void Read(std::string& content,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
867 const std::string& uuid,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
868 FileContentType type)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
869 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
870 if (type != FileContentType_Dicom)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
871 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
872 storage_.Read(content, uuid, type);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
873 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
874 else
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
875 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
876 throw OrthancException(ErrorCode_UnknownResource);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
877 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
878 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
879
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
880 virtual void Remove(const std::string& uuid,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
881 FileContentType type)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
882 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
883 if (type != FileContentType_Dicom)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
884 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
885 storage_.Remove(uuid, type);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
886 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
887 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
888 };
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
889 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
890
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
891
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
892 static IStorageArea* CreateFilesystemStorage()
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
893 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
894 std::string storageDirectoryStr = Configuration::GetGlobalStringParameter("StorageDirectory", "OrthancStorage");
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
895
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
896 boost::filesystem::path storageDirectory = Configuration::InterpretStringParameterAsPath(storageDirectoryStr);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
897 LOG(WARNING) << "Storage directory: " << storageDirectory;
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
898
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
899 if (Configuration::GetGlobalBoolParameter("StoreDicom", true))
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
900 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
901 return new FilesystemStorage(storageDirectory.string());
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
902 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
903 else
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
904 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
905 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
906 return new FilesystemStorageWithoutDicom(storageDirectory.string());
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
907 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
908 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
909
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
910
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
911 IDatabaseWrapper* Configuration::CreateDatabaseWrapper()
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
912 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
913 return CreateSQLiteWrapper();
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
914 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
915
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
916
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
917 IStorageArea* Configuration::CreateStorageArea()
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
918 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
919 return CreateFilesystemStorage();
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
920 }
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
921
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
922
1587
d7e569640d09 New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
923
d7e569640d09 New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
924 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
925 {
d7e569640d09 New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
926 boost::mutex::scoped_lock lock(globalMutex_);
d7e569640d09 New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
927 result = configuration_;
d7e569640d09 New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
928 }
d7e569640d09 New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
929
d7e569640d09 New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
930
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
931 void Configuration::FormatConfiguration(std::string& result)
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
932 {
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
933 Json::Value config;
1587
d7e569640d09 New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
934 GetConfiguration(config);
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
935
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
936 Json::StyledWriter w;
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
937 result = w.write(config);
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1423
diff changeset
938 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
939 }