annotate OrthancServer/OrthancInitialization.cpp @ 1328:b7351ecb79b4

fix in the plugin destruction
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 18 Feb 2015 13:06:01 +0100
parents 59b603763f43
children a3559b66fba7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1275
diff changeset
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1275
diff changeset
4 * Department, University Hospital of Liege, Belgium
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
136
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
10 *
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
11 * In addition, as a special exception, the copyright holders of this
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
12 * program give permission to link the code of its release with the
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
15 * the linked executables. You must obey the GNU General Public License
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
19 * you do not wish to do so, delete this exception statement from your
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
20 * version. If you delete this exception statement from all source files
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
21 * in the program, then also delete it here.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
33 #include "PrecompiledHeadersServer.h"
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
34 #include "OrthancInitialization.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
476
4aae0261515e move HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 457
diff changeset
36 #include "../Core/HttpClient.h"
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
37 #include "../Core/OrthancException.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include "../Core/Toolbox.h"
685
b01cc78caba4 possibility to disable the DICOM/HTTP servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 660
diff changeset
39 #include "DicomProtocol/DicomServer.h"
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
40 #include "ServerEnumerations.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include <boost/lexical_cast.hpp>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 #include <boost/filesystem.hpp>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 #include <curl/curl.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 #include <boost/thread.hpp>
108
a6e41de88a53 using glog
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 91
diff changeset
46 #include <glog/logging.h>
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
48 #include "DatabaseWrapper.h"
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
49 #include "../Core/FileStorage/FilesystemStorage.h"
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
50
847
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
51
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
52 #if ORTHANC_JPEG_ENABLED == 1
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
53 #include <dcmtk/dcmjpeg/djdecode.h>
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
54 #endif
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
55
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
56
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
57 #if ORTHANC_JPEG_LOSSLESS_ENABLED == 1
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
58 #include <dcmtk/dcmjpls/djdecode.h>
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
59 #endif
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
60
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
61
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
62 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 static boost::mutex globalMutex_;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 static std::auto_ptr<Json::Value> configuration_;
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
66 static boost::filesystem::path defaultDirectory_;
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
67 static std::string configurationAbsolutePath_;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
69
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 static void ReadGlobalConfiguration(const char* configurationFile)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 configuration_.reset(new Json::Value);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 std::string content;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 if (configurationFile)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 Toolbox::ReadFile(content, configurationFile);
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
79 defaultDirectory_ = boost::filesystem::path(configurationFile).parent_path();
660
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
80 LOG(WARNING) << "Using the configuration from: " << configurationFile;
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
81 configurationAbsolutePath_ = boost::filesystem::absolute(configurationFile).string();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 {
660
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
85 #if ORTHANC_STANDALONE == 1
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
86 // No default path for the standalone configuration
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
87 LOG(WARNING) << "Using the default Orthanc configuration";
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
88 return;
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
89
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
90 #else
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
91 // In a non-standalone build, we use the
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
92 // "Resources/Configuration.json" from the Orthanc source code
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
93
19
e85455ff6039 standalon
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
94 try
e85455ff6039 standalon
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
95 {
660
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
96 boost::filesystem::path p = ORTHANC_PATH;
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
97 p /= "Resources";
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
98 p /= "Configuration.json";
87
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
99 Toolbox::ReadFile(content, p.string());
660
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
100 LOG(WARNING) << "Using the configuration from: " << p.string();
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
101 configurationAbsolutePath_ = boost::filesystem::absolute(p).string();
87
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
102 }
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
103 catch (OrthancException&)
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
104 {
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
105 // No configuration file found, give up with empty configuration
660
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
106 LOG(WARNING) << "Using the default Orthanc configuration";
19
e85455ff6039 standalon
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
107 return;
e85455ff6039 standalon
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
108 }
87
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
109 #endif
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
112
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 Json::Reader reader;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 if (!reader.parse(content, *configuration_))
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 {
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
116 throw OrthancException("Unable to read the configuration file");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
121 static void RegisterUserMetadata()
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
122 {
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
123 if (configuration_->isMember("UserMetadata"))
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
124 {
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
125 const Json::Value& parameter = (*configuration_) ["UserMetadata"];
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
126
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
127 Json::Value::Members members = parameter.getMemberNames();
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
128 for (size_t i = 0; i < members.size(); i++)
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
129 {
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
130 std::string info = "\"" + members[i] + "\" = " + parameter[members[i]].toStyledString();
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
131 LOG(INFO) << "Registering user-defined metadata: " << info;
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
132
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
133 if (!parameter[members[i]].asBool())
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
134 {
439
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
135 LOG(ERROR) << "Not a number in this user-defined metadata: " << info;
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
136 throw OrthancException(ErrorCode_BadParameterType);
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
137 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
138
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
139 int metadata = parameter[members[i]].asInt();
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
140
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
141 try
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
142 {
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
143 RegisterUserMetadata(metadata, members[i]);
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
144 }
657
5425bb6f1ea5 further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
145 catch (OrthancException&)
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
146 {
439
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
147 LOG(ERROR) << "Cannot register this user-defined metadata: " << info;
657
5425bb6f1ea5 further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
148 throw;
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
149 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
150 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
151 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
152 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
153
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
154
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
155 static void RegisterUserContentType()
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
156 {
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
157 if (configuration_->isMember("UserContentType"))
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
158 {
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
159 const Json::Value& parameter = (*configuration_) ["UserContentType"];
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
160
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
161 Json::Value::Members members = parameter.getMemberNames();
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
162 for (size_t i = 0; i < members.size(); i++)
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
163 {
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
164 std::string info = "\"" + members[i] + "\" = " + parameter[members[i]].toStyledString();
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
165 LOG(INFO) << "Registering user-defined attachment type: " << info;
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
166
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
167 if (!parameter[members[i]].asBool())
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
168 {
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
169 LOG(ERROR) << "Not a number in this user-defined attachment type: " << info;
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
170 throw OrthancException(ErrorCode_BadParameterType);
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
171 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
172
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
173 int contentType = parameter[members[i]].asInt();
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
174
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
175 try
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
176 {
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
177 RegisterUserContentType(contentType, members[i]);
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
178 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
179 catch (OrthancException&)
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
180 {
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
181 LOG(ERROR) << "Cannot register this user-defined attachment type: " << info;
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
182 throw;
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
183 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
184 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
185 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
186 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
187
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
188
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
189 void OrthancInitialize(const char* configurationFile)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 boost::mutex::scoped_lock lock(globalMutex_);
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
192
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
193 InitializeServerEnumerations();
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
194 defaultDirectory_ = boost::filesystem::current_path();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 ReadGlobalConfiguration(configurationFile);
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
196
457
997282a61ff8 cleaner names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
197 HttpClient::GlobalInitialize();
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
198
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
199 RegisterUserMetadata();
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
200 RegisterUserContentType();
685
b01cc78caba4 possibility to disable the DICOM/HTTP servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 660
diff changeset
201
b01cc78caba4 possibility to disable the DICOM/HTTP servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 660
diff changeset
202 DicomServer::InitializeDictionary();
847
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
203
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
204 #if ORTHANC_JPEG_LOSSLESS_ENABLED == 1
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
205 LOG(WARNING) << "Registering JPEG Lossless codecs";
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
206 DJLSDecoderRegistration::registerCodecs();
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
207 #endif
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
208
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
209 #if ORTHANC_JPEG_ENABLED == 1
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
210 LOG(WARNING) << "Registering JPEG codecs";
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
211 DJDecoderRegistration::registerCodecs();
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
212 #endif
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
217 void OrthancFinalize()
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 boost::mutex::scoped_lock lock(globalMutex_);
457
997282a61ff8 cleaner names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
220 HttpClient::GlobalFinalize();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 configuration_.reset(NULL);
847
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
222
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
223 #if ORTHANC_JPEG_LOSSLESS_ENABLED == 1
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
224 // Unregister JPEG-LS codecs
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
225 DJLSDecoderRegistration::cleanup();
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
226 #endif
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
227
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
228 #if ORTHANC_JPEG_ENABLED == 1
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
229 // Unregister JPEG codecs
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
230 DJDecoderRegistration::cleanup();
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
231 #endif
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
236 std::string Configuration::GetGlobalStringParameter(const std::string& parameter,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
237 const std::string& defaultValue)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 boost::mutex::scoped_lock lock(globalMutex_);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 if (configuration_->isMember(parameter))
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 return (*configuration_) [parameter].asString();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 return defaultValue;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
252 int Configuration::GetGlobalIntegerParameter(const std::string& parameter,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
253 int defaultValue)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 boost::mutex::scoped_lock lock(globalMutex_);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 if (configuration_->isMember(parameter))
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 return (*configuration_) [parameter].asInt();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 return defaultValue;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
267
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
268 bool Configuration::GetGlobalBoolParameter(const std::string& parameter,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
269 bool defaultValue)
23
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
270 {
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
271 boost::mutex::scoped_lock lock(globalMutex_);
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
272
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
273 if (configuration_->isMember(parameter))
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
274 {
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
275 return (*configuration_) [parameter].asBool();
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
276 }
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
277 else
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
278 {
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
279 return defaultValue;
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
280 }
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
281 }
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
282
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
283
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
284 void Configuration::GetDicomModalityUsingSymbolicName(RemoteModalityParameters& modality,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
285 const std::string& name)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 boost::mutex::scoped_lock lock(globalMutex_);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 if (!configuration_->isMember("DicomModalities"))
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 {
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
291 throw OrthancException(ErrorCode_BadFileFormat);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 const Json::Value& modalities = (*configuration_) ["DicomModalities"];
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 if (modalities.type() != Json::objectValue ||
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
296 !modalities.isMember(name))
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 {
1007
871c49c9b11d lua routing is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 942
diff changeset
298 LOG(ERROR) << "No modality with symbolic name: " << name;
871c49c9b11d lua routing is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 942
diff changeset
299 throw OrthancException(ErrorCode_InexistentItem);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 try
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 {
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
304 modality.FromJson(modalities[name]);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 }
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
306 catch (OrthancException& e)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 {
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
308 LOG(ERROR) << "Syntax error in the definition of modality \"" << name
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
309 << "\". Please check your configuration file.";
942
b3f6fb1130cd fixes thanks to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 847
diff changeset
310 throw;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
316 void Configuration::GetOrthancPeer(OrthancPeerParameters& peer,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
317 const std::string& name)
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
318 {
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
319 boost::mutex::scoped_lock lock(globalMutex_);
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
320
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
321 if (!configuration_->isMember("OrthancPeers"))
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
322 {
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
323 throw OrthancException(ErrorCode_BadFileFormat);
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
324 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
325
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
326 try
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
327 {
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
328 const Json::Value& modalities = (*configuration_) ["OrthancPeers"];
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
329 if (modalities.type() != Json::objectValue ||
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
330 !modalities.isMember(name))
485
bdbde1fbfab3 send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 484
diff changeset
331 {
1007
871c49c9b11d lua routing is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 942
diff changeset
332 LOG(ERROR) << "No peer with symbolic name: " << name;
871c49c9b11d lua routing is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 942
diff changeset
333 throw OrthancException(ErrorCode_InexistentItem);
485
bdbde1fbfab3 send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 484
diff changeset
334 }
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
335
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
336 peer.FromJson(modalities[name]);
485
bdbde1fbfab3 send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 484
diff changeset
337 }
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
338 catch (OrthancException& e)
485
bdbde1fbfab3 send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 484
diff changeset
339 {
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
340 LOG(ERROR) << "Syntax error in the definition of peer \"" << name
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
341 << "\". Please check your configuration file.";
942
b3f6fb1130cd fixes thanks to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 847
diff changeset
342 throw;
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
343 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
344 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
345
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
346
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
347 static bool ReadKeys(std::set<std::string>& target,
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
348 const char* parameter,
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
349 bool onlyAlphanumeric)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 boost::mutex::scoped_lock lock(globalMutex_);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 target.clear();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
355 if (!configuration_->isMember(parameter))
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 {
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
357 return true;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
360 const Json::Value& modalities = (*configuration_) [parameter];
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 if (modalities.type() != Json::objectValue)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 {
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
363 throw OrthancException(ErrorCode_BadFileFormat);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 Json::Value::Members members = modalities.getMemberNames();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 for (size_t i = 0; i < members.size(); i++)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 {
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
369 if (onlyAlphanumeric)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 {
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
371 for (size_t j = 0; j < members[i].size(); j++)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 {
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
373 if (!isalnum(members[i][j]) && members[i][j] != '-')
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
374 {
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
375 return false;
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
376 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380 target.insert(members[i]);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 }
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
382
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
383 return true;
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
384 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
385
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
386
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
387 void Configuration::GetListOfDicomModalities(std::set<std::string>& target)
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
388 {
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
389 if (!ReadKeys(target, "DicomModalities", true))
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
390 {
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
391 throw OrthancException("Only alphanumeric and dash characters are allowed in the names of the modalities");
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
392 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
393 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
394
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
395
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
396 void Configuration::GetListOfOrthancPeers(std::set<std::string>& target)
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
397 {
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
398 if (!ReadKeys(target, "OrthancPeers", true))
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
399 {
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
400 throw OrthancException("Only alphanumeric and dash characters are allowed in the names of Orthanc peers");
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
401 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 }
25
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
403
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
404
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
405
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
406 void Configuration::SetupRegisteredUsers(MongooseServer& httpServer)
25
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
407 {
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
408 boost::mutex::scoped_lock lock(globalMutex_);
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
409
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
410 httpServer.ClearUsers();
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
411
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
412 if (!configuration_->isMember("RegisteredUsers"))
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
413 {
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
414 return;
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
415 }
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
416
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
417 const Json::Value& users = (*configuration_) ["RegisteredUsers"];
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
418 if (users.type() != Json::objectValue)
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
419 {
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
420 throw OrthancException("Badly formatted list of users");
25
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
421 }
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
422
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
423 Json::Value::Members usernames = users.getMemberNames();
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
424 for (size_t i = 0; i < usernames.size(); i++)
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
425 {
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
426 const std::string& username = usernames[i];
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
427 std::string password = users[username].asString();
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
428 httpServer.RegisterUser(username.c_str(), password.c_str());
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
429 }
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
430 }
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
431
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
432
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
433 std::string Configuration::InterpretRelativePath(const std::string& baseDirectory,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
434 const std::string& relativePath)
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
435 {
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
436 boost::filesystem::path base(baseDirectory);
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
437 boost::filesystem::path relative(relativePath);
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
438
428
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
439 /**
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
440 The following lines should be equivalent to this one:
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
441
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
442 return (base / relative).string();
428
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
443
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
444 However, for some unknown reason, some versions of Boost do not
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
445 make the proper path resolution when "baseDirectory" is an
428
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
446 absolute path. So, a hack is used below.
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
447 **/
428
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
448
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
449 if (relative.is_absolute())
427
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
450 {
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
451 return relative.string();
427
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
452 }
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
453 else
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
454 {
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
455 return (base / relative).string();
427
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
456 }
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
457 }
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
458
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
459 std::string Configuration::InterpretStringParameterAsPath(const std::string& parameter)
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
460 {
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
461 boost::mutex::scoped_lock lock(globalMutex_);
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
462 return InterpretRelativePath(defaultDirectory_.string(), parameter);
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
463 }
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
464
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
465
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
466 void Configuration::GetGlobalListOfStringsParameter(std::list<std::string>& target,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
467 const std::string& key)
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
468 {
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
469 boost::mutex::scoped_lock lock(globalMutex_);
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
470
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
471 target.clear();
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
472
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
473 if (!configuration_->isMember(key))
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
474 {
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
475 return;
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
476 }
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
477
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
478 const Json::Value& lst = (*configuration_) [key];
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
479
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
480 if (lst.type() != Json::arrayValue)
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
481 {
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
482 throw OrthancException("Badly formatted list of strings");
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
483 }
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
484
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
485 for (Json::Value::ArrayIndex i = 0; i < lst.size(); i++)
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
486 {
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
487 target.push_back(lst[i].asString());
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
488 }
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
489 }
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
490
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
491
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
492 bool Configuration::IsSameAETitle(const std::string& aet1,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
493 const std::string& aet2)
690
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
494 {
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
495 if (GetGlobalBoolParameter("StrictAetComparison", false))
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
496 {
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
497 // Case-sensitive matching
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
498 return aet1 == aet2;
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
499 }
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
500 else
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
501 {
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
502 // Case-insensitive matching (default)
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
503 std::string tmp1, tmp2;
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
504 Toolbox::ToLowerCase(tmp1, aet1);
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
505 Toolbox::ToLowerCase(tmp2, aet2);
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
506 return tmp1 == tmp2;
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
507 }
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
508 }
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
509
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
510
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
511 bool Configuration::LookupDicomModalityUsingAETitle(RemoteModalityParameters& modality,
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
512 const std::string& aet)
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
513 {
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
514 std::set<std::string> modalities;
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
515 GetListOfDicomModalities(modalities);
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
516
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
517 for (std::set<std::string>::const_iterator
656
08eca5d86aad fixes to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
518 it = modalities.begin(); it != modalities.end(); ++it)
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
519 {
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
520 try
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
521 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
522 GetDicomModalityUsingSymbolicName(modality, *it);
725
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 696
diff changeset
523
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
524 if (IsSameAETitle(aet, modality.GetApplicationEntityTitle()))
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
525 {
617
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
526 return true;
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
527 }
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
528 }
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
529 catch (OrthancException&)
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
530 {
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
531 }
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
532 }
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
533
617
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
534 return false;
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
535 }
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
536
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
537
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
538 bool Configuration::IsKnownAETitle(const std::string& aet)
617
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
539 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
540 RemoteModalityParameters modality;
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
541 return LookupDicomModalityUsingAETitle(modality, aet);
617
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
542 }
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
543
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
544
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
545 RemoteModalityParameters Configuration::GetModalityUsingSymbolicName(const std::string& name)
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
546 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
547 RemoteModalityParameters modality;
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
548 GetDicomModalityUsingSymbolicName(modality, name);
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
549
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
550 return modality;
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
551 }
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
552
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 772
diff changeset
553
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
554 RemoteModalityParameters Configuration::GetModalityUsingAet(const std::string& aet)
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
555 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
556 RemoteModalityParameters modality;
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
557
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
558 if (LookupDicomModalityUsingAETitle(modality, aet))
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
559 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
560 return modality;
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
561 }
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
562 else
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
563 {
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
564 throw OrthancException("Unknown modality for AET: " + aet);
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
565 }
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
566 }
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
567
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
568
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
569 void Configuration::UpdateModality(const std::string& symbolicName,
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
570 const RemoteModalityParameters& modality)
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
571 {
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
572 boost::mutex::scoped_lock lock(globalMutex_);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
573
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
574 if (!configuration_->isMember("DicomModalities"))
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
575 {
814
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 812
diff changeset
576 (*configuration_) ["DicomModalities"] = Json::objectValue;
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
577 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
578
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
579 Json::Value& modalities = (*configuration_) ["DicomModalities"];
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
580 if (modalities.type() != Json::objectValue)
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
581 {
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
582 throw OrthancException(ErrorCode_BadFileFormat);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
583 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
584
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
585 modalities.removeMember(symbolicName);
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
586
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
587 Json::Value v;
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
588 modality.ToJson(v);
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
589 modalities[symbolicName] = v;
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
590 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
591
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
592
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
593 void Configuration::RemoveModality(const std::string& symbolicName)
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
594 {
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
595 boost::mutex::scoped_lock lock(globalMutex_);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
596
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
597 if (!configuration_->isMember("DicomModalities"))
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
598 {
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
599 throw OrthancException(ErrorCode_BadFileFormat);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
600 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
601
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
602 Json::Value& modalities = (*configuration_) ["DicomModalities"];
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
603 if (modalities.type() != Json::objectValue)
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
604 {
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
605 throw OrthancException(ErrorCode_BadFileFormat);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
606 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
607
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
608 modalities.removeMember(symbolicName.c_str());
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
609 }
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
610
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
611
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
612 void Configuration::UpdatePeer(const std::string& symbolicName,
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
613 const OrthancPeerParameters& peer)
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
614 {
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
615 boost::mutex::scoped_lock lock(globalMutex_);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
616
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
617 if (!configuration_->isMember("OrthancPeers"))
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
618 {
814
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 812
diff changeset
619 (*configuration_) ["OrthancPeers"] = Json::objectValue;
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
620 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
621
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
622 Json::Value& peers = (*configuration_) ["OrthancPeers"];
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
623 if (peers.type() != Json::objectValue)
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
624 {
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
625 throw OrthancException(ErrorCode_BadFileFormat);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
626 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
627
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
628 peers.removeMember(symbolicName);
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
629
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
630 Json::Value v;
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
631 peer.ToJson(v);
812
8a36c947490c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
632 peers[symbolicName] = v;
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
633 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
634
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
635
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
636 void Configuration::RemovePeer(const std::string& symbolicName)
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
637 {
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
638 boost::mutex::scoped_lock lock(globalMutex_);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
639
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
640 if (!configuration_->isMember("OrthancPeers"))
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
641 {
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
642 throw OrthancException(ErrorCode_BadFileFormat);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
643 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
644
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
645 Json::Value& peers = (*configuration_) ["OrthancPeers"];
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
646 if (peers.type() != Json::objectValue)
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
647 {
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
648 throw OrthancException(ErrorCode_BadFileFormat);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
649 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
650
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
651 peers.removeMember(symbolicName.c_str());
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
652 }
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
653
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
654
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
655
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
656 const std::string& Configuration::GetConfigurationAbsolutePath()
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
657 {
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
658 return configurationAbsolutePath_;
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
659 }
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
660
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
661
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
662 static IDatabaseWrapper* CreateSQLiteWrapper()
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
663 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
664 std::string storageDirectoryStr = Configuration::GetGlobalStringParameter("StorageDirectory", "OrthancStorage");
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
665
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
666 // Open the database
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
667 boost::filesystem::path indexDirectory = Configuration::InterpretStringParameterAsPath(
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
668 Configuration::GetGlobalStringParameter("IndexDirectory", storageDirectoryStr));
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
669
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
670 LOG(WARNING) << "SQLite index directory: " << indexDirectory;
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
671
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
672 try
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
673 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
674 boost::filesystem::create_directories(indexDirectory);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
675 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
676 catch (boost::filesystem::filesystem_error)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
677 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
678 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
679
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
680 return new DatabaseWrapper(indexDirectory.string() + "/index");
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
681 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
682
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
683
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
684 namespace
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
685 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
686 // Anonymous namespace to avoid clashes between compilation modules
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
687
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
688 class FilesystemStorageWithoutDicom : public IStorageArea
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
689 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
690 private:
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
691 FilesystemStorage storage_;
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
692
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
693 public:
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
694 FilesystemStorageWithoutDicom(const std::string& path) : storage_(path)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
695 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
696 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
697
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
698 virtual void Create(const std::string& uuid,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
699 const void* content,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
700 size_t size,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
701 FileContentType type)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
702 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
703 if (type != FileContentType_Dicom)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
704 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
705 storage_.Create(uuid, content, size, type);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
706 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
707 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
708
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
709 virtual void Read(std::string& content,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
710 const std::string& uuid,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
711 FileContentType type)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
712 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
713 if (type != FileContentType_Dicom)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
714 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
715 storage_.Read(content, uuid, type);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
716 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
717 else
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
718 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
719 throw OrthancException(ErrorCode_UnknownResource);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
720 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
721 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
722
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
723 virtual void Remove(const std::string& uuid,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
724 FileContentType type)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
725 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
726 if (type != FileContentType_Dicom)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
727 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
728 storage_.Remove(uuid, type);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
729 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
730 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
731 };
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
732 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
733
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
734
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
735 static IStorageArea* CreateFilesystemStorage()
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
736 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
737 std::string storageDirectoryStr = Configuration::GetGlobalStringParameter("StorageDirectory", "OrthancStorage");
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
738
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
739 boost::filesystem::path storageDirectory = Configuration::InterpretStringParameterAsPath(storageDirectoryStr);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
740 LOG(WARNING) << "Storage directory: " << storageDirectory;
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
741
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
742 if (Configuration::GetGlobalBoolParameter("StoreDicom", true))
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
743 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
744 return new FilesystemStorage(storageDirectory.string());
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
745 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
746 else
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
747 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
748 LOG(WARNING) << "The DICOM files will not be stored, Orthanc running in index-only mode";
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
749 return new FilesystemStorageWithoutDicom(storageDirectory.string());
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
750 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
751 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
752
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
753
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
754 IDatabaseWrapper* Configuration::CreateDatabaseWrapper()
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
755 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
756 return CreateSQLiteWrapper();
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
757 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
758
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
759
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
760 IStorageArea* Configuration::CreateStorageArea()
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
761 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
762 return CreateFilesystemStorage();
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
763 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
764 }