Mercurial > hg > orthanc
annotate OrthancServer/Sources/ServerContext.cpp @ 4190:9ce5c89328f5
New configuration options to enable HTTP peers identification through certificates
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Tue, 15 Sep 2020 15:47:28 +0200 |
parents | 1ec3e1e18f50 |
children | 37310bb1cd30 |
rev | line source |
---|---|
224 | 1 /** |
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:
1285
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3535
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
224 | 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. | |
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. | |
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" |
224 | 35 #include "ServerContext.h" |
36 | |
4045 | 37 #include "../../OrthancFramework/Sources/DicomParsing/Internals/DicomImageDecoder.h" |
38 #include "../../OrthancFramework/Sources/Cache/SharedArchive.h" | |
39 #include "../../OrthancFramework/Sources/DicomParsing/DcmtkTranscoder.h" | |
40 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" | |
41 #include "../../OrthancFramework/Sources/FileStorage/StorageAccessor.h" | |
42 #include "../../OrthancFramework/Sources/HttpServer/FilesystemHttpSender.h" | |
43 #include "../../OrthancFramework/Sources/HttpServer/HttpStreamTranscoder.h" | |
44 #include "../../OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.h" | |
45 #include "../../OrthancFramework/Sources/Logging.h" | |
46 #include "../../OrthancFramework/Sources/MetricsRegistry.h" | |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
47 #include "../Plugins/Engine/OrthancPlugins.h" |
3095
beeeb6096f27
removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
48 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
49 #include "OrthancConfiguration.h" |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
50 #include "OrthancRestApi/OrthancRestApi.h" |
3094
61da3c9b4121
cont reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
51 #include "Search/DatabaseLookup.h" |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
52 #include "ServerJobs/OrthancJobUnserializer.h" |
397
941ea46e9e26
lua filter of new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
53 #include "ServerToolbox.h" |
3736
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
54 #include "StorageCommitmentReports.h" |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
55 |
794 | 56 #include <dcmtk/dcmdata/dcfilefo.h> |
224 | 57 |
1001
f3929718ea7e
autorouting primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
998
diff
changeset
|
58 |
f3929718ea7e
autorouting primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
998
diff
changeset
|
59 |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
60 #define ENABLE_DICOM_CACHE 1 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
61 |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
62 static const size_t DICOM_CACHE_SIZE = 2; |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
63 |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
64 /** |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
65 * IMPORTANT: We make the assumption that the same instance of |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
66 * FileStorage can be accessed from multiple threads. This seems OK |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
67 * since the filesystem implements the required locking mechanisms, |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
68 * but maybe a read-writer lock on the "FileStorage" could be |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
69 * useful. Conversely, "ServerIndex" already implements mutex-based |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
70 * locking. |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
71 **/ |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
72 |
224 | 73 namespace Orthanc |
74 { | |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
75 void ServerContext::ChangeThread(ServerContext* that, |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
76 unsigned int sleepDelay) |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
77 { |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
78 while (!that->done_) |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
79 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3679
diff
changeset
|
80 std::unique_ptr<IDynamicObject> obj(that->pendingChanges_.Dequeue(sleepDelay)); |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
81 |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
82 if (obj.get() != NULL) |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
83 { |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
84 const ServerIndexChange& change = dynamic_cast<const ServerIndexChange&>(*obj.get()); |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
85 |
3947
cf6eb4fc6841
fix issue 179: use a shared mutex to avoid deadlock in python plugins
Alain Mazy <alain@mazy.be>
parents:
3945
diff
changeset
|
86 boost::shared_lock<boost::shared_mutex> lock(that->listenersMutex_); |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
87 for (ServerListeners::iterator it = that->listeners_.begin(); |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
88 it != that->listeners_.end(); ++it) |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
89 { |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
90 try |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
91 { |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
92 try |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
93 { |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
94 it->GetListener().SignalChange(change); |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
95 } |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
96 catch (std::bad_alloc&) |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
97 { |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
98 LOG(ERROR) << "Not enough memory while signaling a change"; |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
99 } |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
100 catch (...) |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
101 { |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
102 throw OrthancException(ErrorCode_InternalError); |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
103 } |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
104 } |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
105 catch (OrthancException& e) |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
106 { |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
107 LOG(ERROR) << "Error in the " << it->GetDescription() |
2135
cadfe0a2a393
fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2134
diff
changeset
|
108 << " callback while signaling a change: " << e.What() |
cadfe0a2a393
fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2134
diff
changeset
|
109 << " (code " << e.GetErrorCode() << ")"; |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
110 } |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
111 } |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
112 } |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
113 } |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
114 } |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
115 |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
116 |
2672
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
117 void ServerContext::SaveJobsThread(ServerContext* that, |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
118 unsigned int sleepDelay) |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
119 { |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
120 static const boost::posix_time::time_duration PERIODICITY = |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
121 boost::posix_time::seconds(10); |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
122 |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
123 boost::posix_time::ptime next = |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
124 boost::posix_time::microsec_clock::universal_time() + PERIODICITY; |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
125 |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
126 while (!that->done_) |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
127 { |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
128 boost::this_thread::sleep(boost::posix_time::milliseconds(sleepDelay)); |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
129 |
2673
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
130 if (that->haveJobsChanged_ || |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
131 boost::posix_time::microsec_clock::universal_time() >= next) |
2672
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
132 { |
2673
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
133 that->haveJobsChanged_ = false; |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
134 that->SaveJobsEngine(); |
2672
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
135 next = boost::posix_time::microsec_clock::universal_time() + PERIODICITY; |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
136 } |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
137 } |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
138 } |
2673
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
139 |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
140 |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
141 void ServerContext::SignalJobSubmitted(const std::string& jobId) |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
142 { |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
143 haveJobsChanged_ = true; |
2738
3a55b77339ff
fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2716
diff
changeset
|
144 mainLua_.SignalJobSubmitted(jobId); |
4129 | 145 |
146 #if ORTHANC_ENABLE_PLUGINS == 1 | |
147 if (HasPlugins()) | |
148 { | |
149 GetPlugins().SignalJobSubmitted(jobId); | |
150 } | |
151 #endif | |
2673
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
152 } |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
153 |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
154 |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
155 void ServerContext::SignalJobSuccess(const std::string& jobId) |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
156 { |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
157 haveJobsChanged_ = true; |
2738
3a55b77339ff
fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2716
diff
changeset
|
158 mainLua_.SignalJobSuccess(jobId); |
4129 | 159 |
160 #if ORTHANC_ENABLE_PLUGINS == 1 | |
161 if (HasPlugins()) | |
162 { | |
163 GetPlugins().SignalJobSuccess(jobId); | |
164 } | |
165 #endif | |
2673
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
166 } |
2672
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
167 |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
168 |
2673
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
169 void ServerContext::SignalJobFailure(const std::string& jobId) |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
170 { |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
171 haveJobsChanged_ = true; |
2738
3a55b77339ff
fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2716
diff
changeset
|
172 mainLua_.SignalJobFailure(jobId); |
4129 | 173 |
174 #if ORTHANC_ENABLE_PLUGINS == 1 | |
175 if (HasPlugins()) | |
176 { | |
177 GetPlugins().SignalJobFailure(jobId); | |
178 } | |
179 #endif | |
2673
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
180 } |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
181 |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
182 |
2671
06c0a6b8a871
new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2668
diff
changeset
|
183 void ServerContext::SetupJobsEngine(bool unitTesting, |
06c0a6b8a871
new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2668
diff
changeset
|
184 bool loadJobsFromDatabase) |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
185 { |
2671
06c0a6b8a871
new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2668
diff
changeset
|
186 if (loadJobsFromDatabase) |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
187 { |
2671
06c0a6b8a871
new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2668
diff
changeset
|
188 std::string serialized; |
06c0a6b8a871
new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2668
diff
changeset
|
189 if (index_.LookupGlobalProperty(serialized, GlobalProperty_JobsRegistry)) |
06c0a6b8a871
new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2668
diff
changeset
|
190 { |
06c0a6b8a871
new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2668
diff
changeset
|
191 LOG(WARNING) << "Reloading the jobs from the last execution of Orthanc"; |
2815
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2808
diff
changeset
|
192 OrthancJobUnserializer unserializer(*this); |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
193 |
2671
06c0a6b8a871
new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2668
diff
changeset
|
194 try |
06c0a6b8a871
new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2668
diff
changeset
|
195 { |
2815
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2808
diff
changeset
|
196 jobsEngine_.LoadRegistryFromString(unserializer, serialized); |
2671
06c0a6b8a871
new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2668
diff
changeset
|
197 } |
06c0a6b8a871
new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2668
diff
changeset
|
198 catch (OrthancException& e) |
06c0a6b8a871
new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2668
diff
changeset
|
199 { |
2925
a80ba85d89e6
Orthanc starts even if jobs from a previous execution cannot be unserialized
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2898
diff
changeset
|
200 LOG(WARNING) << "Cannot unserialize the jobs engine, starting anyway: " << e.What(); |
2671
06c0a6b8a871
new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2668
diff
changeset
|
201 } |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
202 } |
2671
06c0a6b8a871
new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2668
diff
changeset
|
203 else |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
204 { |
2671
06c0a6b8a871
new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2668
diff
changeset
|
205 LOG(INFO) << "The last execution of Orthanc has archived no job"; |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
206 } |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
207 } |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
208 else |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
209 { |
2925
a80ba85d89e6
Orthanc starts even if jobs from a previous execution cannot be unserialized
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2898
diff
changeset
|
210 LOG(INFO) << "Not reloading the jobs from the last execution of Orthanc"; |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
211 } |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
212 |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
213 jobsEngine_.GetRegistry().SetObserver(*this); |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
214 jobsEngine_.Start(); |
2815
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2808
diff
changeset
|
215 isJobsEngineUnserialized_ = true; |
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2808
diff
changeset
|
216 |
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2808
diff
changeset
|
217 saveJobsThread_ = boost::thread(SaveJobsThread, this, (unitTesting ? 20 : 100)); |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
218 } |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
219 |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
220 |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
221 void ServerContext::SaveJobsEngine() |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
222 { |
3165
1fe524e211af
New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
223 if (saveJobs_) |
1fe524e211af
New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
224 { |
1fe524e211af
New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
225 VLOG(1) << "Serializing the content of the jobs engine"; |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
226 |
3165
1fe524e211af
New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
227 try |
1fe524e211af
New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
228 { |
1fe524e211af
New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
229 Json::Value value; |
1fe524e211af
New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
230 jobsEngine_.GetRegistry().Serialize(value); |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
231 |
3165
1fe524e211af
New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
232 Json::FastWriter writer; |
1fe524e211af
New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
233 std::string serialized = writer.write(value); |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
234 |
3165
1fe524e211af
New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
235 index_.SetGlobalProperty(GlobalProperty_JobsRegistry, serialized); |
1fe524e211af
New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
236 } |
1fe524e211af
New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
237 catch (OrthancException& e) |
1fe524e211af
New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
238 { |
1fe524e211af
New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
239 LOG(ERROR) << "Cannot serialize the jobs engine: " << e.What(); |
1fe524e211af
New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
240 } |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
241 } |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
242 } |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
243 |
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
244 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
245 ServerContext::ServerContext(IDatabaseWrapper& database, |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2626
diff
changeset
|
246 IStorageArea& area, |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
247 bool unitTesting, |
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
248 size_t maxCompletedJobs) : |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2626
diff
changeset
|
249 index_(*this, database, (unitTesting ? 20 : 500)), |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
250 area_(area), |
656 | 251 compressionEnabled_(false), |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
252 storeMD5_(true), |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
253 provider_(*this), |
995
8c67382f44a7
limit number of jobs in the scheduler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
942
diff
changeset
|
254 dicomCache_(provider_, DICOM_CACHE_SIZE), |
2738
3a55b77339ff
fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2716
diff
changeset
|
255 mainLua_(*this), |
3a55b77339ff
fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2716
diff
changeset
|
256 filterLua_(*this), |
3a55b77339ff
fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2716
diff
changeset
|
257 luaListener_(*this), |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
258 jobsEngine_(maxCompletedJobs), |
2136
dd609a99d39a
uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2135
diff
changeset
|
259 #if ORTHANC_ENABLE_PLUGINS == 1 |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
260 plugins_(NULL), |
1632
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
261 #endif |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
262 done_(false), |
2673
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2672
diff
changeset
|
263 haveJobsChanged_(false), |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3165
diff
changeset
|
264 isJobsEngineUnserialized_(false), |
3533
2090ec6a83a5
create a default user if none is provided, while issuing a warning in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3346
diff
changeset
|
265 metricsRegistry_(new MetricsRegistry), |
3535
41365091a41e
display a security warning in the logs at startup when ExecuteLuaEnabled is true
Alain Mazy <alain@mazy.be>
parents:
3534
diff
changeset
|
266 isHttpServerSecure_(true), |
3813
aaaa442bfe39
moving SetOverwriteInstances from ServerIndex to ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3736
diff
changeset
|
267 isExecuteLuaEnabled_(false), |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
268 overwriteInstances_(false), |
3939
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
269 dcmtkTranscoder_(new DcmtkTranscoder), |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
270 isIngestTranscoding_(false) |
224 | 271 { |
3939
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
272 try |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
273 { |
3939
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
274 unsigned int lossyQuality; |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
275 |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
276 { |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
277 OrthancConfiguration::ReaderLock lock; |
2965
9c0b0a6d8b54
MediaArchiveSize configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
278 |
3939
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
279 queryRetrieveArchive_.reset( |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
280 new SharedArchive(lock.GetConfiguration().GetUnsignedIntegerParameter("QueryRetrieveSize", 100))); |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
281 mediaArchive_.reset( |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
282 new SharedArchive(lock.GetConfiguration().GetUnsignedIntegerParameter("MediaArchiveSize", 1))); |
4143
1ec3e1e18f50
Add missing tag "Retrieve AE Title (0008,0054)" in C-FIND SCP responses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
283 defaultLocalAet_ = lock.GetConfiguration().GetOrthancAET(); |
3939
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
284 jobsEngine_.SetWorkersCount(lock.GetConfiguration().GetUnsignedIntegerParameter("ConcurrentJobs", 2)); |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
285 saveJobs_ = lock.GetConfiguration().GetBooleanParameter("SaveJobs", true); |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
286 metricsRegistry_->SetEnabled(lock.GetConfiguration().GetBooleanParameter("MetricsEnabled", true)); |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
287 |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
288 // New configuration options in Orthanc 1.5.1 |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
289 findStorageAccessMode_ = StringToFindStorageAccessMode(lock.GetConfiguration().GetStringParameter("StorageAccessOnFind", "Always")); |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
290 limitFindInstances_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindInstances", 0); |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
291 limitFindResults_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindResults", 0); |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
292 |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
293 // New configuration option in Orthanc 1.6.0 |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
294 storageCommitmentReports_.reset(new StorageCommitmentReports(lock.GetConfiguration().GetUnsignedIntegerParameter("StorageCommitmentReportsSize", 100))); |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
295 |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
296 // New options in Orthanc 1.7.0 |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
297 transcodeDicomProtocol_ = lock.GetConfiguration().GetBooleanParameter("TranscodeDicomProtocol", true); |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
298 builtinDecoderTranscoderOrder_ = StringToBuiltinDecoderTranscoderOrder(lock.GetConfiguration().GetStringParameter("BuiltinDecoderTranscoderOrder", "After")); |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
299 lossyQuality = lock.GetConfiguration().GetUnsignedIntegerParameter("DicomLossyTranscodingQuality", 90); |
3677
4182cde57afb
refactoring FindStorageAccessMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
300 |
3939
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
301 std::string s; |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
302 if (lock.GetConfiguration().LookupStringParameter(s, "IngestTranscoding")) |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
303 { |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
304 if (LookupTransferSyntax(ingestTransferSyntax_, s)) |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
305 { |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
306 isIngestTranscoding_ = true; |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
307 LOG(WARNING) << "Incoming DICOM instances will automatically be transcoded to " |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
308 << "transfer syntax: " << GetTransferSyntaxUid(ingestTransferSyntax_); |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
309 } |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
310 else |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
311 { |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
312 throw OrthancException(ErrorCode_ParameterOutOfRange, |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
313 "Unknown transfer syntax for ingest transcoding: " + s); |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
314 } |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
315 } |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
316 else |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
317 { |
3941
771dbd9eb3bd
class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
318 isIngestTranscoding_ = false; |
3939
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
319 LOG(INFO) << "Automated transcoding of incoming DICOM instances is disabled"; |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
320 } |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
321 } |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
322 |
3939
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
323 jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200); |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
324 |
3939
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
325 listeners_.push_back(ServerListener(luaListener_, "Lua")); |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
326 changeThread_ = boost::thread(ChangeThread, this, (unitTesting ? 20 : 100)); |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
327 |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
328 dynamic_cast<DcmtkTranscoder&>(*dcmtkTranscoder_).SetLossyQuality(lossyQuality); |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
329 } |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
330 catch (OrthancException&) |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
331 { |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
332 Stop(); |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
333 throw; |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
334 } |
224 | 335 } |
336 | |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
337 |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
338 |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
339 ServerContext::~ServerContext() |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
340 { |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
341 if (!done_) |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
342 { |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
343 LOG(ERROR) << "INTERNAL ERROR: ServerContext::Stop() should be invoked manually to avoid mess in the destruction order!"; |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
344 Stop(); |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
345 } |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
346 } |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
347 |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
348 |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
349 void ServerContext::Stop() |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
350 { |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
351 if (!done_) |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
352 { |
1459 | 353 { |
3947
cf6eb4fc6841
fix issue 179: use a shared mutex to avoid deadlock in python plugins
Alain Mazy <alain@mazy.be>
parents:
3945
diff
changeset
|
354 boost::unique_lock<boost::shared_mutex> lock(listenersMutex_); |
1459 | 355 listeners_.clear(); |
356 } | |
357 | |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
358 done_ = true; |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
359 |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
360 if (changeThread_.joinable()) |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
361 { |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
362 changeThread_.join(); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
363 } |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
364 |
2672
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
365 if (saveJobsThread_.joinable()) |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
366 { |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
367 saveJobsThread_.join(); |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
368 } |
3efc44fac209
periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
369 |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
370 jobsEngine_.GetRegistry().ResetObserver(); |
2815
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2808
diff
changeset
|
371 |
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2808
diff
changeset
|
372 if (isJobsEngineUnserialized_) |
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2808
diff
changeset
|
373 { |
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2808
diff
changeset
|
374 // Avoid losing jobs if the JobsRegistry cannot be unserialized |
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2808
diff
changeset
|
375 SaveJobsEngine(); |
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2808
diff
changeset
|
376 } |
2668
d26dd081df97
saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
377 |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
378 // Do not change the order below! |
2570
2e879c796ec7
JobsRegistry::SubmitAndWait(), StoreScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2507
diff
changeset
|
379 jobsEngine_.Stop(); |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
380 index_.Stop(); |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
381 } |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
382 } |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
383 |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
384 |
236 | 385 void ServerContext::SetCompressionEnabled(bool enabled) |
386 { | |
387 if (enabled) | |
388 LOG(WARNING) << "Disk compression is enabled"; | |
389 else | |
390 LOG(WARNING) << "Disk compression is disabled"; | |
391 | |
392 compressionEnabled_ = enabled; | |
393 } | |
394 | |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
395 |
1126
bf67431a7383
handling of file content type in IStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1124
diff
changeset
|
396 void ServerContext::RemoveFile(const std::string& fileUuid, |
bf67431a7383
handling of file content type in IStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1124
diff
changeset
|
397 FileContentType type) |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
398 { |
3175
574890d14c92
new metrics: orthanc_store_dicom_duration_ms, orthanc_storage_[create|read|remove]_duration_ms
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
399 StorageAccessor accessor(area_, GetMetricsRegistry()); |
574890d14c92
new metrics: orthanc_store_dicom_duration_ms, orthanc_storage_[create|read|remove]_duration_ms
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
400 accessor.Remove(fileUuid, type); |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
401 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
402 |
996
cf52f3bcb2b3
clarification of Lua classes wrt multithreading
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
995
diff
changeset
|
403 |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
404 StoreStatus ServerContext::StoreAfterTranscoding(std::string& resultPublicId, |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
405 DicomInstanceToStore& dicom, |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
406 StoreInstanceMode mode) |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
407 { |
3814
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
408 bool overwrite; |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
409 switch (mode) |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
410 { |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
411 case StoreInstanceMode_Default: |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
412 overwrite = overwriteInstances_; |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
413 break; |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
414 |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
415 case StoreInstanceMode_OverwriteDuplicate: |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
416 overwrite = true; |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
417 break; |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
418 |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
419 case StoreInstanceMode_IgnoreDuplicate: |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
420 overwrite = false; |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
421 break; |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
422 |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
423 default: |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
424 throw OrthancException(ErrorCode_ParameterOutOfRange); |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
425 } |
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
426 |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
427 try |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
428 { |
3175
574890d14c92
new metrics: orthanc_store_dicom_duration_ms, orthanc_storage_[create|read|remove]_duration_ms
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
429 MetricsRegistry::Timer timer(GetMetricsRegistry(), "orthanc_store_dicom_duration_ms"); |
574890d14c92
new metrics: orthanc_store_dicom_duration_ms, orthanc_storage_[create|read|remove]_duration_ms
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
430 StorageAccessor accessor(area_, GetMetricsRegistry()); |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
431 |
2898
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
432 resultPublicId = dicom.GetHasher().HashInstance(); |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
433 |
1574
0c29ebe80ac9
give access to full request origin in ReceivedInstanceFilter (Lua)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1550
diff
changeset
|
434 Json::Value simplifiedTags; |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
435 Toolbox::SimplifyDicomAsJson(simplifiedTags, dicom.GetJson(), DicomToJsonFormat_Human); |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
436 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
437 // Test if the instance must be filtered out |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
438 bool accepted = true; |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
439 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
440 { |
3947
cf6eb4fc6841
fix issue 179: use a shared mutex to avoid deadlock in python plugins
Alain Mazy <alain@mazy.be>
parents:
3945
diff
changeset
|
441 boost::shared_lock<boost::shared_mutex> lock(listenersMutex_); |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
442 |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
443 for (ServerListeners::iterator it = listeners_.begin(); it != listeners_.end(); ++it) |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
444 { |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
445 try |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
446 { |
1574
0c29ebe80ac9
give access to full request origin in ReceivedInstanceFilter (Lua)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1550
diff
changeset
|
447 if (!it->GetListener().FilterIncomingInstance(dicom, simplifiedTags)) |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
448 { |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
449 accepted = false; |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
450 break; |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
451 } |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
452 } |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
453 catch (OrthancException& e) |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
454 { |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
455 LOG(ERROR) << "Error in the " << it->GetDescription() |
2135
cadfe0a2a393
fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2134
diff
changeset
|
456 << " callback while receiving an instance: " << e.What() |
cadfe0a2a393
fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2134
diff
changeset
|
457 << " (code " << e.GetErrorCode() << ")"; |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
458 throw; |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
459 } |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
460 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
461 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
462 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
463 if (!accepted) |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
464 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
465 LOG(INFO) << "An incoming instance has been discarded by the filter"; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
466 return StoreStatus_FilteredOut; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
467 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
468 |
2825
8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
469 { |
8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
470 // Remove the file from the DicomCache (useful if |
8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
471 // "OverwriteInstances" is set to "true") |
8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
472 boost::mutex::scoped_lock lock(dicomCacheMutex_); |
8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
473 dicomCache_.Invalidate(resultPublicId); |
8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
474 } |
8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
475 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
476 // TODO Should we use "gzip" instead? |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
477 CompressionType compression = (compressionEnabled_ ? CompressionType_ZlibWithSize : CompressionType_None); |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
478 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
479 FileInfo dicomInfo = accessor.Write(dicom.GetBufferData(), dicom.GetBufferSize(), |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
480 FileContentType_Dicom, compression, storeMD5_); |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
481 FileInfo jsonInfo = accessor.Write(dicom.GetJson().toStyledString(), |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
482 FileContentType_DicomAsJson, compression, storeMD5_); |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
483 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
484 ServerIndex::Attachments attachments; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
485 attachments.push_back(dicomInfo); |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
486 attachments.push_back(jsonInfo); |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
487 |
1067
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
488 typedef std::map<MetadataType, std::string> InstanceMetadata; |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
489 InstanceMetadata instanceMetadata; |
3813
aaaa442bfe39
moving SetOverwriteInstances from ServerIndex to ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3736
diff
changeset
|
490 StoreStatus status = index_.Store( |
3814
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3813
diff
changeset
|
491 instanceMetadata, dicom, attachments, overwrite); |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
492 |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
493 // Only keep the metadata for the "instance" level |
1067
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
494 dicom.GetMetadata().clear(); |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
495 |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
496 for (InstanceMetadata::const_iterator it = instanceMetadata.begin(); |
1304 | 497 it != instanceMetadata.end(); ++it) |
1067
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
498 { |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
499 dicom.GetMetadata().insert(std::make_pair(std::make_pair(ResourceType_Instance, it->first), |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
500 it->second)); |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
501 } |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
502 |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
503 if (status != StoreStatus_Success) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
504 { |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
505 accessor.Remove(dicomInfo); |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
506 accessor.Remove(jsonInfo); |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
507 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
508 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
509 switch (status) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
510 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
511 case StoreStatus_Success: |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
512 LOG(INFO) << "New instance stored"; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
513 break; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
514 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
515 case StoreStatus_AlreadyStored: |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
516 LOG(INFO) << "Already stored"; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
517 break; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
518 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
519 case StoreStatus_Failure: |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
520 LOG(ERROR) << "Store failure"; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
521 break; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
522 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
523 default: |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
524 // This should never happen |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
525 break; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
526 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
527 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
528 if (status == StoreStatus_Success || |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
529 status == StoreStatus_AlreadyStored) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
530 { |
3947
cf6eb4fc6841
fix issue 179: use a shared mutex to avoid deadlock in python plugins
Alain Mazy <alain@mazy.be>
parents:
3945
diff
changeset
|
531 boost::shared_lock<boost::shared_mutex> lock(listenersMutex_); |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
532 |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
533 for (ServerListeners::iterator it = listeners_.begin(); it != listeners_.end(); ++it) |
1066
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1065
diff
changeset
|
534 { |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1065
diff
changeset
|
535 try |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1065
diff
changeset
|
536 { |
1574
0c29ebe80ac9
give access to full request origin in ReceivedInstanceFilter (Lua)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1550
diff
changeset
|
537 it->GetListener().SignalStoredInstance(resultPublicId, dicom, simplifiedTags); |
1066
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1065
diff
changeset
|
538 } |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1065
diff
changeset
|
539 catch (OrthancException& e) |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1065
diff
changeset
|
540 { |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
541 LOG(ERROR) << "Error in the " << it->GetDescription() |
2135
cadfe0a2a393
fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2134
diff
changeset
|
542 << " callback while receiving an instance: " << e.What() |
cadfe0a2a393
fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2134
diff
changeset
|
543 << " (code " << e.GetErrorCode() << ")"; |
1066
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1065
diff
changeset
|
544 } |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1065
diff
changeset
|
545 } |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
546 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
547 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
548 return status; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
549 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
550 catch (OrthancException& e) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
551 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
552 if (e.GetErrorCode() == ErrorCode_InexistentTag) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
553 { |
2380
96b3ec054b69
reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2304
diff
changeset
|
554 dicom.GetSummary().LogMissingTagsForStore(); |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
555 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
556 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
557 throw; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
558 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
559 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
560 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
561 |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
562 StoreStatus ServerContext::Store(std::string& resultPublicId, |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
563 DicomInstanceToStore& dicom, |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
564 StoreInstanceMode mode) |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
565 { |
3939
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
566 if (!isIngestTranscoding_) |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
567 { |
3941
771dbd9eb3bd
class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
568 // No automated transcoding. This was the only path in Orthanc <= 1.6.1. |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
569 return StoreAfterTranscoding(resultPublicId, dicom, mode); |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
570 } |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
571 else |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
572 { |
3939
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
573 // Automated transcoding of incoming DICOM files |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
574 |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
575 DicomTransferSyntax sourceSyntax; |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
576 if (!FromDcmtkBridge::LookupOrthancTransferSyntax( |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
577 sourceSyntax, dicom.GetParsedDicomFile().GetDcmtkObject()) || |
3939
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
578 sourceSyntax == ingestTransferSyntax_) |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
579 { |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
580 // No transcoding |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
581 return StoreAfterTranscoding(resultPublicId, dicom, mode); |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
582 } |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
583 else |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
584 { |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
585 std::set<DicomTransferSyntax> syntaxes; |
3939
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
586 syntaxes.insert(ingestTransferSyntax_); |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
587 |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
588 IDicomTranscoder::DicomImage source; |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
589 source.SetExternalBuffer(dicom.GetBufferData(), dicom.GetBufferSize()); |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
590 |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
591 IDicomTranscoder::DicomImage transcoded; |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3947
diff
changeset
|
592 if (Transcode(transcoded, source, syntaxes, true /* allow new SOP instance UID */)) |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
593 { |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
594 std::unique_ptr<ParsedDicomFile> tmp(transcoded.ReleaseAsParsedDicomFile()); |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
595 |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
596 DicomInstanceToStore toStore; |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
597 toStore.SetParsedDicomFile(*tmp); |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
598 toStore.SetOrigin(dicom.GetOrigin()); |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
599 |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
600 StoreStatus ok = StoreAfterTranscoding(resultPublicId, toStore, mode); |
3938 | 601 assert(resultPublicId == tmp->GetHasher().HashInstance()); |
602 | |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
603 return ok; |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
604 } |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
605 else |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
606 { |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
607 // Cannot transcode => store the original file |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
608 return StoreAfterTranscoding(resultPublicId, dicom, mode); |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
609 } |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
610 } |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
611 } |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
612 } |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
613 |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
614 |
1146
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
615 void ServerContext::AnswerAttachment(RestApiOutput& output, |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
616 const std::string& resourceId, |
1146
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
617 FileContentType content) |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
618 { |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
227
diff
changeset
|
619 FileInfo attachment; |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
620 if (!index_.LookupAttachment(attachment, resourceId, content)) |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
227
diff
changeset
|
621 { |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
622 throw OrthancException(ErrorCode_UnknownResource); |
236 | 623 } |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
624 |
3175
574890d14c92
new metrics: orthanc_store_dicom_duration_ms, orthanc_storage_[create|read|remove]_duration_ms
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
625 StorageAccessor accessor(area_, GetMetricsRegistry()); |
1772
53e045b5a8ec
MIME content type can be associated to custom attachments (cf. "UserContentType")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1758
diff
changeset
|
626 accessor.AnswerFile(output, attachment, GetFileContentMime(content)); |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
627 } |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
628 |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
629 |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
630 void ServerContext::ChangeAttachmentCompression(const std::string& resourceId, |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
631 FileContentType attachmentType, |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
632 CompressionType compression) |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
633 { |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
634 LOG(INFO) << "Changing compression type for attachment " |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
635 << EnumerationToString(attachmentType) |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
636 << " of resource " << resourceId << " to " |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
637 << compression; |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
638 |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
639 FileInfo attachment; |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
640 if (!index_.LookupAttachment(attachment, resourceId, attachmentType)) |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
641 { |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
642 throw OrthancException(ErrorCode_UnknownResource); |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
643 } |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
644 |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
645 if (attachment.GetCompressionType() == compression) |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
646 { |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
647 // Nothing to do |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
648 return; |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
649 } |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
650 |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
651 std::string content; |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
652 |
3175
574890d14c92
new metrics: orthanc_store_dicom_duration_ms, orthanc_storage_[create|read|remove]_duration_ms
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
653 StorageAccessor accessor(area_, GetMetricsRegistry()); |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
654 accessor.Read(content, attachment); |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
655 |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
656 FileInfo modified = accessor.Write(content.empty() ? NULL : content.c_str(), |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
657 content.size(), attachmentType, compression, storeMD5_); |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
658 |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
659 try |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
660 { |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
661 StoreStatus status = index_.AddAttachment(modified, resourceId); |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
662 if (status != StoreStatus_Success) |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
663 { |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
664 accessor.Remove(modified); |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
665 throw OrthancException(ErrorCode_Database); |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
666 } |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
667 } |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
668 catch (OrthancException&) |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
669 { |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
670 accessor.Remove(modified); |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
671 throw; |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
672 } |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
673 } |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
674 |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
675 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
676 void ServerContext::ReadDicomAsJsonInternal(std::string& result, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
677 const std::string& instancePublicId) |
2127 | 678 { |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
679 FileInfo attachment; |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
680 if (index_.LookupAttachment(attachment, instancePublicId, FileContentType_DicomAsJson)) |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
681 { |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
682 ReadAttachment(result, attachment); |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
683 } |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
684 else |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
685 { |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
686 // The "DICOM as JSON" summary is not available from the Orthanc |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
687 // store (most probably deleted), reconstruct it from the DICOM file |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
688 std::string dicom; |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
689 ReadDicom(dicom, instancePublicId); |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
690 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
691 LOG(INFO) << "Reconstructing the missing DICOM-as-JSON summary for instance: " |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
692 << instancePublicId; |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
693 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
694 ParsedDicomFile parsed(dicom); |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
695 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
696 Json::Value summary; |
4140
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4129
diff
changeset
|
697 OrthancConfiguration::DefaultDicomDatasetToJson(summary, parsed); |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
698 |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
699 result = summary.toStyledString(); |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
700 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
701 if (!AddAttachment(instancePublicId, FileContentType_DicomAsJson, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
702 result.c_str(), result.size())) |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
703 { |
2956 | 704 throw OrthancException(ErrorCode_InternalError, |
705 "Cannot associate the DICOM-as-JSON summary to instance: " + instancePublicId); | |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
706 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
707 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
708 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
709 |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
710 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
711 void ServerContext::ReadDicomAsJson(std::string& result, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
712 const std::string& instancePublicId, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
713 const std::set<DicomTag>& ignoreTagLength) |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
714 { |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
715 if (ignoreTagLength.empty()) |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
716 { |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
717 ReadDicomAsJsonInternal(result, instancePublicId); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
718 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
719 else |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
720 { |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
721 Json::Value tmp; |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
722 ReadDicomAsJson(tmp, instancePublicId, ignoreTagLength); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
723 result = tmp.toStyledString(); |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
724 } |
2127 | 725 } |
726 | |
727 | |
2124 | 728 void ServerContext::ReadDicomAsJson(Json::Value& result, |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
729 const std::string& instancePublicId, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
730 const std::set<DicomTag>& ignoreTagLength) |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
731 { |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
732 if (ignoreTagLength.empty()) |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
733 { |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
734 std::string tmp; |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
735 ReadDicomAsJsonInternal(tmp, instancePublicId); |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
736 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
737 Json::Reader reader; |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
738 if (!reader.parse(tmp, result)) |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
739 { |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
740 throw OrthancException(ErrorCode_CorruptedFile); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
741 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
742 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
743 else |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
744 { |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
745 // The "DicomAsJson" attachment might have stored some tags as |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
746 // "too long". We are forced to re-parse the DICOM file. |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
747 std::string dicom; |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
748 ReadDicom(dicom, instancePublicId); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
749 |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
750 ParsedDicomFile parsed(dicom); |
4140
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4129
diff
changeset
|
751 OrthancConfiguration::DefaultDicomDatasetToJson(result, parsed, ignoreTagLength); |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
752 } |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
753 } |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
754 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
755 |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
756 void ServerContext::ReadAttachment(std::string& result, |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
757 const std::string& instancePublicId, |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
758 FileContentType content, |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
759 bool uncompressIfNeeded) |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
760 { |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
227
diff
changeset
|
761 FileInfo attachment; |
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
227
diff
changeset
|
762 if (!index_.LookupAttachment(attachment, instancePublicId, content)) |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
763 { |
2956 | 764 throw OrthancException(ErrorCode_InternalError, |
765 "Unable to read attachment " + EnumerationToString(content) + | |
766 " of instance " + instancePublicId); | |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
767 } |
1550 | 768 |
3175
574890d14c92
new metrics: orthanc_store_dicom_duration_ms, orthanc_storage_[create|read|remove]_duration_ms
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
769 assert(attachment.GetContentType() == content); |
574890d14c92
new metrics: orthanc_store_dicom_duration_ms, orthanc_storage_[create|read|remove]_duration_ms
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
770 |
1550 | 771 if (uncompressIfNeeded) |
772 { | |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
773 ReadAttachment(result, attachment); |
1550 | 774 } |
775 else | |
776 { | |
3175
574890d14c92
new metrics: orthanc_store_dicom_duration_ms, orthanc_storage_[create|read|remove]_duration_ms
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
777 // Do not uncompress the content of the storage area, return the |
1550 | 778 // raw data |
3175
574890d14c92
new metrics: orthanc_store_dicom_duration_ms, orthanc_storage_[create|read|remove]_duration_ms
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
779 StorageAccessor accessor(area_, GetMetricsRegistry()); |
574890d14c92
new metrics: orthanc_store_dicom_duration_ms, orthanc_storage_[create|read|remove]_duration_ms
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
780 accessor.ReadRaw(result, attachment); |
1550 | 781 } |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
782 } |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
783 |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
784 |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
785 void ServerContext::ReadAttachment(std::string& result, |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
786 const FileInfo& attachment) |
1778
776573e592da
create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
787 { |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
788 // This will decompress the attachment |
3175
574890d14c92
new metrics: orthanc_store_dicom_duration_ms, orthanc_storage_[create|read|remove]_duration_ms
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
789 StorageAccessor accessor(area_, GetMetricsRegistry()); |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
790 accessor.Read(result, attachment); |
1778
776573e592da
create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
791 } |
776573e592da
create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
792 |
776573e592da
create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
793 |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
794 IDynamicObject* ServerContext::DicomCacheProvider::Provide(const std::string& instancePublicId) |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
795 { |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
796 std::string content; |
2124 | 797 context_.ReadDicom(content, instancePublicId); |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
798 return new ParsedDicomFile(content); |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
799 } |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
800 |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
801 |
778
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
802 ServerContext::DicomCacheLocker::DicomCacheLocker(ServerContext& that, |
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
803 const std::string& instancePublicId) : |
1129
8dabdc0d3007
fix possible deadlock
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1126
diff
changeset
|
804 that_(that), |
8dabdc0d3007
fix possible deadlock
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1126
diff
changeset
|
805 lock_(that_.dicomCacheMutex_) |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
806 { |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
807 #if ENABLE_DICOM_CACHE == 0 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3679
diff
changeset
|
808 static std::unique_ptr<IDynamicObject> p; |
3836 | 809 p.reset(that_.provider_.Provide(instancePublicId)); |
778
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
810 dicom_ = dynamic_cast<ParsedDicomFile*>(p.get()); |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
811 #else |
778
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
812 dicom_ = &dynamic_cast<ParsedDicomFile&>(that_.dicomCache_.Access(instancePublicId)); |
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
813 #endif |
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
814 } |
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
815 |
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
816 |
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
817 ServerContext::DicomCacheLocker::~DicomCacheLocker() |
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
818 { |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
819 } |
304 | 820 |
821 | |
695
c59bc408fb10
parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
822 void ServerContext::SetStoreMD5ForAttachments(bool storeMD5) |
c59bc408fb10
parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
823 { |
c59bc408fb10
parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
824 LOG(INFO) << "Storing MD5 for attachments: " << (storeMD5 ? "yes" : "no"); |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
825 storeMD5_ = storeMD5; |
695
c59bc408fb10
parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
826 } |
c59bc408fb10
parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
827 |
699
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
828 |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
829 bool ServerContext::AddAttachment(const std::string& resourceId, |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
830 FileContentType attachmentType, |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
831 const void* data, |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
832 size_t size) |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
833 { |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
834 LOG(INFO) << "Adding attachment " << EnumerationToString(attachmentType) << " to resource " << resourceId; |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
835 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
836 // TODO Should we use "gzip" instead? |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
837 CompressionType compression = (compressionEnabled_ ? CompressionType_ZlibWithSize : CompressionType_None); |
699
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
838 |
3175
574890d14c92
new metrics: orthanc_store_dicom_duration_ms, orthanc_storage_[create|read|remove]_duration_ms
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
839 StorageAccessor accessor(area_, GetMetricsRegistry()); |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
840 FileInfo attachment = accessor.Write(data, size, attachmentType, compression, storeMD5_); |
699
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
841 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
842 StoreStatus status = index_.AddAttachment(attachment, resourceId); |
699
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
843 if (status != StoreStatus_Success) |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
844 { |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
845 accessor.Remove(attachment); |
699
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
846 return false; |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
847 } |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
848 else |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
849 { |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
850 return true; |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
851 } |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
852 } |
1145
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
853 |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
854 |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
855 bool ServerContext::DeleteResource(Json::Value& target, |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
856 const std::string& uuid, |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
857 ResourceType expectedType) |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
858 { |
2507 | 859 if (expectedType == ResourceType_Instance) |
860 { | |
861 // remove the file from the DicomCache | |
862 boost::mutex::scoped_lock lock(dicomCacheMutex_); | |
863 dicomCache_.Invalidate(uuid); | |
864 } | |
865 | |
1145
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
866 return index_.DeleteResource(target, uuid, expectedType); |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
867 } |
1189
6b9b02a16e99
NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1165
diff
changeset
|
868 |
6b9b02a16e99
NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1165
diff
changeset
|
869 |
1198 | 870 void ServerContext::SignalChange(const ServerIndexChange& change) |
1189
6b9b02a16e99
NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1165
diff
changeset
|
871 { |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
872 pendingChanges_.Enqueue(change.Clone()); |
1189
6b9b02a16e99
NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1165
diff
changeset
|
873 } |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
874 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
875 |
2136
dd609a99d39a
uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2135
diff
changeset
|
876 #if ORTHANC_ENABLE_PLUGINS == 1 |
1434
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
877 void ServerContext::SetPlugins(OrthancPlugins& plugins) |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
878 { |
3947
cf6eb4fc6841
fix issue 179: use a shared mutex to avoid deadlock in python plugins
Alain Mazy <alain@mazy.be>
parents:
3945
diff
changeset
|
879 boost::unique_lock<boost::shared_mutex> lock(listenersMutex_); |
1459 | 880 |
1434
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
881 plugins_ = &plugins; |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
882 |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
883 // TODO REFACTOR THIS |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
884 listeners_.clear(); |
2738
3a55b77339ff
fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2716
diff
changeset
|
885 listeners_.push_back(ServerListener(luaListener_, "Lua")); |
1434
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
886 listeners_.push_back(ServerListener(plugins, "plugin")); |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
887 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
888 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
889 |
1434
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
890 void ServerContext::ResetPlugins() |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
891 { |
3947
cf6eb4fc6841
fix issue 179: use a shared mutex to avoid deadlock in python plugins
Alain Mazy <alain@mazy.be>
parents:
3945
diff
changeset
|
892 boost::unique_lock<boost::shared_mutex> lock(listenersMutex_); |
1459 | 893 |
1434
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
894 plugins_ = NULL; |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
895 |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
896 // TODO REFACTOR THIS |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
897 listeners_.clear(); |
2738
3a55b77339ff
fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2716
diff
changeset
|
898 listeners_.push_back(ServerListener(luaListener_, "Lua")); |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
899 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
900 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
901 |
1434
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
902 const OrthancPlugins& ServerContext::GetPlugins() const |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
903 { |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
904 if (HasPlugins()) |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
905 { |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
906 return *plugins_; |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
907 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
908 else |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
909 { |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
910 throw OrthancException(ErrorCode_InternalError); |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
911 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
912 } |
1632
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
913 |
1741
06addfcd1d4c
OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
914 OrthancPlugins& ServerContext::GetPlugins() |
06addfcd1d4c
OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
915 { |
06addfcd1d4c
OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
916 if (HasPlugins()) |
06addfcd1d4c
OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
917 { |
06addfcd1d4c
OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
918 return *plugins_; |
06addfcd1d4c
OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
919 } |
06addfcd1d4c
OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
920 else |
06addfcd1d4c
OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
921 { |
06addfcd1d4c
OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
922 throw OrthancException(ErrorCode_InternalError); |
06addfcd1d4c
OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
923 } |
06addfcd1d4c
OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
924 } |
06addfcd1d4c
OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
925 |
1632
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
926 #endif |
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
927 |
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
928 |
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
929 bool ServerContext::HasPlugins() const |
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
930 { |
2136
dd609a99d39a
uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2135
diff
changeset
|
931 #if ORTHANC_ENABLE_PLUGINS == 1 |
1632
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
932 return (plugins_ != NULL); |
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
933 #else |
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
934 return false; |
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
935 #endif |
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
936 } |
1757
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
937 |
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
938 |
3021
2cbafb5d5a62
renamed LookupResource::IVisitor as ServerContext::ILookupVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3015
diff
changeset
|
939 void ServerContext::Apply(ILookupVisitor& visitor, |
3033
5da6d1063d8f
effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3031
diff
changeset
|
940 const DatabaseLookup& lookup, |
5da6d1063d8f
effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3031
diff
changeset
|
941 ResourceType queryLevel, |
2304
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
942 size_t since, |
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
943 size_t limit) |
1757
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
944 { |
3679
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
945 unsigned int databaseLimit = (queryLevel == ResourceType_Instance ? |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
946 limitFindInstances_ : limitFindResults_); |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
947 |
1757
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
948 std::vector<std::string> resources, instances; |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
949 |
3204
8792867b739a
fix incorrect "too many results"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3175
diff
changeset
|
950 { |
8792867b739a
fix incorrect "too many results"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3175
diff
changeset
|
951 const size_t lookupLimit = (databaseLimit == 0 ? 0 : databaseLimit + 1); |
8792867b739a
fix incorrect "too many results"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3175
diff
changeset
|
952 GetIndex().ApplyLookupResources(resources, &instances, lookup, queryLevel, lookupLimit); |
8792867b739a
fix incorrect "too many results"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3175
diff
changeset
|
953 } |
3025
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3021
diff
changeset
|
954 |
3033
5da6d1063d8f
effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3031
diff
changeset
|
955 bool complete = (databaseLimit == 0 || |
3204
8792867b739a
fix incorrect "too many results"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3175
diff
changeset
|
956 resources.size() <= databaseLimit); |
1757
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
957 |
3005
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3003
diff
changeset
|
958 LOG(INFO) << "Number of candidate resources after fast DB filtering on main DICOM tags: " << resources.size(); |
3003
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
959 |
3679
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
960 /** |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
961 * "resources" contains the Orthanc ID of the resource at level |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
962 * "queryLevel", "instances" contains one the Orthanc ID of one |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
963 * sample instance from this resource. |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
964 **/ |
1757
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
965 assert(resources.size() == instances.size()); |
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
966 |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2965
diff
changeset
|
967 size_t countResults = 0; |
2304
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
968 size_t skipped = 0; |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
969 |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
970 const bool isDicomAsJsonNeeded = visitor.IsDicomAsJsonNeeded(); |
3012
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
971 |
1757
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
972 for (size_t i = 0; i < instances.size(); i++) |
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
973 { |
3012
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
974 // Optimization in Orthanc 1.5.1 - Don't read the full JSON from |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
975 // the disk if only "main DICOM tags" are to be returned |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
976 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3679
diff
changeset
|
977 std::unique_ptr<Json::Value> dicomAsJson; |
3012
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
978 |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
979 bool hasOnlyMainDicomTags; |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
980 DicomMap dicom; |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
981 |
3677
4182cde57afb
refactoring FindStorageAccessMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
982 if (findStorageAccessMode_ == FindStorageAccessMode_DatabaseOnly || |
4182cde57afb
refactoring FindStorageAccessMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
983 findStorageAccessMode_ == FindStorageAccessMode_DiskOnAnswer || |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
984 lookup.HasOnlyMainDicomTags()) |
3012
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
985 { |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
986 // Case (1): The main DICOM tags, as stored in the database, |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
987 // are sufficient to look for match |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
988 |
3679
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
989 DicomMap tmp; |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
990 if (!GetIndex().GetAllMainDicomTags(tmp, instances[i])) |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
991 { |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
992 // The instance has been removed during the execution of the |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
993 // lookup, ignore it |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
994 continue; |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
995 } |
3679
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
996 |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
997 #if 1 |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
998 // New in Orthanc 1.6.0: Only keep the main DICOM tags at the |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
999 // level of interest for the query |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1000 switch (queryLevel) |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1001 { |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1002 // WARNING: Don't reorder cases below, and don't add "break" |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1003 case ResourceType_Instance: |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1004 dicom.MergeMainDicomTags(tmp, ResourceType_Instance); |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1005 |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1006 case ResourceType_Series: |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1007 dicom.MergeMainDicomTags(tmp, ResourceType_Series); |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1008 |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1009 case ResourceType_Study: |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1010 dicom.MergeMainDicomTags(tmp, ResourceType_Study); |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1011 |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1012 case ResourceType_Patient: |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1013 dicom.MergeMainDicomTags(tmp, ResourceType_Patient); |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1014 break; |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1015 |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1016 default: |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1017 throw OrthancException(ErrorCode_InternalError); |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1018 } |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1019 |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1020 // Special case of the "Modality" at the study level, in order |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1021 // to deal with C-FIND on "ModalitiesInStudy" (0008,0061). |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1022 // Check out integration test "test_rest_modalities_in_study". |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1023 if (queryLevel == ResourceType_Study) |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1024 { |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1025 dicom.CopyTagIfExists(tmp, DICOM_TAG_MODALITY); |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1026 } |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1027 #else |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1028 dicom.Assign(tmp); // This emulates Orthanc <= 1.5.8 |
6358923d3ced
C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3677
diff
changeset
|
1029 #endif |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1030 |
3012
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1031 hasOnlyMainDicomTags = true; |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1032 } |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1033 else |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1034 { |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1035 // Case (2): Need to read the "DICOM-as-JSON" attachment from |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1036 // the storage area |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1037 dicomAsJson.reset(new Json::Value); |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1038 ReadDicomAsJson(*dicomAsJson, instances[i]); |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1039 |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1040 dicom.FromDicomAsJson(*dicomAsJson); |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1041 |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1042 // This map contains the entire JSON, i.e. more than the main DICOM tags |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1043 hasOnlyMainDicomTags = false; |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1044 } |
1757
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
1045 |
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
1046 if (lookup.IsMatch(dicom)) |
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
1047 { |
2304
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1048 if (skipped < since) |
1757
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
1049 { |
2304
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1050 skipped++; |
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1051 } |
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1052 else if (limit != 0 && |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2965
diff
changeset
|
1053 countResults >= limit) |
2304
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1054 { |
3003
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
1055 // Too many results, don't mark as complete |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
1056 complete = false; |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
1057 break; |
1757
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
1058 } |
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
1059 else |
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
1060 { |
3677
4182cde57afb
refactoring FindStorageAccessMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1061 if ((findStorageAccessMode_ == FindStorageAccessMode_DiskOnLookupAndAnswer || |
4182cde57afb
refactoring FindStorageAccessMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1062 findStorageAccessMode_ == FindStorageAccessMode_DiskOnAnswer) && |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1063 dicomAsJson.get() == NULL && |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1064 isDicomAsJsonNeeded) |
3012
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1065 { |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1066 dicomAsJson.reset(new Json::Value); |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1067 ReadDicomAsJson(*dicomAsJson, instances[i]); |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1068 } |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1069 |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1070 if (hasOnlyMainDicomTags) |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1071 { |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1072 // This is Case (1): The variable "dicom" only contains the main DICOM tags |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1073 visitor.Visit(resources[i], instances[i], dicom, dicomAsJson.get()); |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1074 } |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1075 else |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1076 { |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1077 // Remove the non-main DICOM tags from "dicom" if Case (2) |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1078 // was used, for consistency with Case (1) |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1079 |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1080 DicomMap mainDicomTags; |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1081 mainDicomTags.ExtractMainDicomTags(dicom); |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1082 visitor.Visit(resources[i], instances[i], mainDicomTags, dicomAsJson.get()); |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1083 } |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
1084 |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2965
diff
changeset
|
1085 countResults ++; |
1757
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
1086 } |
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
1087 } |
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
1088 } |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2965
diff
changeset
|
1089 |
3003
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
1090 if (complete) |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
1091 { |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
1092 visitor.MarkAsComplete(); |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
1093 } |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
1094 |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
1095 LOG(INFO) << "Number of matching resources: " << countResults; |
1757
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
1096 } |
98abb8d7f905
ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1741
diff
changeset
|
1097 |
2626 | 1098 |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1099 bool ServerContext::LookupOrReconstructMetadata(std::string& target, |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1100 const std::string& publicId, |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1101 MetadataType metadata) |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1102 { |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1103 // This is a backwards-compatibility function, that can |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1104 // reconstruct metadata that were not generated by an older |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1105 // release of Orthanc |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1106 |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1107 if (metadata == MetadataType_Instance_SopClassUid || |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1108 metadata == MetadataType_Instance_TransferSyntax) |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1109 { |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1110 if (index_.LookupMetadata(target, publicId, metadata)) |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1111 { |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1112 return true; |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1113 } |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1114 else |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1115 { |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1116 // These metadata are mandatory in DICOM instances, and were |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1117 // introduced in Orthanc 1.2.0. The fact that |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1118 // "LookupMetadata()" has failed indicates that this database |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1119 // comes from an older release of Orthanc. |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1120 |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1121 DicomTag tag(0, 0); |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1122 |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1123 switch (metadata) |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1124 { |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1125 case MetadataType_Instance_SopClassUid: |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1126 tag = DICOM_TAG_SOP_CLASS_UID; |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1127 break; |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1128 |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1129 case MetadataType_Instance_TransferSyntax: |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1130 tag = DICOM_TAG_TRANSFER_SYNTAX_UID; |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1131 break; |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1132 |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1133 default: |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1134 throw OrthancException(ErrorCode_InternalError); |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1135 } |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1136 |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1137 Json::Value dicomAsJson; |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1138 ReadDicomAsJson(dicomAsJson, publicId); |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1139 |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1140 DicomMap tags; |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1141 tags.FromDicomAsJson(dicomAsJson); |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1142 |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1143 const DicomValue* value = tags.TestAndGetValue(tag); |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1144 |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1145 if (value != NULL && |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1146 !value->IsNull() && |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1147 !value->IsBinary()) |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1148 { |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1149 target = value->GetContent(); |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1150 |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1151 // Store for reuse |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1152 index_.SetMetadata(publicId, metadata, target); |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1153 return true; |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1154 } |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1155 else |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1156 { |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1157 // Should never happen |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1158 return false; |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1159 } |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1160 } |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1161 } |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1162 else |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1163 { |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1164 // No backward |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1165 return index_.LookupMetadata(target, publicId, metadata); |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1166 } |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1167 } |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1168 |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1169 |
2626 | 1170 void ServerContext::AddChildInstances(SetOfInstancesJob& job, |
1171 const std::string& publicId) | |
1172 { | |
1173 std::list<std::string> instances; | |
1174 GetIndex().GetChildInstances(instances, publicId); | |
1175 | |
1176 job.Reserve(job.GetInstancesCount() + instances.size()); | |
1177 | |
1178 for (std::list<std::string>::const_iterator | |
1179 it = instances.begin(); it != instances.end(); ++it) | |
1180 { | |
1181 job.AddInstance(*it); | |
1182 } | |
1183 } | |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1184 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1185 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1186 void ServerContext::SignalUpdatedModalities() |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1187 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1188 #if ORTHANC_ENABLE_PLUGINS == 1 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1189 if (HasPlugins()) |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1190 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1191 GetPlugins().SignalUpdatedModalities(); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1192 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1193 #endif |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1194 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1195 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1196 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1197 void ServerContext::SignalUpdatedPeers() |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1198 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1199 #if ORTHANC_ENABLE_PLUGINS == 1 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1200 if (HasPlugins()) |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1201 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1202 GetPlugins().SignalUpdatedPeers(); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1203 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1204 #endif |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2925
diff
changeset
|
1205 } |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1206 |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1207 |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1208 IStorageCommitmentFactory::ILookupHandler* |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1209 ServerContext::CreateStorageCommitment(const std::string& jobId, |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1210 const std::string& transactionUid, |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1211 const std::vector<std::string>& sopClassUids, |
3662
d8371b4302ff
OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3660
diff
changeset
|
1212 const std::vector<std::string>& sopInstanceUids, |
d8371b4302ff
OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3660
diff
changeset
|
1213 const std::string& remoteAet, |
d8371b4302ff
OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3660
diff
changeset
|
1214 const std::string& calledAet) |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1215 { |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1216 #if ORTHANC_ENABLE_PLUGINS == 1 |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1217 if (HasPlugins()) |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1218 { |
3662
d8371b4302ff
OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3660
diff
changeset
|
1219 return GetPlugins().CreateStorageCommitment( |
d8371b4302ff
OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3660
diff
changeset
|
1220 jobId, transactionUid, sopClassUids, sopInstanceUids, remoteAet, calledAet); |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1221 } |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1222 #endif |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1223 |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1224 return NULL; |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1225 } |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1226 |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1227 |
3928
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1228 ImageAccessor* ServerContext::DecodeDicomFrame(const std::string& publicId, |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1229 unsigned int frameIndex) |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1230 { |
3931
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1231 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_Before) |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1232 { |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1233 // Use Orthanc's built-in decoder, using the cache to speed-up |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1234 // things on multi-frame images |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1235 ServerContext::DicomCacheLocker locker(*this, publicId); |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1236 std::unique_ptr<ImageAccessor> decoded( |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1237 DicomImageDecoder::Decode(locker.GetDicom(), frameIndex)); |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1238 if (decoded.get() != NULL) |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1239 { |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1240 return decoded.release(); |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1241 } |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1242 } |
3928
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1243 |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1244 #if ORTHANC_ENABLE_PLUGINS == 1 |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1245 if (HasPlugins() && |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1246 GetPlugins().HasCustomImageDecoder()) |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1247 { |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1248 // TODO: Store the raw buffer in the DicomCacheLocker |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1249 std::string dicomContent; |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1250 ReadDicom(dicomContent, publicId); |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1251 std::unique_ptr<ImageAccessor> decoded( |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1252 GetPlugins().Decode(dicomContent.c_str(), dicomContent.size(), frameIndex)); |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1253 if (decoded.get() != NULL) |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1254 { |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1255 return decoded.release(); |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1256 } |
3931
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1257 else if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After) |
3928
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1258 { |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1259 LOG(INFO) << "The installed image decoding plugins cannot handle an image, " |
3930
b99acc213937
transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3928
diff
changeset
|
1260 << "fallback to the built-in DCMTK decoder"; |
3928
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1261 } |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1262 } |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1263 #endif |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1264 |
3931
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1265 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After) |
3928
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1266 { |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1267 ServerContext::DicomCacheLocker locker(*this, publicId); |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1268 return DicomImageDecoder::Decode(locker.GetDicom(), frameIndex); |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1269 } |
3931
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1270 else |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1271 { |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1272 return NULL; // Built-in decoder is disabled |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1273 } |
3928
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1274 } |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1275 |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1276 |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1277 ImageAccessor* ServerContext::DecodeDicomFrame(const DicomInstanceToStore& dicom, |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1278 unsigned int frameIndex) |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1279 { |
3931
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1280 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_Before) |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1281 { |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1282 std::unique_ptr<ImageAccessor> decoded( |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1283 DicomImageDecoder::Decode(dicom.GetParsedDicomFile(), frameIndex)); |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1284 if (decoded.get() != NULL) |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1285 { |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1286 return decoded.release(); |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1287 } |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1288 } |
3928
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1289 |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1290 #if ORTHANC_ENABLE_PLUGINS == 1 |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1291 if (HasPlugins() && |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1292 GetPlugins().HasCustomImageDecoder()) |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1293 { |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1294 std::unique_ptr<ImageAccessor> decoded( |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1295 GetPlugins().Decode(dicom.GetBufferData(), dicom.GetBufferSize(), frameIndex)); |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1296 if (decoded.get() != NULL) |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1297 { |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1298 return decoded.release(); |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1299 } |
3931
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1300 else if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After) |
3928
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1301 { |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1302 LOG(INFO) << "The installed image decoding plugins cannot handle an image, " |
3930
b99acc213937
transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3928
diff
changeset
|
1303 << "fallback to the built-in DCMTK decoder"; |
3928
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1304 } |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1305 } |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1306 #endif |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1307 |
3931
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1308 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After) |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1309 { |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1310 return DicomImageDecoder::Decode(dicom.GetParsedDicomFile(), frameIndex); |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1311 } |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1312 else |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1313 { |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1314 return NULL; |
e6606d3ec892
new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1315 } |
3928
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1316 } |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1317 |
4cdc875510d1
ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3913
diff
changeset
|
1318 |
3980
e42f5445d20d
Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
1319 ImageAccessor* ServerContext::DecodeDicomFrame(const void* dicom, |
e42f5445d20d
Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
1320 size_t size, |
e42f5445d20d
Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
1321 unsigned int frameIndex) |
e42f5445d20d
Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
1322 { |
e42f5445d20d
Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
1323 DicomInstanceToStore instance; |
e42f5445d20d
Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
1324 instance.SetBuffer(dicom, size); |
e42f5445d20d
Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
1325 return DecodeDicomFrame(instance, frameIndex); |
e42f5445d20d
Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
1326 } |
e42f5445d20d
Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
1327 |
e42f5445d20d
Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
1328 |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1329 void ServerContext::StoreWithTranscoding(std::string& sopClassUid, |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1330 std::string& sopInstanceUid, |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1331 DicomStoreUserConnection& connection, |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1332 const std::string& dicom, |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1333 bool hasMoveOriginator, |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1334 const std::string& moveOriginatorAet, |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1335 uint16_t moveOriginatorId) |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1336 { |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1337 const void* data = dicom.empty() ? NULL : dicom.c_str(); |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1338 |
3911
0ef7f4528be2
renamed option TranscodingEnabled to TranscodeDicomProtocol
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3910
diff
changeset
|
1339 if (!transcodeDicomProtocol_ || |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1340 !connection.GetParameters().GetRemoteModality().IsTranscodingAllowed()) |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1341 { |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1342 connection.Store(sopClassUid, sopInstanceUid, data, dicom.size(), |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1343 hasMoveOriginator, moveOriginatorAet, moveOriginatorId); |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1344 } |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1345 else |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1346 { |
3930
b99acc213937
transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3928
diff
changeset
|
1347 connection.Transcode(sopClassUid, sopInstanceUid, *this, data, dicom.size(), |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3911
diff
changeset
|
1348 hasMoveOriginator, moveOriginatorAet, moveOriginatorId); |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1349 } |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3839
diff
changeset
|
1350 } |
3930
b99acc213937
transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3928
diff
changeset
|
1351 |
b99acc213937
transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3928
diff
changeset
|
1352 |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1353 bool ServerContext::Transcode(DicomImage& target, |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1354 DicomImage& source /* in, "GetParsed()" possibly modified */, |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1355 const std::set<DicomTransferSyntax>& allowedSyntaxes, |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1356 bool allowNewSopInstanceUid) |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1357 { |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1358 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_Before) |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1359 { |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3947
diff
changeset
|
1360 if (dcmtkTranscoder_->Transcode(target, source, allowedSyntaxes, allowNewSopInstanceUid)) |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1361 { |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1362 return true; |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1363 } |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1364 } |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1365 |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1366 #if ORTHANC_ENABLE_PLUGINS == 1 |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1367 if (HasPlugins() && |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1368 GetPlugins().HasCustomTranscoder()) |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1369 { |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3947
diff
changeset
|
1370 if (GetPlugins().Transcode(target, source, allowedSyntaxes, allowNewSopInstanceUid)) |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1371 { |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1372 return true; |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1373 } |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1374 else if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After) |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1375 { |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1376 LOG(INFO) << "The installed transcoding plugins cannot handle an image, " |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1377 << "fallback to the built-in DCMTK transcoder"; |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1378 } |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1379 } |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1380 #endif |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1381 |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1382 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After) |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1383 { |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3947
diff
changeset
|
1384 return dcmtkTranscoder_->Transcode(target, source, allowedSyntaxes, allowNewSopInstanceUid); |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1385 } |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1386 else |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1387 { |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1388 return false; |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1389 } |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3941
diff
changeset
|
1390 } |
224 | 1391 } |