Mercurial > hg > orthanc-stone
annotate Applications/StoneWebViewer/Plugin/Plugin.cpp @ 2177:4d21befb1501 default tip
clarify DICOMweb version check
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 Oct 2024 19:27:56 +0200 |
parents | c4df20981eb1 |
children |
rev | line source |
---|---|
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
2124
16c01cc201e7
updated copyright, as Osimis is not active on Orthanc anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2121
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
2114
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * modify it under the terms of the GNU Affero General Public License |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * the License, or (at your option) any later version. |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * Affero General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
17 * |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU Affero General Public License |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
1877
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
23 #include "../../../RenderingPlugin/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" |
1508
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1500
diff
changeset
|
24 |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include <EmbeddedResources.h> |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
1627 | 27 #include <Logging.h> |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 #include <SystemToolbox.h> |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 #include <Toolbox.h> |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 |
2177
4d21befb1501
clarify DICOMweb version check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
31 #include <boost/algorithm/string/predicate.hpp> |
4d21befb1501
clarify DICOMweb version check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
32 |
1713
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
33 |
1727
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
34 static const std::string STONE_WEB_VIEWER_ROOT = "/stone-webviewer"; // (*) |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
35 static const char* CONFIG_SECTION = "StoneWebViewer"; |
1713
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
36 |
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
37 |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 OrthancPluginErrorCode OnChangeCallback(OrthancPluginChangeType changeType, |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 OrthancPluginResourceType resourceType, |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 const char* resourceId) |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 try |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 if (changeType == OrthancPluginChangeType_OrthancStarted) |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 Json::Value info; |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 if (!OrthancPlugins::RestApiGet(info, "/plugins/dicom-web", false)) |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 throw Orthanc::OrthancException( |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 Orthanc::ErrorCode_InternalError, |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 "The Stone Web viewer requires the DICOMweb plugin to be installed"); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 if (info.type() != Json::objectValue || |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 !info.isMember("ID") || |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 !info.isMember("Version") || |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 info["ID"].type() != Json::stringValue || |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 info["Version"].type() != Json::stringValue || |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 info["ID"].asString() != "dicom-web") |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 "The DICOMweb plugin is not properly installed"); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 std::string version = info["Version"].asString(); |
2177
4d21befb1501
clarify DICOMweb version check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
66 if (version == "mainline" || |
4d21befb1501
clarify DICOMweb version check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
67 boost::starts_with(version, "mainline-")) // Allow DICOMweb versions such as "mainline-commitId" |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 std::vector<std::string> tokens; |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 Orthanc::Toolbox::TokenizeString(tokens, version, '.'); |
1960
40f8009ceb4e
added compatibility against release 1.10.1 of the DICOMweb plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
71 if (tokens.size() != 2 && |
40f8009ceb4e
added compatibility against release 1.10.1 of the DICOMweb plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
72 tokens.size() != 3) |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 "Bad version of the DICOMweb plugin: " + version); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 int major, minor; |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 try |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 major = boost::lexical_cast<int>(tokens[0]); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 minor = boost::lexical_cast<int>(tokens[1]); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 catch (boost::bad_lexical_cast&) |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 "Bad version of the DICOMweb plugin: " + version); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 if (major <= 0 || |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 (major == 1 && minor <= 1)) |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 throw Orthanc::OrthancException( |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 Orthanc::ErrorCode_InternalError, |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 "The Stone Web viewer requires DICOMweb plugin with version >= 1.2, found: " + version); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 if (major <= 0 || |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 (major == 1 && minor == 2)) |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 /** |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 * DICOMweb 1.3 is better than 1.2 for 2 reasons: (1) |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 * MONOCHROME1 images are not properly rendered in DICOMweb |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 * 1.2, and (2) DICOMweb 1.2 cannot transcode images (this |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 * causes issues on JPEG2k images). |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 **/ |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 LOG(WARNING) << "The Stone Web viewer has some incompatibilities " |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 << "with DICOMweb plugin 1.2, consider upgrading the DICOMweb plugin"; |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 catch (Orthanc::OrthancException& e) |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 LOG(ERROR) << "Exception: " << e.What(); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode()); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 return OrthancPluginErrorCode_Success; |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 template <enum Orthanc::EmbeddedResources::DirectoryResourceId folder> |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 void ServeEmbeddedFolder(OrthancPluginRestOutput* output, |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 const char* url, |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 const OrthancPluginHttpRequest* request) |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 OrthancPluginContext* context = OrthancPlugins::GetGlobalContext(); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 if (request->method != OrthancPluginHttpMethod_Get) |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 OrthancPluginSendMethodNotAllowed(context, output, "GET"); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 else |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 std::string path = "/" + std::string(request->groups[0]); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 const char* mime = Orthanc::EnumerationToString(Orthanc::SystemToolbox::AutodetectMimeType(path)); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 std::string s; |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 Orthanc::EmbeddedResources::GetDirectoryResource(s, folder, path.c_str()); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 const char* resource = s.size() ? s.c_str() : NULL; |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 OrthancPluginAnswerBuffer(context, output, resource, s.size(), mime); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 template <enum Orthanc::EmbeddedResources::FileResourceId file> |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 void ServeEmbeddedFile(OrthancPluginRestOutput* output, |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 const char* url, |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 const OrthancPluginHttpRequest* request) |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 OrthancPluginContext* context = OrthancPlugins::GetGlobalContext(); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 if (request->method != OrthancPluginHttpMethod_Get) |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 OrthancPluginSendMethodNotAllowed(context, output, "GET"); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 else |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 const char* mime = Orthanc::EnumerationToString(Orthanc::SystemToolbox::AutodetectMimeType(url)); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 std::string s; |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 Orthanc::EmbeddedResources::GetFileResource(s, file); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 const char* resource = s.size() ? s.c_str() : NULL; |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 OrthancPluginAnswerBuffer(context, output, resource, s.size(), mime); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 |
1727
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
173 static void GetDefaultConfiguration(Json::Value& target) |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
174 { |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
175 std::string s; |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
176 Orthanc::EmbeddedResources::GetDirectoryResource( |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
177 s, Orthanc::EmbeddedResources::WEB_APPLICATION, "/configuration.json"); |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
178 |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
179 Json::Value full; |
1737
ef2f56c0311c
remove calls to deprecated classes of JsonCpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1727
diff
changeset
|
180 if (!Orthanc::Toolbox::ReadJson(full, s) || |
1727
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
181 full.type() != Json::objectValue || |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
182 !full.isMember(CONFIG_SECTION) || |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
183 full[CONFIG_SECTION].type() != Json::objectValue) |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
184 { |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
185 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat, |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
186 "Cannot read the default configuration"); |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
187 } |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
188 |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
189 Orthanc::Toolbox::CopyJsonWithoutComments(target, full); |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
190 } |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
191 |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
192 |
1700
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
193 void ServeConfiguration(OrthancPluginRestOutput* output, |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
194 const char* url, |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
195 const OrthancPluginHttpRequest* request) |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
196 { |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
197 OrthancPluginContext* context = OrthancPlugins::GetGlobalContext(); |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
198 |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
199 if (request->method != OrthancPluginHttpMethod_Get) |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
200 { |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
201 OrthancPluginSendMethodNotAllowed(context, output, "GET"); |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
202 } |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
203 else |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
204 { |
1713
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
205 static const char* ORTHANC_API_ROOT = "OrthancApiRoot"; |
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
206 static const char* DICOM_WEB_ROOT = "DicomWebRoot"; |
1727
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
207 static const char* EXPECTED_MESSAGE_ORIGIN = "ExpectedMessageOrigin"; |
1700
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
208 |
1727
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
209 Json::Value defaultConfig; |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
210 GetDefaultConfiguration(defaultConfig); |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
211 defaultConfig[CONFIG_SECTION][EXPECTED_MESSAGE_ORIGIN] = ""; // By default, disable messages for security |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
212 |
1709
2931f5e15320
download study from Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1700
diff
changeset
|
213 Json::Value config = Json::objectValue; |
1700
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
214 |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
215 OrthancPlugins::OrthancConfiguration orthanc; |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
216 if (orthanc.IsSection(CONFIG_SECTION)) |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
217 { |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
218 OrthancPlugins::OrthancConfiguration section(false); |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
219 orthanc.GetSection(section, CONFIG_SECTION); |
1709
2931f5e15320
download study from Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1700
diff
changeset
|
220 config[CONFIG_SECTION] = section.GetJson(); |
1700
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
221 } |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
222 else |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
223 { |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
224 LOG(WARNING) << "The Orthanc configuration file doesn't contain a section \"" |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
225 << CONFIG_SECTION << "\" to configure the Stone Web viewer: " |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
226 << "Will use default settings"; |
1727
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
227 config = defaultConfig; |
1700
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
228 } |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
229 |
1713
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
230 assert(config[CONFIG_SECTION].type() == Json::objectValue); |
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
231 |
1727
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
232 // Assume that the Stone Web viewer is mapped at "/stone-webviewer" in the REST API (*) |
1713
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
233 config[CONFIG_SECTION][ORTHANC_API_ROOT] = ".."; |
1709
2931f5e15320
download study from Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1700
diff
changeset
|
234 |
1713
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
235 if (!config[CONFIG_SECTION].isMember(DICOM_WEB_ROOT)) |
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
236 { |
1727
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
237 config[CONFIG_SECTION][DICOM_WEB_ROOT] = "../dicom-web"; // (*) |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
238 } |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
239 |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
240 |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
241 // Copy the default values for the missing options |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
242 std::vector<std::string> defaultOptions = defaultConfig[CONFIG_SECTION].getMemberNames(); |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
243 |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
244 for (size_t i = 0; i < defaultOptions.size(); i++) |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
245 { |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
246 if (!config[CONFIG_SECTION].isMember(defaultOptions[i])) |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
247 { |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
248 config[CONFIG_SECTION][defaultOptions[i]] = defaultConfig[CONFIG_SECTION][defaultOptions[i]]; |
c6139e08132b
the plugin sets the default value for all the configuration options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
249 } |
1713
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
250 } |
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
251 |
1709
2931f5e15320
download study from Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1700
diff
changeset
|
252 const std::string s = config.toStyledString(); |
2931f5e15320
download study from Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1700
diff
changeset
|
253 OrthancPluginAnswerBuffer(context, output, s.c_str(), s.size(), "application/json"); |
1700
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
254 } |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
255 } |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
256 |
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
257 |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
258 extern "C" |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
260 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
261 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
262 OrthancPlugins::SetGlobalContext(context); |
1500
6e832ff72a5e
improved Orthanc::Logging::Initialize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1495
diff
changeset
|
263 |
1530 | 264 #if ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 7, 2) |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 Orthanc::Logging::InitializePluginContext(context); |
1500
6e832ff72a5e
improved Orthanc::Logging::Initialize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1495
diff
changeset
|
266 #else |
6e832ff72a5e
improved Orthanc::Logging::Initialize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1495
diff
changeset
|
267 Orthanc::Logging::Initialize(context); |
6e832ff72a5e
improved Orthanc::Logging::Initialize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1495
diff
changeset
|
268 #endif |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
269 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 /* Check the version of the Orthanc core */ |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
271 if (OrthancPluginCheckVersion(context) == 0) |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
272 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
273 char info[1024]; |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
274 sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin", |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
275 context->orthancVersion, |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
276 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
277 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
278 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
279 OrthancPluginLogError(context, info); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
280 return -1; |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
281 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
282 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
283 try |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
284 { |
2119
11bc8a304038
fix deprecated calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2118
diff
changeset
|
285 OrthancPlugins::SetDescription(PLUGIN_NAME, "Stone Web viewer"); |
2118
7926c9a09757
added description to plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2114
diff
changeset
|
286 |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
287 std::string explorer; |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
288 Orthanc::EmbeddedResources::GetFileResource( |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
289 explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER); |
2121 | 290 OrthancPlugins::ExtendOrthancExplorer(PLUGIN_NAME, explorer); |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
291 |
1700
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
292 OrthancPlugins::RegisterRestCallback<ServeConfiguration> |
1713
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
293 (STONE_WEB_VIEWER_ROOT + "/configuration.json", true); |
1700
f1bd464dc3e1
the plugin uses the Orthanc configuration instead of the default configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1627
diff
changeset
|
294 |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
295 OrthancPlugins::RegisterRestCallback |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
296 <ServeEmbeddedFile<Orthanc::EmbeddedResources::STONE_WEB_VIEWER_WASM> > |
1713
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
297 (STONE_WEB_VIEWER_ROOT + "/StoneWebViewer.wasm", true); |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
298 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
299 OrthancPlugins::RegisterRestCallback |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
300 <ServeEmbeddedFile<Orthanc::EmbeddedResources::STONE_WEB_VIEWER_JS> > |
1713
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
301 (STONE_WEB_VIEWER_ROOT + "/StoneWebViewer.js", true); |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
302 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
303 OrthancPlugins::RegisterRestCallback |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
304 <ServeEmbeddedFile<Orthanc::EmbeddedResources::STONE_WRAPPER> > |
1713
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
305 (STONE_WEB_VIEWER_ROOT + "/stone.js", true); |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
307 OrthancPlugins::RegisterRestCallback |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
308 <ServeEmbeddedFolder<Orthanc::EmbeddedResources::IMAGES> > |
1713
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
309 (STONE_WEB_VIEWER_ROOT + "/img/(.*)", true); |
1555
b894072b9e2f
static JavaScript resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1544
diff
changeset
|
310 |
b894072b9e2f
static JavaScript resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1544
diff
changeset
|
311 OrthancPlugins::RegisterRestCallback |
b894072b9e2f
static JavaScript resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1544
diff
changeset
|
312 <ServeEmbeddedFolder<Orthanc::EmbeddedResources::LIBRARIES_CSS> > |
1713
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
313 (STONE_WEB_VIEWER_ROOT + "/css/(.*)", true); |
1555
b894072b9e2f
static JavaScript resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1544
diff
changeset
|
314 |
b894072b9e2f
static JavaScript resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1544
diff
changeset
|
315 OrthancPlugins::RegisterRestCallback |
b894072b9e2f
static JavaScript resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1544
diff
changeset
|
316 <ServeEmbeddedFolder<Orthanc::EmbeddedResources::LIBRARIES_JS> > |
1713
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
317 (STONE_WEB_VIEWER_ROOT + "/js/(.*)", true); |
1555
b894072b9e2f
static JavaScript resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1544
diff
changeset
|
318 |
b894072b9e2f
static JavaScript resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1544
diff
changeset
|
319 OrthancPlugins::RegisterRestCallback |
b894072b9e2f
static JavaScript resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1544
diff
changeset
|
320 <ServeEmbeddedFolder<Orthanc::EmbeddedResources::LIBRARIES_WEBFONTS> > |
1713
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
321 (STONE_WEB_VIEWER_ROOT + "/webfonts/(.*)", true); |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
322 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
323 OrthancPlugins::RegisterRestCallback |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
324 <ServeEmbeddedFolder<Orthanc::EmbeddedResources::WEB_APPLICATION> > |
1713
aec45e0b2528
configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1709
diff
changeset
|
325 (STONE_WEB_VIEWER_ROOT + "/(.*)", true); |
1495
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
326 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
327 OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
328 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
329 catch (...) |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
330 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
331 OrthancPlugins::LogError("Exception while initializing the Stone Web viewer plugin"); |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 return -1; |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
333 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
334 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
335 return 0; |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
336 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
337 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
338 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
339 ORTHANC_PLUGINS_API void OrthancPluginFinalize() |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
340 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
341 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
342 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
343 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
344 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
345 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
346 return PLUGIN_NAME; |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
347 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
348 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
349 |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
351 { |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
352 return PLUGIN_VERSION; |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
353 } |
fb74ed5d8c22
initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
354 } |