annotate OrthancServer/Sources/OrthancInitialization.cpp @ 4185:b289a1234822

giving a try to cross-platform compilation of SyncStorageArea
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 14 Sep 2020 18:09:30 +0200
parents c02a2d9efbc2
children 0034f855c023
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
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1892
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1275
diff changeset
4 * Department, University Hospital of Liege, Belgium
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3093
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
136
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
11 *
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
12 * In addition, as a special exception, the copyright holders of this
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
13 * 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
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
16 * the linked executables. You must obey the GNU General Public License
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
17 * 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
18 * 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
19 * 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
20 * 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
21 * version. If you delete this exception statement from all source files
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
22 * in the program, then also delete it here.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * 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
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
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
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
34 #include "PrecompiledHeadersServer.h"
2547
8b6b0b6ece6b MinGW, ORTHANC_FRAMEWORK_URL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
35
8b6b0b6ece6b MinGW, ORTHANC_FRAMEWORK_URL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
36 #if defined(_WIN32)
8b6b0b6ece6b MinGW, ORTHANC_FRAMEWORK_URL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
37 // "Please include winsock2.h before windows.h"
8b6b0b6ece6b MinGW, ORTHANC_FRAMEWORK_URL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
38 # include <winsock2.h>
8b6b0b6ece6b MinGW, ORTHANC_FRAMEWORK_URL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
39 #endif
8b6b0b6ece6b MinGW, ORTHANC_FRAMEWORK_URL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
40
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
41 #include "OrthancInitialization.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
43 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
44 #include "../../OrthancFramework/Sources/FileStorage/FilesystemStorage.h"
4105
c02a2d9efbc2 move FromDcmtkBridge::ExecuteToDicom() to LuaFunctionCall, to remove dependency of DCMTK on Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
45 #include "../../OrthancFramework/Sources/HttpClient.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
46 #include "../../OrthancFramework/Sources/Logging.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
47 #include "../../OrthancFramework/Sources/OrthancException.h"
1485
27661b33f624 Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1429
diff changeset
48
3093
2e1808b6146a reorganization of folders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
49 #include "Database/SQLiteDatabaseWrapper.h"
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
50 #include "OrthancConfiguration.h"
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
51
4032
058b5ade8acd renaming embedded resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4031
diff changeset
52 #include <OrthancServerResources.h>
4031
e3b3af80732d ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4026
diff changeset
53
2381
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
54 #include <dcmtk/dcmnet/dul.h> // For dcmDisableGethostbyaddr()
1927
b60f27664b8f simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
55
b60f27664b8f simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
56
b60f27664b8f simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
57
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
58 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
60 static void RegisterUserMetadata(const Json::Value& config)
1423
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
61 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
62 if (config.isMember("UserMetadata"))
1423
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
63 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
64 const Json::Value& parameter = config["UserMetadata"];
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
65
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
66 Json::Value::Members members = parameter.getMemberNames();
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
67 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
68 {
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
69 const std::string& name = members[i];
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
70
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
71 if (!parameter[name].isInt())
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
72 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
73 throw OrthancException(ErrorCode_BadParameterType,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
74 "Not a number in this user-defined metadata: " + name);
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
75 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
76
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
77 int metadata = parameter[name].asInt();
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
78
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
79 LOG(INFO) << "Registering user-defined metadata: " << name << " (index "
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
80 << metadata << ")";
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
81
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
82 try
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
83 {
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
84 RegisterUserMetadata(metadata, name);
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
85 }
657
5425bb6f1ea5 further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
86 catch (OrthancException&)
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
87 {
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
88 LOG(ERROR) << "Cannot register this user-defined metadata: " << name;
657
5425bb6f1ea5 further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
89 throw;
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
90 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
91 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
92 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
93 }
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
94
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
95
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
96 static void RegisterUserContentType(const Json::Value& config)
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
97 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
98 if (config.isMember("UserContentType"))
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
99 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
100 const Json::Value& parameter = config["UserContentType"];
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
101
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
102 Json::Value::Members members = parameter.getMemberNames();
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
103 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
104 {
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
105 const std::string& name = members[i];
2905
ae20fccdd867 refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2871
diff changeset
106 std::string mime = MIME_BINARY;
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
107
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
108 const Json::Value& value = parameter[name];
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
109 int contentType;
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
110
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
111 if (value.isArray() &&
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
112 value.size() == 2 &&
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
113 value[0].isInt() &&
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
114 value[1].isString())
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
115 {
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
116 contentType = value[0].asInt();
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
117 mime = value[1].asString();
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
118 }
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
119 else if (value.isInt())
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
120 {
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
121 contentType = value.asInt();
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
122 }
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
123 else
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
124 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
125 throw OrthancException(ErrorCode_BadParameterType,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
126 "Not a number in this user-defined attachment type: " + name);
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
127 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
128
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
129 LOG(INFO) << "Registering user-defined attachment type: " << name << " (index "
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
130 << contentType << ") with MIME type \"" << mime << "\"";
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
131
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
132 try
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
133 {
1772
53e045b5a8ec MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
134 RegisterUserContentType(contentType, name, mime);
696
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
135 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
136 catch (OrthancException&)
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 throw;
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 }
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 }
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
143
4c1860179cc5 dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
144
1765
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
145 static void LoadCustomDictionary(const Json::Value& configuration)
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
146 {
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
147 if (configuration.type() != Json::objectValue ||
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
148 !configuration.isMember("Dictionary") ||
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
149 configuration["Dictionary"].type() != Json::objectValue)
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
150 {
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
151 return;
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
152 }
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
153
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
154 Json::Value::Members tags(configuration["Dictionary"].getMemberNames());
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
155
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
156 for (Json::Value::ArrayIndex i = 0; i < tags.size(); i++)
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
157 {
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
158 const Json::Value& content = configuration["Dictionary"][tags[i]];
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
159 if (content.type() != Json::arrayValue ||
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
160 content.size() < 2 ||
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2099
diff changeset
161 content.size() > 5 ||
1765
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
162 content[0].type() != Json::stringValue ||
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
163 content[1].type() != Json::stringValue ||
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
164 (content.size() >= 3 && content[2].type() != Json::intValue) ||
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2099
diff changeset
165 (content.size() >= 4 && content[3].type() != Json::intValue) ||
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2099
diff changeset
166 (content.size() >= 5 && content[4].type() != Json::stringValue))
1765
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
167 {
4011
914b15dedae3 fix for non private sequence tags in C-Find
Alain Mazy <alain@mazy.be>
parents: 3640
diff changeset
168 throw OrthancException(ErrorCode_BadFileFormat, "The definition of the '" + tags[i] + "' dictionary entry is invalid.");
1765
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
169 }
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
170
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
171 DicomTag tag(FromDcmtkBridge::ParseTag(tags[i]));
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
172 ValueRepresentation vr = StringToValueRepresentation(content[0].asString(), true);
1765
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
173 std::string name = content[1].asString();
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
174 unsigned int minMultiplicity = (content.size() >= 2) ? content[2].asUInt() : 1;
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
175 unsigned int maxMultiplicity = (content.size() >= 3) ? content[3].asUInt() : 1;
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2099
diff changeset
176 std::string privateCreator = (content.size() >= 4) ? content[4].asString() : "";
1765
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
177
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2099
diff changeset
178 FromDcmtkBridge::RegisterDictionaryTag(tag, vr, name, minMultiplicity, maxMultiplicity, privateCreator);
1765
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
179 }
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
180 }
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
181
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
182
2022
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
183 static void ConfigurePkcs11(const Json::Value& config)
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
184 {
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
185 if (config.type() != Json::objectValue ||
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
186 !config.isMember("Module") ||
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
187 config["Module"].type() != Json::stringValue)
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
188 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
189 throw OrthancException(ErrorCode_BadFileFormat,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
190 "No path to the PKCS#11 module (DLL or .so) is provided "
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
191 "for HTTPS client authentication");
2022
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
192 }
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
193
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
194 std::string pin;
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
195 if (config.isMember("Pin"))
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
196 {
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
197 if (config["Pin"].type() == Json::stringValue)
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
198 {
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
199 pin = config["Pin"].asString();
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
200 }
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
201 else
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
202 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
203 throw OrthancException(ErrorCode_BadFileFormat,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
204 "The PIN number in the PKCS#11 configuration must be a string");
2022
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
205 }
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
206 }
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
207
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
208 bool verbose = false;
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
209 if (config.isMember("Verbose"))
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
210 {
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
211 if (config["Verbose"].type() == Json::booleanValue)
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
212 {
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
213 verbose = config["Verbose"].asBool();
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
214 }
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
215 else
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
216 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
217 throw OrthancException(ErrorCode_BadFileFormat,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
218 "The Verbose option in the PKCS#11 configuration must be a Boolean");
2022
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
219 }
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
220 }
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
221
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
222 HttpClient::InitializePkcs11(config["Module"].asString(), pin, verbose);
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
223 }
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
224
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
225
1656
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
226
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
227 void OrthancInitialize(const char* configurationFile)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
229 OrthancConfiguration::WriterLock lock;
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
230
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
231 InitializeServerEnumerations();
1423
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
232
7b7d597a190c The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1422
diff changeset
233 // Read the user-provided configuration
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
234 lock.GetConfiguration().Read(configurationFile);
435
28ba73274919 registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 430
diff changeset
235
2330
9c7a80c87ae9 "Locale" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2326
diff changeset
236 {
4026
05a363186da6 ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4011
diff changeset
237 std::string locale;
05a363186da6 ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4011
diff changeset
238
05a363186da6 ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4011
diff changeset
239 if (lock.GetJson().isMember("Locale"))
05a363186da6 ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4011
diff changeset
240 {
05a363186da6 ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4011
diff changeset
241 locale = lock.GetConfiguration().GetStringParameter("Locale", "");
05a363186da6 ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4011
diff changeset
242 }
05a363186da6 ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4011
diff changeset
243
05a363186da6 ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4011
diff changeset
244 bool loadPrivate = lock.GetConfiguration().GetBooleanParameter("LoadPrivateDictionary", true);
05a363186da6 ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4011
diff changeset
245 Orthanc::InitializeFramework(locale, loadPrivate);
2330
9c7a80c87ae9 "Locale" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2326
diff changeset
246 }
4026
05a363186da6 ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4011
diff changeset
247
05a363186da6 ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4011
diff changeset
248 // The Orthanc framework is now initialized
2330
9c7a80c87ae9 "Locale" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2326
diff changeset
249
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
250 if (lock.GetJson().isMember("DefaultEncoding"))
2381
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
251 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
252 std::string encoding = lock.GetConfiguration().GetStringParameter("DefaultEncoding", "");
2381
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
253 SetDefaultDicomEncoding(StringToEncoding(encoding.c_str()));
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
254 }
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
255 else
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
256 {
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
257 SetDefaultDicomEncoding(ORTHANC_DEFAULT_DICOM_ENCODING);
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
258 }
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
259
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
260 if (lock.GetJson().isMember("Pkcs11"))
2022
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
261 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
262 ConfigurePkcs11(lock.GetJson()["Pkcs11"]);
2022
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
263 }
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
264
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
265 RegisterUserMetadata(lock.GetJson());
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
266 RegisterUserContentType(lock.GetJson());
685
b01cc78caba4 possibility to disable the DICOM/HTTP servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 660
diff changeset
267
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
268 LoadCustomDictionary(lock.GetJson());
847
03ea55da7429 fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
269
4031
e3b3af80732d ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4026
diff changeset
270 lock.GetConfiguration().RegisterFont(ServerResources::FONT_UBUNTU_MONO_BOLD_16);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 }
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
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 58
diff changeset
275 void OrthancFinalize()
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
277 OrthancConfiguration::WriterLock lock;
4026
05a363186da6 ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4011
diff changeset
278 Orthanc::FinalizeFramework();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
282 static IDatabaseWrapper* CreateSQLiteWrapper()
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
283 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
284 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
285
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
286 std::string storageDirectoryStr =
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
287 lock.GetConfiguration().GetStringParameter("StorageDirectory", "OrthancStorage");
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
288
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
289 // Open the database
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
290 boost::filesystem::path indexDirectory = lock.GetConfiguration().InterpretStringParameterAsPath(
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
291 lock.GetConfiguration().GetStringParameter("IndexDirectory", storageDirectoryStr));
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
292
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
293 LOG(WARNING) << "SQLite index directory: " << indexDirectory;
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
294
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
295 try
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
296 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
297 boost::filesystem::create_directories(indexDirectory);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
298 }
2836
7133ad478eea fix Debian warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2801
diff changeset
299 catch (boost::filesystem::filesystem_error&)
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
300 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
301 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
302
3017
517fc4767ae0 renamed class DatabaseWrapper as SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
303 return new SQLiteDatabaseWrapper(indexDirectory.string() + "/index");
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
304 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
305
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
306
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
307 namespace
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
308 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
309 // Anonymous namespace to avoid clashes between compilation modules
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
310
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
311 class FilesystemStorageWithoutDicom : public IStorageArea
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
312 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
313 private:
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
314 FilesystemStorage storage_;
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
315
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
316 public:
4185
b289a1234822 giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4105
diff changeset
317 FilesystemStorageWithoutDicom(const std::string& path,
b289a1234822 giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4105
diff changeset
318 bool fsyncOnWrite) :
b289a1234822 giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4105
diff changeset
319 storage_(path, fsyncOnWrite)
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
320 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
321 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
322
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
323 virtual void Create(const std::string& uuid,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
324 const void* content,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
325 size_t size,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
326 FileContentType type)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
327 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
328 if (type != FileContentType_Dicom)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
329 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
330 storage_.Create(uuid, content, size, type);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
331 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
332 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
333
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
334 virtual void Read(std::string& content,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
335 const std::string& uuid,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
336 FileContentType type)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
337 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
338 if (type != FileContentType_Dicom)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
339 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
340 storage_.Read(content, uuid, type);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
341 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
342 else
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
343 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
344 throw OrthancException(ErrorCode_UnknownResource);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
345 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
346 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
347
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
348 virtual void Remove(const std::string& uuid,
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
349 FileContentType type)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
350 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
351 if (type != FileContentType_Dicom)
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
352 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
353 storage_.Remove(uuid, type);
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
354 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
355 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
356 };
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
357 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
358
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
359
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
360 static IStorageArea* CreateFilesystemStorage()
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
361 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
362 OrthancConfiguration::ReaderLock lock;
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
363
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
364 std::string storageDirectoryStr =
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
365 lock.GetConfiguration().GetStringParameter("StorageDirectory", "OrthancStorage");
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
366
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
367 boost::filesystem::path storageDirectory =
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
368 lock.GetConfiguration().InterpretStringParameterAsPath(storageDirectoryStr);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
369
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
370 LOG(WARNING) << "Storage directory: " << storageDirectory;
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
371
4185
b289a1234822 giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4105
diff changeset
372 // New in Orthanc 1.7.4
b289a1234822 giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4105
diff changeset
373 bool fsyncOnWrite = lock.GetConfiguration().GetBooleanParameter("SyncStorageArea", true);
b289a1234822 giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4105
diff changeset
374
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
375 if (lock.GetConfiguration().GetBooleanParameter("StoreDicom", true))
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
376 {
4185
b289a1234822 giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4105
diff changeset
377 return new FilesystemStorage(storageDirectory.string(), fsyncOnWrite);
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
378 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
379 else
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
380 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
381 LOG(WARNING) << "The DICOM files will not be stored, Orthanc running in index-only mode";
4185
b289a1234822 giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4105
diff changeset
382 return new FilesystemStorageWithoutDicom(storageDirectory.string(), fsyncOnWrite);
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
383 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
384 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
385
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
386
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
387 IDatabaseWrapper* CreateDatabaseWrapper()
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
388 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
389 return CreateSQLiteWrapper();
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
390 }
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
391
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
392
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2933
diff changeset
393 IStorageArea* CreateStorageArea()
1274
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
394 {
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
395 return CreateFilesystemStorage();
b9e2ed59cae4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
396 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 }