Mercurial > hg > orthanc
annotate OrthancServer/Plugins/Samples/MultitenantDicom/Plugin.cpp @ 5408:095c59b52f04
todo
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 07 Nov 2023 08:31:43 +0100 |
parents | 94a52168480b |
children | 48b8dae6dc77 |
rev | line source |
---|---|
5273
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
5371
a8385880902f
fix incorrect license for MultitenantDicom plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5277
diff
changeset
|
9 * modify it under the terms of the GNU General Public License as |
a8385880902f
fix incorrect license for MultitenantDicom plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5277
diff
changeset
|
10 * published by the Free Software Foundation, either version 3 of the |
a8385880902f
fix incorrect license for MultitenantDicom plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5277
diff
changeset
|
11 * License, or (at your option) any later version. |
5273
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5371
a8385880902f
fix incorrect license for MultitenantDicom plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5277
diff
changeset
|
16 * General Public License for more details. |
5273
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
5371
a8385880902f
fix incorrect license for MultitenantDicom plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5277
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
a8385880902f
fix incorrect license for MultitenantDicom plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5277
diff
changeset
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
5273
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #include "MultitenantDicomServer.h" |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include "../../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 #include "../../../../OrthancFramework/Sources/Logging.h" |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 #include "../../../../OrthancFramework/Sources/OrthancException.h" |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 #include "../Common/OrthancPluginCppWrapper.h" |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 typedef std::list<MultitenantDicomServer*> DicomServers; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 static DicomServers dicomServers_; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 static OrthancPluginErrorCode OnChangeCallback(OrthancPluginChangeType changeType, |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 OrthancPluginResourceType resourceType, |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 const char* resourceId) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 switch (changeType) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 case OrthancPluginChangeType_OrthancStarted: |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 for (DicomServers::iterator it = dicomServers_.begin(); it != dicomServers_.end(); ++it) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 if (*it != NULL) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 try |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 (*it)->Start(); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 catch (Orthanc::OrthancException& e) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 LOG(ERROR) << "Exception while stopping the multitenant DICOM server: " << e.What(); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 break; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 case OrthancPluginChangeType_OrthancStopped: |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 for (DicomServers::iterator it = dicomServers_.begin(); it != dicomServers_.end(); ++it) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 if (*it != NULL) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 try |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 (*it)->Stop(); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 catch (Orthanc::OrthancException& e) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 LOG(ERROR) << "Exception while stopping the multitenant DICOM server: " << e.What(); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 break; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 default: |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 break; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 return OrthancPluginErrorCode_Success; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 extern "C" |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 OrthancPlugins::SetGlobalContext(context); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 /* Check the version of the Orthanc core */ |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 if (OrthancPluginCheckVersion(OrthancPlugins::GetGlobalContext()) == 0) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 char info[1024]; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin", |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 OrthancPlugins::GetGlobalContext()->orthancVersion, |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 OrthancPluginLogError(OrthancPlugins::GetGlobalContext(), info); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 return -1; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 #if ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 7, 2) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 Orthanc::Logging::InitializePluginContext(context); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 #else |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 Orthanc::Logging::Initialize(context); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 #endif |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 if (!OrthancPlugins::CheckMinimalOrthancVersion(1, 12, 0)) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 OrthancPlugins::ReportMinimalOrthancVersion(1, 12, 0); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 return -1; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 |
5372
94a52168480b
Fix loading of DCMTK dictionary in the MultitenantDicom plugin when built dynamically
Alain Mazy <am@osimis.io>
parents:
5371
diff
changeset
|
122 // For static builds, this is not required - but does not harm - because the dictionary seems to be shared between the Orthanc Core and the plugin. |
94a52168480b
Fix loading of DCMTK dictionary in the MultitenantDicom plugin when built dynamically
Alain Mazy <am@osimis.io>
parents:
5371
diff
changeset
|
123 // For dynamic builds, this is however required. See https://discourse.orthanc-server.org/t/dimse-failure-using-multitenant-plugin/3665 |
94a52168480b
Fix loading of DCMTK dictionary in the MultitenantDicom plugin when built dynamically
Alain Mazy <am@osimis.io>
parents:
5371
diff
changeset
|
124 Orthanc::FromDcmtkBridge::InitializeDictionary(false /* loadPrivateDictionary */); |
94a52168480b
Fix loading of DCMTK dictionary in the MultitenantDicom plugin when built dynamically
Alain Mazy <am@osimis.io>
parents:
5371
diff
changeset
|
125 |
5273
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 /* Disable "gethostbyaddr" (which results in memory leaks) and use raw IP addresses */ |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 dcmDisableGethostbyaddr.set(OFTrue); |
5277 | 128 |
5273
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 OrthancPluginSetDescription(context, "Multitenant plugin for Orthanc."); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 try |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 OrthancPlugins::OrthancConfiguration globalConfig; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 OrthancPlugins::OrthancConfiguration pluginConfig; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 globalConfig.GetSection(pluginConfig, KEY_MULTITENANT_DICOM); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 if (pluginConfig.GetJson().isMember(KEY_SERVERS)) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 const Json::Value& servers = pluginConfig.GetJson() [KEY_SERVERS]; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 if (servers.type() != Json::arrayValue) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadParameterType, "Configuration option \"" + |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 std::string(KEY_MULTITENANT_DICOM) + "." + std::string(KEY_SERVERS) + "\" must be an array"); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 else |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 for (Json::Value::ArrayIndex i = 0; i < servers.size(); i++) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 dicomServers_.push_back(new MultitenantDicomServer(servers[i])); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 return 0; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 catch (Orthanc::OrthancException& e) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 LOG(ERROR) << "Exception while starting the multitenant DICOM server: " << e.What(); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 return -1; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 ORTHANC_PLUGINS_API void OrthancPluginFinalize() |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 for (DicomServers::iterator it = dicomServers_.begin(); it != dicomServers_.end(); ++it) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 if (*it != NULL) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 try |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 delete *it; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 catch (Orthanc::OrthancException& e) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 LOG(ERROR) << "Exception while destroying the multitenant DICOM server: " << e.What(); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 return "multitenant-dicom"; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 return ORTHANC_PLUGIN_VERSION; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 } |