annotate OrthancServer/OrthancConfiguration.cpp @ 3470:9aaf40d504a2

merge
author amazy
date Thu, 11 Jul 2019 11:49:15 +0200
parents 8f44dadcdbc1
children 0d248cc63ded
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
3060
4e43e67f8ecf preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "PrecompiledHeadersServer.h"
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "OrthancConfiguration.h"
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
3138
ab46e537f92e renamed class MongooseServer as HttpServer, CivetWeb made default HTTP server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
37 #include "../Core/HttpServer/HttpServer.h"
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include "../Core/Logging.h"
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 #include "../Core/OrthancException.h"
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 #include "../Core/SystemToolbox.h"
3181
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
41 #include "../Core/TemporaryFile.h"
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include "../Core/Toolbox.h"
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
2941
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
44 #include "ServerIndex.h"
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
45
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
46
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
47 static const char* const DICOM_MODALITIES = "DicomModalities";
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
48 static const char* const DICOM_MODALITIES_IN_DB = "DicomModalitiesInDatabase";
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
49 static const char* const ORTHANC_PEERS = "OrthancPeers";
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
50 static const char* const ORTHANC_PEERS_IN_DB = "OrthancPeersInDatabase";
3181
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
51 static const char* const TEMPORARY_DIRECTORY = "TemporaryDirectory";
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
52
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 namespace Orthanc
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 static void AddFileToConfiguration(Json::Value& target,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 const boost::filesystem::path& path)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 std::map<std::string, std::string> env;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 SystemToolbox::GetEnvironmentVariables(env);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 LOG(WARNING) << "Reading the configuration from: " << path;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 Json::Value config;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 std::string content;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 SystemToolbox::ReadFile(content, path.string());
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 content = Toolbox::SubstituteVariables(content, env);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 Json::Value tmp;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 Json::Reader reader;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 if (!reader.parse(content, tmp) ||
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 tmp.type() != Json::objectValue)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2946
diff changeset
76 throw OrthancException(ErrorCode_BadJson,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2946
diff changeset
77 "The configuration file does not follow the JSON syntax: " + path.string());
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 Toolbox::CopyJsonWithoutComments(config, tmp);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 if (target.size() == 0)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 target = config;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 // Merge the newly-added file with the previous content of "target"
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 Json::Value::Members members = config.getMemberNames();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 for (Json::Value::ArrayIndex i = 0; i < members.size(); i++)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 if (target.isMember(members[i]))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2946
diff changeset
95 throw OrthancException(ErrorCode_BadFileFormat,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2946
diff changeset
96 "The configuration section \"" + members[i] +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2946
diff changeset
97 "\" is defined in 2 different configuration files");
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 target[members[i]] = config[members[i]];
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 static void ScanFolderForConfiguration(Json::Value& target,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 const char* folder)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 using namespace boost::filesystem;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 LOG(WARNING) << "Scanning folder \"" << folder << "\" for configuration files";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 directory_iterator end_it; // default construction yields past-the-end
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 for (directory_iterator it(folder);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 it != end_it;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 ++it)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 if (!is_directory(it->status()))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 std::string extension = boost::filesystem::extension(it->path());
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 Toolbox::ToLowerCase(extension);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 if (extension == ".json")
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 AddFileToConfiguration(target, it->path().string());
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 static void ReadConfiguration(Json::Value& target,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 const char* configurationFile)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 target = Json::objectValue;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
139 if (configurationFile != NULL)
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 if (!boost::filesystem::exists(configurationFile))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
143 throw OrthancException(ErrorCode_InexistentFile,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
144 "Inexistent path to configuration: " +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
145 std::string(configurationFile));
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 if (boost::filesystem::is_directory(configurationFile))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 ScanFolderForConfiguration(target, configurationFile);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 AddFileToConfiguration(target, configurationFile);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 #if ORTHANC_STANDALONE == 1
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 // No default path for the standalone configuration
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 LOG(WARNING) << "Using the default Orthanc configuration";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 return;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 #else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 // In a non-standalone build, we use the
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 // "Resources/Configuration.json" from the Orthanc source code
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 boost::filesystem::path p = ORTHANC_PATH;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 p /= "Resources";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 p /= "Configuration.json";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 AddFileToConfiguration(target, p);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 #endif
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
177
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
178 static void CheckAlphanumeric(const std::string& s)
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
180 for (size_t j = 0; j < s.size(); j++)
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
181 {
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
182 if (!isalnum(s[j]) &&
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
183 s[j] != '-')
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
184 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
185 throw OrthancException(ErrorCode_BadFileFormat,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
186 "Only alphanumeric and dash characters are allowed "
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
187 "in the names of modalities/peers, but found: " + s);
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
188 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
189 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
190 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
191
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
192
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
193 void OrthancConfiguration::LoadModalitiesFromJson(const Json::Value& source)
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
194 {
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
195 modalities_.clear();
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
196
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
197 if (source.type() != Json::objectValue)
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
198 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
199 throw OrthancException(ErrorCode_BadFileFormat,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
200 "Bad format of the \"" + std::string(DICOM_MODALITIES) +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
201 "\" configuration section");
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
202 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
203
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
204 Json::Value::Members members = source.getMemberNames();
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
206 for (size_t i = 0; i < members.size(); i++)
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
208 const std::string& name = members[i];
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
209 CheckAlphanumeric(name);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
210
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
211 RemoteModalityParameters modality;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
212 modality.Unserialize(source[name]);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
213 modalities_[name] = modality;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
214 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
215 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
216
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
217
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
218 void OrthancConfiguration::LoadPeersFromJson(const Json::Value& source)
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
219 {
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
220 peers_.clear();
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
221
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
222 if (source.type() != Json::objectValue)
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
223 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
224 throw OrthancException(ErrorCode_BadFileFormat,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
225 "Bad format of the \"" + std::string(ORTHANC_PEERS) +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
226 "\" configuration section");
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
229 Json::Value::Members members = source.getMemberNames();
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
230
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
231 for (size_t i = 0; i < members.size(); i++)
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
232 {
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
233 const std::string& name = members[i];
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
234 CheckAlphanumeric(name);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
235
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
236 WebServiceParameters peer;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
237 peer.Unserialize(source[name]);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
238 peers_[name] = peer;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
239 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
240 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
241
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
242
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
243 void OrthancConfiguration::LoadModalities()
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
244 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
245 if (GetBooleanParameter(DICOM_MODALITIES_IN_DB, false))
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
246 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
247 // Modalities are stored in the database
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
248 if (serverIndex_ == NULL)
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
249 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
250 throw Orthanc::OrthancException(ErrorCode_BadSequenceOfCalls);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
251 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
252 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
253 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
254 std::string property = serverIndex_->GetGlobalProperty(GlobalProperty_Modalities, "{}");
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
255
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
256 Json::Reader reader;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
257 Json::Value modalities;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
258 if (reader.parse(property, modalities))
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
259 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
260 LoadModalitiesFromJson(modalities);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
261 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
262 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
263 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
264 throw OrthancException(ErrorCode_InternalError,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
265 "Cannot unserialize the list of modalities from the Orthanc database");
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
266 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
267 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
268 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
269 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
270 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
271 // Modalities are stored in the configuration files
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
272 if (json_.isMember(DICOM_MODALITIES))
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
273 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
274 LoadModalitiesFromJson(json_[DICOM_MODALITIES]);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
275 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
276 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
277 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
278 modalities_.clear();
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
279 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
280 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
281 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
282
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
283 void OrthancConfiguration::LoadPeers()
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
284 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
285 if (GetBooleanParameter(ORTHANC_PEERS_IN_DB, false))
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
286 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
287 // Peers are stored in the database
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
288 if (serverIndex_ == NULL)
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
289 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
290 throw Orthanc::OrthancException(ErrorCode_BadSequenceOfCalls);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
291 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
292 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
293 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
294 std::string property = serverIndex_->GetGlobalProperty(GlobalProperty_Peers, "{}");
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
295
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
296 Json::Reader reader;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
297 Json::Value peers;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
298 if (reader.parse(property, peers))
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
299 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
300 LoadPeersFromJson(peers);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
301 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
302 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
303 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
304 throw OrthancException(ErrorCode_InternalError,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
305 "Cannot unserialize the list of peers from the Orthanc database");
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
306 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
307 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
308 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
309 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
310 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
311 // Peers are stored in the configuration files
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
312 if (json_.isMember(ORTHANC_PEERS))
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
313 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
314 LoadPeersFromJson(json_[ORTHANC_PEERS]);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
315 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
316 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
317 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
318 peers_.clear();
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
319 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
320 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
321 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
322
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
323
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
324 void OrthancConfiguration::SaveModalitiesToJson(Json::Value& target)
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
325 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
326 target = Json::objectValue;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
327
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
328 for (Modalities::const_iterator it = modalities_.begin(); it != modalities_.end(); ++it)
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
329 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
330 Json::Value modality;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
331 it->second.Serialize(modality, true /* force advanced format */);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
332
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
333 target[it->first] = modality;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
334 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
335 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
336
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
337
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
338 void OrthancConfiguration::SavePeersToJson(Json::Value& target)
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
339 {
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
340 target = Json::objectValue;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
341
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
342 for (Peers::const_iterator it = peers_.begin(); it != peers_.end(); ++it)
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
343 {
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
344 Json::Value peer;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
345 it->second.Serialize(peer,
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
346 false /* use simple format if possible */,
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
347 true /* include passwords */);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
348
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
349 target[it->first] = peer;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
350 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
351 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
352
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
353
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
354 void OrthancConfiguration::SaveModalities()
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
355 {
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
356 if (GetBooleanParameter(DICOM_MODALITIES_IN_DB, false))
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
357 {
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
358 // Modalities are stored in the database
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
359 if (serverIndex_ == NULL)
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
360 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
361 throw Orthanc::OrthancException(ErrorCode_BadSequenceOfCalls);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
362 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
363 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
364 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
365 Json::Value modalities;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
366 SaveModalitiesToJson(modalities);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
367
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
368 Json::FastWriter writer;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
369 std::string s = writer.write(modalities);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
370
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
371 serverIndex_->SetGlobalProperty(GlobalProperty_Modalities, s);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
372 }
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
373 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
374 else
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 {
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
376 // Modalities are stored in the configuration files
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
377 if (!modalities_.empty() ||
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
378 json_.isMember(DICOM_MODALITIES))
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
379 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
380 SaveModalitiesToJson(json_[DICOM_MODALITIES]);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
381 }
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
386 void OrthancConfiguration::SavePeers()
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
387 {
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
388 if (GetBooleanParameter(ORTHANC_PEERS_IN_DB, false))
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
389 {
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
390 // Peers are stored in the database
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
391 if (serverIndex_ == NULL)
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
392 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
393 throw Orthanc::OrthancException(ErrorCode_BadSequenceOfCalls);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
394 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
395 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
396 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
397 Json::Value peers;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
398 SavePeersToJson(peers);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
399
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
400 Json::FastWriter writer;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
401 std::string s = writer.write(peers);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
402
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
403 serverIndex_->SetGlobalProperty(GlobalProperty_Peers, s);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
404 }
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
405 }
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
406 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
407 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
408 // Peers are stored in the configuration files
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
409 if (!peers_.empty() ||
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
410 json_.isMember(ORTHANC_PEERS))
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
411 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
412 SavePeersToJson(json_[ORTHANC_PEERS]);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
413 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
414 }
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
415 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
416
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
417
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 OrthancConfiguration& OrthancConfiguration::GetInstance()
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 static OrthancConfiguration configuration;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 return configuration;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 std::string OrthancConfiguration::GetStringParameter(const std::string& parameter,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 const std::string& defaultValue) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 if (json_.isMember(parameter))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 if (json_[parameter].type() != Json::stringValue)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
432 throw OrthancException(ErrorCode_BadParameterType,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
433 "The configuration option \"" + parameter + "\" must be a string");
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437 return json_[parameter].asString();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442 return defaultValue;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447 int OrthancConfiguration::GetIntegerParameter(const std::string& parameter,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 int defaultValue) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
449 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450 if (json_.isMember(parameter))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
451 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452 if (json_[parameter].type() != Json::intValue)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
454 throw OrthancException(ErrorCode_BadParameterType,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
455 "The configuration option \"" + parameter + "\" must be an integer");
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459 return json_[parameter].asInt();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464 return defaultValue;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469 unsigned int OrthancConfiguration::GetUnsignedIntegerParameter(
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470 const std::string& parameter,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 unsigned int defaultValue) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 int v = GetIntegerParameter(parameter, defaultValue);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475 if (v < 0)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
476 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
477 throw OrthancException(ErrorCode_ParameterOutOfRange,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
478 "The configuration option \"" + parameter + "\" must be a positive integer");
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482 return static_cast<unsigned int>(v);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
487 bool OrthancConfiguration::GetBooleanParameter(const std::string& parameter,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488 bool defaultValue) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
489 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490 if (json_.isMember(parameter))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492 if (json_[parameter].type() != Json::booleanValue)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
494 throw OrthancException(ErrorCode_BadParameterType,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
495 "The configuration option \"" + parameter +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
496 "\" must be a Boolean (true or false)");
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 return json_[parameter].asBool();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
502 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 return defaultValue;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
510 void OrthancConfiguration::Read(const char* configurationFile)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512 // Read the content of the configuration
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513 configurationFileArg_ = configurationFile;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514 ReadConfiguration(json_, configurationFile);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 // Adapt the paths to the configurations
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517 defaultDirectory_ = boost::filesystem::current_path();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518 configurationAbsolutePath_ = "";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520 if (configurationFile)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
521 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
522 if (boost::filesystem::is_directory(configurationFile))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
523 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
524 defaultDirectory_ = boost::filesystem::path(configurationFile);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525 configurationAbsolutePath_ = boost::filesystem::absolute(configurationFile).parent_path().string();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
526 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
527 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
528 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529 defaultDirectory_ = boost::filesystem::path(configurationFile).parent_path();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530 configurationAbsolutePath_ = boost::filesystem::absolute(configurationFile).string();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
531 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
533 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
534 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535 #if ORTHANC_STANDALONE != 1
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536 // In a non-standalone build, we use the
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537 // "Resources/Configuration.json" from the Orthanc source code
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
538
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539 boost::filesystem::path p = ORTHANC_PATH;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
540 p /= "Resources";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541 p /= "Configuration.json";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542 configurationAbsolutePath_ = boost::filesystem::absolute(p).string();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
543 #endif
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
544 }
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
545 }
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
547
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
548 void OrthancConfiguration::LoadModalitiesAndPeers()
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
549 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
550 LoadModalities();
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
551 LoadPeers();
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
552 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555 void OrthancConfiguration::GetDicomModalityUsingSymbolicName(
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556 RemoteModalityParameters& modality,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 const std::string& name) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
559 Modalities::const_iterator found = modalities_.find(name);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
560
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
561 if (found == modalities_.end())
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
563 throw OrthancException(ErrorCode_InexistentItem,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
564 "No modality with symbolic name: " + name);
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565 }
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
566 else
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
567 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
568 modality = found->second;
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
571
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
572
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
573 bool OrthancConfiguration::LookupOrthancPeer(WebServiceParameters& peer,
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
574 const std::string& name) const
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
575 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
576 Peers::const_iterator found = peers_.find(name);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
577
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
578 if (found == peers_.end())
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
580 LOG(ERROR) << "No peer with symbolic name: " << name;
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581 return false;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
582 }
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
583 else
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
585 peer = found->second;
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586 return true;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
587 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
588 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
589
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
590
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591 void OrthancConfiguration::GetListOfDicomModalities(std::set<std::string>& target) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
592 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
593 target.clear();
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
594
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
595 for (Modalities::const_iterator
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
596 it = modalities_.begin(); it != modalities_.end(); ++it)
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
597 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
598 target.insert(it->first);
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
599 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
602
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603 void OrthancConfiguration::GetListOfOrthancPeers(std::set<std::string>& target) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605 target.clear();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
606
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
607 for (Peers::const_iterator it = peers_.begin(); it != peers_.end(); ++it)
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
608 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
609 target.insert(it->first);
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
610 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
611 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
612
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
613
3138
ab46e537f92e renamed class MongooseServer as HttpServer, CivetWeb made default HTTP server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
614 void OrthancConfiguration::SetupRegisteredUsers(HttpServer& httpServer) const
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
615 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616 httpServer.ClearUsers();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
617
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
618 if (!json_.isMember("RegisteredUsers"))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
619 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
620 return;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
621 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
622
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
623 const Json::Value& users = json_["RegisteredUsers"];
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
624 if (users.type() != Json::objectValue)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
625 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
626 throw OrthancException(ErrorCode_BadFileFormat, "Badly formatted list of users");
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
627 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
628
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
629 Json::Value::Members usernames = users.getMemberNames();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
630 for (size_t i = 0; i < usernames.size(); i++)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
631 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
632 const std::string& username = usernames[i];
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
633 std::string password = users[username].asString();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
634 httpServer.RegisterUser(username.c_str(), password.c_str());
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
635 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
636 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
637
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
638
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639 std::string OrthancConfiguration::InterpretStringParameterAsPath(
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
640 const std::string& parameter) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
641 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
642 return SystemToolbox::InterpretRelativePath(defaultDirectory_.string(), parameter);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
643 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
644
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
645
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
646 void OrthancConfiguration::GetListOfStringsParameter(std::list<std::string>& target,
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
647 const std::string& key) const
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
648 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
649 target.clear();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
650
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
651 if (!json_.isMember(key))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
652 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
653 return;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
654 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
655
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
656 const Json::Value& lst = json_[key];
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
657
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
658 if (lst.type() != Json::arrayValue)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
659 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
660 throw OrthancException(ErrorCode_BadFileFormat, "Badly formatted list of strings");
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
661 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
662
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
663 for (Json::Value::ArrayIndex i = 0; i < lst.size(); i++)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
664 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
665 target.push_back(lst[i].asString());
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
666 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
667 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
668
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
669
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
670 bool OrthancConfiguration::IsSameAETitle(const std::string& aet1,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
671 const std::string& aet2) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
672 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
673 if (GetBooleanParameter("StrictAetComparison", false))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
674 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
675 // Case-sensitive matching
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
676 return aet1 == aet2;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
677 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
678 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
679 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
680 // Case-insensitive matching (default)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
681 std::string tmp1, tmp2;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
682 Toolbox::ToLowerCase(tmp1, aet1);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
683 Toolbox::ToLowerCase(tmp2, aet2);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
684 return tmp1 == tmp2;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
685 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
686 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
687
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
688
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
689 bool OrthancConfiguration::LookupDicomModalityUsingAETitle(RemoteModalityParameters& modality,
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
690 const std::string& aet) const
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
691 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
692 for (Modalities::const_iterator it = modalities_.begin(); it != modalities_.end(); ++it)
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
693 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
694 if (IsSameAETitle(aet, it->second.GetApplicationEntityTitle()))
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
695 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
696 modality = it->second;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
697 return true;
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
698 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
699 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
700
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
701 return false;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
702 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
703
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
704
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
705 bool OrthancConfiguration::IsKnownAETitle(const std::string& aet,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
706 const std::string& ip) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
707 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
708 RemoteModalityParameters modality;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
709
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
710 if (!LookupDicomModalityUsingAETitle(modality, aet))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
711 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
712 LOG(WARNING) << "Modality \"" << aet
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
713 << "\" is not listed in the \"DicomModalities\" configuration option";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
714 return false;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
715 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
716 else if (!GetBooleanParameter("DicomCheckModalityHost", false) ||
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
717 ip == modality.GetHost())
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
718 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
719 return true;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
720 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
721 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
722 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
723 LOG(WARNING) << "Forbidding access from AET \"" << aet
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
724 << "\" given its hostname (" << ip << ") does not match "
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
725 << "the \"DicomModalities\" configuration option ("
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
726 << modality.GetHost() << " was expected)";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
727 return false;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
728 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
729 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
730
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
731
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
732 RemoteModalityParameters
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
733 OrthancConfiguration::GetModalityUsingSymbolicName(const std::string& name) const
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
734 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
735 RemoteModalityParameters modality;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
736 GetDicomModalityUsingSymbolicName(modality, name);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
737
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
738 return modality;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
739 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
740
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
741
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
742 RemoteModalityParameters
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
743 OrthancConfiguration::GetModalityUsingAet(const std::string& aet) const
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
744 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
745 RemoteModalityParameters modality;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
746
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
747 if (LookupDicomModalityUsingAETitle(modality, aet))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
748 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
749 return modality;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
750 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
751 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
752 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
753 throw OrthancException(ErrorCode_InexistentItem,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
754 "Unknown modality for AET: " + aet);
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
755 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
756 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
757
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
758
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
759 void OrthancConfiguration::UpdateModality(const std::string& symbolicName,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
760 const RemoteModalityParameters& modality)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
761 {
3341
8f44dadcdbc1 Fix issue #138 (POST to modalities/{name} accepts invalid characters)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3184
diff changeset
762 CheckAlphanumeric(symbolicName);
8f44dadcdbc1 Fix issue #138 (POST to modalities/{name} accepts invalid characters)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3184
diff changeset
763
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
764 modalities_[symbolicName] = modality;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
765 SaveModalities();
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
766 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
767
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
768
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
769 void OrthancConfiguration::RemoveModality(const std::string& symbolicName)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
770 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
771 modalities_.erase(symbolicName);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
772 SaveModalities();
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
773 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
774
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
775
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
776 void OrthancConfiguration::UpdatePeer(const std::string& symbolicName,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
777 const WebServiceParameters& peer)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
778 {
3341
8f44dadcdbc1 Fix issue #138 (POST to modalities/{name} accepts invalid characters)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3184
diff changeset
779 CheckAlphanumeric(symbolicName);
8f44dadcdbc1 Fix issue #138 (POST to modalities/{name} accepts invalid characters)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3184
diff changeset
780
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
781 peer.CheckClientCertificate();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
782
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
783 peers_[symbolicName] = peer;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
784 SavePeers();
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
785 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
786
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
787
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
788 void OrthancConfiguration::RemovePeer(const std::string& symbolicName)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
789 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
790 peers_.erase(symbolicName);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
791 SavePeers();
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
792 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
793
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
794
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
795 void OrthancConfiguration::Format(std::string& result) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
796 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
797 Json::StyledWriter w;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
798 result = w.write(json_);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
799 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
800
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
801
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
802 void OrthancConfiguration::SetDefaultEncoding(Encoding encoding)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
803 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
804 SetDefaultDicomEncoding(encoding);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
805
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
806 // Propagate the encoding to the configuration file that is
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
807 // stored in memory
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
808 json_["DefaultEncoding"] = EnumerationToString(encoding);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
809 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
810
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
811
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
812 bool OrthancConfiguration::HasConfigurationChanged() const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
813 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
814 Json::Value current;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
815 ReadConfiguration(current, configurationFileArg_);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
816
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
817 Json::FastWriter writer;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
818 std::string a = writer.write(json_);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
819 std::string b = writer.write(current);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
820
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
821 return a != b;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
822 }
2941
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
823
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
824
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
825 void OrthancConfiguration::SetServerIndex(ServerIndex& index)
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
826 {
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
827 serverIndex_ = &index;
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
828 }
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
829
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
830
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
831 void OrthancConfiguration::ResetServerIndex()
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
832 {
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
833 serverIndex_ = NULL;
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
834 }
3181
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
835
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
836
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
837 TemporaryFile* OrthancConfiguration::CreateTemporaryFile() const
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
838 {
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
839 if (json_.isMember(TEMPORARY_DIRECTORY))
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
840 {
3184
5d1f5984dc41 improved log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3181
diff changeset
841 return new TemporaryFile(InterpretStringParameterAsPath(GetStringParameter(TEMPORARY_DIRECTORY, ".")), "");
3181
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
842 }
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
843 else
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
844 {
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
845 return new TemporaryFile;
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
846 }
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
847 }
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
848 }