Mercurial > hg > orthanc
annotate OrthancServer/ServerContext.cpp @ 1579:b93c398f934d
check the size of the enumerations in the plugin engine
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 25 Aug 2015 15:45:50 +0200 |
parents | 0c29ebe80ac9 |
children | bd1889029cbb |
rev | line source |
---|---|
224 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1285
diff
changeset
|
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics |
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1285
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
224 | 5 * |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
10 * | |
11 * In addition, as a special exception, the copyright holders of this | |
12 * program give permission to link the code of its release with the | |
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
14 * that use the same license as the "OpenSSL" library), and distribute | |
15 * the linked executables. You must obey the GNU General Public License | |
16 * in all respects for all of the code used other than "OpenSSL". If you | |
17 * modify file(s) with this exception, you may extend this exception to | |
18 * your version of the file(s), but you are not obligated to do so. If | |
19 * you do not wish to do so, delete this exception statement from your | |
20 * version. If you delete this exception statement from all source files | |
21 * in the program, then also delete it here. | |
22 * | |
23 * This program is distributed in the hope that it will be useful, but | |
24 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
26 * General Public License for more details. | |
27 * | |
28 * You should have received a copy of the GNU General Public License | |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
30 **/ | |
31 | |
32 | |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
33 #include "PrecompiledHeadersServer.h" |
224 | 34 #include "ServerContext.h" |
35 | |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
36 #include "../Core/FileStorage/StorageAccessor.h" |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
37 #include "../Core/HttpServer/FilesystemHttpSender.h" |
1525 | 38 #include "../Core/HttpServer/HttpStreamTranscoder.h" |
1486
f967bdf8534e
refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1459
diff
changeset
|
39 #include "../Core/Logging.h" |
795 | 40 #include "FromDcmtkBridge.h" |
397
941ea46e9e26
lua filter of new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
41 #include "ServerToolbox.h" |
771 | 42 #include "OrthancInitialization.h" |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
43 |
394
9784f19f7e1b
path relative to configuration path, list of lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
376
diff
changeset
|
44 #include <EmbeddedResources.h> |
794 | 45 #include <dcmtk/dcmdata/dcfilefo.h> |
224 | 46 |
1001
f3929718ea7e
autorouting primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
998
diff
changeset
|
47 |
1065
921532f67770
Lua scripts can invoke system commands, with CallSystem()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1010
diff
changeset
|
48 #include "Scheduler/CallSystemCommand.h" |
1001
f3929718ea7e
autorouting primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
998
diff
changeset
|
49 #include "Scheduler/DeleteInstanceCommand.h" |
1008 | 50 #include "Scheduler/ModifyInstanceCommand.h" |
1001
f3929718ea7e
autorouting primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
998
diff
changeset
|
51 #include "Scheduler/StoreScuCommand.h" |
1007
871c49c9b11d
lua routing is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1006
diff
changeset
|
52 #include "Scheduler/StorePeerCommand.h" |
1010 | 53 #include "OrthancRestApi/OrthancRestApi.h" |
1133 | 54 #include "../Plugins/Engine/OrthancPlugins.h" |
1001
f3929718ea7e
autorouting primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
998
diff
changeset
|
55 |
f3929718ea7e
autorouting primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
998
diff
changeset
|
56 |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
57 #define ENABLE_DICOM_CACHE 1 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
58 |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
59 static const size_t DICOM_CACHE_SIZE = 2; |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
60 |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
61 /** |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
62 * 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
|
63 * 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
|
64 * since the filesystem implements the required locking mechanisms, |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
65 * 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
|
66 * useful. Conversely, "ServerIndex" already implements mutex-based |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
67 * locking. |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
68 **/ |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
69 |
224 | 70 namespace Orthanc |
71 { | |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
72 void ServerContext::ChangeThread(ServerContext* that) |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
73 { |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
74 while (!that->done_) |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
75 { |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
76 std::auto_ptr<IDynamicObject> obj(that->pendingChanges_.Dequeue(100)); |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
77 |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
78 if (obj.get() != NULL) |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
79 { |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
80 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
|
81 |
1456
68827c07e683
fix recursive calls with Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1453
diff
changeset
|
82 boost::recursive_mutex::scoped_lock lock(that->listenersMutex_); |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
83 for (ServerListeners::iterator it = that->listeners_.begin(); |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
84 it != that->listeners_.end(); ++it) |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
85 { |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
86 try |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
87 { |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
88 it->GetListener().SignalChange(change); |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
89 } |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
90 catch (OrthancException& e) |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
91 { |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
92 LOG(ERROR) << "Error in the " << it->GetDescription() |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
93 << " callback while signaling a change: " << e.What(); |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
94 } |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
95 } |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
96 } |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
97 } |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
98 } |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
99 |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
100 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
101 ServerContext::ServerContext(IDatabaseWrapper& database, |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
102 IStorageArea& area) : |
1247 | 103 index_(*this, database), |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
104 area_(area), |
656 | 105 compressionEnabled_(false), |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
106 storeMD5_(true), |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
107 provider_(*this), |
995
8c67382f44a7
limit number of jobs in the scheduler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
942
diff
changeset
|
108 dicomCache_(provider_, DICOM_CACHE_SIZE), |
1066
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1065
diff
changeset
|
109 scheduler_(Configuration::GetGlobalIntegerParameter("LimitJobs", 10)), |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
110 lua_(*this), |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
111 plugins_(NULL), |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
112 done_(false), |
1427
d710ea64f0fd
Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
113 queryRetrieveArchive_(Configuration::GetGlobalIntegerParameter("QueryRetrieveSize", 10)), |
d710ea64f0fd
Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
114 defaultLocalAet_(Configuration::GetGlobalStringParameter("DicomAet", "ORTHANC")) |
224 | 115 { |
1284
21ea32170764
Option "DicomAssociationCloseDelay" to set delay before closing DICOM association
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1273
diff
changeset
|
116 uint64_t s = Configuration::GetGlobalIntegerParameter("DicomAssociationCloseDelay", 5); // In seconds |
21ea32170764
Option "DicomAssociationCloseDelay" to set delay before closing DICOM association
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1273
diff
changeset
|
117 scu_.SetMillisecondsBeforeClose(s * 1000); // Milliseconds are expected here |
774 | 118 |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
119 listeners_.push_back(ServerListener(lua_, "Lua")); |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
120 |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
121 changeThread_ = boost::thread(ChangeThread, this); |
224 | 122 } |
123 | |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
124 |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
125 |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
126 ServerContext::~ServerContext() |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
127 { |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
128 if (!done_) |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
129 { |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
130 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
|
131 Stop(); |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
132 } |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
133 } |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
134 |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
135 |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
136 void ServerContext::Stop() |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
137 { |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
138 if (!done_) |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
139 { |
1459 | 140 { |
141 boost::recursive_mutex::scoped_lock lock(listenersMutex_); | |
142 listeners_.clear(); | |
143 } | |
144 | |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
145 done_ = true; |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
146 |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
147 if (changeThread_.joinable()) |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
148 { |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
149 changeThread_.join(); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
150 } |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
151 |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
152 scu_.Finalize(); |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
153 |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
154 // Do not change the order below! |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
155 scheduler_.Stop(); |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
156 index_.Stop(); |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
157 } |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
158 } |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
159 |
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
160 |
236 | 161 void ServerContext::SetCompressionEnabled(bool enabled) |
162 { | |
163 if (enabled) | |
164 LOG(WARNING) << "Disk compression is enabled"; | |
165 else | |
166 LOG(WARNING) << "Disk compression is disabled"; | |
167 | |
168 compressionEnabled_ = enabled; | |
169 } | |
170 | |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
171 |
1126
bf67431a7383
handling of file content type in IStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1124
diff
changeset
|
172 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
|
173 FileContentType type) |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
174 { |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
175 area_.Remove(fileUuid, type); |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
176 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
177 |
996
cf52f3bcb2b3
clarification of Lua classes wrt multithreading
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
995
diff
changeset
|
178 |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
179 StoreStatus ServerContext::Store(std::string& resultPublicId, |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
180 DicomInstanceToStore& dicom) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
181 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
182 try |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
183 { |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
184 StorageAccessor accessor(area_); |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
185 |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
186 DicomInstanceHasher hasher(dicom.GetSummary()); |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
187 resultPublicId = hasher.HashInstance(); |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
188 |
1574
0c29ebe80ac9
give access to full request origin in ReceivedInstanceFilter (Lua)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1550
diff
changeset
|
189 Json::Value simplifiedTags; |
0c29ebe80ac9
give access to full request origin in ReceivedInstanceFilter (Lua)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1550
diff
changeset
|
190 SimplifyTags(simplifiedTags, dicom.GetJson()); |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
191 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
192 // Test if the instance must be filtered out |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
193 bool accepted = true; |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
194 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
195 { |
1456
68827c07e683
fix recursive calls with Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1453
diff
changeset
|
196 boost::recursive_mutex::scoped_lock lock(listenersMutex_); |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
197 |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
198 for (ServerListeners::iterator it = listeners_.begin(); it != listeners_.end(); ++it) |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
199 { |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
200 try |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
201 { |
1574
0c29ebe80ac9
give access to full request origin in ReceivedInstanceFilter (Lua)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1550
diff
changeset
|
202 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
|
203 { |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
204 accepted = false; |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
205 break; |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
206 } |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
207 } |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
208 catch (OrthancException& e) |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
209 { |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
210 LOG(ERROR) << "Error in the " << it->GetDescription() |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
211 << " callback while receiving an instance: " << e.What(); |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
212 throw; |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
213 } |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
214 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
215 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
216 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
217 if (!accepted) |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
218 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
219 LOG(INFO) << "An incoming instance has been discarded by the filter"; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
220 return StoreStatus_FilteredOut; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
221 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
222 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
223 // TODO Should we use "gzip" instead? |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
224 CompressionType compression = (compressionEnabled_ ? CompressionType_ZlibWithSize : CompressionType_None); |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
225 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
226 FileInfo dicomInfo = accessor.Write(dicom.GetBufferData(), dicom.GetBufferSize(), |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
227 FileContentType_Dicom, compression, storeMD5_); |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
228 FileInfo jsonInfo = accessor.Write(dicom.GetJson().toStyledString(), |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
229 FileContentType_DicomAsJson, compression, storeMD5_); |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
230 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
231 ServerIndex::Attachments attachments; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
232 attachments.push_back(dicomInfo); |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
233 attachments.push_back(jsonInfo); |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
234 |
1067
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
235 typedef std::map<MetadataType, std::string> InstanceMetadata; |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
236 InstanceMetadata instanceMetadata; |
1006
649d47854314
proper handling of metadata in Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1005
diff
changeset
|
237 StoreStatus status = index_.Store(instanceMetadata, dicom.GetSummary(), attachments, |
649d47854314
proper handling of metadata in Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1005
diff
changeset
|
238 dicom.GetRemoteAet(), dicom.GetMetadata()); |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
239 |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
240 // Only keep the metadata for the "instance" level |
1067
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
241 dicom.GetMetadata().clear(); |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
242 |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
243 for (InstanceMetadata::const_iterator it = instanceMetadata.begin(); |
1304 | 244 it != instanceMetadata.end(); ++it) |
1067
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
245 { |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
246 dicom.GetMetadata().insert(std::make_pair(std::make_pair(ResourceType_Instance, it->first), |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
247 it->second)); |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
248 } |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
249 |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
250 if (status != StoreStatus_Success) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
251 { |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
252 accessor.Remove(dicomInfo); |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
253 accessor.Remove(jsonInfo); |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
254 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
255 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
256 switch (status) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
257 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
258 case StoreStatus_Success: |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
259 LOG(INFO) << "New instance stored"; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
260 break; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
261 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
262 case StoreStatus_AlreadyStored: |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
263 LOG(INFO) << "Already stored"; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
264 break; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
265 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
266 case StoreStatus_Failure: |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
267 LOG(ERROR) << "Store failure"; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
268 break; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
269 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
270 default: |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
271 // This should never happen |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
272 break; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
273 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
274 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
275 if (status == StoreStatus_Success || |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
276 status == StoreStatus_AlreadyStored) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
277 { |
1456
68827c07e683
fix recursive calls with Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1453
diff
changeset
|
278 boost::recursive_mutex::scoped_lock lock(listenersMutex_); |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1447
diff
changeset
|
279 |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
280 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
|
281 { |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1065
diff
changeset
|
282 try |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1065
diff
changeset
|
283 { |
1574
0c29ebe80ac9
give access to full request origin in ReceivedInstanceFilter (Lua)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1550
diff
changeset
|
284 it->GetListener().SignalStoredInstance(resultPublicId, dicom, simplifiedTags); |
1066
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1065
diff
changeset
|
285 } |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1065
diff
changeset
|
286 catch (OrthancException& e) |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1065
diff
changeset
|
287 { |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
288 LOG(ERROR) << "Error in the " << it->GetDescription() |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
289 << " callback while receiving an instance: " << e.What(); |
1066
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1065
diff
changeset
|
290 } |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1065
diff
changeset
|
291 } |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
292 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
293 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
294 return status; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
295 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
296 catch (OrthancException& e) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
297 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
298 if (e.GetErrorCode() == ErrorCode_InexistentTag) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
299 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
300 LogMissingRequiredTag(dicom.GetSummary()); |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
301 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
302 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
303 throw; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
304 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
305 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
306 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
307 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
308 |
1146
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
309 void ServerContext::AnswerAttachment(RestApiOutput& output, |
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
310 const std::string& instancePublicId, |
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
311 FileContentType content) |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
312 { |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
227
diff
changeset
|
313 FileInfo attachment; |
236 | 314 if (!index_.LookupAttachment(attachment, instancePublicId, content)) |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
227
diff
changeset
|
315 { |
236 | 316 throw OrthancException(ErrorCode_InternalError); |
317 } | |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
318 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
319 StorageAccessor accessor(area_); |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
320 accessor.AnswerFile(output, attachment); |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
321 } |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
322 |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
323 |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
324 void ServerContext::ReadJson(Json::Value& result, |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
325 const std::string& instancePublicId) |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
326 { |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
327 std::string s; |
697
dd1ce9a2844c
access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
696
diff
changeset
|
328 ReadFile(s, instancePublicId, FileContentType_DicomAsJson); |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
329 |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
330 Json::Reader reader; |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
331 if (!reader.parse(s, result)) |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
332 { |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
333 throw OrthancException("Corrupted JSON file"); |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
334 } |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
335 } |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
336 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
337 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
338 void ServerContext::ReadFile(std::string& result, |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
339 const std::string& instancePublicId, |
697
dd1ce9a2844c
access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
696
diff
changeset
|
340 FileContentType content, |
dd1ce9a2844c
access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
696
diff
changeset
|
341 bool uncompressIfNeeded) |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
342 { |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
227
diff
changeset
|
343 FileInfo attachment; |
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
227
diff
changeset
|
344 if (!index_.LookupAttachment(attachment, instancePublicId, content)) |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
345 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
346 throw OrthancException(ErrorCode_InternalError); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
347 } |
1550 | 348 |
349 if (uncompressIfNeeded) | |
350 { | |
351 StorageAccessor accessor(area_); | |
352 accessor.Read(result, attachment); | |
353 } | |
354 else | |
355 { | |
356 // Do not interpret the content of the storage area, return the | |
357 // raw data | |
358 area_.Read(result, attachment.GetUuid(), content); | |
359 } | |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
360 } |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
361 |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
362 |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
363 IDynamicObject* ServerContext::DicomCacheProvider::Provide(const std::string& instancePublicId) |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
364 { |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
365 std::string content; |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
366 context_.ReadFile(content, instancePublicId, FileContentType_Dicom); |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
367 return new ParsedDicomFile(content); |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
368 } |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
369 |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
370 |
778
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
371 ServerContext::DicomCacheLocker::DicomCacheLocker(ServerContext& that, |
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
372 const std::string& instancePublicId) : |
1129
8dabdc0d3007
fix possible deadlock
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1126
diff
changeset
|
373 that_(that), |
8dabdc0d3007
fix possible deadlock
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1126
diff
changeset
|
374 lock_(that_.dicomCacheMutex_) |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
375 { |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
376 #if ENABLE_DICOM_CACHE == 0 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
377 static std::auto_ptr<IDynamicObject> p; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
378 p.reset(provider_.Provide(instancePublicId)); |
778
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
379 dicom_ = dynamic_cast<ParsedDicomFile*>(p.get()); |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
380 #else |
778
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
381 dicom_ = &dynamic_cast<ParsedDicomFile&>(that_.dicomCache_.Access(instancePublicId)); |
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
382 #endif |
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
383 } |
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
384 |
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
385 |
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
386 ServerContext::DicomCacheLocker::~DicomCacheLocker() |
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
774
diff
changeset
|
387 { |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
388 } |
304 | 389 |
390 | |
695
c59bc408fb10
parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
391 void ServerContext::SetStoreMD5ForAttachments(bool storeMD5) |
c59bc408fb10
parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
392 { |
c59bc408fb10
parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
393 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
|
394 storeMD5_ = storeMD5; |
695
c59bc408fb10
parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
395 } |
c59bc408fb10
parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
396 |
699
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
397 |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
398 bool ServerContext::AddAttachment(const std::string& resourceId, |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
399 FileContentType attachmentType, |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
400 const void* data, |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
401 size_t size) |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
402 { |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
403 LOG(INFO) << "Adding attachment " << EnumerationToString(attachmentType) << " to resource " << resourceId; |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
404 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
405 // TODO Should we use "gzip" instead? |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
406 CompressionType compression = (compressionEnabled_ ? CompressionType_ZlibWithSize : CompressionType_None); |
699
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
407 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
408 StorageAccessor accessor(area_); |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
409 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
|
410 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
411 StoreStatus status = index_.AddAttachment(attachment, resourceId); |
699
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
412 if (status != StoreStatus_Success) |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
413 { |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
414 accessor.Remove(attachment); |
699
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
415 return false; |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
416 } |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
417 else |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
418 { |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
419 return true; |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
420 } |
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
697
diff
changeset
|
421 } |
1145
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
422 |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
423 |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
424 bool ServerContext::DeleteResource(Json::Value& target, |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
425 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
|
426 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
|
427 { |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
428 return index_.DeleteResource(target, uuid, expectedType); |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
429 } |
1189
6b9b02a16e99
NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1165
diff
changeset
|
430 |
6b9b02a16e99
NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1165
diff
changeset
|
431 |
1198 | 432 void ServerContext::SignalChange(const ServerIndexChange& change) |
1189
6b9b02a16e99
NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1165
diff
changeset
|
433 { |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
434 pendingChanges_.Enqueue(change.Clone()); |
1189
6b9b02a16e99
NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1165
diff
changeset
|
435 } |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
436 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
437 |
1434
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
438 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
|
439 { |
1459 | 440 boost::recursive_mutex::scoped_lock lock(listenersMutex_); |
441 | |
1434
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
442 plugins_ = &plugins; |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
443 |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
444 // TODO REFACTOR THIS |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
445 listeners_.clear(); |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
446 listeners_.push_back(ServerListener(lua_, "Lua")); |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
447 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
|
448 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
449 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
450 |
1434
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
451 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
|
452 { |
1459 | 453 boost::recursive_mutex::scoped_lock lock(listenersMutex_); |
454 | |
1434
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
455 plugins_ = NULL; |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
456 |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
457 // TODO REFACTOR THIS |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
458 listeners_.clear(); |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
459 listeners_.push_back(ServerListener(lua_, "Lua")); |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
460 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
461 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
462 |
1434
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
463 bool ServerContext::HasPlugins() const |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
464 { |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
465 return (plugins_ != NULL); |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
466 } |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
467 |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
468 |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
469 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
|
470 { |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
471 if (HasPlugins()) |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
472 { |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
473 return *plugins_; |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
474 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
475 else |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
476 { |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
477 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
|
478 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1198
diff
changeset
|
479 } |
224 | 480 } |