annotate OrthancServer/Sources/ServerContext.cpp @ 4792:434843934307 storage-cache

Added a StorageCache in the StorageAccessor
author Alain Mazy <am@osimis.io>
date Thu, 30 Sep 2021 12:14:19 +0200
parents 51ec061516c9
children 7afbb54bd028
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
224
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
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
4437
d9473bd5ed43 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4394
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
224
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
34 #include "PrecompiledHeadersServer.h"
224
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "ServerContext.h"
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
37 #include "../../OrthancFramework/Sources/Cache/SharedArchive.h"
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
38 #include "../../OrthancFramework/Sources/DicomFormat/DicomElement.h"
4499
6f99949b2878 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
39 #include "../../OrthancFramework/Sources/DicomFormat/DicomStreamReader.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
40 #include "../../OrthancFramework/Sources/DicomParsing/DcmtkTranscoder.h"
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
41 #include "../../OrthancFramework/Sources/DicomParsing/DicomModification.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
42 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h"
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
43 #include "../../OrthancFramework/Sources/DicomParsing/Internals/DicomImageDecoder.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
44 #include "../../OrthancFramework/Sources/FileStorage/StorageAccessor.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
45 #include "../../OrthancFramework/Sources/HttpServer/FilesystemHttpSender.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
46 #include "../../OrthancFramework/Sources/HttpServer/HttpStreamTranscoder.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
47 #include "../../OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
48 #include "../../OrthancFramework/Sources/Logging.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
49 #include "../../OrthancFramework/Sources/MetricsRegistry.h"
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
50 #include "../Plugins/Engine/OrthancPlugins.h"
3095
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3094
diff changeset
51
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
52 #include "OrthancConfiguration.h"
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
53 #include "OrthancRestApi/OrthancRestApi.h"
3094
61da3c9b4121 cont reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
54 #include "Search/DatabaseLookup.h"
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
55 #include "ServerJobs/OrthancJobUnserializer.h"
397
941ea46e9e26 lua filter of new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 394
diff changeset
56 #include "ServerToolbox.h"
3736
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
57 #include "StorageCommitmentReports.h"
226
8a26a8e85edf refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
58
794
437c4a83d2cc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 792
diff changeset
59 #include <dcmtk/dcmdata/dcfilefo.h>
224
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
1001
f3929718ea7e autorouting primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 998
diff changeset
61
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
62 static size_t DICOM_CACHE_SIZE = 128 * 1024 * 1024; // 128 MB
1001
f3929718ea7e autorouting primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 998
diff changeset
63
285
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 269
diff changeset
64
227
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
65 /**
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
66 * 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
67 * 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
68 * since the filesystem implements the required locking mechanisms,
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
69 * 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
70 * useful. Conversely, "ServerIndex" already implements mutex-based
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
71 * locking.
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
72 **/
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
73
224
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 namespace Orthanc
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
76 static bool IsUncompressedTransferSyntax(DicomTransferSyntax transferSyntax)
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
77 {
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
78 return (transferSyntax == DicomTransferSyntax_LittleEndianImplicit ||
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
79 transferSyntax == DicomTransferSyntax_LittleEndianExplicit ||
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
80 transferSyntax == DicomTransferSyntax_BigEndianExplicit);
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
81 }
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
82
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
83
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
84 static bool IsTranscodableTransferSyntax(DicomTransferSyntax transferSyntax)
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
85 {
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
86 return (
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
87 // Do not try to transcode DICOM videos (new in Orthanc 1.8.2)
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
88 transferSyntax != DicomTransferSyntax_MPEG2MainProfileAtMainLevel &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
89 transferSyntax != DicomTransferSyntax_MPEG2MainProfileAtHighLevel &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
90 transferSyntax != DicomTransferSyntax_MPEG4HighProfileLevel4_1 &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
91 transferSyntax != DicomTransferSyntax_MPEG4BDcompatibleHighProfileLevel4_1 &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
92 transferSyntax != DicomTransferSyntax_MPEG4HighProfileLevel4_2_For2DVideo &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
93 transferSyntax != DicomTransferSyntax_MPEG4HighProfileLevel4_2_For3DVideo &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
94 transferSyntax != DicomTransferSyntax_MPEG4StereoHighProfileLevel4_2 &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
95 transferSyntax != DicomTransferSyntax_HEVCMainProfileLevel5_1 &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
96 transferSyntax != DicomTransferSyntax_HEVCMain10ProfileLevel5_1 &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
97
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
98 // Do not try to transcode special transfer syntaxes
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
99 transferSyntax != DicomTransferSyntax_RFC2557MimeEncapsulation &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
100 transferSyntax != DicomTransferSyntax_XML);
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
101 }
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
102
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
103
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
104 void ServerContext::ChangeThread(ServerContext* that,
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
105 unsigned int sleepDelay)
1436
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 while (!that->done_)
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
108 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3679
diff changeset
109 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
110
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
111 if (obj.get() != NULL)
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 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
114
3947
cf6eb4fc6841 fix issue 179: use a shared mutex to avoid deadlock in python plugins
Alain Mazy <alain@mazy.be>
parents: 3945
diff changeset
115 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
116 for (ServerListeners::iterator it = that->listeners_.begin();
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
117 it != that->listeners_.end(); ++it)
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
118 {
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
119 try
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
120 {
2134
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
121 try
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
122 {
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
123 it->GetListener().SignalChange(change);
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
124 }
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
125 catch (std::bad_alloc&)
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
126 {
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
127 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
128 }
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
129 catch (...)
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
130 {
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
131 throw OrthancException(ErrorCode_InternalError);
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
132 }
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
133 }
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
134 catch (OrthancException& e)
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
135 {
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
136 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
137 << " callback while signaling a change: " << e.What()
cadfe0a2a393 fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2134
diff changeset
138 << " (code " << e.GetErrorCode() << ")";
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
139 }
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
140 }
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
141 }
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
142 }
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
143 }
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
144
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
145
2672
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
146 void ServerContext::SaveJobsThread(ServerContext* that,
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
147 unsigned int sleepDelay)
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
148 {
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
149 static const boost::posix_time::time_duration PERIODICITY =
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
150 boost::posix_time::seconds(10);
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
151
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
152 boost::posix_time::ptime next =
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
153 boost::posix_time::microsec_clock::universal_time() + PERIODICITY;
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
154
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
155 while (!that->done_)
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
156 {
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
157 boost::this_thread::sleep(boost::posix_time::milliseconds(sleepDelay));
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
158
2673
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
159 if (that->haveJobsChanged_ ||
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
160 boost::posix_time::microsec_clock::universal_time() >= next)
2672
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
161 {
2673
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
162 that->haveJobsChanged_ = false;
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
163 that->SaveJobsEngine();
2672
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
164 next = boost::posix_time::microsec_clock::universal_time() + PERIODICITY;
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
165 }
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
166 }
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
167 }
2673
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
168
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
169
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
170 void ServerContext::SignalJobSubmitted(const std::string& jobId)
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
171 {
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
172 haveJobsChanged_ = true;
2738
3a55b77339ff fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2716
diff changeset
173 mainLua_.SignalJobSubmitted(jobId);
4129
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
174
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
175 #if ORTHANC_ENABLE_PLUGINS == 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
176 if (HasPlugins())
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
177 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
178 GetPlugins().SignalJobSubmitted(jobId);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
179 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
180 #endif
2673
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
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
183
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
184 void ServerContext::SignalJobSuccess(const std::string& jobId)
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
185 {
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
186 haveJobsChanged_ = true;
2738
3a55b77339ff fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2716
diff changeset
187 mainLua_.SignalJobSuccess(jobId);
4129
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
188
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
189 #if ORTHANC_ENABLE_PLUGINS == 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
190 if (HasPlugins())
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
191 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
192 GetPlugins().SignalJobSuccess(jobId);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
193 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
194 #endif
2673
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
195 }
2672
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
196
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
197
2673
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
198 void ServerContext::SignalJobFailure(const std::string& jobId)
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
199 {
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
200 haveJobsChanged_ = true;
2738
3a55b77339ff fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2716
diff changeset
201 mainLua_.SignalJobFailure(jobId);
4129
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
202
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
203 #if ORTHANC_ENABLE_PLUGINS == 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
204 if (HasPlugins())
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
205 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
206 GetPlugins().SignalJobFailure(jobId);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
207 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4055
diff changeset
208 #endif
2673
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
209 }
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
210
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
211
2671
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
212 void ServerContext::SetupJobsEngine(bool unitTesting,
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
213 bool loadJobsFromDatabase)
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
214 {
2671
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
215 if (loadJobsFromDatabase)
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
216 {
2671
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
217 std::string serialized;
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4519
diff changeset
218 if (index_.LookupGlobalProperty(serialized, GlobalProperty_JobsRegistry, false /* not shared */))
2671
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
219 {
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
220 LOG(WARNING) << "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
221
2671
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
222 try
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
223 {
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4203
diff changeset
224 OrthancJobUnserializer unserializer(*this);
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
225 jobsEngine_.LoadRegistryFromString(unserializer, serialized);
2671
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
226 }
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
227 catch (OrthancException& e)
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
228 {
2925
a80ba85d89e6 Orthanc starts even if jobs from a previous execution cannot be unserialized
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2898
diff changeset
229 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
230 }
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
231 }
2671
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
232 else
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
233 {
2671
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
234 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
235 }
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
236 }
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
237 else
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
238 {
2925
a80ba85d89e6 Orthanc starts even if jobs from a previous execution cannot be unserialized
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2898
diff changeset
239 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
240 }
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
241
4024
1d2b31fc782f new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents: 4022
diff changeset
242 jobsEngine_.GetRegistry().SetObserver(*this);
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
243 jobsEngine_.Start();
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
244 isJobsEngineUnserialized_ = true;
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
245
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
246 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
247 }
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
248
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
249
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
250 void ServerContext::SaveJobsEngine()
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
251 {
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
252 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
253 {
4268
0ae2ca210077 new macro TLOG() to replace VLOG() for trace logs with a category
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4265
diff changeset
254 LOG(TRACE) << "Serializing the content of the jobs engine";
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
255
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
256 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
257 {
1fe524e211af New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
258 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
259 jobsEngine_.GetRegistry().Serialize(value);
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
260
4392
3af1d763763a confining Json::Reader and Json::*Writer into Toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4384
diff changeset
261 std::string serialized;
4394
f7104e9d044c functions to read/write JSON in OrthancPluginCppWrapper.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4392
diff changeset
262 Toolbox::WriteFastJson(serialized, value);
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
263
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4519
diff changeset
264 index_.SetGlobalProperty(GlobalProperty_JobsRegistry, false /* not shared */, serialized);
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
265 }
1fe524e211af New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
266 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
267 {
1fe524e211af New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
268 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
269 }
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
270 }
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
271 }
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
272
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
273
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
274 void ServerContext::PublishDicomCacheMetrics()
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
275 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
276 metricsRegistry_->SetValue("orthanc_dicom_cache_size",
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
277 static_cast<float>(dicomCache_.GetCurrentSize()) / static_cast<float>(1024 * 1024));
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
278 metricsRegistry_->SetValue("orthanc_dicom_cache_count",
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
279 static_cast<float>(dicomCache_.GetNumberOfItems()));
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
280 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
281
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
282
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
283 ServerContext::ServerContext(IDatabaseWrapper& database,
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2626
diff changeset
284 IStorageArea& area,
2950
dc18d5804746 support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
285 bool unitTesting,
dc18d5804746 support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
286 size_t maxCompletedJobs) :
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2626
diff changeset
287 index_(*this, database, (unitTesting ? 20 : 500)),
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
288 area_(area),
656
08eca5d86aad fixes to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 409
diff changeset
289 compressionEnabled_(false),
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
290 storeMD5_(true),
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
291 largeDicomThrottler_(1),
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
292 dicomCache_(DICOM_CACHE_SIZE),
2738
3a55b77339ff fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2716
diff changeset
293 mainLua_(*this),
3a55b77339ff fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2716
diff changeset
294 filterLua_(*this),
3a55b77339ff fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2716
diff changeset
295 luaListener_(*this),
2950
dc18d5804746 support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
296 jobsEngine_(maxCompletedJobs),
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2135
diff changeset
297 #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
298 plugins_(NULL),
1632
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
299 #endif
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
300 done_(false),
2673
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
301 haveJobsChanged_(false),
3174
8ea7c4546c3a primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3165
diff changeset
302 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
303 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
304 isHttpServerSecure_(true),
3813
aaaa442bfe39 moving SetOverwriteInstances from ServerIndex to ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3736
diff changeset
305 isExecuteLuaEnabled_(false),
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
306 overwriteInstances_(false),
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
307 dcmtkTranscoder_(new DcmtkTranscoder),
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
308 isIngestTranscoding_(false),
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
309 ingestTranscodingOfUncompressed_(true),
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
310 ingestTranscodingOfCompressed_(true),
4465
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
311 preferredTransferSyntax_(DicomTransferSyntax_LittleEndianExplicit),
4376
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
312 deidentifyLogs_(false)
224
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 {
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
314 try
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
315 {
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
316 unsigned int lossyQuality;
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
317
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
318 {
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
319 OrthancConfiguration::ReaderLock lock;
2965
9c0b0a6d8b54 MediaArchiveSize configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
320
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
321 queryRetrieveArchive_.reset(
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
322 new SharedArchive(lock.GetConfiguration().GetUnsignedIntegerParameter("QueryRetrieveSize", 100)));
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
323 mediaArchive_.reset(
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
324 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
325 defaultLocalAet_ = lock.GetConfiguration().GetOrthancAET();
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
326 jobsEngine_.SetWorkersCount(lock.GetConfiguration().GetUnsignedIntegerParameter("ConcurrentJobs", 2));
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
327 saveJobs_ = lock.GetConfiguration().GetBooleanParameter("SaveJobs", true);
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
328 metricsRegistry_->SetEnabled(lock.GetConfiguration().GetBooleanParameter("MetricsEnabled", true));
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 // 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
331 findStorageAccessMode_ = StringToFindStorageAccessMode(lock.GetConfiguration().GetStringParameter("StorageAccessOnFind", "Always"));
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
332 limitFindInstances_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindInstances", 0);
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
333 limitFindResults_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindResults", 0);
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
334
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
335 // 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
336 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
337
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
338 // New options in Orthanc 1.7.0
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
339 transcodeDicomProtocol_ = lock.GetConfiguration().GetBooleanParameter("TranscodeDicomProtocol", true);
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
340 builtinDecoderTranscoderOrder_ = StringToBuiltinDecoderTranscoderOrder(lock.GetConfiguration().GetStringParameter("BuiltinDecoderTranscoderOrder", "After"));
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
341 lossyQuality = lock.GetConfiguration().GetUnsignedIntegerParameter("DicomLossyTranscodingQuality", 90);
3677
4182cde57afb refactoring FindStorageAccessMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
342
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
343 std::string s;
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
344 if (lock.GetConfiguration().LookupStringParameter(s, "IngestTranscoding"))
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
345 {
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
346 if (LookupTransferSyntax(ingestTransferSyntax_, s))
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
347 {
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
348 isIngestTranscoding_ = true;
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
349 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
350 << "transfer syntax: " << GetTransferSyntaxUid(ingestTransferSyntax_);
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
351
4465
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
352 // New options in Orthanc 1.8.2
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
353 ingestTranscodingOfUncompressed_ = lock.GetConfiguration().GetBooleanParameter("IngestTranscodingOfUncompressed", true);
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
354 ingestTranscodingOfCompressed_ = lock.GetConfiguration().GetBooleanParameter("IngestTranscodingOfCompressed", true);
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
355
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
356 LOG(WARNING) << " Ingest transcoding will "
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
357 << (ingestTranscodingOfUncompressed_ ? "be applied" : "*not* be applied")
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
358 << " to uncompressed transfer syntaxes (Little Endian Implicit/Explicit, Big Endian Explicit)";
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
359
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
360 LOG(WARNING) << " Ingest transcoding will "
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
361 << (ingestTranscodingOfCompressed_ ? "be applied" : "*not* be applied")
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
362 << " to compressed transfer syntaxes";
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
363 }
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
364 else
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
365 {
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
366 throw OrthancException(ErrorCode_ParameterOutOfRange,
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
367 "Unknown transfer syntax for ingest transcoding: " + s);
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
368 }
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
369 }
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
370 else
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
371 {
3941
771dbd9eb3bd class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3939
diff changeset
372 isIngestTranscoding_ = false;
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
373 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
374 }
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
375
4465
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
376 // New options in Orthanc 1.8.2
4376
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
377 if (lock.GetConfiguration().GetBooleanParameter("DeidentifyLogs", true))
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
378 {
4376
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
379 deidentifyLogs_ = true;
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
380 CLOG(INFO, DICOM) << "Deidentification of log contents (notably for DIMSE queries) is enabled";
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
381
4376
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
382 DicomVersion version = StringToDicomVersion(
4677
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4666
diff changeset
383 lock.GetConfiguration().GetStringParameter("DeidentifyLogsDicomVersion", "2021b"));
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
384 CLOG(INFO, DICOM) << "Version of DICOM standard used for deidentification is "
4376
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
385 << EnumerationToString(version);
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
386
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
387 logsDeidentifierRules_.SetupAnonymization(version);
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
388 }
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
389 else
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
390 {
4376
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
391 deidentifyLogs_ = false;
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
392 CLOG(INFO, DICOM) << "Deidentification of log contents (notably for DIMSE queries) is disabled";
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
393 }
4465
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
394
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
395 // New options in Orthanc 1.9.0
4465
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
396 if (lock.GetConfiguration().LookupStringParameter(s, "DicomScuPreferredTransferSyntax") &&
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
397 !LookupTransferSyntax(preferredTransferSyntax_, s))
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
398 {
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
399 throw OrthancException(ErrorCode_ParameterOutOfRange,
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
400 "Unknown preferred transfer syntax: " + s);
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
401 }
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
402
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
403 CLOG(INFO, DICOM) << "Preferred transfer syntax for Orthanc C-STORE SCU: "
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
404 << GetTransferSyntaxUid(preferredTransferSyntax_);
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
405
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
406 lock.GetConfiguration().GetAcceptedTransferSyntaxes(acceptedTransferSyntaxes_);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
407
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
408 isUnknownSopClassAccepted_ = lock.GetConfiguration().GetBooleanParameter("UnknownSopClassAccepted", false);
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
409 }
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
410
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
411 jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200);
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
412
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
413 listeners_.push_back(ServerListener(luaListener_, "Lua"));
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
414 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
415
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
416 dynamic_cast<DcmtkTranscoder&>(*dcmtkTranscoder_).SetLossyQuality(lossyQuality);
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
417 }
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
418 catch (OrthancException&)
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
419 {
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
420 Stop();
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
421 throw;
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
422 }
224
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 }
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
425
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
426
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
427 ServerContext::~ServerContext()
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
428 {
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
429 if (!done_)
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
430 {
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
431 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
432 Stop();
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
433 }
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
434 }
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
435
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
436
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
437 void ServerContext::Stop()
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
438 {
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
439 if (!done_)
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
440 {
1459
040d58493998 security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1456
diff changeset
441 {
3947
cf6eb4fc6841 fix issue 179: use a shared mutex to avoid deadlock in python plugins
Alain Mazy <alain@mazy.be>
parents: 3945
diff changeset
442 boost::unique_lock<boost::shared_mutex> lock(listenersMutex_);
1459
040d58493998 security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1456
diff changeset
443 listeners_.clear();
040d58493998 security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1456
diff changeset
444 }
040d58493998 security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1456
diff changeset
445
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
446 done_ = true;
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
448 if (changeThread_.joinable())
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
449 {
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
450 changeThread_.join();
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
451 }
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
452
2672
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
453 if (saveJobsThread_.joinable())
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
454 {
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
455 saveJobsThread_.join();
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
456 }
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
457
4024
1d2b31fc782f new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents: 4022
diff changeset
458 jobsEngine_.GetRegistry().ResetObserver();
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
459
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
460 if (isJobsEngineUnserialized_)
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
461 {
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
462 // 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
463 SaveJobsEngine();
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
464 }
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
465
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
466 // Do not change the order below!
2570
2e879c796ec7 JobsRegistry::SubmitAndWait(), StoreScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2507
diff changeset
467 jobsEngine_.Stop();
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
468 index_.Stop();
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
469 }
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
470 }
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
471
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
472
236
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
473 void ServerContext::SetCompressionEnabled(bool enabled)
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
474 {
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
475 if (enabled)
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
476 LOG(WARNING) << "Disk compression is enabled";
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
477 else
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
478 LOG(WARNING) << "Disk compression is disabled";
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
479
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
480 compressionEnabled_ = enabled;
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
481 }
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
482
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
483
1126
bf67431a7383 handling of file content type in IStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1124
diff changeset
484 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
485 FileContentType type)
227
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
486 {
4792
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
487 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
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
488 accessor.Remove(fileUuid, type);
227
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
489 }
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
490
996
cf52f3bcb2b3 clarification of Lua classes wrt multithreading
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 995
diff changeset
491
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
492 StoreStatus ServerContext::StoreAfterTranscoding(std::string& resultPublicId,
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
493 DicomInstanceToStore& dicom,
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
494 StoreInstanceMode mode)
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
495 {
3814
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
496 bool overwrite;
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
497 switch (mode)
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
498 {
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
499 case StoreInstanceMode_Default:
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
500 overwrite = overwriteInstances_;
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
501 break;
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
502
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
503 case StoreInstanceMode_OverwriteDuplicate:
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
504 overwrite = true;
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
505 break;
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
506
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
507 case StoreInstanceMode_IgnoreDuplicate:
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
508 overwrite = false;
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
509 break;
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
510
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
511 default:
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
512 throw OrthancException(ErrorCode_ParameterOutOfRange);
4499
6f99949b2878 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
513 }
6f99949b2878 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
514
6f99949b2878 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
515 bool hasPixelDataOffset;
6f99949b2878 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
516 uint64_t pixelDataOffset;
6f99949b2878 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
517 hasPixelDataOffset = DicomStreamReader::LookupPixelDataOffset(
6f99949b2878 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
518 pixelDataOffset, dicom.GetBufferData(), dicom.GetBufferSize());
4506
ac69c9f76c71 refactoring ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4505
diff changeset
519
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4506
diff changeset
520 DicomTransferSyntax transferSyntax;
4506
ac69c9f76c71 refactoring ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4505
diff changeset
521 bool hasTransferSyntax = dicom.LookupTransferSyntax(transferSyntax);
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4506
diff changeset
522
4505
97d103b57cd1 removed cached dicom summary from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
523 DicomMap summary;
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4506
diff changeset
524 dicom.GetSummary(summary);
4505
97d103b57cd1 removed cached dicom summary from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
525
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
526 try
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
527 {
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
528 MetricsRegistry::Timer timer(GetMetricsRegistry(), "orthanc_store_dicom_duration_ms");
4792
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
529 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
530
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4506
diff changeset
531 DicomInstanceHasher hasher(summary);
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4506
diff changeset
532 resultPublicId = hasher.HashInstance();
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
533
4504
7d1eabfac6e0 removed cached dicom-as-json from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4500
diff changeset
534 Json::Value dicomAsJson;
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4506
diff changeset
535 dicom.GetDicomAsJson(dicomAsJson);
4504
7d1eabfac6e0 removed cached dicom-as-json from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4500
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 Json::Value simplifiedTags;
4504
7d1eabfac6e0 removed cached dicom-as-json from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4500
diff changeset
538 Toolbox::SimplifyDicomAsJson(simplifiedTags, dicomAsJson, DicomToJsonFormat_Human);
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
539
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
540 // Test if the instance must be filtered out
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
541 bool accepted = true;
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
542
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
543 {
3947
cf6eb4fc6841 fix issue 179: use a shared mutex to avoid deadlock in python plugins
Alain Mazy <alain@mazy.be>
parents: 3945
diff changeset
544 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
545
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
546 for (ServerListeners::iterator it = listeners_.begin(); it != listeners_.end(); ++it)
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
547 {
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
548 try
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
549 {
1574
0c29ebe80ac9 give access to full request origin in ReceivedInstanceFilter (Lua)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1550
diff changeset
550 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
551 {
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
552 accepted = false;
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
553 break;
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
554 }
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
555 }
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
556 catch (OrthancException& e)
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
557 {
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
558 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
559 << " callback while receiving an instance: " << e.What()
cadfe0a2a393 fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2134
diff changeset
560 << " (code " << e.GetErrorCode() << ")";
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
561 throw;
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
562 }
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
563 }
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
564 }
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
565
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
566 if (!accepted)
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
567 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
568 LOG(INFO) << "An incoming instance has been discarded by the filter";
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
569 return StoreStatus_FilteredOut;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
570 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
571
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
572 // Remove the file from the DicomCache (useful if
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
573 // "OverwriteInstances" is set to "true")
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
574 dicomCache_.Invalidate(resultPublicId);
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
575 PublishDicomCacheMetrics();
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
576
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
577 // TODO Should we use "gzip" instead?
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
578 CompressionType compression = (compressionEnabled_ ? CompressionType_ZlibWithSize : CompressionType_None);
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
579
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
580 FileInfo dicomInfo = accessor.Write(dicom.GetBufferData(), dicom.GetBufferSize(),
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
581 FileContentType_Dicom, compression, storeMD5_);
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
582
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
583 ServerIndex::Attachments attachments;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
584 attachments.push_back(dicomInfo);
4500
3b4940bca158 added safeguards in Orthanc::FileInfo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4499
diff changeset
585
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
586 FileInfo dicomUntilPixelData;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
587 if (hasPixelDataOffset &&
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
588 (!area_.HasReadRange() ||
4519
a3c6678aa7b1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4514
diff changeset
589 compressionEnabled_))
4500
3b4940bca158 added safeguards in Orthanc::FileInfo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4499
diff changeset
590 {
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
591 dicomUntilPixelData = accessor.Write(dicom.GetBufferData(), pixelDataOffset,
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
592 FileContentType_DicomUntilPixelData, compression, storeMD5_);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
593 attachments.push_back(dicomUntilPixelData);
4500
3b4940bca158 added safeguards in Orthanc::FileInfo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4499
diff changeset
594 }
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
595
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
596 typedef std::map<MetadataType, std::string> InstanceMetadata;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
597 InstanceMetadata instanceMetadata;
4506
ac69c9f76c71 refactoring ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4505
diff changeset
598 StoreStatus status = index_.Store(
ac69c9f76c71 refactoring ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4505
diff changeset
599 instanceMetadata, summary, attachments, dicom.GetMetadata(), dicom.GetOrigin(), overwrite,
ac69c9f76c71 refactoring ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4505
diff changeset
600 hasTransferSyntax, transferSyntax, hasPixelDataOffset, pixelDataOffset);
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
601
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
602 // Only keep the metadata for the "instance" level
4506
ac69c9f76c71 refactoring ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4505
diff changeset
603 dicom.ClearMetadata();
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
604
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
605 for (InstanceMetadata::const_iterator it = instanceMetadata.begin();
1304
7b6925b0890d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
606 it != instanceMetadata.end(); ++it)
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
607 {
4506
ac69c9f76c71 refactoring ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4505
diff changeset
608 dicom.AddMetadata(ResourceType_Instance, it->first, it->second);
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
609 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
610
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
611 if (status != StoreStatus_Success)
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
612 {
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
613 accessor.Remove(dicomInfo);
4500
3b4940bca158 added safeguards in Orthanc::FileInfo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4499
diff changeset
614
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
615 if (dicomUntilPixelData.IsValid())
4500
3b4940bca158 added safeguards in Orthanc::FileInfo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4499
diff changeset
616 {
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
617 accessor.Remove(dicomUntilPixelData);
4500
3b4940bca158 added safeguards in Orthanc::FileInfo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4499
diff changeset
618 }
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
619 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
620
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
621 switch (status)
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
622 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
623 case StoreStatus_Success:
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
624 LOG(INFO) << "New instance stored";
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
625 break;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
626
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
627 case StoreStatus_AlreadyStored:
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
628 LOG(INFO) << "Already stored";
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
629 break;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
630
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
631 case StoreStatus_Failure:
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
632 LOG(ERROR) << "Store failure";
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
633 break;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
634
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
635 default:
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
636 // This should never happen
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
637 break;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
638 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
639
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
640 if (status == StoreStatus_Success ||
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
641 status == StoreStatus_AlreadyStored)
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
642 {
3947
cf6eb4fc6841 fix issue 179: use a shared mutex to avoid deadlock in python plugins
Alain Mazy <alain@mazy.be>
parents: 3945
diff changeset
643 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
644
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
645 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
646 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1065
diff changeset
647 try
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1065
diff changeset
648 {
1574
0c29ebe80ac9 give access to full request origin in ReceivedInstanceFilter (Lua)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1550
diff changeset
649 it->GetListener().SignalStoredInstance(resultPublicId, dicom, simplifiedTags);
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1065
diff changeset
650 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1065
diff changeset
651 catch (OrthancException& e)
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1065
diff changeset
652 {
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
653 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
654 << " callback while receiving an instance: " << e.What()
cadfe0a2a393 fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2134
diff changeset
655 << " (code " << e.GetErrorCode() << ")";
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1065
diff changeset
656 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1065
diff changeset
657 }
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
658 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
659
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
660 return status;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
661 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
662 catch (OrthancException& e)
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
663 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
664 if (e.GetErrorCode() == ErrorCode_InexistentTag)
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
665 {
4505
97d103b57cd1 removed cached dicom summary from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
666 summary.LogMissingTagsForStore();
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
667 }
4505
97d103b57cd1 removed cached dicom summary from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
668
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
669 throw;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
670 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
671 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
672
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
673
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
674 StoreStatus ServerContext::Store(std::string& resultPublicId,
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
675 DicomInstanceToStore& dicom,
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
676 StoreInstanceMode mode)
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
677 {
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
678 if (!isIngestTranscoding_)
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
679 {
3941
771dbd9eb3bd class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3939
diff changeset
680 // 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
681 return StoreAfterTranscoding(resultPublicId, dicom, mode);
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
682 }
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
683 else
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
684 {
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
685 // Automated transcoding of incoming DICOM instance
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
686
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
687 bool transcode = false;
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
688
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
689 DicomTransferSyntax sourceSyntax;
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4506
diff changeset
690 if (!dicom.LookupTransferSyntax(sourceSyntax) ||
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
691 sourceSyntax == ingestTransferSyntax_)
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
692 {
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
693 // Don't transcode if the incoming DICOM is already in the proper transfer syntax
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
694 transcode = false;
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
695 }
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
696 else if (!IsTranscodableTransferSyntax(sourceSyntax))
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
697 {
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
698 // Don't try to transcode video files, this is useless (new in
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
699 // Orthanc 1.8.2). This could be accepted in the future if
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
700 // video transcoding gets implemented.
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
701 transcode = false;
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
702 }
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
703 else if (IsUncompressedTransferSyntax(sourceSyntax))
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
704 {
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
705 // This is an uncompressed transfer syntax (new in Orthanc 1.8.2)
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
706 transcode = ingestTranscodingOfUncompressed_;
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
707 }
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
708 else
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
709 {
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
710 // This is an compressed transfer syntax (new in Orthanc 1.8.2)
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
711 transcode = ingestTranscodingOfCompressed_;
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
712 }
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
713
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
714 if (!transcode)
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
715 {
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
716 // No transcoding
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
717 return StoreAfterTranscoding(resultPublicId, dicom, mode);
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
718 }
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
719 else
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
720 {
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
721 // Trancoding
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
722 std::set<DicomTransferSyntax> syntaxes;
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
723 syntaxes.insert(ingestTransferSyntax_);
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
724
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
725 IDicomTranscoder::DicomImage source;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
726 source.SetExternalBuffer(dicom.GetBufferData(), dicom.GetBufferSize());
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
727
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
728 IDicomTranscoder::DicomImage transcoded;
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3947
diff changeset
729 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
730 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
731 std::unique_ptr<ParsedDicomFile> tmp(transcoded.ReleaseAsParsedDicomFile());
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
732
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
733 std::unique_ptr<DicomInstanceToStore> toStore(DicomInstanceToStore::CreateFromParsedDicomFile(*tmp));
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
734 toStore->SetOrigin(dicom.GetOrigin());
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
735
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
736 StoreStatus ok = StoreAfterTranscoding(resultPublicId, *toStore, mode);
3938
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3931
diff changeset
737 assert(resultPublicId == tmp->GetHasher().HashInstance());
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3931
diff changeset
738
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
739 return ok;
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
740 }
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
741 else
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
742 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
743 // Cannot transcode => store the original file
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
744 return StoreAfterTranscoding(resultPublicId, dicom, mode);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
745 }
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
746 }
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
747 }
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
748 }
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
749
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
750
1146
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
751 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
752 const std::string& resourceId,
1146
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
753 FileContentType content)
226
8a26a8e85edf refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
754 {
232
5368bbe813cf refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
755 FileInfo attachment;
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
756 int64_t revision;
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
757 if (!index_.LookupAttachment(attachment, revision, resourceId, content))
232
5368bbe813cf refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
758 {
1700
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
759 throw OrthancException(ErrorCode_UnknownResource);
236
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
760 }
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
761 else
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
762 {
4792
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
763 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
764 accessor.AnswerFile(output, attachment, GetFileContentMime(content));
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
765 }
226
8a26a8e85edf refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
766 }
8a26a8e85edf refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
767
8a26a8e85edf refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
768
1700
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
769 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
770 FileContentType attachmentType,
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
771 CompressionType compression)
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
772 {
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
773 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
774 << EnumerationToString(attachmentType)
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
775 << " of resource " << resourceId << " to "
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
776 << compression;
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
777
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
778 FileInfo attachment;
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
779 int64_t revision;
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
780 if (!index_.LookupAttachment(attachment, revision, resourceId, attachmentType))
1700
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
781 {
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
782 throw OrthancException(ErrorCode_UnknownResource);
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
783 }
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
784
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
785 if (attachment.GetCompressionType() == compression)
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
786 {
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
787 // Nothing to do
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
788 return;
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
789 }
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
790
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
791 std::string content;
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
792
4792
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
793 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
1700
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
794 accessor.Read(content, attachment);
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
795
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
796 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
797 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
798
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
799 try
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
800 {
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
801 int64_t newRevision; // ignored
4640
66109d24d26e "ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4629
diff changeset
802 StoreStatus status = index_.AddAttachment(newRevision, modified, resourceId,
66109d24d26e "ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4629
diff changeset
803 true, revision, modified.GetUncompressedMD5());
1700
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
804 if (status != StoreStatus_Success)
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
805 {
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
806 accessor.Remove(modified);
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
807 throw OrthancException(ErrorCode_Database);
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
808 }
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
809 }
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
810 catch (OrthancException&)
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
811 {
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
812 accessor.Remove(modified);
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
813 throw;
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
814 }
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
815 }
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
816
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
817
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
818 static void InjectEmptyPixelData(Json::Value& dicomAsJson)
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
819 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
820 // This is for backward compatibility with Orthanc <= 1.9.0
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
821 Json::Value pixelData = Json::objectValue;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
822 pixelData["Name"] = "PixelData";
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
823 pixelData["Type"] = "Null";
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
824 pixelData["Value"] = Json::nullValue;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
825
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
826 dicomAsJson["7fe0,0010"] = pixelData;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
827 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
828
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
829
2124
2b1520efa282 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2122
diff changeset
830 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
831 const std::string& instancePublicId,
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
832 const std::set<DicomTag>& ignoreTagLength)
226
8a26a8e85edf refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
833 {
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
834 /**
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
835 * CASE 1: The DICOM file, truncated at pixel data, is available
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
836 * as an attachment (it was created either because the storage
4666
Alain Mazy <am@osimis.io>
parents: 4640
diff changeset
837 * area does not support range reads, or if "StorageCompression"
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
838 * is enabled). Simply return this attachment.
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
839 **/
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
840
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
841 FileInfo attachment;
4629
88e892e25a51 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4627
diff changeset
842 int64_t revision; // Ignored
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
843
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
844 if (index_.LookupAttachment(attachment, revision, instancePublicId, FileContentType_DicomUntilPixelData))
2409
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
845 {
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
846 std::string dicom;
4513
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
847
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
848 {
4792
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
849 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
850 accessor.Read(dicom, attachment);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
851 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
852
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
853 ParsedDicomFile parsed(dicom);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
854 OrthancConfiguration::DefaultDicomDatasetToJson(result, parsed, ignoreTagLength);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
855 InjectEmptyPixelData(result);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
856 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
857 else
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
858 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
859 /**
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
860 * The truncated DICOM file is not stored as a standalone
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
861 * attachment. Lookup whether the pixel data offset has already
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
862 * been computed for this instance.
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
863 **/
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
864
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
865 bool hasPixelDataOffset;
4519
a3c6678aa7b1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4514
diff changeset
866 uint64_t pixelDataOffset = 0; // dummy initialization
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
867
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
868 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
869 std::string s;
4623
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
870 if (index_.LookupMetadata(s, revision, instancePublicId, ResourceType_Instance,
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
871 MetadataType_Instance_PixelDataOffset))
4513
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
872 {
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
873 hasPixelDataOffset = false;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
874
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
875 if (!s.empty())
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
876 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
877 try
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
878 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
879 pixelDataOffset = boost::lexical_cast<uint64_t>(s);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
880 hasPixelDataOffset = true;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
881 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
882 catch (boost::bad_lexical_cast&)
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
883 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
884 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
885 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
886
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
887 if (!hasPixelDataOffset)
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
888 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
889 LOG(ERROR) << "Metadata \"PixelDataOffset\" is corrupted for instance: " << instancePublicId;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
890 }
4513
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
891 }
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
892 else
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
893 {
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
894 // This instance was created by a version of Orthanc <= 1.9.0
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
895 hasPixelDataOffset = false;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
896 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
897 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
898
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
899
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
900 if (hasPixelDataOffset &&
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
901 area_.HasReadRange() &&
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
902 index_.LookupAttachment(attachment, revision, instancePublicId, FileContentType_Dicom) &&
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
903 attachment.GetCompressionType() == CompressionType_None)
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
904 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
905 /**
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
906 * CASE 2: The pixel data offset is known, AND that a range read
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
907 * can be used to retrieve the truncated DICOM file. Note that
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
908 * this case cannot be used if "StorageCompression" option is
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
909 * "true".
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
910 **/
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
911
4519
a3c6678aa7b1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4514
diff changeset
912 std::unique_ptr<IMemoryBuffer> dicom;
a3c6678aa7b1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4514
diff changeset
913 {
4792
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
914 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
915 dicom.reset(accessor.ReadStartRange(attachment.GetUuid(), FileContentType_Dicom, pixelDataOffset, FileContentType_DicomUntilPixelData));
4519
a3c6678aa7b1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4514
diff changeset
916 }
4513
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
917
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
918 if (dicom.get() == NULL)
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
919 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
920 throw OrthancException(ErrorCode_InternalError);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
921 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
922 else
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
923 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
924 assert(dicom->GetSize() == pixelDataOffset);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
925 ParsedDicomFile parsed(dicom->GetData(), dicom->GetSize());
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
926 OrthancConfiguration::DefaultDicomDatasetToJson(result, parsed, ignoreTagLength);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
927 InjectEmptyPixelData(result);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
928 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
929 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
930 else if (ignoreTagLength.empty() &&
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
931 index_.LookupAttachment(attachment, revision, instancePublicId, FileContentType_DicomAsJson))
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
932 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
933 /**
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
934 * CASE 3: This instance was created using Orthanc <=
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
935 * 1.9.0. Reuse the old "DICOM-as-JSON" attachment if available.
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
936 * This is for backward compatibility: A call to
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
937 * "/tools/invalidate-tags" or to one flavors of
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
938 * "/.../.../reconstruct" will disable this case.
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
939 **/
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
940
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
941 std::string dicomAsJson;
4513
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
942
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
943 {
4792
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
944 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
945 accessor.Read(dicomAsJson, attachment);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
946 }
4513
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
947
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
948 if (!Toolbox::ReadJson(result, dicomAsJson))
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
949 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
950 throw OrthancException(ErrorCode_CorruptedFile,
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
951 "Corrupted DICOM-as-JSON attachment of instance: " + instancePublicId);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
952 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
953 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
954 else
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
955 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
956 /**
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
957 * CASE 4: Neither the truncated DICOM file is accessible, nor
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
958 * the DICOM-as-JSON summary. We have to retrieve the full DICOM
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
959 * file from the storage area.
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
960 **/
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
961
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
962 std::string dicom;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
963 ReadDicom(dicom, instancePublicId);
4513
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
964
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
965 ParsedDicomFile parsed(dicom);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
966 OrthancConfiguration::DefaultDicomDatasetToJson(result, parsed, ignoreTagLength);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
967
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
968 if (!hasPixelDataOffset)
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
969 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
970 /**
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
971 * The pixel data offset was never computed for this
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
972 * instance, which indicates that it was created using
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
973 * Orthanc <= 1.9.0, or that calls to
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
974 * "LookupPixelDataOffset()" from earlier versions of
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
975 * Orthanc have failed. Try again this precomputation now
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
976 * for future calls.
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
977 **/
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
978 if (DicomStreamReader::LookupPixelDataOffset(pixelDataOffset, dicom) &&
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
979 pixelDataOffset < dicom.size())
4513
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
980 {
4623
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
981 index_.OverwriteMetadata(instancePublicId, MetadataType_Instance_PixelDataOffset,
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
982 boost::lexical_cast<std::string>(pixelDataOffset));
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
983
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
984 if (!area_.HasReadRange() ||
4519
a3c6678aa7b1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4514
diff changeset
985 compressionEnabled_)
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
986 {
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
987 int64_t newRevision;
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
988 AddAttachment(newRevision, instancePublicId, FileContentType_DicomUntilPixelData,
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
989 dicom.empty() ? NULL: dicom.c_str(), pixelDataOffset,
4640
66109d24d26e "ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4629
diff changeset
990 false /* no old revision */, -1 /* dummy revision */, "" /* dummy MD5 */);
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
991 }
4513
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
992 }
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
993 }
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
994 }
226
8a26a8e85edf refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
995 }
8a26a8e85edf refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
996 }
227
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
997
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
998
4511
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
999 void ServerContext::ReadDicomAsJson(Json::Value& result,
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1000 const std::string& instancePublicId)
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1001 {
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1002 std::set<DicomTag> ignoreTagLength;
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1003 ReadDicomAsJson(result, instancePublicId, ignoreTagLength);
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1004 }
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1005
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1006
4509
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1007 void ServerContext::ReadDicom(std::string& dicom,
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1008 const std::string& instancePublicId)
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1009 {
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1010 int64_t revision;
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1011 ReadAttachment(dicom, revision, instancePublicId, FileContentType_Dicom, true /* uncompress */);
4509
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1012 }
4792
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1013
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1014 void ServerContext::ReadDicomForHeader(std::string& dicom,
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1015 const std::string& instancePublicId)
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1016 {
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1017 if (!ReadDicomUntilPixelData(dicom, instancePublicId))
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1018 {
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1019 ReadDicom(dicom, instancePublicId);
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1020 }
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1021 }
4509
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1022
4511
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1023 bool ServerContext::ReadDicomUntilPixelData(std::string& dicom,
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1024 const std::string& instancePublicId)
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1025 {
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1026 if (!area_.HasReadRange())
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1027 {
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1028 return false;
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1029 }
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1030
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1031 FileInfo attachment;
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1032 int64_t revision; // Ignored
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1033 if (!index_.LookupAttachment(attachment, revision, instancePublicId, FileContentType_Dicom))
4511
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1034 {
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1035 throw OrthancException(ErrorCode_InternalError,
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1036 "Unable to read the DICOM file of instance " + instancePublicId);
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1037 }
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1038
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1039 std::string s;
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1040
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1041 if (attachment.GetCompressionType() == CompressionType_None &&
4623
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1042 index_.LookupMetadata(s, revision, instancePublicId, ResourceType_Instance,
4511
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1043 MetadataType_Instance_PixelDataOffset) &&
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1044 !s.empty())
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1045 {
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1046 try
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1047 {
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1048 uint64_t pixelDataOffset = boost::lexical_cast<uint64_t>(s);
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1049
4792
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1050 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1051
4511
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1052 std::unique_ptr<IMemoryBuffer> buffer(
4792
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1053 accessor.ReadStartRange(attachment.GetUuid(), attachment.GetContentType(), pixelDataOffset, FileContentType_DicomUntilPixelData));
4511
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1054 buffer->MoveToString(dicom);
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1055 return true; // Success
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1056 }
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1057 catch (boost::bad_lexical_cast&)
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1058 {
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1059 LOG(ERROR) << "Metadata \"PixelDataOffset\" is corrupted for instance: " << instancePublicId;
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1060 }
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1061 }
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1062
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1063 return false;
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1064 }
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1065
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1066
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2127
diff changeset
1067 void ServerContext::ReadAttachment(std::string& result,
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1068 int64_t& revision,
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2127
diff changeset
1069 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
1070 FileContentType content,
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2127
diff changeset
1071 bool uncompressIfNeeded)
227
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
1072 {
232
5368bbe813cf refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
1073 FileInfo attachment;
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1074 if (!index_.LookupAttachment(attachment, revision, instancePublicId, content))
227
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
1075 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2950
diff changeset
1076 throw OrthancException(ErrorCode_InternalError,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2950
diff changeset
1077 "Unable to read attachment " + EnumerationToString(content) +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2950
diff changeset
1078 " of instance " + instancePublicId);
227
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
1079 }
1550
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1549
diff changeset
1080
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
1081 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
1082
1550
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1549
diff changeset
1083 {
4792
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1084 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
4509
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1085
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1086 if (uncompressIfNeeded)
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1087 {
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1088 accessor.Read(result, attachment);
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1089 }
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1090 else
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1091 {
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1092 // Do not uncompress the content of the storage area, return the
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1093 // raw data
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1094 accessor.ReadRaw(result, attachment);
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1095 }
1550
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1549
diff changeset
1096 }
227
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
1097 }
285
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 269
diff changeset
1098
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 269
diff changeset
1099
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1100 ServerContext::DicomCacheLocker::DicomCacheLocker(ServerContext& context,
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1101 const std::string& instancePublicId) :
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1102 context_(context),
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1103 instancePublicId_(instancePublicId)
285
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 269
diff changeset
1104 {
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1105 accessor_.reset(new ParsedDicomCache::Accessor(context_.dicomCache_, instancePublicId));
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1106
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1107 if (!accessor_->IsValid())
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1108 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1109 accessor_.reset(NULL);
285
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 269
diff changeset
1110
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1111 // Throttle to avoid loading several large DICOM files simultaneously
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1112 largeDicomLocker_.reset(new Semaphore::Locker(context.largeDicomThrottler_));
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1113
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1114 std::string content;
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1115 context_.ReadDicom(content, instancePublicId);
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1116
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1117 // Release the throttle if loading "small" DICOM files (under
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1118 // 50MB, which is an arbitrary value)
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1119 if (content.size() < 50 * 1024 * 1024)
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1120 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1121 largeDicomLocker_.reset(NULL);
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1122 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1123
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1124 dicom_.reset(new ParsedDicomFile(content));
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1125 dicomSize_ = content.size();
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1126 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1127
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1128 assert(accessor_.get() != NULL ||
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1129 dicom_.get() != NULL);
778
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 774
diff changeset
1130 }
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 774
diff changeset
1131
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 774
diff changeset
1132
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 774
diff changeset
1133 ServerContext::DicomCacheLocker::~DicomCacheLocker()
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 774
diff changeset
1134 {
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1135 if (dicom_.get() != NULL)
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1136 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1137 try
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1138 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1139 context_.dicomCache_.Acquire(instancePublicId_, dicom_.release(), dicomSize_);
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1140 context_.PublishDicomCacheMetrics();
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1141 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1142 catch (OrthancException&)
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1143 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1144 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1145 }
285
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 269
diff changeset
1146 }
304
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
1147
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
1148
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1149 ParsedDicomFile& ServerContext::DicomCacheLocker::GetDicom() const
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1150 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1151 if (dicom_.get() != NULL)
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1152 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1153 return *dicom_;
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1154 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1155 else
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1156 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1157 assert(accessor_.get() != NULL);
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1158 return accessor_->GetDicom();
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1159 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1160 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1161
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1162
695
c59bc408fb10 parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
1163 void ServerContext::SetStoreMD5ForAttachments(bool storeMD5)
c59bc408fb10 parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
1164 {
c59bc408fb10 parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
1165 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
1166 storeMD5_ = storeMD5;
695
c59bc408fb10 parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
1167 }
c59bc408fb10 parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
1168
699
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1169
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1170 bool ServerContext::AddAttachment(int64_t& newRevision,
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1171 const std::string& resourceId,
699
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1172 FileContentType attachmentType,
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1173 const void* data,
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1174 size_t size,
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1175 bool hasOldRevision,
4640
66109d24d26e "ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4629
diff changeset
1176 int64_t oldRevision,
66109d24d26e "ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4629
diff changeset
1177 const std::string& oldMD5)
699
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1178 {
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1179 LOG(INFO) << "Adding attachment " << EnumerationToString(attachmentType) << " to resource " << resourceId;
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1180
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
1181 // TODO Should we use "gzip" instead?
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
1182 CompressionType compression = (compressionEnabled_ ? CompressionType_ZlibWithSize : CompressionType_None);
699
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1183
4792
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1184 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
1185 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
1186
4752
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1187 try
699
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1188 {
4752
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1189 StoreStatus status = index_.AddAttachment(
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1190 newRevision, attachment, resourceId, hasOldRevision, oldRevision, oldMD5);
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1191 if (status != StoreStatus_Success)
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1192 {
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1193 accessor.Remove(attachment);
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1194 return false;
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1195 }
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1196 else
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1197 {
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1198 return true;
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1199 }
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1200 }
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1201 catch (OrthancException&)
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1202 {
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1203 // Fixed in Orthanc 1.9.6
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
1204 accessor.Remove(attachment);
4752
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1205 throw;
699
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1206 }
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1207 }
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
1208
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
1209
4694
da1edb7d6332 "/tools/bulk-delete" to delete a group of multiple, unrelated resources at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1210 bool ServerContext::DeleteResource(Json::Value& remainingAncestor,
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
1211 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
1212 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
1213 {
2507
99116ed6f38c invalidate DicomCache when deleting instance
amazy
parents: 2447
diff changeset
1214 if (expectedType == ResourceType_Instance)
99116ed6f38c invalidate DicomCache when deleting instance
amazy
parents: 2447
diff changeset
1215 {
99116ed6f38c invalidate DicomCache when deleting instance
amazy
parents: 2447
diff changeset
1216 // remove the file from the DicomCache
99116ed6f38c invalidate DicomCache when deleting instance
amazy
parents: 2447
diff changeset
1217 dicomCache_.Invalidate(uuid);
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1218 PublishDicomCacheMetrics();
2507
99116ed6f38c invalidate DicomCache when deleting instance
amazy
parents: 2447
diff changeset
1219 }
99116ed6f38c invalidate DicomCache when deleting instance
amazy
parents: 2447
diff changeset
1220
4694
da1edb7d6332 "/tools/bulk-delete" to delete a group of multiple, unrelated resources at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1221 return index_.DeleteResource(remainingAncestor, uuid, expectedType);
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
1222 }
1189
6b9b02a16e99 NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1165
diff changeset
1223
6b9b02a16e99 NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1165
diff changeset
1224
1198
1169528a9a5f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1189
diff changeset
1225 void ServerContext::SignalChange(const ServerIndexChange& change)
1189
6b9b02a16e99 NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1165
diff changeset
1226 {
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1227 if (change.GetResourceType() == ResourceType_Instance &&
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1228 change.GetChangeType() == ChangeType_Deleted)
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1229 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1230 dicomCache_.Invalidate(change.GetPublicId());
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1231 PublishDicomCacheMetrics();
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1232 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1233
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
1234 pendingChanges_.Enqueue(change.Clone());
1189
6b9b02a16e99 NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1165
diff changeset
1235 }
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1236
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1237
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2135
diff changeset
1238 #if ORTHANC_ENABLE_PLUGINS == 1
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1239 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
1240 {
3947
cf6eb4fc6841 fix issue 179: use a shared mutex to avoid deadlock in python plugins
Alain Mazy <alain@mazy.be>
parents: 3945
diff changeset
1241 boost::unique_lock<boost::shared_mutex> lock(listenersMutex_);
1459
040d58493998 security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1456
diff changeset
1242
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1243 plugins_ = &plugins;
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1244
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1245 // TODO REFACTOR THIS
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1246 listeners_.clear();
2738
3a55b77339ff fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2716
diff changeset
1247 listeners_.push_back(ServerListener(luaListener_, "Lua"));
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1248 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
1249 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1250
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1251
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1252 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
1253 {
3947
cf6eb4fc6841 fix issue 179: use a shared mutex to avoid deadlock in python plugins
Alain Mazy <alain@mazy.be>
parents: 3945
diff changeset
1254 boost::unique_lock<boost::shared_mutex> lock(listenersMutex_);
1459
040d58493998 security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1456
diff changeset
1255
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1256 plugins_ = NULL;
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1257
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1258 // TODO REFACTOR THIS
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1259 listeners_.clear();
2738
3a55b77339ff fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2716
diff changeset
1260 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
1261 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1262
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1263
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1264 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
1265 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1266 if (HasPlugins())
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1267 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1268 return *plugins_;
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1269 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1270 else
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1271 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1272 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
1273 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1274 }
1632
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1275
1741
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1276 OrthancPlugins& ServerContext::GetPlugins()
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1277 {
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1278 if (HasPlugins())
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1279 {
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1280 return *plugins_;
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1281 }
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1282 else
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1283 {
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1284 throw OrthancException(ErrorCode_InternalError);
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1285 }
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1286 }
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1287
1632
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1288 #endif
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1289
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1290
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1291 bool ServerContext::HasPlugins() const
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1292 {
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2135
diff changeset
1293 #if ORTHANC_ENABLE_PLUGINS == 1
1632
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1294 return (plugins_ != NULL);
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1295 #else
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1296 return false;
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1297 #endif
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1298 }
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1299
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1300
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1301 void ServerContext::ApplyInternal(ILookupVisitor& visitor,
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1302 const DatabaseLookup& lookup,
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1303 ResourceType queryLevel,
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1304 size_t since,
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1305 size_t limit)
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1306 {
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
1307 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
1308 limitFindInstances_ : limitFindResults_);
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1309
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1310 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
1311
3204
8792867b739a fix incorrect "too many results"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3175
diff changeset
1312 {
8792867b739a fix incorrect "too many results"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3175
diff changeset
1313 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
1314 GetIndex().ApplyLookupResources(resources, &instances, lookup, queryLevel, lookupLimit);
8792867b739a fix incorrect "too many results"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3175
diff changeset
1315 }
3025
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3021
diff changeset
1316
3033
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3031
diff changeset
1317 bool complete = (databaseLimit == 0 ||
3204
8792867b739a fix incorrect "too many results"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3175
diff changeset
1318 resources.size() <= databaseLimit);
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1319
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3003
diff changeset
1320 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
1321
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
1322 /**
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
1323 * "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
1324 * "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
1325 * 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
1326 **/
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1327 assert(resources.size() == instances.size());
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1328
3001
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2965
diff changeset
1329 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
1330 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
1331
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1332 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
1333
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1334 for (size_t i = 0; i < instances.size(); i++)
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1335 {
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
1336 // 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
1337 // 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
1338
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3679
diff changeset
1339 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
1340
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
1341 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
1342 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
1343
3677
4182cde57afb refactoring FindStorageAccessMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1344 if (findStorageAccessMode_ == FindStorageAccessMode_DatabaseOnly ||
4182cde57afb refactoring FindStorageAccessMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1345 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
1346 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
1347 {
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
1348 // 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
1349 // 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
1350
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
1351 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
1352 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
1353 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1354 // 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
1355 // lookup, ignore it
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1356 continue;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1357 }
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
1358
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
1359 // 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
1360 // 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
1361 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
1362 {
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
1363 // 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
1364 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
1365 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
1366
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
1367 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
1368 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
1369
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
1370 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
1371 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
1372
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
1373 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
1374 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
1375 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
1376
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
1377 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
1378 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
1379 }
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1380
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
1381 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
1382 }
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
1383 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
1384 {
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
1385 // 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
1386 // 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
1387 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
1388 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
1389
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
1390 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
1391
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
1392 // 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
1393 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
1394 }
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1395
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1396 if (lookup.IsMatch(dicom))
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1397 {
2304
563bf878407a Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1398 if (skipped < since)
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1399 {
2304
563bf878407a Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1400 skipped++;
563bf878407a Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1401 }
563bf878407a Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1402 else if (limit != 0 &&
3001
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2965
diff changeset
1403 countResults >= limit)
2304
563bf878407a Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1404 {
3003
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
1405 // Too many results, don't mark as complete
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
1406 complete = false;
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
1407 break;
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1408 }
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1409 else
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1410 {
3677
4182cde57afb refactoring FindStorageAccessMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1411 if ((findStorageAccessMode_ == FindStorageAccessMode_DiskOnLookupAndAnswer ||
4182cde57afb refactoring FindStorageAccessMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1412 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
1413 dicomAsJson.get() == NULL &&
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1414 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
1415 {
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
1416 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
1417 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
1418 }
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
1419
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
1420 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
1421 {
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
1422 // 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
1423 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
1424 }
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
1425 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
1426 {
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
1427 // 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
1428 // 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
1429
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
1430 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
1431 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
1432 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
1433 }
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
1434
3001
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2965
diff changeset
1435 countResults ++;
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1436 }
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1437 }
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1438 }
3001
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2965
diff changeset
1439
3003
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
1440 if (complete)
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
1441 {
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
1442 visitor.MarkAsComplete();
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
1443 }
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
1444
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
1445 LOG(INFO) << "Number of matching resources: " << countResults;
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1446 }
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1447
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1448
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1449
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1450 namespace
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1451 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1452 class ModalitiesInStudyVisitor : public ServerContext::ILookupVisitor
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1453 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1454 private:
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1455 class Study : public boost::noncopyable
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1456 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1457 private:
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1458 std::string orthancId_;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1459 std::string instanceId_;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1460 DicomMap mainDicomTags_;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1461 Json::Value dicomAsJson_;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1462 std::set<std::string> modalitiesInStudy_;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1463
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1464 public:
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1465 Study(const std::string& instanceId,
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1466 const DicomMap& seriesTags) :
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1467 instanceId_(instanceId),
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1468 dicomAsJson_(Json::nullValue)
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1469 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1470 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1471 DicomMap tmp;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1472 tmp.Assign(seriesTags);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1473 tmp.SetValue(DICOM_TAG_SOP_INSTANCE_UID, "dummy", false);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1474 DicomInstanceHasher hasher(tmp);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1475 orthancId_ = hasher.HashStudy();
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1476 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1477
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1478 mainDicomTags_.MergeMainDicomTags(seriesTags, ResourceType_Study);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1479 mainDicomTags_.MergeMainDicomTags(seriesTags, ResourceType_Patient);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1480 AddModality(seriesTags);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1481 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1482
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1483 void AddModality(const DicomMap& seriesTags)
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1484 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1485 std::string modality;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1486 if (seriesTags.LookupStringValue(modality, DICOM_TAG_MODALITY, false) &&
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1487 !modality.empty())
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1488 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1489 modalitiesInStudy_.insert(modality);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1490 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1491 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1492
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1493 void SetDicomAsJson(const Json::Value& dicomAsJson)
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1494 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1495 dicomAsJson_ = dicomAsJson;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1496 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1497
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1498 const std::string& GetOrthancId() const
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1499 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1500 return orthancId_;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1501 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1502
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1503 const std::string& GetInstanceId() const
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1504 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1505 return instanceId_;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1506 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1507
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1508 const DicomMap& GetMainDicomTags() const
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1509 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1510 return mainDicomTags_;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1511 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1512
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1513 const Json::Value* GetDicomAsJson() const
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1514 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1515 if (dicomAsJson_.type() == Json::nullValue)
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1516 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1517 return NULL;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1518 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1519 else
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1520 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1521 return &dicomAsJson_;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1522 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1523 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1524 };
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1525
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1526 typedef std::map<std::string, Study*> Studies;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1527
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1528 bool isDicomAsJsonNeeded_;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1529 bool complete_;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1530 Studies studies_;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1531
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1532 public:
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4203
diff changeset
1533 explicit ModalitiesInStudyVisitor(bool isDicomAsJsonNeeded) :
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4203
diff changeset
1534 isDicomAsJsonNeeded_(isDicomAsJsonNeeded),
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4203
diff changeset
1535 complete_(false)
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1536 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1537 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1538
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1539 ~ModalitiesInStudyVisitor()
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1540 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1541 for (Studies::const_iterator it = studies_.begin(); it != studies_.end(); ++it)
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1542 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1543 assert(it->second != NULL);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1544 delete it->second;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1545 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1546
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1547 studies_.clear();
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1548 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1549
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4203
diff changeset
1550 virtual bool IsDicomAsJsonNeeded() const ORTHANC_OVERRIDE
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1551 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1552 return isDicomAsJsonNeeded_;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1553 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1554
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4203
diff changeset
1555 virtual void MarkAsComplete() ORTHANC_OVERRIDE
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1556 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1557 complete_ = true;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1558 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1559
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1560 virtual void Visit(const std::string& publicId,
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1561 const std::string& instanceId,
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1562 const DicomMap& seriesTags,
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4203
diff changeset
1563 const Json::Value* dicomAsJson) ORTHANC_OVERRIDE
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1564 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1565 std::string studyInstanceUid;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1566 if (seriesTags.LookupStringValue(studyInstanceUid, DICOM_TAG_STUDY_INSTANCE_UID, false))
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1567 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1568 Studies::iterator found = studies_.find(studyInstanceUid);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1569 if (found == studies_.end())
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1570 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1571 // New study
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1572 std::unique_ptr<Study> study(new Study(instanceId, seriesTags));
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1573
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1574 if (dicomAsJson != NULL)
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1575 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1576 study->SetDicomAsJson(*dicomAsJson);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1577 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1578
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1579 studies_[studyInstanceUid] = study.release();
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1580 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1581 else
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1582 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1583 // Already existing study
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1584 found->second->AddModality(seriesTags);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1585 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1586 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1587 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1588
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1589 void Forward(ILookupVisitor& callerVisitor,
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1590 size_t since,
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1591 size_t limit) const
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4203
diff changeset
1592 {
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1593 size_t index = 0;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1594 size_t countForwarded = 0;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1595
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1596 for (Studies::const_iterator it = studies_.begin(); it != studies_.end(); ++it, index++)
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1597 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1598 if (limit == 0 ||
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1599 (index >= since &&
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1600 index < limit))
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1601 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1602 assert(it->second != NULL);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1603 const Study& study = *it->second;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1604
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1605 countForwarded++;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1606 callerVisitor.Visit(study.GetOrthancId(), study.GetInstanceId(),
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1607 study.GetMainDicomTags(), study.GetDicomAsJson());
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1608 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1609 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1610
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1611 if (countForwarded == studies_.size())
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1612 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1613 callerVisitor.MarkAsComplete();
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1614 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1615 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1616 };
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1617 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1618
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1619
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1620 void ServerContext::Apply(ILookupVisitor& visitor,
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1621 const DatabaseLookup& lookup,
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1622 ResourceType queryLevel,
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1623 size_t since,
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1624 size_t limit)
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1625 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1626 if (queryLevel == ResourceType_Study &&
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1627 lookup.HasTag(DICOM_TAG_MODALITIES_IN_STUDY))
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1628 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1629 // Convert the study-level query, into a series-level query,
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1630 // where "ModalitiesInStudy" is replaced by "Modality"
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1631 DatabaseLookup seriesLookup;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1632
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1633 for (size_t i = 0; i < lookup.GetConstraintsCount(); i++)
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1634 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1635 const DicomTagConstraint& constraint = lookup.GetConstraint(i);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1636 if (constraint.GetTag() == DICOM_TAG_MODALITIES_IN_STUDY)
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1637 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1638 if ((constraint.GetConstraintType() == ConstraintType_Equal && constraint.GetValue().empty()) ||
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1639 (constraint.GetConstraintType() == ConstraintType_List && constraint.GetValues().empty()))
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1640 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1641 // Ignore universal lookup on "ModalitiesInStudy" (0008,0061),
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1642 // this should have been handled by the caller
4218
8e069a7e1c11 validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4205
diff changeset
1643 ApplyInternal(visitor, lookup, queryLevel, since, limit);
8e069a7e1c11 validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4205
diff changeset
1644 return;
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1645 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1646 else
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1647 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1648 DicomTagConstraint modality(constraint);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1649 modality.SetTag(DICOM_TAG_MODALITY);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1650 seriesLookup.AddConstraint(modality);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1651 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1652 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1653 else
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1654 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1655 seriesLookup.AddConstraint(constraint);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1656 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1657 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1658
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1659 ModalitiesInStudyVisitor seriesVisitor(visitor.IsDicomAsJsonNeeded());
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1660 ApplyInternal(seriesVisitor, seriesLookup, ResourceType_Series, 0, 0);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1661 seriesVisitor.Forward(visitor, since, limit);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1662 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1663 else
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1664 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1665 ApplyInternal(visitor, lookup, queryLevel, since, limit);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1666 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1667 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1668
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1669
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1670 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
1671 const std::string& publicId,
4460
6831de40acd9 New metadata automatically computed at the series level: "RemoteAET"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4457
diff changeset
1672 ResourceType level,
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1673 MetadataType metadata)
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1674 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1675 // 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
1676 // 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
1677 // release of Orthanc
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1678
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1679 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
1680 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
1681 {
4623
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1682 int64_t revision; // Ignored
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1683 if (index_.LookupMetadata(target, revision, publicId, level, metadata))
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1684 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1685 return true;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1686 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1687 else
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1688 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1689 // 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
1690 // 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
1691 // "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
1692 // 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
1693
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1694 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
1695
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1696 switch (metadata)
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1697 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1698 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
1699 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
1700 break;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1701
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1702 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
1703 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
1704 break;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1705
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1706 default:
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1707 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
1708 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1709
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1710 Json::Value dicomAsJson;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1711 ReadDicomAsJson(dicomAsJson, publicId);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1712
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1713 DicomMap tags;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1714 tags.FromDicomAsJson(dicomAsJson);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1715
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1716 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
1717
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1718 if (value != NULL &&
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1719 !value->IsNull() &&
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1720 !value->IsBinary())
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1721 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1722 target = value->GetContent();
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1723
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1724 // Store for reuse
4623
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1725 index_.OverwriteMetadata(publicId, metadata, target);
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1726 return true;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1727 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1728 else
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1729 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1730 // Should never happen
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1731 return false;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1732 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1733 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1734 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1735 else
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1736 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1737 // No backward
4623
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1738 int64_t revision; // Ignored
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1739 return index_.LookupMetadata(target, revision, publicId, level, metadata);
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1740 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1741 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1742
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1743
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1744 void ServerContext::AddChildInstances(SetOfInstancesJob& job,
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1745 const std::string& publicId)
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1746 {
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1747 std::list<std::string> instances;
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1748 GetIndex().GetChildInstances(instances, publicId);
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1749
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1750 job.Reserve(job.GetInstancesCount() + instances.size());
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1751
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1752 for (std::list<std::string>::const_iterator
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1753 it = instances.begin(); it != instances.end(); ++it)
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1754 {
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1755 job.AddInstance(*it);
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1756 }
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1757 }
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1758
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1759
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1760 void ServerContext::SignalUpdatedModalities()
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1761 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1762 #if ORTHANC_ENABLE_PLUGINS == 1
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1763 if (HasPlugins())
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1764 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1765 GetPlugins().SignalUpdatedModalities();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1766 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1767 #endif
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1768 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1769
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1770
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1771 void ServerContext::SignalUpdatedPeers()
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1772 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1773 #if ORTHANC_ENABLE_PLUGINS == 1
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1774 if (HasPlugins())
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1775 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1776 GetPlugins().SignalUpdatedPeers();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1777 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1778 #endif
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1779 }
3660
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1780
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1781
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1782 IStorageCommitmentFactory::ILookupHandler*
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1783 ServerContext::CreateStorageCommitment(const std::string& jobId,
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1784 const std::string& transactionUid,
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1785 const std::vector<std::string>& sopClassUids,
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3660
diff changeset
1786 const std::vector<std::string>& sopInstanceUids,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3660
diff changeset
1787 const std::string& remoteAet,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3660
diff changeset
1788 const std::string& calledAet)
3660
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1789 {
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1790 #if ORTHANC_ENABLE_PLUGINS == 1
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1791 if (HasPlugins())
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1792 {
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3660
diff changeset
1793 return GetPlugins().CreateStorageCommitment(
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3660
diff changeset
1794 jobId, transactionUid, sopClassUids, sopInstanceUids, remoteAet, calledAet);
3660
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1795 }
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1796 #endif
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1797
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1798 return NULL;
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1799 }
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1800
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1801
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1802 ImageAccessor* ServerContext::DecodeDicomFrame(const std::string& publicId,
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1803 unsigned int frameIndex)
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1804 {
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1805 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_Before)
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1806 {
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1807 // 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
1808 // things on multi-frame images
4265
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1809
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1810 std::unique_ptr<ImageAccessor> decoded;
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1811 try
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1812 {
4274
09ed936fd381 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
1813 ServerContext::DicomCacheLocker locker(*this, publicId);
4265
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1814 decoded.reset(locker.GetDicom().DecodeFrame(frameIndex));
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1815 }
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1816 catch (OrthancException& e)
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1817 {
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1818 }
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1819
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1820 if (decoded.get() != NULL)
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1821 {
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1822 return decoded.release();
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1823 }
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1824 }
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1825
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1826 #if ORTHANC_ENABLE_PLUGINS == 1
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1827 if (HasPlugins() &&
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1828 GetPlugins().HasCustomImageDecoder())
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1829 {
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1830 // TODO: Store the raw buffer in the DicomCacheLocker
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1831 std::string dicomContent;
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1832 ReadDicom(dicomContent, publicId);
4265
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1833
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1834 std::unique_ptr<ImageAccessor> decoded;
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1835 try
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1836 {
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1837 decoded.reset(GetPlugins().Decode(dicomContent.c_str(), dicomContent.size(), frameIndex));
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1838 }
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1839 catch (OrthancException& e)
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1840 {
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1841 }
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1842
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1843 if (decoded.get() != NULL)
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1844 {
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1845 return decoded.release();
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1846 }
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1847 else if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After)
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1848 {
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1849 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
1850 << "fallback to the built-in DCMTK decoder";
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1851 }
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1852 }
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1853 #endif
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1854
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1855 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After)
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1856 {
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1857 ServerContext::DicomCacheLocker locker(*this, publicId);
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4196
diff changeset
1858 return locker.GetDicom().DecodeFrame(frameIndex);
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1859 }
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1860 else
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1861 {
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1862 return NULL; // Built-in decoder is disabled
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1863 }
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1864 }
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1865
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1866
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1867 ImageAccessor* ServerContext::DecodeDicomFrame(const DicomInstanceToStore& dicom,
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1868 unsigned int frameIndex)
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1869 {
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1870 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_Before)
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1871 {
4265
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1872 std::unique_ptr<ImageAccessor> decoded;
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1873 try
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1874 {
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4506
diff changeset
1875 decoded.reset(dicom.DecodeFrame(frameIndex));
4265
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1876 }
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1877 catch (OrthancException& e)
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1878 {
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1879 }
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1880
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1881 if (decoded.get() != NULL)
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1882 {
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1883 return decoded.release();
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1884 }
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1885 }
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1886
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1887 #if ORTHANC_ENABLE_PLUGINS == 1
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1888 if (HasPlugins() &&
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1889 GetPlugins().HasCustomImageDecoder())
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1890 {
4265
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1891 std::unique_ptr<ImageAccessor> decoded;
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1892 try
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1893 {
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1894 decoded.reset(GetPlugins().Decode(dicom.GetBufferData(), dicom.GetBufferSize(), frameIndex));
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1895 }
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1896 catch (OrthancException& e)
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1897 {
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1898 }
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1899
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1900 if (decoded.get() != NULL)
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1901 {
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1902 return decoded.release();
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1903 }
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1904 else if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After)
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1905 {
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1906 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
1907 << "fallback to the built-in DCMTK decoder";
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1908 }
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1909 }
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1910 #endif
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1911
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1912 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After)
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1913 {
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4506
diff changeset
1914 return dicom.DecodeFrame(frameIndex);
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1915 }
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1916 else
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1917 {
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1918 return NULL;
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1919 }
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1920 }
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1921
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1922
3980
e42f5445d20d Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3951
diff changeset
1923 ImageAccessor* ServerContext::DecodeDicomFrame(const void* dicom,
e42f5445d20d Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3951
diff changeset
1924 size_t size,
e42f5445d20d Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3951
diff changeset
1925 unsigned int frameIndex)
e42f5445d20d Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3951
diff changeset
1926 {
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
1927 std::unique_ptr<DicomInstanceToStore> instance(DicomInstanceToStore::CreateFromBuffer(dicom, size));
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
1928 return DecodeDicomFrame(*instance, frameIndex);
3980
e42f5445d20d Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3951
diff changeset
1929 }
e42f5445d20d Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3951
diff changeset
1930
e42f5445d20d Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3951
diff changeset
1931
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1932 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
1933 std::string& sopInstanceUid,
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1934 DicomStoreUserConnection& connection,
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1935 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
1936 bool hasMoveOriginator,
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1937 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
1938 uint16_t moveOriginatorId)
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1939 {
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1940 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
1941
3911
0ef7f4528be2 renamed option TranscodingEnabled to TranscodeDicomProtocol
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3910
diff changeset
1942 if (!transcodeDicomProtocol_ ||
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1943 !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
1944 {
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1945 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
1946 hasMoveOriginator, moveOriginatorAet, moveOriginatorId);
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1947 }
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1948 else
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1949 {
4465
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
1950 connection.Transcode(sopClassUid, sopInstanceUid, *this, data, dicom.size(), preferredTransferSyntax_,
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
1951 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
1952 }
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1953 }
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3928
diff changeset
1954
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3928
diff changeset
1955
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1956 bool ServerContext::Transcode(DicomImage& target,
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1957 DicomImage& source /* in, "GetParsed()" possibly modified */,
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1958 const std::set<DicomTransferSyntax>& allowedSyntaxes,
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1959 bool allowNewSopInstanceUid)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1960 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1961 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_Before)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1962 {
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3947
diff changeset
1963 if (dcmtkTranscoder_->Transcode(target, source, allowedSyntaxes, allowNewSopInstanceUid))
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1964 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1965 return true;
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1966 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1967 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1968
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1969 #if ORTHANC_ENABLE_PLUGINS == 1
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1970 if (HasPlugins() &&
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1971 GetPlugins().HasCustomTranscoder())
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1972 {
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3947
diff changeset
1973 if (GetPlugins().Transcode(target, source, allowedSyntaxes, allowNewSopInstanceUid))
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1974 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1975 return true;
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1976 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1977 else if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1978 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1979 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
1980 << "fallback to the built-in DCMTK transcoder";
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1981 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1982 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1983 #endif
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1984
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1985 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1986 {
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3947
diff changeset
1987 return dcmtkTranscoder_->Transcode(target, source, allowedSyntaxes, allowNewSopInstanceUid);
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1988 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1989 else
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1990 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1991 return false;
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1992 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1993 }
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
1994
4376
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
1995 const std::string& ServerContext::GetDeidentifiedContent(const DicomElement &element) const
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
1996 {
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
1997 static const std::string redactedContent = "*** POTENTIAL PHI ***";
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
1998
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
1999 const DicomTag& tag = element.GetTag();
4789
51ec061516c9 Fix handling of option "DeidentifyLogs", notably for tags (0010,0010) and (0010,0020)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4752
diff changeset
2000 if (deidentifyLogs_ &&
51ec061516c9 Fix handling of option "DeidentifyLogs", notably for tags (0010,0010) and (0010,0020)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4752
diff changeset
2001 !element.GetValue().GetContent().empty() &&
51ec061516c9 Fix handling of option "DeidentifyLogs", notably for tags (0010,0010) and (0010,0020)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4752
diff changeset
2002 logsDeidentifierRules_.IsAlteredTag(tag))
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2003 {
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2004 return redactedContent;
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2005 }
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2006 else
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2007 {
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2008 return element.GetValue().GetContent();
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2009 }
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2010 }
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2011
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2012
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2013 void ServerContext::GetAcceptedTransferSyntaxes(std::set<DicomTransferSyntax>& syntaxes)
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2014 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2015 boost::mutex::scoped_lock lock(dynamicOptionsMutex_);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2016 syntaxes = acceptedTransferSyntaxes_;
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2017 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2018
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2019
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2020 void ServerContext::SetAcceptedTransferSyntaxes(const std::set<DicomTransferSyntax>& syntaxes)
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2021 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2022 boost::mutex::scoped_lock lock(dynamicOptionsMutex_);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2023 acceptedTransferSyntaxes_ = syntaxes;
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2024 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2025
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2026
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2027 bool ServerContext::IsUnknownSopClassAccepted()
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2028 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2029 boost::mutex::scoped_lock lock(dynamicOptionsMutex_);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2030 return isUnknownSopClassAccepted_;
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2031 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2032
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2033
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2034 void ServerContext::SetUnknownSopClassAccepted(bool accepted)
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2035 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2036 boost::mutex::scoped_lock lock(dynamicOptionsMutex_);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2037 isUnknownSopClassAccepted_ = accepted;
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2038 }
224
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2039 }