Mercurial > hg > orthanc
annotate OrthancServer/Sources/OrthancInitialization.cpp @ 4299:3f85db78c441
cppcheck
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 05 Nov 2020 18:24:50 +0100 |
parents | d2f79a475b51 |
children | 6a39ca7083b9 |
rev | line source |
---|---|
0 | 1 /** |
62 | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 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 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
136 | 11 * |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
0 | 23 * |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
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 | 41 #include "OrthancInitialization.h" |
0 | 42 |
4045 | 43 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" |
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 | 46 #include "../../OrthancFramework/Sources/Logging.h" |
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 | 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 |
4280
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
54 #include <dcmtk/dcmnet/dul.h> // For dcmDisableGethostbyaddr() |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
55 #include <dcmtk/dcmnet/diutil.h> // For DCM_dcmnetLogger |
1927
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 |
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
58 |
62 | 59 namespace Orthanc |
0 | 60 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
61 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
|
62 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
63 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
|
64 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
65 const Json::Value& parameter = config["UserMetadata"]; |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
66 |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
67 Json::Value::Members members = parameter.getMemberNames(); |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
68 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
|
69 { |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
70 const std::string& name = members[i]; |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
71 |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
72 if (!parameter[name].isInt()) |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
73 { |
2955 | 74 throw OrthancException(ErrorCode_BadParameterType, |
75 "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
|
76 } |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
77 |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
78 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
|
79 |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
80 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
|
81 << metadata << ")"; |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
82 |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
83 try |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
84 { |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
85 RegisterUserMetadata(metadata, name); |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
86 } |
657
5425bb6f1ea5
further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
87 catch (OrthancException&) |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
88 { |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
89 LOG(ERROR) << "Cannot register this user-defined metadata: " << name; |
657
5425bb6f1ea5
further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
90 throw; |
435
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 |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
96 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
97 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
|
98 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
99 if (config.isMember("UserContentType")) |
696
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
100 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
101 const Json::Value& parameter = config["UserContentType"]; |
696
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
102 |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
103 Json::Value::Members members = parameter.getMemberNames(); |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
104 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
|
105 { |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
106 const std::string& name = members[i]; |
2905
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
107 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
|
108 |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
109 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
|
110 int contentType; |
696
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
111 |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
112 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
|
113 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
|
114 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
|
115 value[1].isString()) |
696
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
116 { |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
117 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
|
118 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
|
119 } |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
120 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
|
121 { |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
122 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
|
123 } |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
124 else |
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
125 { |
2955 | 126 throw OrthancException(ErrorCode_BadParameterType, |
127 "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
|
128 } |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
129 |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
130 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
|
131 << contentType << ") with MIME type \"" << mime << "\""; |
696
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
132 |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
133 try |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
134 { |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
135 RegisterUserContentType(contentType, name, mime); |
696
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
136 } |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
137 catch (OrthancException&) |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
138 { |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
139 throw; |
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 |
4c1860179cc5
dictionary of user-defined content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
145 |
1765
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
146 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
|
147 { |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
148 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
|
149 !configuration.isMember("Dictionary") || |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
150 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
|
151 { |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
152 return; |
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 |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
155 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
|
156 |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
157 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
|
158 { |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
159 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
|
160 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
|
161 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
|
162 content.size() > 5 || |
1765
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
163 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
|
164 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
|
165 (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
|
166 (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
|
167 (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
|
168 { |
4011
914b15dedae3
fix for non private sequence tags in C-Find
Alain Mazy <alain@mazy.be>
parents:
3640
diff
changeset
|
169 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
|
170 } |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
171 |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
172 DicomTag tag(FromDcmtkBridge::ParseTag(tags[i])); |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1987
diff
changeset
|
173 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
|
174 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
|
175 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
|
176 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
|
177 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
|
178 |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2099
diff
changeset
|
179 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
|
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 |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
183 |
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
|
184 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
|
185 { |
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 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
|
187 !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
|
188 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
|
189 { |
2955 | 190 throw OrthancException(ErrorCode_BadFileFormat, |
191 "No path to the PKCS#11 module (DLL or .so) is provided " | |
192 "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
|
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 |
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 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
|
196 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
|
197 { |
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 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
|
199 { |
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 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
|
201 } |
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 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
|
203 { |
2955 | 204 throw OrthancException(ErrorCode_BadFileFormat, |
205 "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
|
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 |
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 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
|
210 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
|
211 { |
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 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
|
213 { |
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 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
|
215 } |
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 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
|
217 { |
2955 | 218 throw OrthancException(ErrorCode_BadFileFormat, |
219 "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
|
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 |
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 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
|
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 |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
226 |
1656 | 227 |
62 | 228 void OrthancInitialize(const char* configurationFile) |
0 | 229 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
230 OrthancConfiguration::WriterLock lock; |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
231 |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
232 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
|
233 |
7b7d597a190c
The configuration can be splitted into several files stored inside the same folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1422
diff
changeset
|
234 // Read the user-provided configuration |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
235 lock.GetConfiguration().Read(configurationFile); |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
236 |
2330
9c7a80c87ae9
"Locale" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
237 { |
4026
05a363186da6
ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4011
diff
changeset
|
238 std::string locale; |
05a363186da6
ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4011
diff
changeset
|
239 |
05a363186da6
ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4011
diff
changeset
|
240 if (lock.GetJson().isMember("Locale")) |
05a363186da6
ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4011
diff
changeset
|
241 { |
05a363186da6
ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4011
diff
changeset
|
242 locale = lock.GetConfiguration().GetStringParameter("Locale", ""); |
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 |
05a363186da6
ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4011
diff
changeset
|
245 bool loadPrivate = lock.GetConfiguration().GetBooleanParameter("LoadPrivateDictionary", true); |
05a363186da6
ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4011
diff
changeset
|
246 Orthanc::InitializeFramework(locale, loadPrivate); |
2330
9c7a80c87ae9
"Locale" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
247 } |
4026
05a363186da6
ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4011
diff
changeset
|
248 |
05a363186da6
ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4011
diff
changeset
|
249 // The Orthanc framework is now initialized |
2330
9c7a80c87ae9
"Locale" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
250 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
251 if (lock.GetJson().isMember("DefaultEncoding")) |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
252 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
253 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
|
254 SetDefaultDicomEncoding(StringToEncoding(encoding.c_str())); |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
255 } |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
256 else |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
257 { |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
258 SetDefaultDicomEncoding(ORTHANC_DEFAULT_DICOM_ENCODING); |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
259 } |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
260 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
261 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
|
262 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
263 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
|
264 } |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2020
diff
changeset
|
265 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
266 RegisterUserMetadata(lock.GetJson()); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
267 RegisterUserContentType(lock.GetJson()); |
685
b01cc78caba4
possibility to disable the DICOM/HTTP servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
660
diff
changeset
|
268 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
269 LoadCustomDictionary(lock.GetJson()); |
847
03ea55da7429
fully functional JPEG-LS conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
270 |
4031
e3b3af80732d
ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4026
diff
changeset
|
271 lock.GetConfiguration().RegisterFont(ServerResources::FONT_UBUNTU_MONO_BOLD_16); |
0 | 272 } |
273 | |
274 | |
275 | |
62 | 276 void OrthancFinalize() |
0 | 277 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
278 OrthancConfiguration::WriterLock lock; |
4026
05a363186da6
ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4011
diff
changeset
|
279 Orthanc::FinalizeFramework(); |
0 | 280 } |
281 | |
282 | |
1274 | 283 static IDatabaseWrapper* CreateSQLiteWrapper() |
284 { | |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
285 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
286 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
287 std::string storageDirectoryStr = |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
288 lock.GetConfiguration().GetStringParameter("StorageDirectory", "OrthancStorage"); |
1274 | 289 |
290 // Open the database | |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
291 boost::filesystem::path indexDirectory = lock.GetConfiguration().InterpretStringParameterAsPath( |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
292 lock.GetConfiguration().GetStringParameter("IndexDirectory", storageDirectoryStr)); |
1274 | 293 |
294 LOG(WARNING) << "SQLite index directory: " << indexDirectory; | |
295 | |
296 try | |
297 { | |
298 boost::filesystem::create_directories(indexDirectory); | |
299 } | |
2836
7133ad478eea
fix Debian warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2801
diff
changeset
|
300 catch (boost::filesystem::filesystem_error&) |
1274 | 301 { |
302 } | |
303 | |
3017
517fc4767ae0
renamed class DatabaseWrapper as SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
304 return new SQLiteDatabaseWrapper(indexDirectory.string() + "/index"); |
1274 | 305 } |
306 | |
307 | |
308 namespace | |
309 { | |
310 // Anonymous namespace to avoid clashes between compilation modules | |
311 | |
312 class FilesystemStorageWithoutDicom : public IStorageArea | |
313 { | |
314 private: | |
315 FilesystemStorage storage_; | |
316 | |
317 public: | |
4185
b289a1234822
giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
318 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
|
319 bool fsyncOnWrite) : |
b289a1234822
giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
320 storage_(path, fsyncOnWrite) |
1274 | 321 { |
322 } | |
323 | |
324 virtual void Create(const std::string& uuid, | |
325 const void* content, | |
326 size_t size, | |
327 FileContentType type) | |
328 { | |
329 if (type != FileContentType_Dicom) | |
330 { | |
331 storage_.Create(uuid, content, size, type); | |
332 } | |
333 } | |
334 | |
335 virtual void Read(std::string& content, | |
336 const std::string& uuid, | |
337 FileContentType type) | |
338 { | |
339 if (type != FileContentType_Dicom) | |
340 { | |
341 storage_.Read(content, uuid, type); | |
342 } | |
343 else | |
344 { | |
345 throw OrthancException(ErrorCode_UnknownResource); | |
346 } | |
347 } | |
348 | |
349 virtual void Remove(const std::string& uuid, | |
350 FileContentType type) | |
351 { | |
352 if (type != FileContentType_Dicom) | |
353 { | |
354 storage_.Remove(uuid, type); | |
355 } | |
356 } | |
357 }; | |
358 } | |
359 | |
360 | |
361 static IStorageArea* CreateFilesystemStorage() | |
362 { | |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
363 OrthancConfiguration::ReaderLock lock; |
1274 | 364 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
365 std::string storageDirectoryStr = |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
366 lock.GetConfiguration().GetStringParameter("StorageDirectory", "OrthancStorage"); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
367 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
368 boost::filesystem::path storageDirectory = |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
369 lock.GetConfiguration().InterpretStringParameterAsPath(storageDirectoryStr); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
370 |
1274 | 371 LOG(WARNING) << "Storage directory: " << storageDirectory; |
372 | |
4185
b289a1234822
giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
373 // 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
|
374 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
|
375 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
376 if (lock.GetConfiguration().GetBooleanParameter("StoreDicom", true)) |
1274 | 377 { |
4185
b289a1234822
giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
378 return new FilesystemStorage(storageDirectory.string(), fsyncOnWrite); |
1274 | 379 } |
380 else | |
381 { | |
382 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
|
383 return new FilesystemStorageWithoutDicom(storageDirectory.string(), fsyncOnWrite); |
1274 | 384 } |
385 } | |
386 | |
387 | |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
388 IDatabaseWrapper* CreateDatabaseWrapper() |
1274 | 389 { |
390 return CreateSQLiteWrapper(); | |
391 } | |
392 | |
393 | |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2933
diff
changeset
|
394 IStorageArea* CreateStorageArea() |
1274 | 395 { |
396 return CreateFilesystemStorage(); | |
4280
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
397 } |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
398 |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
399 |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
400 static void SetDcmtkVerbosity(Verbosity verbosity) |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
401 { |
4281
d2f79a475b51
debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4280
diff
changeset
|
402 // INFO_LOG_LEVEL was the DCMTK log level in Orthanc <= 1.8.0 |
4280
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
403 // https://support.dcmtk.org/docs-dcmrt/classOFLogger.html#ae20bf2616f15313c1f089da2eefb8245 |
4281
d2f79a475b51
debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4280
diff
changeset
|
404 |
d2f79a475b51
debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4280
diff
changeset
|
405 OFLogger::LogLevel dataLevel, networkLevel; |
4280
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
406 |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
407 switch (verbosity) |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
408 { |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
409 case Verbosity_Default: |
4281
d2f79a475b51
debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4280
diff
changeset
|
410 // Turn off logging in DCMTK core |
d2f79a475b51
debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4280
diff
changeset
|
411 dataLevel = OFLogger::OFF_LOG_LEVEL; |
d2f79a475b51
debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4280
diff
changeset
|
412 networkLevel = OFLogger::OFF_LOG_LEVEL; |
4280
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
413 break; |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
414 |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
415 case Verbosity_Verbose: |
4281
d2f79a475b51
debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4280
diff
changeset
|
416 dataLevel = OFLogger::INFO_LOG_LEVEL; |
d2f79a475b51
debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4280
diff
changeset
|
417 networkLevel = OFLogger::INFO_LOG_LEVEL; |
4280
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
418 break; |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
419 |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
420 case Verbosity_Trace: |
4281
d2f79a475b51
debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4280
diff
changeset
|
421 dataLevel = OFLogger::INFO_LOG_LEVEL; // DEBUG here makes DCMTK too verbose to be useful |
d2f79a475b51
debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4280
diff
changeset
|
422 networkLevel = OFLogger::DEBUG_LOG_LEVEL; |
4280
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
423 break; |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
424 |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
425 default: |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
426 throw OrthancException(ErrorCode_ParameterOutOfRange); |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
427 } |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
428 |
4281
d2f79a475b51
debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4280
diff
changeset
|
429 OFLog::configure(dataLevel); |
d2f79a475b51
debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4280
diff
changeset
|
430 assert(dcmtk::log4cplus::Logger::getRoot().getChainedLogLevel() == dataLevel); |
4280
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
431 |
4281
d2f79a475b51
debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4280
diff
changeset
|
432 DCM_dcmdataLogger.setLogLevel(dataLevel); // This seems to be implied by "OFLog::configure()" |
d2f79a475b51
debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4280
diff
changeset
|
433 DCM_dcmnetLogger.setLogLevel(networkLevel); // This will display PDU in DICOM networking |
4280
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
434 } |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
435 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
436 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
437 void SetGlobalVerbosity(Verbosity verbosity) |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
438 { |
4280
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
439 SetDcmtkVerbosity(verbosity); |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
440 |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
441 switch (verbosity) |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
442 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
443 case Verbosity_Default: |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
444 Logging::EnableInfoLevel(false); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
445 Logging::EnableTraceLevel(false); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
446 break; |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
447 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
448 case Verbosity_Verbose: |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
449 Logging::EnableInfoLevel(true); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
450 Logging::EnableTraceLevel(false); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
451 break; |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
452 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
453 case Verbosity_Trace: |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
454 Logging::EnableInfoLevel(true); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
455 Logging::EnableTraceLevel(true); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
456 break; |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
457 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
458 default: |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
459 throw OrthancException(ErrorCode_ParameterOutOfRange); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
460 } |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
461 } |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
462 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
463 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
464 Verbosity GetGlobalVerbosity() |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
465 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
466 if (Logging::IsTraceLevelEnabled()) |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
467 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
468 return Verbosity_Trace; |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
469 } |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
470 else if (Logging::IsInfoLevelEnabled()) |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
471 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
472 return Verbosity_Verbose; |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
473 } |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
474 else |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
475 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
476 return Verbosity_Default; |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
477 } |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
478 } |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
479 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
480 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
481 void SetCategoryVerbosity(Logging::LogCategory category, |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
482 Verbosity verbosity) |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
483 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
484 switch (verbosity) |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
485 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
486 case Verbosity_Default: |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
487 Logging::SetCategoryEnabled(Logging::LogLevel_INFO, category, false); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
488 Logging::SetCategoryEnabled(Logging::LogLevel_TRACE, category, false); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
489 break; |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
490 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
491 case Verbosity_Verbose: |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
492 Logging::SetCategoryEnabled(Logging::LogLevel_INFO, category, true); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
493 Logging::SetCategoryEnabled(Logging::LogLevel_TRACE, category, false); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
494 break; |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
495 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
496 case Verbosity_Trace: |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
497 Logging::SetCategoryEnabled(Logging::LogLevel_INFO, category, true); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
498 Logging::SetCategoryEnabled(Logging::LogLevel_TRACE, category, true); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
499 break; |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
500 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
501 default: |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
502 throw OrthancException(ErrorCode_ParameterOutOfRange); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
503 } |
4280
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
504 |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
505 if (category == Logging::LogCategory_DICOM) |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
506 { |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
507 SetDcmtkVerbosity(verbosity); |
58e757ded69e
SetDcmtkVerbosity()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
508 } |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
509 } |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
510 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
511 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
512 Verbosity GetCategoryVerbosity(Logging::LogCategory category) |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
513 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
514 if (Logging::IsCategoryEnabled(Logging::LogLevel_TRACE, category)) |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
515 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
516 return Verbosity_Trace; |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
517 } |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
518 else if (Logging::IsCategoryEnabled(Logging::LogLevel_INFO, category)) |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
519 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
520 return Verbosity_Verbose; |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
521 } |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
522 else |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
523 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
524 return Verbosity_Default; |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
525 } |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4185
diff
changeset
|
526 } |
0 | 527 } |