annotate OrthancServer/Sources/OrthancConfiguration.cpp @ 5643:b1a18218860c

2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
author Alain Mazy <am@orthanc.team>
date Fri, 31 May 2024 16:56:35 +0200
parents f7adfb22e20e
children 078b724dcbf8
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
5640
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5627
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5627
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * This program is free software: you can redistribute it and/or
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * 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
11 * published by the Free Software Foundation, either version 3 of the
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * License, or (at your option) any later version.
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 *
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * 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
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * General Public License for more details.
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * 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
20 * 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
21 **/
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
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 #include "PrecompiledHeadersServer.h"
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "OrthancConfiguration.h"
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4487
diff changeset
27 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h"
4140
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
28 #include "../../OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
29 #include "../../OrthancFramework/Sources/HttpServer/HttpServer.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
30 #include "../../OrthancFramework/Sources/Logging.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
31 #include "../../OrthancFramework/Sources/OrthancException.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
32 #include "../../OrthancFramework/Sources/SystemToolbox.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
33 #include "../../OrthancFramework/Sources/TemporaryFile.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
34 #include "../../OrthancFramework/Sources/Toolbox.h"
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
2941
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
36 #include "ServerIndex.h"
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
37
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
38 #include <boost/regex.hpp>
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
39
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
40
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
41 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
42 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
43 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
44 static const char* const ORTHANC_PEERS_IN_DB = "OrthancPeersInDatabase";
3181
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
45 static const char* const TEMPORARY_DIRECTORY = "TemporaryDirectory";
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4604
diff changeset
46 static const char* const DATABASE_SERVER_IDENTIFIER = "DatabaseServerIdentifier";
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
47 static const char* const WARNINGS = "Warnings";
5130
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
48 static const char* const JOBS_ENGINE_THREADS_COUNT = "JobsEngineThreadsCount";
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
49
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 namespace Orthanc
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 static void AddFileToConfiguration(Json::Value& target,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 const boost::filesystem::path& path)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 std::map<std::string, std::string> env;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 SystemToolbox::GetEnvironmentVariables(env);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 LOG(WARNING) << "Reading the configuration from: " << path;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 Json::Value config;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
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 std::string content;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 SystemToolbox::ReadFile(content, path.string());
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 content = Toolbox::SubstituteVariables(content, env);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 Json::Value tmp;
4392
3af1d763763a confining Json::Reader and Json::*Writer into Toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4267
diff changeset
69 if (!Toolbox::ReadJson(tmp, content) ||
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 tmp.type() != Json::objectValue)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2946
diff changeset
72 throw OrthancException(ErrorCode_BadJson,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2946
diff changeset
73 "The configuration file does not follow the JSON syntax: " + path.string());
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 Toolbox::CopyJsonWithoutComments(config, tmp);
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
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 if (target.size() == 0)
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 target = config;
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 else
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 // Merge the newly-added file with the previous content of "target"
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 Json::Value::Members members = config.getMemberNames();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 for (Json::Value::ArrayIndex i = 0; i < members.size(); i++)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 if (target.isMember(members[i]))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2946
diff changeset
91 throw OrthancException(ErrorCode_BadFileFormat,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2946
diff changeset
92 "The configuration section \"" + members[i] +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2946
diff changeset
93 "\" is defined in 2 different configuration files");
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 else
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 target[members[i]] = config[members[i]];
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 }
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 static void ScanFolderForConfiguration(Json::Value& target,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 const char* folder)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 using namespace boost::filesystem;
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 LOG(WARNING) << "Scanning folder \"" << folder << "\" for configuration files";
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 directory_iterator end_it; // default construction yields past-the-end
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 for (directory_iterator it(folder);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 it != end_it;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 ++it)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 if (!is_directory(it->status()))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 {
5627
a7c88563c8cc fix build with boost 1.85.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
118 std::string extension = it->path().extension().string();
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 Toolbox::ToLowerCase(extension);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 if (extension == ".json")
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 AddFileToConfiguration(target, it->path().string());
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 }
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 static void ReadConfiguration(Json::Value& target,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 const char* configurationFile)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 target = Json::objectValue;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
135 if (configurationFile != NULL)
2933
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 (!boost::filesystem::exists(configurationFile))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
139 throw OrthancException(ErrorCode_InexistentFile,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
140 "Inexistent path to configuration: " +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
141 std::string(configurationFile));
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 }
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 if (boost::filesystem::is_directory(configurationFile))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 ScanFolderForConfiguration(target, configurationFile);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 AddFileToConfiguration(target, configurationFile);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 #if ORTHANC_STANDALONE == 1
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 // No default path for the standalone configuration
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 LOG(WARNING) << "Using the default Orthanc configuration";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 return;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 #else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 // In a non-standalone build, we use the
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 // "Resources/Configuration.json" from the Orthanc source code
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 boost::filesystem::path p = ORTHANC_PATH;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 p /= "Resources";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 p /= "Configuration.json";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 AddFileToConfiguration(target, p);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 #endif
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 }
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
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
173
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
174 static void CheckAlphanumeric(const std::string& s)
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
176 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
177 {
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
178 if (!isalnum(s[j]) &&
4164
b3c5418109a9 underscores are now allowed in peers/modalities symbolic names
Alain Mazy <alain@mazy.be>
parents: 4140
diff changeset
179 s[j] != '-' && s[j] != '_')
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
180 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
181 throw OrthancException(ErrorCode_BadFileFormat,
4164
b3c5418109a9 underscores are now allowed in peers/modalities symbolic names
Alain Mazy <alain@mazy.be>
parents: 4140
diff changeset
182 "Only alphanumeric, dash characters and underscores are allowed "
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
183 "in the names of modalities/peers, but found: " + s);
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
184 }
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 void OrthancConfiguration::LoadModalitiesFromJson(const Json::Value& source)
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
190 {
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
191 modalities_.clear();
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
192
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
193 if (source.type() != Json::objectValue)
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
194 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
195 throw OrthancException(ErrorCode_BadFileFormat,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
196 "Bad format of the \"" + std::string(DICOM_MODALITIES) +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
197 "\" configuration section");
2944
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 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
220 throw OrthancException(ErrorCode_BadFileFormat,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
221 "Bad format of the \"" + std::string(ORTHANC_PEERS) +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
222 "\" configuration section");
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
225 Json::Value::Members members = source.getMemberNames();
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
226
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
227 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
228 {
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
229 const std::string& name = members[i];
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
230 CheckAlphanumeric(name);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
231
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
232 WebServiceParameters peer;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
233 peer.Unserialize(source[name]);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
234 peers_[name] = peer;
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
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
238
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
239 void OrthancConfiguration::LoadModalities()
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
240 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
241 if (GetBooleanParameter(DICOM_MODALITIES_IN_DB, false))
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
242 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
243 // Modalities are stored in the database
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
244 if (serverIndex_ == NULL)
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
245 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
246 throw Orthanc::OrthancException(ErrorCode_BadSequenceOfCalls);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
247 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
248 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
249 {
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4604
diff changeset
250 std::string property = serverIndex_->GetGlobalProperty(GlobalProperty_Modalities, false /* not shared */, "{}");
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
251
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
252 Json::Value modalities;
4392
3af1d763763a confining Json::Reader and Json::*Writer into Toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4267
diff changeset
253 if (Toolbox::ReadJson(modalities, property))
2946
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 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
259 throw OrthancException(ErrorCode_InternalError,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
260 "Cannot unserialize the list of modalities from the Orthanc database");
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
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
5130
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
278 void OrthancConfiguration::LoadJobsEngineThreadsCount()
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
279 {
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
280 // default values
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
281 jobsEngineThreadsCount_["ResourceModification"] = 1;
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
282
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
283 if (json_.isMember(JOBS_ENGINE_THREADS_COUNT))
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
284 {
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
285 const Json::Value& source = json_[JOBS_ENGINE_THREADS_COUNT];
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
286 if (source.type() != Json::objectValue)
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
287 {
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
288 throw OrthancException(ErrorCode_BadFileFormat,
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
289 "Bad format of the \"" + std::string(JOBS_ENGINE_THREADS_COUNT) +
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
290 "\" configuration section");
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
291 }
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
292
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
293 Json::Value::Members members = source.getMemberNames();
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
294
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
295 for (size_t i = 0; i < members.size(); i++)
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
296 {
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
297 const std::string& name = members[i];
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
298 if (!source[name].isUInt())
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
299 {
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
300 throw OrthancException(ErrorCode_BadFileFormat,
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
301 "Bad format for \"" + std::string(JOBS_ENGINE_THREADS_COUNT) + "." + name +
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
302 "\". It should be an unsigned integer");
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
303 }
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
304 jobsEngineThreadsCount_[name] = source[name].asUInt();
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
305 }
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
306 }
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
307 }
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
308
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
309 unsigned int OrthancConfiguration::GetJobsEngineWorkersThread(const std::string& jobType) const
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
310 {
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
311 unsigned int workersThread = 1;
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
312
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
313 const JobsEngineThreadsCount::const_iterator it = jobsEngineThreadsCount_.find(jobType);
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
314 if (it != jobsEngineThreadsCount_.end())
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
315 {
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
316 workersThread = it->second;
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
317 }
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
318
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
319 if (workersThread == 0)
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
320 {
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
321 workersThread = SystemToolbox::GetHardwareConcurrency();
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
322 }
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
323
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
324 return workersThread;
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
325 }
f2dcdbe05884 ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
326
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
327 void OrthancConfiguration::LoadPeers()
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
328 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
329 if (GetBooleanParameter(ORTHANC_PEERS_IN_DB, false))
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 // Peers are stored in the database
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
332 if (serverIndex_ == NULL)
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
333 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
334 throw Orthanc::OrthancException(ErrorCode_BadSequenceOfCalls);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
335 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
336 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
337 {
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4604
diff changeset
338 std::string property = serverIndex_->GetGlobalProperty(GlobalProperty_Peers, false /* not shared */, "{}");
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
339
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
340 Json::Value peers;
4392
3af1d763763a confining Json::Reader and Json::*Writer into Toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4267
diff changeset
341 if (Toolbox::ReadJson(peers, property))
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
342 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
343 LoadPeersFromJson(peers);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
344 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
345 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
346 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
347 throw OrthancException(ErrorCode_InternalError,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
348 "Cannot unserialize the list of peers from the Orthanc database");
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
349 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
350 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
351 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
352 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
353 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
354 // Peers are stored in the configuration files
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
355 if (json_.isMember(ORTHANC_PEERS))
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
356 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
357 LoadPeersFromJson(json_[ORTHANC_PEERS]);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
358 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
359 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
360 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
361 peers_.clear();
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 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
364 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
365
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
366
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
367 void OrthancConfiguration::SaveModalitiesToJson(Json::Value& target)
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
368 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
369 target = Json::objectValue;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
370
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
371 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
372 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
373 Json::Value modality;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
374 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
375
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
376 target[it->first] = modality;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
377 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
378 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
379
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
380
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
381 void OrthancConfiguration::SavePeersToJson(Json::Value& target)
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
382 {
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
383 target = Json::objectValue;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
384
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
385 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
386 {
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
387 Json::Value peer;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
388 it->second.Serialize(peer,
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
389 false /* use simple format if possible */,
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
390 true /* include passwords */);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
391
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
392 target[it->first] = peer;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
393 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
394 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
395
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
396
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
397 void OrthancConfiguration::SaveModalities()
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
398 {
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
399 if (GetBooleanParameter(DICOM_MODALITIES_IN_DB, false))
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 // Modalities are stored in the database
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
402 if (serverIndex_ == NULL)
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
403 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
404 throw Orthanc::OrthancException(ErrorCode_BadSequenceOfCalls);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
405 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
406 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
407 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
408 Json::Value modalities;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
409 SaveModalitiesToJson(modalities);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
410
4392
3af1d763763a confining Json::Reader and Json::*Writer into Toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4267
diff changeset
411 std::string s;
4394
f7104e9d044c functions to read/write JSON in OrthancPluginCppWrapper.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4392
diff changeset
412 Toolbox::WriteFastJson(s, modalities);
4392
3af1d763763a confining Json::Reader and Json::*Writer into Toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4267
diff changeset
413
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4604
diff changeset
414 serverIndex_->SetGlobalProperty(GlobalProperty_Modalities, false /* not shared */, s);
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
415 }
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
416 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
417 else
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 {
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
419 // Modalities are stored in the configuration files
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
420 if (!modalities_.empty() ||
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
421 json_.isMember(DICOM_MODALITIES))
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
422 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
423 SaveModalitiesToJson(json_[DICOM_MODALITIES]);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
424 }
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 }
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
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
429 void OrthancConfiguration::SavePeers()
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
430 {
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
431 if (GetBooleanParameter(ORTHANC_PEERS_IN_DB, false))
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
432 {
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
433 // Peers are stored in the database
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
434 if (serverIndex_ == NULL)
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
435 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
436 throw Orthanc::OrthancException(ErrorCode_BadSequenceOfCalls);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
437 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
438 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
439 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
440 Json::Value peers;
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
441 SavePeersToJson(peers);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
442
4392
3af1d763763a confining Json::Reader and Json::*Writer into Toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4267
diff changeset
443 std::string s;
4394
f7104e9d044c functions to read/write JSON in OrthancPluginCppWrapper.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4392
diff changeset
444 Toolbox::WriteFastJson(s, peers);
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
445
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4604
diff changeset
446 serverIndex_->SetGlobalProperty(GlobalProperty_Peers, false /* not shared */, s);
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
447 }
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
448 }
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
449 else
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
450 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
451 // Peers are stored in the configuration files
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
452 if (!peers_.empty() ||
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
453 json_.isMember(ORTHANC_PEERS))
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
454 {
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
455 SavePeersToJson(json_[ORTHANC_PEERS]);
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
456 }
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
457 }
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
458 }
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
459
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
460
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461 OrthancConfiguration& OrthancConfiguration::GetInstance()
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 static OrthancConfiguration configuration;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464 return configuration;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
468 bool OrthancConfiguration::LookupStringParameter(std::string& target,
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
469 const std::string& parameter) const
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 if (json_.isMember(parameter))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 if (json_[parameter].type() != Json::stringValue)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
475 throw OrthancException(ErrorCode_BadParameterType,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
476 "The configuration option \"" + parameter + "\" must be a string");
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 {
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
480 target = json_[parameter].asString();
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
481 return true;
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485 {
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
486 return false;
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
487 }
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
488 }
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
489
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
490
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
491 std::string OrthancConfiguration::GetStringParameter(const std::string& parameter,
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
492 const std::string& defaultValue) const
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
493 {
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
494 std::string value;
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
495 if (LookupStringParameter(value, parameter))
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
496 {
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
497 return value;
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
498 }
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
499 else
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
500 {
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501 return defaultValue;
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
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506 int OrthancConfiguration::GetIntegerParameter(const std::string& parameter,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507 int defaultValue) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509 if (json_.isMember(parameter))
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 if (json_[parameter].type() != Json::intValue)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
513 throw OrthancException(ErrorCode_BadParameterType,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
514 "The configuration option \"" + parameter + "\" must be an integer");
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518 return json_[parameter].asInt();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
521 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
522 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
523 return defaultValue;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
524 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525 }
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 unsigned int OrthancConfiguration::GetUnsignedIntegerParameter(
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529 const std::string& parameter,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530 unsigned int defaultValue) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
531 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532 int v = GetIntegerParameter(parameter, defaultValue);
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 if (v < 0)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
536 throw OrthancException(ErrorCode_ParameterOutOfRange,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
537 "The configuration option \"" + parameter + "\" must be a positive integer");
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
538 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
540 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541 return static_cast<unsigned int>(v);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
543 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
544
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
545
3506
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
546 bool OrthancConfiguration::LookupBooleanParameter(bool& target,
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
547 const std::string& parameter) const
2933
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 if (json_.isMember(parameter))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
550 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
551 if (json_[parameter].type() != Json::booleanValue)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
552 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
553 throw OrthancException(ErrorCode_BadParameterType,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
554 "The configuration option \"" + parameter +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
555 "\" must be a Boolean (true or false)");
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558 {
3506
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
559 target = json_[parameter].asBool();
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
560 return true;
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
561 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
563 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
564 {
3506
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
565 return false;
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
566 }
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
567 }
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
568
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
569
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
570 bool OrthancConfiguration::GetBooleanParameter(const std::string& parameter,
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
571 bool defaultValue) const
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
572 {
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
573 bool value;
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
574 if (LookupBooleanParameter(value, parameter))
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
575 {
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
576 return value;
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
577 }
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
578 else
d2b9981017c4 better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3500
diff changeset
579 {
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580 return defaultValue;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581 }
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 void OrthancConfiguration::Read(const char* configurationFile)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
587 // Read the content of the configuration
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
588 configurationFileArg_ = configurationFile;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
589 ReadConfiguration(json_, configurationFile);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
590
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591 // Adapt the paths to the configurations
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
592 defaultDirectory_ = boost::filesystem::current_path();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
593 configurationAbsolutePath_ = "";
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 if (configurationFile)
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 if (boost::filesystem::is_directory(configurationFile))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
598 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
599 defaultDirectory_ = boost::filesystem::path(configurationFile);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600 configurationAbsolutePath_ = boost::filesystem::absolute(configurationFile).parent_path().string();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
602 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604 defaultDirectory_ = boost::filesystem::path(configurationFile).parent_path();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605 configurationAbsolutePath_ = boost::filesystem::absolute(configurationFile).string();
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 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
609 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
610 #if ORTHANC_STANDALONE != 1
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
611 // In a non-standalone build, we use the
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
612 // "Resources/Configuration.json" from the Orthanc source code
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
613
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
614 boost::filesystem::path p = ORTHANC_PATH;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
615 p /= "Resources";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616 p /= "Configuration.json";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
617 configurationAbsolutePath_ = boost::filesystem::absolute(p).string();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
618 #endif
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
619 }
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
620 }
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
621
2946
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
622
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
623 void OrthancConfiguration::LoadModalitiesAndPeers()
2e751f615e03 new configuration options: DicomModalitiesInDatabase and OrthancPeersInDatabase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
624 {
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
625 if (serverIndex_ == NULL)
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
626 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
627 throw OrthancException(ErrorCode_BadSequenceOfCalls);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
628 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
629 else
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
630 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
631 LoadModalities();
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
632 LoadPeers();
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
633 }
2933
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
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
636
4031
e3b3af80732d ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3939
diff changeset
637 void OrthancConfiguration::RegisterFont(ServerResources::FileResourceId resource)
e3b3af80732d ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3939
diff changeset
638 {
e3b3af80732d ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3939
diff changeset
639 std::string content;
e3b3af80732d ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3939
diff changeset
640 ServerResources::GetFileResource(content, resource);
e3b3af80732d ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3939
diff changeset
641 fontRegistry_.AddFromMemory(content);
e3b3af80732d ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3939
diff changeset
642 }
e3b3af80732d ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3939
diff changeset
643
e3b3af80732d ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3939
diff changeset
644
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
645 void OrthancConfiguration::GetDicomModalityUsingSymbolicName(
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
646 RemoteModalityParameters& modality,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
647 const std::string& name) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
648 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
649 Modalities::const_iterator found = modalities_.find(name);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
650
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
651 if (found == modalities_.end())
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
652 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
653 throw OrthancException(ErrorCode_InexistentItem,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
654 "No modality with symbolic name: " + name);
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
655 }
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
656 else
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
657 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
658 modality = found->second;
2933
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 }
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
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
663 bool OrthancConfiguration::LookupOrthancPeer(WebServiceParameters& peer,
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
664 const std::string& name) const
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
665 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
666 Peers::const_iterator found = peers_.find(name);
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
667
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
668 if (found == peers_.end())
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
669 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
670 LOG(ERROR) << "No peer with symbolic name: " << name;
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
671 return false;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
672 }
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
673 else
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
674 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
675 peer = found->second;
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
676 return true;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
677 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
678 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
679
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
680
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
681 void OrthancConfiguration::GetListOfDicomModalities(std::set<std::string>& target) const
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 target.clear();
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
684
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
685 for (Modalities::const_iterator
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
686 it = modalities_.begin(); it != modalities_.end(); ++it)
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
687 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
688 target.insert(it->first);
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
689 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
690 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
691
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
692
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
693 void OrthancConfiguration::GetListOfOrthancPeers(std::set<std::string>& target) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
694 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
695 target.clear();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
696
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
697 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
698 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
699 target.insert(it->first);
2933
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
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
703
3500
0d248cc63ded Security: If remote HTTP access is enabled, HTTP authentication automatically gets enabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3341
diff changeset
704 bool OrthancConfiguration::SetupRegisteredUsers(HttpServer& httpServer) const
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
705 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
706 httpServer.ClearUsers();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
707
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
708 if (!json_.isMember("RegisteredUsers"))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
709 {
3500
0d248cc63ded Security: If remote HTTP access is enabled, HTTP authentication automatically gets enabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3341
diff changeset
710 return false;
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
711 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
712
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
713 const Json::Value& users = json_["RegisteredUsers"];
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
714 if (users.type() != Json::objectValue)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
715 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
716 throw OrthancException(ErrorCode_BadFileFormat, "Badly formatted list of users");
2933
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
3500
0d248cc63ded Security: If remote HTTP access is enabled, HTTP authentication automatically gets enabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3341
diff changeset
719 bool hasUser = false;
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
720 Json::Value::Members usernames = users.getMemberNames();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
721 for (size_t i = 0; i < usernames.size(); i++)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
722 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
723 const std::string& username = usernames[i];
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
724 std::string password = users[username].asString();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
725 httpServer.RegisterUser(username.c_str(), password.c_str());
3500
0d248cc63ded Security: If remote HTTP access is enabled, HTTP authentication automatically gets enabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3341
diff changeset
726 hasUser = true;
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
727 }
3500
0d248cc63ded Security: If remote HTTP access is enabled, HTTP authentication automatically gets enabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3341
diff changeset
728
0d248cc63ded Security: If remote HTTP access is enabled, HTTP authentication automatically gets enabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3341
diff changeset
729 return hasUser;
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
730 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
731
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
732
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
733 std::string OrthancConfiguration::InterpretStringParameterAsPath(
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
734 const std::string& parameter) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
735 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
736 return SystemToolbox::InterpretRelativePath(defaultDirectory_.string(), parameter);
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
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
739
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
740 void OrthancConfiguration::GetListOfStringsParameter(std::list<std::string>& target,
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
741 const std::string& key) const
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
742 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
743 target.clear();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
744
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
745 if (!json_.isMember(key))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
746 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
747 return;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
748 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
749
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
750 const Json::Value& lst = json_[key];
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
751
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
752 if (lst.type() != Json::arrayValue)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
753 {
5643
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
754 throw OrthancException(ErrorCode_BadFileFormat, "Badly formatted list of strings: " + key);
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
755 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
756
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
757 for (Json::Value::ArrayIndex i = 0; i < lst.size(); i++)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
758 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
759 target.push_back(lst[i].asString());
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
760 }
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
5643
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
763
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
764 void OrthancConfiguration::GetSetOfStringsParameter(std::set<std::string>& target,
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
765 const std::string& key) const
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
766 {
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
767 target.clear();
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
768
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
769 if (!json_.isMember(key))
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
770 {
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
771 return;
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
772 }
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
773
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
774 const Json::Value& lst = json_[key];
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
775
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
776 if (lst.type() != Json::arrayValue)
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
777 {
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
778 throw OrthancException(ErrorCode_BadFileFormat, "Badly formatted set of strings: " + key);
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
779 }
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
780
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
781 for (Json::Value::ArrayIndex i = 0; i < lst.size(); i++)
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
782 {
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
783 target.insert(lst[i].asString());
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
784 }
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
785 }
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
786
b1a18218860c 2 new configurations: DicomTlsMinimumProtocolVersion + DicomTlsCiphersAccepted
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
787
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
788 bool OrthancConfiguration::IsSameAETitle(const std::string& aet1,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
789 const std::string& aet2) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
790 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
791 if (GetBooleanParameter("StrictAetComparison", false))
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 // Case-sensitive matching
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
794 return aet1 == aet2;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
795 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
796 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
797 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
798 // Case-insensitive matching (default)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
799 std::string tmp1, tmp2;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
800 Toolbox::ToLowerCase(tmp1, aet1);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
801 Toolbox::ToLowerCase(tmp2, aet2);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
802 return tmp1 == tmp2;
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
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
806
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
807 bool OrthancConfiguration::LookupDicomModalityUsingAETitle(RemoteModalityParameters& modality,
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
808 const std::string& aet) const
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
809 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
810 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
811 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
812 if (IsSameAETitle(aet, it->second.GetApplicationEntityTitle()))
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
813 {
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
814 modality = it->second;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
815 return true;
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
816 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
817 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
818
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
819 return false;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
820 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
821
4646
4beebbb3636e Fix regression in the handling of "DicomCheckModalityHost" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
822
4beebbb3636e Fix regression in the handling of "DicomCheckModalityHost" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
823 void OrthancConfiguration::LookupDicomModalitiesUsingAETitle(std::list<RemoteModalityParameters>& modalities,
4182
1c9c2c41c015 When checking DICOM allowed methods, if there are multiple modalities with the same AET, differentiate them from the calling IP
Alain Mazy <alain@mazy.be>
parents: 4164
diff changeset
824 const std::string& aet) const
1c9c2c41c015 When checking DICOM allowed methods, if there are multiple modalities with the same AET, differentiate them from the calling IP
Alain Mazy <alain@mazy.be>
parents: 4164
diff changeset
825 {
1c9c2c41c015 When checking DICOM allowed methods, if there are multiple modalities with the same AET, differentiate them from the calling IP
Alain Mazy <alain@mazy.be>
parents: 4164
diff changeset
826 modalities.clear();
1c9c2c41c015 When checking DICOM allowed methods, if there are multiple modalities with the same AET, differentiate them from the calling IP
Alain Mazy <alain@mazy.be>
parents: 4164
diff changeset
827
1c9c2c41c015 When checking DICOM allowed methods, if there are multiple modalities with the same AET, differentiate them from the calling IP
Alain Mazy <alain@mazy.be>
parents: 4164
diff changeset
828 for (Modalities::const_iterator it = modalities_.begin(); it != modalities_.end(); ++it)
1c9c2c41c015 When checking DICOM allowed methods, if there are multiple modalities with the same AET, differentiate them from the calling IP
Alain Mazy <alain@mazy.be>
parents: 4164
diff changeset
829 {
1c9c2c41c015 When checking DICOM allowed methods, if there are multiple modalities with the same AET, differentiate them from the calling IP
Alain Mazy <alain@mazy.be>
parents: 4164
diff changeset
830 if (IsSameAETitle(aet, it->second.GetApplicationEntityTitle()))
1c9c2c41c015 When checking DICOM allowed methods, if there are multiple modalities with the same AET, differentiate them from the calling IP
Alain Mazy <alain@mazy.be>
parents: 4164
diff changeset
831 {
1c9c2c41c015 When checking DICOM allowed methods, if there are multiple modalities with the same AET, differentiate them from the calling IP
Alain Mazy <alain@mazy.be>
parents: 4164
diff changeset
832 modalities.push_back(it->second);
1c9c2c41c015 When checking DICOM allowed methods, if there are multiple modalities with the same AET, differentiate them from the calling IP
Alain Mazy <alain@mazy.be>
parents: 4164
diff changeset
833 }
1c9c2c41c015 When checking DICOM allowed methods, if there are multiple modalities with the same AET, differentiate them from the calling IP
Alain Mazy <alain@mazy.be>
parents: 4164
diff changeset
834 }
1c9c2c41c015 When checking DICOM allowed methods, if there are multiple modalities with the same AET, differentiate them from the calling IP
Alain Mazy <alain@mazy.be>
parents: 4164
diff changeset
835 }
1c9c2c41c015 When checking DICOM allowed methods, if there are multiple modalities with the same AET, differentiate them from the calling IP
Alain Mazy <alain@mazy.be>
parents: 4164
diff changeset
836
1c9c2c41c015 When checking DICOM allowed methods, if there are multiple modalities with the same AET, differentiate them from the calling IP
Alain Mazy <alain@mazy.be>
parents: 4164
diff changeset
837
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
838
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
839 bool OrthancConfiguration::IsKnownAETitle(const std::string& aet,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
840 const std::string& ip) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
841 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
842 RemoteModalityParameters modality;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
843
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
844 if (!LookupDicomModalityUsingAETitle(modality, aet))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
845 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
846 LOG(WARNING) << "Modality \"" << aet
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
847 << "\" is not listed in the \"DicomModalities\" configuration option";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
848 return false;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
849 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
850 else if (!GetBooleanParameter("DicomCheckModalityHost", false) ||
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
851 ip == modality.GetHost())
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
852 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
853 return true;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
854 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
855 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
856 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
857 LOG(WARNING) << "Forbidding access from AET \"" << aet
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
858 << "\" given its hostname (" << ip << ") does not match "
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
859 << "the \"DicomModalities\" configuration option ("
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
860 << modality.GetHost() << " was expected)";
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
861 return false;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
862 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
863 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
864
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
865
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
866 RemoteModalityParameters
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
867 OrthancConfiguration::GetModalityUsingSymbolicName(const std::string& name) const
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
868 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
869 RemoteModalityParameters modality;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
870 GetDicomModalityUsingSymbolicName(modality, name);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
871
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
872 return modality;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
873 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
874
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
875
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
876 RemoteModalityParameters
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
877 OrthancConfiguration::GetModalityUsingAet(const std::string& aet) const
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
878 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
879 RemoteModalityParameters modality;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
880
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
881 if (LookupDicomModalityUsingAETitle(modality, aet))
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
882 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
883 return modality;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
884 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
885 else
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
886 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
887 throw OrthancException(ErrorCode_InexistentItem,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
888 "Unknown modality for AET: " + aet);
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
889 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
890 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
891
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
892
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
893 void OrthancConfiguration::UpdateModality(const std::string& symbolicName,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
894 const RemoteModalityParameters& modality)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
895 {
3341
8f44dadcdbc1 Fix issue #138 (POST to modalities/{name} accepts invalid characters)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3184
diff changeset
896 CheckAlphanumeric(symbolicName);
8f44dadcdbc1 Fix issue #138 (POST to modalities/{name} accepts invalid characters)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3184
diff changeset
897
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
898 modalities_[symbolicName] = modality;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
899 SaveModalities();
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
900 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
901
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
902
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
903 void OrthancConfiguration::RemoveModality(const std::string& symbolicName)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
904 {
4267
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
905 if (modalities_.find(symbolicName) == modalities_.end())
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
906 {
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
907 throw OrthancException(ErrorCode_InexistentItem,
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
908 "Unknown DICOM modality with symbolic name: " + symbolicName);
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
909 }
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
910 else
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
911 {
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
912 modalities_.erase(symbolicName);
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
913 SaveModalities();
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
914 }
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
915 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
916
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
917
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
918 void OrthancConfiguration::UpdatePeer(const std::string& symbolicName,
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
919 const WebServiceParameters& peer)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
920 {
3341
8f44dadcdbc1 Fix issue #138 (POST to modalities/{name} accepts invalid characters)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3184
diff changeset
921 CheckAlphanumeric(symbolicName);
8f44dadcdbc1 Fix issue #138 (POST to modalities/{name} accepts invalid characters)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3184
diff changeset
922
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
923 peer.CheckClientCertificate();
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
924
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
925 peers_[symbolicName] = peer;
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2941
diff changeset
926 SavePeers();
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
927 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
928
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
929
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
930 void OrthancConfiguration::RemovePeer(const std::string& symbolicName)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
931 {
4267
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
932 if (peers_.find(symbolicName) == peers_.end())
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
933 {
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
934 throw OrthancException(ErrorCode_InexistentItem,
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
935 "Unknown Orthanc peer: " + symbolicName);
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
936 }
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
937 else
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
938 {
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
939 peers_.erase(symbolicName);
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
940 SavePeers();
a20928107a90 REST API returns 404 error if deleting an inexistent peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
941 }
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
942 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
943
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
944
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
945 void OrthancConfiguration::Format(std::string& result) const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
946 {
4394
f7104e9d044c functions to read/write JSON in OrthancPluginCppWrapper.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4392
diff changeset
947 Toolbox::WriteStyledJson(result, json_);
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
948 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
949
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
950
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
951 void OrthancConfiguration::SetDefaultEncoding(Encoding encoding)
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
952 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
953 SetDefaultDicomEncoding(encoding);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
954
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
955 // Propagate the encoding to the configuration file that is
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
956 // stored in memory
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
957 json_["DefaultEncoding"] = EnumerationToString(encoding);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
958 }
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
959
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
960
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
961 bool OrthancConfiguration::HasConfigurationChanged() const
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
962 {
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
963 Json::Value current;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
964 ReadConfiguration(current, configurationFileArg_);
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
965
4392
3af1d763763a confining Json::Reader and Json::*Writer into Toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4267
diff changeset
966 std::string a, b;
4394
f7104e9d044c functions to read/write JSON in OrthancPluginCppWrapper.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4392
diff changeset
967 Toolbox::WriteFastJson(a, json_);
f7104e9d044c functions to read/write JSON in OrthancPluginCppWrapper.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4392
diff changeset
968 Toolbox::WriteFastJson(b, current);
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
969
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
970 return a != b;
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
971 }
2941
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
972
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
973
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
974 void OrthancConfiguration::SetServerIndex(ServerIndex& index)
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
975 {
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
976 serverIndex_ = &index;
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
977 }
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
978
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
979
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
980 void OrthancConfiguration::ResetServerIndex()
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
981 {
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
982 serverIndex_ = NULL;
e292798f9980 OrthancConfiguration::SetServerIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
983 }
3181
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
984
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
985
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
986 TemporaryFile* OrthancConfiguration::CreateTemporaryFile() const
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
987 {
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
988 if (json_.isMember(TEMPORARY_DIRECTORY))
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
989 {
3184
5d1f5984dc41 improved log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3181
diff changeset
990 return new TemporaryFile(InterpretStringParameterAsPath(GetStringParameter(TEMPORARY_DIRECTORY, ".")), "");
3181
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
991 }
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
992 else
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
993 {
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
994 return new TemporaryFile;
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
995 }
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3138
diff changeset
996 }
3709
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
997
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
998
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
999 std::string OrthancConfiguration::GetDefaultPrivateCreator() const
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1000 {
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1001 // New configuration option in Orthanc 1.6.0
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1002 return GetStringParameter("DefaultPrivateCreator", "");
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1003 }
4140
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1004
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1005
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1006 static void GetAcceptOption(std::set<DicomTransferSyntax>& target,
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1007 const OrthancConfiguration& configuration,
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1008 const std::string& optionName,
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1009 TransferSyntaxGroup optionGroup)
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1010 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1011 bool accept;
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1012 if (configuration.LookupBooleanParameter(accept, optionName))
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1013 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1014 std::set<DicomTransferSyntax> group;
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1015 GetTransferSyntaxGroup(group, optionGroup);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1016
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1017 for (std::set<DicomTransferSyntax>::const_iterator
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1018 syntax = group.begin(); syntax != group.end(); ++syntax)
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1019 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1020 if (accept)
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1021 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1022 target.insert(*syntax);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1023 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1024 else
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1025 {
4474
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1026 target.erase(*syntax);
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1027 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1028 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1029 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1030 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1031
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1032
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1033 void OrthancConfiguration::GetAcceptedTransferSyntaxes(std::set<DicomTransferSyntax>& target) const
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1034 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1035 target.clear();
4474
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1036
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1037 #if 1
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1038 /**
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1039 * This is the behavior in Orthanc >= 1.9.0. All the transfer
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1040 * syntaxes are accepted by default, and the
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1041 * "TransferSyntaxAccepted" options can be used to disable groups
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1042 * of transfer syntaxes.
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1043 **/
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1044
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1045 static const char* const ACCEPTED_TRANSFER_SYNTAXES = "AcceptedTransferSyntaxes";
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1046
4487
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4474
diff changeset
1047 if (json_.isMember(ACCEPTED_TRANSFER_SYNTAXES))
4474
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1048 {
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1049 ParseAcceptedTransferSyntaxes(target, json_[ACCEPTED_TRANSFER_SYNTAXES]);
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1050 }
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1051 else
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1052 {
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1053 GetAllDicomTransferSyntaxes(target);
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1054 }
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1055 #else
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1056 /**
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1057 * This was the behavior of Orthanc <= 1.8.2. The uncompressed
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1058 * transfer syntaxes were always accepted, and additional transfer
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1059 * syntaxes were added using the configuration options
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1060 * "XXXTransferSyntaxAccepted".
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1061 **/
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1062
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1063 // The 3 transfer syntaxes below were the only ones to be supported in Orthanc <= 0.7.1
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1064 target.insert(DicomTransferSyntax_LittleEndianExplicit);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1065 target.insert(DicomTransferSyntax_BigEndianExplicit);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1066 target.insert(DicomTransferSyntax_LittleEndianImplicit);
4474
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1067 #endif
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1068
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1069 // Groups of transfer syntaxes, supported since Orthanc 0.7.2
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1070 GetAcceptOption(target, *this, "DeflatedTransferSyntaxAccepted", TransferSyntaxGroup_Deflated);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1071 GetAcceptOption(target, *this, "JpegTransferSyntaxAccepted", TransferSyntaxGroup_Jpeg);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1072 GetAcceptOption(target, *this, "Jpeg2000TransferSyntaxAccepted", TransferSyntaxGroup_Jpeg2000);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1073 GetAcceptOption(target, *this, "JpegLosslessTransferSyntaxAccepted", TransferSyntaxGroup_JpegLossless);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1074 GetAcceptOption(target, *this, "JpipTransferSyntaxAccepted", TransferSyntaxGroup_Jpip);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1075 GetAcceptOption(target, *this, "Mpeg2TransferSyntaxAccepted", TransferSyntaxGroup_Mpeg2);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1076 GetAcceptOption(target, *this, "Mpeg4TransferSyntaxAccepted", TransferSyntaxGroup_Mpeg4);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1077 GetAcceptOption(target, *this, "RleTransferSyntaxAccepted", TransferSyntaxGroup_Rle);
4474
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1078 GetAcceptOption(target, *this, "H265TransferSyntaxAccepted", TransferSyntaxGroup_H265);
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1079 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1080
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1081
4604
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1082 std::string OrthancConfiguration::GetDatabaseServerIdentifier() const
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1083 {
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1084 std::string id;
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1085
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4604
diff changeset
1086 if (LookupStringParameter(id, DATABASE_SERVER_IDENTIFIER))
4604
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1087 {
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4604
diff changeset
1088 if (id.empty())
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4604
diff changeset
1089 {
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4604
diff changeset
1090 throw OrthancException(ErrorCode_ParameterOutOfRange, "Global configuration option \"" +
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4604
diff changeset
1091 std::string(DATABASE_SERVER_IDENTIFIER) + "\" cannot be empty");
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4604
diff changeset
1092 }
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4604
diff changeset
1093 else
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4604
diff changeset
1094 {
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4604
diff changeset
1095 return id;
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4604
diff changeset
1096 }
4604
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1097 }
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1098 else
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1099 {
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1100 std::set<std::string> items;
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1101
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1102 {
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1103 std::set<std::string> mac;
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1104 SystemToolbox::GetMacAddresses(mac);
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1105
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1106 for (std::set<std::string>::const_iterator it = mac.begin(); it != mac.end(); ++it)
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1107 {
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1108 items.insert("mac=" + *it);
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1109 }
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1110 }
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1111
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1112 items.insert("aet=" + GetStringParameter("DicomAet", "ORTHANC"));
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1113 items.insert("dicom-port=" + boost::lexical_cast<std::string>(GetUnsignedIntegerParameter("DicomPort", 4242)));
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1114 items.insert("http-port=" + boost::lexical_cast<std::string>(GetUnsignedIntegerParameter("HttpPort", 8042)));
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1115
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1116 for (std::set<std::string>::const_iterator it = items.begin(); it != items.end(); ++it)
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1117 {
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1118 if (id.empty())
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1119 {
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1120 id = *it;
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1121 }
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1122 else
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1123 {
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1124 id += ("|" + *it);
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1125 }
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1126 }
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1127
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1128 std::string hash;
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1129 Toolbox::ComputeSHA1(hash, id);
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1130 return hash;
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1131 }
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1132 }
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1133
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1134 void OrthancConfiguration::LoadWarnings()
4934
94a7b681b340 added configuration for extra main dicom tags + save signature in metadata + show warning if inconsistent main dicom tags
Alain Mazy <am@osimis.io>
parents: 4892
diff changeset
1135 {
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1136 if (json_.isMember(WARNINGS))
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1137 {
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1138 const Json::Value& warnings = json_[WARNINGS];
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1139 if (!warnings.isObject())
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1140 {
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1141 throw OrthancException(ErrorCode_BadFileFormat, std::string(WARNINGS) + " configuration entry is not a Json object");
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1142 }
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1143
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1144 Json::Value::Members members = warnings.getMemberNames();
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1145
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1146 for (size_t i = 0; i < members.size(); i++)
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1147 {
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1148 const std::string& name = members[i];
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1149 bool enabled = warnings[name].asBool();
4941
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4934
diff changeset
1150
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1151 Warnings warning = Warnings_None;
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1152 if (name == "W001_TagsBeingReadFromStorage")
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1153 {
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1154 warning = Warnings_001_TagsBeingReadFromStorage;
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1155 }
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1156 else if (name == "W002_InconsistentDicomTagsInDb")
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1157 {
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1158 warning = Warnings_002_InconsistentDicomTagsInDb;
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1159 }
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1160 else
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1161 {
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1162 throw OrthancException(ErrorCode_BadFileFormat, name + " is not recognized as a valid warning name");
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1163 }
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1164
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1165 if (!enabled)
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1166 {
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1167 disabledWarnings_.insert(warning);
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1168 }
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1169 }
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1170 }
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1171 else
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1172 {
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1173 disabledWarnings_.clear();
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1174 }
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1175
4941
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4934
diff changeset
1176 }
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4934
diff changeset
1177
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4934
diff changeset
1178
4140
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1179 void OrthancConfiguration::DefaultExtractDicomSummary(DicomMap& target,
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4182
diff changeset
1180 const ParsedDicomFile& dicom)
4140
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1181 {
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1182 std::set<DicomTag> ignoreTagLength;
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1183 dicom.ExtractDicomSummary(target, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength);
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1184 }
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1185
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1186
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4487
diff changeset
1187 void OrthancConfiguration::DefaultExtractDicomSummary(DicomMap& target,
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4487
diff changeset
1188 DcmDataset& dicom)
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4487
diff changeset
1189 {
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4487
diff changeset
1190 std::set<DicomTag> ignoreTagLength;
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4487
diff changeset
1191 FromDcmtkBridge::ExtractDicomSummary(target, dicom, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength);
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4487
diff changeset
1192 }
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4487
diff changeset
1193
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4487
diff changeset
1194
4140
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1195 void OrthancConfiguration::DefaultDicomDatasetToJson(Json::Value& target,
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4182
diff changeset
1196 const ParsedDicomFile& dicom)
4140
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1197 {
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1198 std::set<DicomTag> ignoreTagLength;
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1199 DefaultDicomDatasetToJson(target, dicom, ignoreTagLength);
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1200 }
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4487
diff changeset
1201
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4487
diff changeset
1202
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4487
diff changeset
1203 void OrthancConfiguration::DefaultDicomDatasetToJson(Json::Value& target,
5036
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4944
diff changeset
1204 DcmDataset& dicom,
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4944
diff changeset
1205 const std::set<DicomTag>& ignoreTagLength)
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4487
diff changeset
1206 {
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4487
diff changeset
1207 FromDcmtkBridge::ExtractDicomAsJson(target, dicom, DicomToJsonFormat_Full, DicomToJsonFlags_Default,
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4487
diff changeset
1208 ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength);
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4487
diff changeset
1209 }
4140
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1210
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1211
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1212 void OrthancConfiguration::DefaultDicomDatasetToJson(Json::Value& target,
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4182
diff changeset
1213 const ParsedDicomFile& dicom,
4140
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1214 const std::set<DicomTag>& ignoreTagLength)
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1215 {
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1216 dicom.DatasetToJson(target, DicomToJsonFormat_Full, DicomToJsonFlags_Default,
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1217 ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength);
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1218 }
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1219
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1220
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1221 void OrthancConfiguration::DefaultDicomHeaderToJson(Json::Value& target,
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4182
diff changeset
1222 const ParsedDicomFile& dicom)
4140
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1223 {
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1224 dicom.HeaderToJson(target, DicomToJsonFormat_Full);
0ddc5297a8ab centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1225 }
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1226
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1227
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1228 static void AddTransferSyntaxes(std::set<DicomTransferSyntax>& target,
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1229 const std::string& source)
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1230 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1231 boost::regex pattern(Toolbox::WildcardToRegularExpression(source));
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1232
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1233 std::set<DicomTransferSyntax> allSyntaxes;
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1234 GetAllDicomTransferSyntaxes(allSyntaxes);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1235
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1236 for (std::set<DicomTransferSyntax>::const_iterator
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1237 syntax = allSyntaxes.begin(); syntax != allSyntaxes.end(); ++syntax)
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1238 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1239 if (regex_match(GetTransferSyntaxUid(*syntax), pattern))
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1240 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1241 target.insert(*syntax);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1242 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1243 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1244 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1245
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1246
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1247 void OrthancConfiguration::ParseAcceptedTransferSyntaxes(std::set<DicomTransferSyntax>& target,
4474
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1248 const Json::Value& source)
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1249 {
4474
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1250 if (source.type() == Json::stringValue)
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1251 {
4474
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1252 AddTransferSyntaxes(target, source.asString());
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1253 }
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1254 else if (source.type() == Json::arrayValue)
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1255 {
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1256 for (Json::Value::ArrayIndex i = 0; i < source.size(); i++)
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1257 {
4474
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1258 if (source[i].type() == Json::stringValue)
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1259 {
4474
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1260 AddTransferSyntaxes(target, source[i].asString());
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1261 }
4474
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1262 else
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1263 {
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1264 throw OrthancException(ErrorCode_BadFileFormat);
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1265 }
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1266 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1267 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1268 else
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1269 {
4474
f8c1d94363b6 new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
1270 throw OrthancException(ErrorCode_BadFileFormat);
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1271 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1272 }
2933
4a38d7d4f0e0 new class: OrthancConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1273 }