annotate OrthancServer/OrthancInitialization.cpp @ 807:566a2fb3c1fb

update/delete modalities
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 07 May 2014 15:54:23 +0200
parents 557575fd93e9
children 2d9a000aa3a6
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
689
2d0a347e8cfc switch to 2014
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 685
diff changeset
3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege,
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Belgium
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
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
33 #include "OrthancInitialization.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
476
4aae0261515e move HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 457
diff changeset
35 #include "../Core/HttpClient.h"
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
36 #include "../Core/OrthancException.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../Core/Toolbox.h"
685
b01cc78caba4 possibility to disable the DICOM/HTTP servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 660
diff changeset
38 #include "DicomProtocol/DicomServer.h"
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
39 #include "ServerEnumerations.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 #include <boost/lexical_cast.hpp>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include <boost/filesystem.hpp>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 #include <curl/curl.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 #include <boost/thread.hpp>
108
a6e41de88a53 using glog
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 91
diff changeset
45 #include <glog/logging.h>
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
47 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 static boost::mutex globalMutex_;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 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
51 static boost::filesystem::path defaultDirectory_;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
53
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 static void ReadGlobalConfiguration(const char* configurationFile)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 configuration_.reset(new Json::Value);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 std::string content;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 if (configurationFile)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 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
63 defaultDirectory_ = boost::filesystem::path(configurationFile).parent_path();
660
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
64 LOG(WARNING) << "Using the configuration from: " << configurationFile;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 {
660
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
68 #if ORTHANC_STANDALONE == 1
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
69 // No default path for the standalone configuration
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
70 LOG(WARNING) << "Using the default Orthanc configuration";
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
71 return;
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
72
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
73 #else
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
74 // In a non-standalone build, we use the
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
75 // "Resources/Configuration.json" from the Orthanc source code
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
76
19
e85455ff6039 standalon
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
77 try
e85455ff6039 standalon
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
78 {
660
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
79 boost::filesystem::path p = ORTHANC_PATH;
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
80 p /= "Resources";
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
81 p /= "Configuration.json";
87
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
82 Toolbox::ReadFile(content, p.string());
660
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
83 LOG(WARNING) << "Using the configuration from: " << p.string();
87
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
84 }
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
85 catch (OrthancException&)
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
86 {
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
87 // No configuration file found, give up with empty configuration
660
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
88 LOG(WARNING) << "Using the default Orthanc configuration";
19
e85455ff6039 standalon
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
89 return;
e85455ff6039 standalon
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
90 }
87
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
91 #endif
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 Json::Reader reader;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 if (!reader.parse(content, *configuration_))
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 {
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
97 throw OrthancException("Unable to read the configuration file");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
102 static void RegisterUserMetadata()
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
103 {
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
104 if (configuration_->isMember("UserMetadata"))
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
105 {
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
106 const Json::Value& parameter = (*configuration_) ["UserMetadata"];
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
107
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
108 Json::Value::Members members = parameter.getMemberNames();
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
109 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
110 {
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
111 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
112 LOG(INFO) << "Registering user-defined metadata: " << info;
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
113
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
114 if (!parameter[members[i]].asBool())
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
115 {
439
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
116 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
117 throw OrthancException(ErrorCode_BadParameterType);
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
118 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
119
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
120 int metadata = parameter[members[i]].asInt();
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
121
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
122 try
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
123 {
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
124 RegisterUserMetadata(metadata, members[i]);
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
125 }
657
5425bb6f1ea5 further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
126 catch (OrthancException&)
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
127 {
439
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
128 LOG(ERROR) << "Cannot register this user-defined metadata: " << info;
657
5425bb6f1ea5 further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
129 throw;
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
130 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
131 }
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 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
134
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
135
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
136 static void RegisterUserContentType()
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
137 {
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
138 if (configuration_->isMember("UserContentType"))
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
139 {
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
140 const Json::Value& parameter = (*configuration_) ["UserContentType"];
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
141
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
142 Json::Value::Members members = parameter.getMemberNames();
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
143 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
144 {
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
145 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
146 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
147
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
148 if (!parameter[members[i]].asBool())
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
149 {
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
150 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
151 throw OrthancException(ErrorCode_BadParameterType);
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
152 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
153
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
154 int contentType = parameter[members[i]].asInt();
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
155
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
156 try
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
157 {
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
158 RegisterUserContentType(contentType, members[i]);
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
159 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
160 catch (OrthancException&)
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
161 {
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
162 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
163 throw;
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
164 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
165 }
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 }
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
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
170 void OrthancInitialize(const char* configurationFile)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 boost::mutex::scoped_lock lock(globalMutex_);
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
173
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
174 InitializeServerEnumerations();
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
175 defaultDirectory_ = boost::filesystem::current_path();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 ReadGlobalConfiguration(configurationFile);
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
177
457
997282a61ff8 cleaner names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
178 HttpClient::GlobalInitialize();
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
179
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
180 RegisterUserMetadata();
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
181 RegisterUserContentType();
685
b01cc78caba4 possibility to disable the DICOM/HTTP servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 660
diff changeset
182
b01cc78caba4 possibility to disable the DICOM/HTTP servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 660
diff changeset
183 DicomServer::InitializeDictionary();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
188 void OrthancFinalize()
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 boost::mutex::scoped_lock lock(globalMutex_);
457
997282a61ff8 cleaner names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
191 HttpClient::GlobalFinalize();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 configuration_.reset(NULL);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 std::string GetGlobalStringParameter(const std::string& parameter,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 const std::string& defaultValue)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 boost::mutex::scoped_lock lock(globalMutex_);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 if (configuration_->isMember(parameter))
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 return (*configuration_) [parameter].asString();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 return defaultValue;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 int GetGlobalIntegerParameter(const std::string& parameter,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 int defaultValue)
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 boost::mutex::scoped_lock lock(globalMutex_);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 if (configuration_->isMember(parameter))
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 return (*configuration_) [parameter].asInt();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 return defaultValue;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227
23
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
228 bool GetGlobalBoolParameter(const std::string& parameter,
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
229 bool defaultValue)
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
230 {
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
231 boost::mutex::scoped_lock lock(globalMutex_);
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
232
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
233 if (configuration_->isMember(parameter))
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
234 {
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
235 return (*configuration_) [parameter].asBool();
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
236 }
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
237 else
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
238 {
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
239 return defaultValue;
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
240 }
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
241 }
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
242
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
243
0
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
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
246 void GetDicomModalityUsingSymbolicName(RemoteModalityParameters& modality,
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
247 const std::string& name)
0
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 boost::mutex::scoped_lock lock(globalMutex_);
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 if (!configuration_->isMember("DicomModalities"))
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 {
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
253 throw OrthancException(ErrorCode_BadFileFormat);
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
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 const Json::Value& modalities = (*configuration_) ["DicomModalities"];
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 if (modalities.type() != Json::objectValue ||
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
258 !modalities.isMember(name))
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 {
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
260 throw OrthancException(ErrorCode_BadFileFormat);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 }
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 try
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 {
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
265 modality.FromJson(modalities[name]);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 }
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
267 catch (OrthancException& e)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 {
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
269 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
270 << "\". Please check your configuration file.";
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
271 throw e;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
277 void GetOrthancPeer(OrthancPeerParameters& peer,
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
278 const std::string& name)
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
279 {
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
280 boost::mutex::scoped_lock lock(globalMutex_);
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
281
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
282 if (!configuration_->isMember("OrthancPeers"))
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
283 {
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
284 throw OrthancException(ErrorCode_BadFileFormat);
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
285 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
286
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
287 try
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
288 {
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
289 const Json::Value& modalities = (*configuration_) ["OrthancPeers"];
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
290 if (modalities.type() != Json::objectValue ||
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
291 !modalities.isMember(name))
485
bdbde1fbfab3 send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 484
diff changeset
292 {
bdbde1fbfab3 send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 484
diff changeset
293 throw OrthancException(ErrorCode_BadFileFormat);
bdbde1fbfab3 send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 484
diff changeset
294 }
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
295
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
296 std::string url;
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
297
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
298 try
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
299 {
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
300 url = modalities[name].get(0u, "").asString();
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
301
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
302 if (modalities[name].size() == 1)
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
303 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
304 peer.SetUsername("");
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
305 peer.SetPassword("");
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
306 }
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
307 else if (modalities[name].size() == 3)
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
308 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
309 peer.SetUsername(modalities[name].get(1u, "").asString());
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
310 peer.SetPassword(modalities[name].get(2u, "").asString());
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
311 }
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
312 else
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
313 {
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
314 throw OrthancException(ErrorCode_BadFileFormat);
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
315 }
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
316 }
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
317 catch (...)
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
318 {
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
319 throw OrthancException(ErrorCode_BadFileFormat);
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
320 }
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
321
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
322 if (url.size() != 0 && url[url.size() - 1] != '/')
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
323 {
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
324 url += '/';
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
325 }
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
326
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
327 peer.SetUrl(url);
485
bdbde1fbfab3 send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 484
diff changeset
328 }
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
329 catch (OrthancException& e)
485
bdbde1fbfab3 send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 484
diff changeset
330 {
752
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
331 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
332 << "\". Please check your configuration file.";
45715eadc2e0 port number as a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 725
diff changeset
333 throw e;
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
334 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
335 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
336
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
337
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
338 static bool ReadKeys(std::set<std::string>& target,
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
339 const char* parameter,
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
340 bool onlyAlphanumeric)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 boost::mutex::scoped_lock lock(globalMutex_);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 target.clear();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
346 if (!configuration_->isMember(parameter))
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 {
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
348 return true;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
351 const Json::Value& modalities = (*configuration_) [parameter];
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 if (modalities.type() != Json::objectValue)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 {
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
354 throw OrthancException(ErrorCode_BadFileFormat);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 Json::Value::Members members = modalities.getMemberNames();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358 for (size_t i = 0; i < members.size(); i++)
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 if (onlyAlphanumeric)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 {
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
362 for (size_t j = 0; j < members[i].size(); j++)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 {
484
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
364 if (!isalnum(members[i][j]) && members[i][j] != '-')
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
365 {
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
366 return false;
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
367 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 target.insert(members[i]);
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
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
374 return true;
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
375 }
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
376
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
377
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
378 void GetListOfDicomModalities(std::set<std::string>& target)
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
379 {
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
380 if (!ReadKeys(target, "DicomModalities", true))
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
381 {
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
382 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
383 }
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
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
387 void GetListOfOrthancPeers(std::set<std::string>& target)
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, "OrthancPeers", 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 Orthanc peers");
b8ace6fc1d1f preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 476
diff changeset
392 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393 }
25
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
394
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
395
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
396
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
397 void SetupRegisteredUsers(MongooseServer& httpServer)
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
398 {
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
399 boost::mutex::scoped_lock lock(globalMutex_);
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
400
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
401 httpServer.ClearUsers();
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
402
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
403 if (!configuration_->isMember("RegisteredUsers"))
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 return;
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
406 }
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 const Json::Value& users = (*configuration_) ["RegisteredUsers"];
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
409 if (users.type() != Json::objectValue)
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
410 {
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
411 throw OrthancException("Badly formatted list of users");
25
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
412 }
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 Json::Value::Members usernames = users.getMemberNames();
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
415 for (size_t i = 0; i < usernames.size(); i++)
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 std::string& username = usernames[i];
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
418 std::string password = users[username].asString();
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
419 httpServer.RegisterUser(username.c_str(), password.c_str());
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
420 }
dd1489098265 basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
421 }
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
422
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
423
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
424 std::string InterpretRelativePath(const std::string& baseDirectory,
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
425 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
426 {
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
427 boost::filesystem::path base(baseDirectory);
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
428 boost::filesystem::path relative(relativePath);
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
429
428
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
430 /**
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
431 The following lines should be equivalent to this one:
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
432
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
433 return (base / relative).string();
428
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
434
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
435 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
436 make the proper path resolution when "baseDirectory" is an
428
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
437 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
438 **/
428
6f00823be12a explanations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 427
diff changeset
439
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
440 if (relative.is_absolute())
427
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
441 {
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
442 return relative.string();
427
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
443 }
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
444 else
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
445 {
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
446 return (base / relative).string();
427
9d2e1009076a fix for fedora 18
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
447 }
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
448 }
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
449
429
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
450 std::string InterpretStringParameterAsPath(const std::string& parameter)
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
451 {
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
452 boost::mutex::scoped_lock lock(globalMutex_);
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
453 return InterpretRelativePath(defaultDirectory_.string(), parameter);
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
454 }
09b3c6265a94 unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 428
diff changeset
455
394
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
456
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
457 void GetGlobalListOfStringsParameter(std::list<std::string>& target,
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
458 const std::string& key)
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
459 {
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
460 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
461
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
462 target.clear();
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
463
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
464 if (!configuration_->isMember(key))
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
465 {
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
466 return;
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
467 }
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 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
470
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
471 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
472 {
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
473 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
474 }
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
475
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
476 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
477 {
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
478 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
479 }
9784f19f7e1b path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
480 }
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
481
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
482
690
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
483 bool IsSameAETitle(const std::string& aet1,
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
484 const std::string& aet2)
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
485 {
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
486 if (GetGlobalBoolParameter("StrictAetComparison", false))
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
487 {
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
488 // Case-sensitive matching
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
489 return aet1 == aet2;
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
490 }
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
491 else
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
492 {
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
493 // Case-insensitive matching (default)
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
494 std::string tmp1, tmp2;
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
495 Toolbox::ToLowerCase(tmp1, aet1);
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
496 Toolbox::ToLowerCase(tmp2, aet2);
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
497 return tmp1 == tmp2;
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
498 }
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
2e67366aab83 case-insensitive matching of Application Entity Titles
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
501
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
502 bool LookupDicomModalityUsingAETitle(RemoteModalityParameters& modality,
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
503 const std::string& aet)
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
504 {
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
505 std::set<std::string> modalities;
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
506 GetListOfDicomModalities(modalities);
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
507
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
508 for (std::set<std::string>::const_iterator
656
08eca5d86aad fixes to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
509 it = modalities.begin(); it != modalities.end(); ++it)
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
510 {
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
511 try
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
512 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
513 GetDicomModalityUsingSymbolicName(modality, *it);
725
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 696
diff changeset
514
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
515 if (IsSameAETitle(aet, modality.GetApplicationEntityTitle()))
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
516 {
617
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
517 return true;
613
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
518 }
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 catch (OrthancException&)
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
521 {
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
522 }
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
523 }
60d90e48e809 query/retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
524
617
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
525 return false;
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
526 }
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
527
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
528
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
529 bool IsKnownAETitle(const std::string& aet)
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
530 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
531 RemoteModalityParameters modality;
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
532 return LookupDicomModalityUsingAETitle(modality, aet);
617
a24b0161b171 lookup using aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 613
diff changeset
533 }
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
534
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
535
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
536 RemoteModalityParameters GetModalityUsingSymbolicName(const std::string& name)
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
537 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
538 RemoteModalityParameters modality;
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
539 GetDicomModalityUsingSymbolicName(modality, name);
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
540
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
541 return modality;
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
542 }
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
543
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 772
diff changeset
544
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
545 RemoteModalityParameters GetModalityUsingAet(const std::string& aet)
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;
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
548
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
549 if (LookupDicomModalityUsingAETitle(modality, aet))
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
550 {
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 773
diff changeset
551 return modality;
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
552 }
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
553 else
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
554 {
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
555 throw OrthancException("Unknown modality for AET: " + aet);
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
556 }
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
557 }
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
558
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
559
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
560 void UpdateModality(const RemoteModalityParameters& modality)
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
561 {
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
562 boost::mutex::scoped_lock lock(globalMutex_);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
563
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
564 if (!configuration_->isMember("DicomModalities"))
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
565 {
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
566 throw OrthancException(ErrorCode_BadFileFormat);
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
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
569 Json::Value& modalities = (*configuration_) ["DicomModalities"];
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
570 if (modalities.type() != Json::objectValue)
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 throw OrthancException(ErrorCode_BadFileFormat);
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
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
575 modalities.removeMember(modality.GetName().c_str());
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
576
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
577 Json::Value v;
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
578 modality.ToJson(v);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
579 modalities[modality.GetName()] = v;
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
580 }
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
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
583 void RemoveModality(const std::string& symbolicName)
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
584 {
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
585 boost::mutex::scoped_lock lock(globalMutex_);
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 if (!configuration_->isMember("DicomModalities"))
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
588 {
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
589 throw OrthancException(ErrorCode_BadFileFormat);
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 Json::Value& modalities = (*configuration_) ["DicomModalities"];
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
593 if (modalities.type() != Json::objectValue)
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 throw OrthancException(ErrorCode_BadFileFormat);
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
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
598 modalities.removeMember(symbolicName.c_str());
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
599 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600 }