annotate OrthancServer/ServerContext.cpp @ 1450:a3efc289ec07

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