annotate OrthancServer/OrthancConfiguration.cpp @ 2948:d2e548e643af

New options to URI "/queries/.../answers": "?expand" and "?limit"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Nov 2018 20:36:31 +0100
parents 2e751f615e03
children bbfd95a0c429
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
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
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
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../Core/HttpServer/MongooseServer.h"
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"
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 #include "../Core/Toolbox.h"
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
2941
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
43 #include "ServerIndex.h"
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
44
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
45
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
46 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
47 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
48 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
49 static const char* const ORTHANC_PEERS_IN_DB = "OrthancPeersInDatabase";
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
50
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 namespace Orthanc
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 static void AddFileToConfiguration(Json::Value& target,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 const boost::filesystem::path& path)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 std::map<std::string, std::string> env;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 SystemToolbox::GetEnvironmentVariables(env);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 LOG(WARNING) << "Reading the configuration from: " << path;
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 Json::Value config;
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 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 std::string content;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 SystemToolbox::ReadFile(content, path.string());
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 content = Toolbox::SubstituteVariables(content, env);
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 Json::Value tmp;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 Json::Reader reader;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 if (!reader.parse(content, tmp) ||
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 tmp.type() != Json::objectValue)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 LOG(ERROR) << "The configuration file does not follow the JSON syntax: " << path;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 throw OrthancException(ErrorCode_BadJson);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 Toolbox::CopyJsonWithoutComments(config, tmp);
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
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 if (target.size() == 0)
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 target = config;
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 else
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 // Merge the newly-added file with the previous content of "target"
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 Json::Value::Members members = config.getMemberNames();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 for (Json::Value::ArrayIndex i = 0; i < members.size(); i++)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 if (target.isMember(members[i]))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
93 LOG(ERROR) << "The configuration section \"" << members[i]
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
94 << "\" is defined in 2 different configuration files";
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 throw OrthancException(ErrorCode_BadFileFormat);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 else
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 target[members[i]] = config[members[i]];
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 }
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 static void ScanFolderForConfiguration(Json::Value& target,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 const char* folder)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 using namespace boost::filesystem;
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 LOG(WARNING) << "Scanning folder \"" << folder << "\" for configuration files";
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 directory_iterator end_it; // default construction yields past-the-end
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 for (directory_iterator it(folder);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 it != end_it;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 ++it)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 if (!is_directory(it->status()))
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 std::string extension = boost::filesystem::extension(it->path());
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 Toolbox::ToLowerCase(extension);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 if (extension == ".json")
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 AddFileToConfiguration(target, it->path().string());
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 }
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 static void ReadConfiguration(Json::Value& target,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 const char* configurationFile)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 target = Json::objectValue;
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 if (configurationFile)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 if (!boost::filesystem::exists(configurationFile))
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 LOG(ERROR) << "Inexistent path to configuration: " << configurationFile;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 throw OrthancException(ErrorCode_InexistentFile);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 if (boost::filesystem::is_directory(configurationFile))
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 ScanFolderForConfiguration(target, configurationFile);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 AddFileToConfiguration(target, configurationFile);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 }
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 else
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 #if ORTHANC_STANDALONE == 1
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 // No default path for the standalone configuration
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 LOG(WARNING) << "Using the default Orthanc configuration";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 return;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 #else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 // In a non-standalone build, we use the
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 // "Resources/Configuration.json" from the Orthanc source code
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 boost::filesystem::path p = ORTHANC_PATH;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 p /= "Resources";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 p /= "Configuration.json";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 AddFileToConfiguration(target, p);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 #endif
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 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
174
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
175 static void CheckAlphanumeric(const std::string& s)
2933
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 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
178 {
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
179 if (!isalnum(s[j]) &&
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
180 s[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 LOG(ERROR) << "Only alphanumeric and dash characters are allowed "
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
183 << "in the names of modalities/peers, but found: " << s;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
184 throw OrthancException(ErrorCode_BadFileFormat);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
185 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
186 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
187 }
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 void OrthancConfiguration::LoadModalitiesFromJson(const Json::Value& source)
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 modalities_.clear();
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
193
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
194 if (source.type() != Json::objectValue)
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
195 {
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
196 LOG(ERROR) << "Bad format of the \"" << DICOM_MODALITIES << "\" configuration section";
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
197 throw OrthancException(ErrorCode_BadFileFormat);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
198 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
199
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
200 Json::Value::Members members = source.getMemberNames();
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
202 for (size_t i = 0; i < members.size(); i++)
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
204 const std::string& name = members[i];
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
205 CheckAlphanumeric(name);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
206
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
207 RemoteModalityParameters modality;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
208 modality.Unserialize(source[name]);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
209 modalities_[name] = modality;
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 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
212
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
213
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
214 void OrthancConfiguration::LoadPeersFromJson(const Json::Value& source)
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 peers_.clear();
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 if (source.type() != Json::objectValue)
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 LOG(ERROR) << "Bad format of the \"" << ORTHANC_PEERS << "\" configuration section";
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
221 throw OrthancException(ErrorCode_BadFileFormat);
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
224 Json::Value::Members members = source.getMemberNames();
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
225
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
226 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
227 {
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
228 const std::string& name = members[i];
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
229 CheckAlphanumeric(name);
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 WebServiceParameters peer;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
232 peer.Unserialize(source[name]);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
233 peers_[name] = peer;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
234 }
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
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
237
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
238 void OrthancConfiguration::LoadModalities()
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
239 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
240 if (GetBooleanParameter(DICOM_MODALITIES_IN_DB, false))
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
241 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
242 // Modalities are stored in the database
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
243 if (serverIndex_ == NULL)
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 throw Orthanc::OrthancException(ErrorCode_BadSequenceOfCalls);
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 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
248 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
249 std::string property = serverIndex_->GetGlobalProperty(GlobalProperty_Modalities, "{}");
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
250
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
251 Json::Reader reader;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
252 Json::Value modalities;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
253 if (reader.parse(property, modalities))
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
254 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
255 LoadModalitiesFromJson(modalities);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
256 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
257 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
258 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
259 LOG(ERROR) << "Cannot unserialize the list of modalities from the Orthanc database";
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
260 throw OrthancException(ErrorCode_InternalError);
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 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
263 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
264 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
265 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
266 // Modalities are stored in the configuration files
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
267 if (json_.isMember(DICOM_MODALITIES))
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 LoadModalitiesFromJson(json_[DICOM_MODALITIES]);
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 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
272 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
273 modalities_.clear();
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
274 }
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 }
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 void OrthancConfiguration::LoadPeers()
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 if (GetBooleanParameter(ORTHANC_PEERS_IN_DB, false))
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 // Peers are stored in the database
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
283 if (serverIndex_ == NULL)
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 throw Orthanc::OrthancException(ErrorCode_BadSequenceOfCalls);
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 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
288 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
289 std::string property = serverIndex_->GetGlobalProperty(GlobalProperty_Peers, "{}");
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
290
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
291 Json::Reader reader;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
292 Json::Value peers;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
293 if (reader.parse(property, peers))
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
294 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
295 LoadPeersFromJson(peers);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
296 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
297 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
298 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
299 LOG(ERROR) << "Cannot unserialize the list of peers from the Orthanc database";
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
300 throw OrthancException(ErrorCode_InternalError);
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 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
303 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
304 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
305 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
306 // Peers are stored in the configuration files
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
307 if (json_.isMember(ORTHANC_PEERS))
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 LoadPeersFromJson(json_[ORTHANC_PEERS]);
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 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
312 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
313 peers_.clear();
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
314 }
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 }
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
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
319 void OrthancConfiguration::SaveModalitiesToJson(Json::Value& target)
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 target = Json::objectValue;
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 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
324 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
325 Json::Value modality;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
326 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
327
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
328 target[it->first] = modality;
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 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
331
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
332
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
333 void OrthancConfiguration::SavePeersToJson(Json::Value& target)
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
334 {
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
335 target = Json::objectValue;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
336
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
337 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
338 {
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
339 Json::Value peer;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
340 it->second.Serialize(peer,
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
341 false /* use simple format if possible */,
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
342 true /* include passwords */);
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 target[it->first] = peer;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
345 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
346 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
347
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
348
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
349 void OrthancConfiguration::SaveModalities()
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
350 {
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
351 if (GetBooleanParameter(DICOM_MODALITIES_IN_DB, false))
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
352 {
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
353 // Modalities are stored in the database
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
354 if (serverIndex_ == NULL)
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
355 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
356 throw Orthanc::OrthancException(ErrorCode_BadSequenceOfCalls);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
357 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
358 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
359 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
360 Json::Value modalities;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
361 SaveModalitiesToJson(modalities);
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 Json::FastWriter writer;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
364 std::string s = writer.write(modalities);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
365
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
366 serverIndex_->SetGlobalProperty(GlobalProperty_Modalities, s);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
367 }
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
368 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
369 else
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 {
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
371 // Modalities are stored in the configuration files
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
372 if (!modalities_.empty() ||
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
373 json_.isMember(DICOM_MODALITIES))
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
374 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
375 SaveModalitiesToJson(json_[DICOM_MODALITIES]);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
376 }
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
381 void OrthancConfiguration::SavePeers()
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
382 {
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
383 if (GetBooleanParameter(ORTHANC_PEERS_IN_DB, false))
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
384 {
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
385 // Peers are stored in the database
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
386 if (serverIndex_ == NULL)
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
387 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
388 throw Orthanc::OrthancException(ErrorCode_BadSequenceOfCalls);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
389 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
390 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
391 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
392 Json::Value peers;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
393 SavePeersToJson(peers);
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 Json::FastWriter writer;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
396 std::string s = writer.write(peers);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
397
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
398 serverIndex_->SetGlobalProperty(GlobalProperty_Peers, s);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
399 }
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
400 }
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
401 else
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 // Peers are stored in the configuration files
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
404 if (!peers_.empty() ||
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
405 json_.isMember(ORTHANC_PEERS))
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
406 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
407 SavePeersToJson(json_[ORTHANC_PEERS]);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
408 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
409 }
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
410 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
411
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
412
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 OrthancConfiguration& OrthancConfiguration::GetInstance()
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415 static OrthancConfiguration configuration;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416 return configuration;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418
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 std::string OrthancConfiguration::GetStringParameter(const std::string& parameter,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 const std::string& defaultValue) const
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 if (json_.isMember(parameter))
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 if (json_[parameter].type() != Json::stringValue)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 LOG(ERROR) << "The configuration option \"" << parameter << "\" must be a string";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 throw OrthancException(ErrorCode_BadParameterType);
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 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 return json_[parameter].asString();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433 }
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 defaultValue;
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
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 int OrthancConfiguration::GetIntegerParameter(const std::string& parameter,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443 int defaultValue) const
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 if (json_.isMember(parameter))
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 if (json_[parameter].type() != Json::intValue)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
449 LOG(ERROR) << "The configuration option \"" << parameter << "\" must be an integer";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450 throw OrthancException(ErrorCode_BadParameterType);
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 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 return json_[parameter].asInt();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 }
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 defaultValue;
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
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 unsigned int OrthancConfiguration::GetUnsignedIntegerParameter(
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 const std::string& parameter,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 unsigned int defaultValue) const
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 int v = GetIntegerParameter(parameter, defaultValue);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470 if (v < 0)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 LOG(ERROR) << "The configuration option \"" << parameter << "\" must be a positive integer";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 throw OrthancException(ErrorCode_ParameterOutOfRange);
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 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
476 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 return static_cast<unsigned int>(v);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 }
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
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 bool OrthancConfiguration::GetBooleanParameter(const std::string& parameter,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 bool defaultValue) const
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 if (json_.isMember(parameter))
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 if (json_[parameter].type() != Json::booleanValue)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
489 LOG(ERROR) << "The configuration option \"" << parameter
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490 << "\" must be a Boolean (true or false)";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491 throw OrthancException(ErrorCode_BadParameterType);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495 return json_[parameter].asBool();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 }
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 defaultValue;
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
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 void OrthancConfiguration::Read(const char* configurationFile)
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 // Read the content of the configuration
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508 configurationFileArg_ = configurationFile;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509 ReadConfiguration(json_, configurationFile);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
510
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511 // Adapt the paths to the configurations
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512 defaultDirectory_ = boost::filesystem::current_path();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513 configurationAbsolutePath_ = "";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515 if (configurationFile)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517 if (boost::filesystem::is_directory(configurationFile))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519 defaultDirectory_ = boost::filesystem::path(configurationFile);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520 configurationAbsolutePath_ = boost::filesystem::absolute(configurationFile).parent_path().string();
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 else
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).parent_path();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525 configurationAbsolutePath_ = boost::filesystem::absolute(configurationFile).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 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
528 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530 #if ORTHANC_STANDALONE != 1
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
531 // In a non-standalone build, we use the
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532 // "Resources/Configuration.json" from the Orthanc source code
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
533
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
534 boost::filesystem::path p = ORTHANC_PATH;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535 p /= "Resources";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536 p /= "Configuration.json";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537 configurationAbsolutePath_ = boost::filesystem::absolute(p).string();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
538 #endif
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539 }
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
540 }
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
542
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
543 void OrthancConfiguration::LoadModalitiesAndPeers()
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
544 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
545 LoadModalities();
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
546 LoadPeers();
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
547 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
548
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
550 void OrthancConfiguration::GetDicomModalityUsingSymbolicName(
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
551 RemoteModalityParameters& modality,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
552 const std::string& name) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
554 Modalities::const_iterator found = modalities_.find(name);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
555
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
556 if (found == modalities_.end())
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558 LOG(ERROR) << "No modality with symbolic name: " << name;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
559 throw OrthancException(ErrorCode_InexistentItem);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560 }
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
561 else
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
563 modality = found->second;
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
564 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
566
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 bool OrthancConfiguration::LookupOrthancPeer(WebServiceParameters& peer,
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
569 const std::string& name) const
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
571 Peers::const_iterator found = peers_.find(name);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
572
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
573 if (found == peers_.end())
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
574 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
575 LOG(ERROR) << "No peer with symbolic name: " << name;
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
576 return false;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
577 }
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
578 else
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 peer = found->second;
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581 return true;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
582 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586 void OrthancConfiguration::GetListOfDicomModalities(std::set<std::string>& target) const
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 target.clear();
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
589
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
590 for (Modalities::const_iterator
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
591 it = modalities_.begin(); it != modalities_.end(); ++it)
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
592 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
593 target.insert(it->first);
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
595 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
596
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
597
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
598 void OrthancConfiguration::GetListOfOrthancPeers(std::set<std::string>& target) const
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 target.clear();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
602 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
603 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
604 target.insert(it->first);
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
606 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
607
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
608
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
609 void OrthancConfiguration::SetupRegisteredUsers(MongooseServer& httpServer) const
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 httpServer.ClearUsers();
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 if (!json_.isMember("RegisteredUsers"))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
614 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
615 return;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616 }
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 const Json::Value& users = json_["RegisteredUsers"];
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
619 if (users.type() != Json::objectValue)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
620 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
621 LOG(ERROR) << "Badly formatted list of users";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
622 throw OrthancException(ErrorCode_BadFileFormat);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
623 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
624
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
625 Json::Value::Members usernames = users.getMemberNames();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
626 for (size_t i = 0; i < usernames.size(); i++)
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 const std::string& username = usernames[i];
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
629 std::string password = users[username].asString();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
630 httpServer.RegisterUser(username.c_str(), password.c_str());
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 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
633
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
634
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
635 std::string OrthancConfiguration::InterpretStringParameterAsPath(
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
636 const std::string& parameter) const
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 return SystemToolbox::InterpretRelativePath(defaultDirectory_.string(), parameter);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
640
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
641
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
642 void OrthancConfiguration::GetListOfStringsParameter(std::list<std::string>& target,
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
643 const std::string& key) const
2933
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 target.clear();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
646
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
647 if (!json_.isMember(key))
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 return;
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
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
652 const Json::Value& lst = json_[key];
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
653
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
654 if (lst.type() != Json::arrayValue)
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 LOG(ERROR) << "Badly formatted list of strings";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
657 throw OrthancException(ErrorCode_BadFileFormat);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
658 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
659
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
660 for (Json::Value::ArrayIndex i = 0; i < lst.size(); i++)
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 target.push_back(lst[i].asString());
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
663 }
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
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 bool OrthancConfiguration::IsSameAETitle(const std::string& aet1,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
668 const std::string& aet2) const
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 if (GetBooleanParameter("StrictAetComparison", false))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
671 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
672 // Case-sensitive matching
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
673 return aet1 == aet2;
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 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
676 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
677 // Case-insensitive matching (default)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
678 std::string tmp1, tmp2;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
679 Toolbox::ToLowerCase(tmp1, aet1);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
680 Toolbox::ToLowerCase(tmp2, aet2);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
681 return tmp1 == tmp2;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
682 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
683 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
684
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
685
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
686 bool OrthancConfiguration::LookupDicomModalityUsingAETitle(RemoteModalityParameters& modality,
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
687 const std::string& aet) const
2933
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 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
690 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
691 if (IsSameAETitle(aet, it->second.GetApplicationEntityTitle()))
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
692 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
693 modality = it->second;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
694 return true;
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
695 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
696 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
697
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
698 return false;
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
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
702 bool OrthancConfiguration::IsKnownAETitle(const std::string& aet,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
703 const std::string& ip) const
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 RemoteModalityParameters modality;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
706
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
707 if (!LookupDicomModalityUsingAETitle(modality, aet))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
708 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
709 LOG(WARNING) << "Modality \"" << aet
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
710 << "\" is not listed in the \"DicomModalities\" configuration option";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
711 return false;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
712 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
713 else if (!GetBooleanParameter("DicomCheckModalityHost", false) ||
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
714 ip == modality.GetHost())
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 return true;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
717 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
718 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
719 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
720 LOG(WARNING) << "Forbidding access from AET \"" << aet
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
721 << "\" given its hostname (" << ip << ") does not match "
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
722 << "the \"DicomModalities\" configuration option ("
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
723 << modality.GetHost() << " was expected)";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
724 return false;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
725 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
726 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
727
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
728
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
729 RemoteModalityParameters
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
730 OrthancConfiguration::GetModalityUsingSymbolicName(const std::string& name) const
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
731 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
732 RemoteModalityParameters modality;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
733 GetDicomModalityUsingSymbolicName(modality, name);
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 return modality;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
736 }
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
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
739 RemoteModalityParameters
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
740 OrthancConfiguration::GetModalityUsingAet(const std::string& aet) const
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
741 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
742 RemoteModalityParameters modality;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
743
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
744 if (LookupDicomModalityUsingAETitle(modality, aet))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
745 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
746 return modality;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
747 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
748 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
749 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
750 LOG(ERROR) << "Unknown modality for AET: " << aet;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
751 throw OrthancException(ErrorCode_InexistentItem);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
752 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
753 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
754
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 void OrthancConfiguration::UpdateModality(const std::string& symbolicName,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
757 const RemoteModalityParameters& modality)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
758 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
759 modalities_[symbolicName] = modality;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
760 SaveModalities();
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
761 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
762
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
763
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
764 void OrthancConfiguration::RemoveModality(const std::string& symbolicName)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
765 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
766 modalities_.erase(symbolicName);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
767 SaveModalities();
2933
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
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
770
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
771 void OrthancConfiguration::UpdatePeer(const std::string& symbolicName,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
772 const WebServiceParameters& peer)
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 peer.CheckClientCertificate();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
775
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
776 peers_[symbolicName] = peer;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
777 SavePeers();
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
778 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
779
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
780
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
781 void OrthancConfiguration::RemovePeer(const std::string& symbolicName)
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_.erase(symbolicName);
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::Format(std::string& result) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
789 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
790 Json::StyledWriter w;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
791 result = w.write(json_);
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::SetDefaultEncoding(Encoding encoding)
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 SetDefaultDicomEncoding(encoding);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
798
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
799 // Propagate the encoding to the configuration file that is
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
800 // stored in memory
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
801 json_["DefaultEncoding"] = EnumerationToString(encoding);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
802 }
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
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
805 bool OrthancConfiguration::HasConfigurationChanged() const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
806 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
807 Json::Value current;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
808 ReadConfiguration(current, configurationFileArg_);
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 Json::FastWriter writer;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
811 std::string a = writer.write(json_);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
812 std::string b = writer.write(current);
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 return a != b;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
815 }
2941
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
816
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
817
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
818 void OrthancConfiguration::SetServerIndex(ServerIndex& index)
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
819 {
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
820 serverIndex_ = &index;
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
821 }
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
822
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 void OrthancConfiguration::ResetServerIndex()
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
825 {
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
826 serverIndex_ = NULL;
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
827 }
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
828 }