comparison OrthancServer/Sources/ServerContext.h @ 4899:3ab57510f6dd proto-filter-instance-returning-error-code

integration mainline->proto-filter-instance-returning-error-code
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 20 Feb 2022 12:59:30 +0100
parents 6eff25f70121
children 309fb4f02704
comparison
equal deleted inserted replaced
4791:656784ac6759 4899:3ab57510f6dd
1 /** 1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store 2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium 4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium 5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
6 * 7 *
7 * This program is free software: you can redistribute it and/or 8 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation, either version 3 of the 10 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version. 11 * License, or (at your option) any later version.
11 *
12 * In addition, as a special exception, the copyright holders of this
13 * program give permission to link the code of its release with the
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
15 * that use the same license as the "OpenSSL" library), and distribute
16 * the linked executables. You must obey the GNU General Public License
17 * in all respects for all of the code used other than "OpenSSL". If you
18 * modify file(s) with this exception, you may extend this exception to
19 * your version of the file(s), but you are not obligated to do so. If
20 * you do not wish to do so, delete this exception statement from your
21 * version. If you delete this exception statement from all source files
22 * in the program, then also delete it here.
23 * 12 *
24 * This program is distributed in the hope that it will be useful, but 13 * This program is distributed in the hope that it will be useful, but
25 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * General Public License for more details. 16 * General Public License for more details.
41 30
42 #include "../../OrthancFramework/Sources/DicomFormat/DicomElement.h" 31 #include "../../OrthancFramework/Sources/DicomFormat/DicomElement.h"
43 #include "../../OrthancFramework/Sources/DicomParsing/DicomModification.h" 32 #include "../../OrthancFramework/Sources/DicomParsing/DicomModification.h"
44 #include "../../OrthancFramework/Sources/DicomParsing/IDicomTranscoder.h" 33 #include "../../OrthancFramework/Sources/DicomParsing/IDicomTranscoder.h"
45 #include "../../OrthancFramework/Sources/DicomParsing/ParsedDicomCache.h" 34 #include "../../OrthancFramework/Sources/DicomParsing/ParsedDicomCache.h"
35 #include "../../OrthancFramework/Sources/FileStorage/StorageCache.h"
46 #include "../../OrthancFramework/Sources/MultiThreading/Semaphore.h" 36 #include "../../OrthancFramework/Sources/MultiThreading/Semaphore.h"
47 37
48 38
49 namespace Orthanc 39 namespace Orthanc
50 { 40 {
91 const std::string& instanceId, 81 const std::string& instanceId,
92 const DicomMap& mainDicomTags, 82 const DicomMap& mainDicomTags,
93 const Json::Value* dicomAsJson) = 0; 83 const Json::Value* dicomAsJson) = 0;
94 }; 84 };
95 85
86 struct StoreResult
87 {
88 private:
89 StoreStatus status_;
90 uint16_t cstoreStatusCode_;
91 // uint16_t httpStatusCode_; // for future use
92
93 public:
94 StoreResult();
95
96 void SetStatus(StoreStatus status)
97 {
98 status_ = status;
99 }
100
101 StoreStatus GetStatus()
102 {
103 return status_;
104 }
105
106 void SetCStoreStatusCode(uint16_t statusCode)
107 {
108 cstoreStatusCode_ = statusCode;
109 }
110
111 uint16_t GetCStoreStatusCode()
112 {
113 return cstoreStatusCode_;
114 }
115 };
96 116
97 private: 117 private:
98 class LuaServerListener : public IServerListener 118 class LuaServerListener : public IServerListener
99 { 119 {
100 private: 120 private:
120 140
121 virtual bool FilterIncomingInstance(const DicomInstanceToStore& instance, 141 virtual bool FilterIncomingInstance(const DicomInstanceToStore& instance,
122 const Json::Value& simplified) ORTHANC_OVERRIDE 142 const Json::Value& simplified) ORTHANC_OVERRIDE
123 { 143 {
124 return context_.filterLua_.FilterIncomingInstance(instance, simplified); 144 return context_.filterLua_.FilterIncomingInstance(instance, simplified);
145 }
146
147 virtual uint16_t FilterIncomingCStoreInstance(const DicomInstanceToStore& instance,
148 const Json::Value& simplified) ORTHANC_OVERRIDE
149 {
150 return context_.filterLua_.FilterIncomingCStoreInstance(instance, simplified);
125 } 151 }
126 }; 152 };
127 153
128 class ServerListener 154 class ServerListener
129 { 155 {
167 193
168 virtual void SignalJobFailure(const std::string& jobId) ORTHANC_OVERRIDE; 194 virtual void SignalJobFailure(const std::string& jobId) ORTHANC_OVERRIDE;
169 195
170 ServerIndex index_; 196 ServerIndex index_;
171 IStorageArea& area_; 197 IStorageArea& area_;
198 StorageCache storageCache_;
172 199
173 bool compressionEnabled_; 200 bool compressionEnabled_;
174 bool storeMD5_; 201 bool storeMD5_;
175 202
176 Semaphore largeDicomThrottler_; // New in Orthanc 1.9.0 (notably for very large DICOM files in WSI) 203 Semaphore largeDicomThrottler_; // New in Orthanc 1.9.0 (notably for very large DICOM files in WSI)
229 DicomTransferSyntax preferredTransferSyntax_; 256 DicomTransferSyntax preferredTransferSyntax_;
230 boost::mutex dynamicOptionsMutex_; 257 boost::mutex dynamicOptionsMutex_;
231 bool isUnknownSopClassAccepted_; 258 bool isUnknownSopClassAccepted_;
232 std::set<DicomTransferSyntax> acceptedTransferSyntaxes_; 259 std::set<DicomTransferSyntax> acceptedTransferSyntaxes_;
233 260
234 StoreStatus StoreAfterTranscoding(std::string& resultPublicId, 261 StoreResult StoreAfterTranscoding(std::string& resultPublicId,
235 DicomInstanceToStore& dicom, 262 DicomInstanceToStore& dicom,
236 StoreInstanceMode mode); 263 StoreInstanceMode mode);
237 264
238 void ApplyInternal(ILookupVisitor& visitor, 265 void ApplyInternal(ILookupVisitor& visitor,
239 const DatabaseLookup& lookup, 266 const DatabaseLookup& lookup,
284 bool loadJobsFromDatabase); 311 bool loadJobsFromDatabase);
285 312
286 ServerIndex& GetIndex() 313 ServerIndex& GetIndex()
287 { 314 {
288 return index_; 315 return index_;
316 }
317
318 void SetMaximumStorageCacheSize(size_t size)
319 {
320 return storageCache_.SetMaximumSize(size);
289 } 321 }
290 322
291 void SetCompressionEnabled(bool enabled); 323 void SetCompressionEnabled(bool enabled);
292 324
293 bool IsCompressionEnabled() const 325 bool IsCompressionEnabled() const
302 size_t size, 334 size_t size,
303 bool hasOldRevision, 335 bool hasOldRevision,
304 int64_t oldRevision, 336 int64_t oldRevision,
305 const std::string& oldMD5); 337 const std::string& oldMD5);
306 338
307 StoreStatus Store(std::string& resultPublicId, 339 StoreResult Store(std::string& resultPublicId,
308 DicomInstanceToStore& dicom, 340 DicomInstanceToStore& dicom,
309 StoreInstanceMode mode); 341 StoreInstanceMode mode);
310 342
311 void AnswerAttachment(RestApiOutput& output, 343 void AnswerAttachment(RestApiOutput& output,
312 const std::string& resourceId, 344 const std::string& resourceId,
323 void ReadDicomAsJson(Json::Value& result, 355 void ReadDicomAsJson(Json::Value& result,
324 const std::string& instancePublicId); 356 const std::string& instancePublicId);
325 357
326 void ReadDicom(std::string& dicom, 358 void ReadDicom(std::string& dicom,
327 const std::string& instancePublicId); 359 const std::string& instancePublicId);
328 360
361 void ReadDicomForHeader(std::string& dicom,
362 const std::string& instancePublicId);
363
329 bool ReadDicomUntilPixelData(std::string& dicom, 364 bool ReadDicomUntilPixelData(std::string& dicom,
330 const std::string& instancePublicId); 365 const std::string& instancePublicId);
331 366
332 // This method is for low-level operations on "/instances/.../attachments/..." 367 // This method is for low-level operations on "/instances/.../attachments/..."
333 void ReadAttachment(std::string& result, 368 void ReadAttachment(std::string& result,