Mercurial > hg > orthanc-stone
comparison Applications/StoneWebViewer/Plugin/Plugin.cpp @ 1709:2931f5e15320
download study from Stone Web viewer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 30 Nov 2020 15:36:40 +0100 |
parents | f1bd464dc3e1 |
children | aec45e0b2528 |
comparison
equal
deleted
inserted
replaced
1708:eb59fbee071e | 1709:2931f5e15320 |
---|---|
172 } | 172 } |
173 else | 173 else |
174 { | 174 { |
175 static const char* CONFIG_SECTION = "StoneWebViewer"; | 175 static const char* CONFIG_SECTION = "StoneWebViewer"; |
176 | 176 |
177 std::string config; | 177 Json::Value config = Json::objectValue; |
178 | 178 |
179 OrthancPlugins::OrthancConfiguration orthanc; | 179 OrthancPlugins::OrthancConfiguration orthanc; |
180 if (orthanc.IsSection(CONFIG_SECTION)) | 180 if (orthanc.IsSection(CONFIG_SECTION)) |
181 { | 181 { |
182 OrthancPlugins::OrthancConfiguration section(false); | 182 OrthancPlugins::OrthancConfiguration section(false); |
183 orthanc.GetSection(section, CONFIG_SECTION); | 183 orthanc.GetSection(section, CONFIG_SECTION); |
184 | 184 config[CONFIG_SECTION] = section.GetJson(); |
185 Json::Value wrapper = Json::objectValue; | |
186 wrapper[CONFIG_SECTION] = section.GetJson(); | |
187 config = wrapper.toStyledString(); | |
188 } | 185 } |
189 else | 186 else |
190 { | 187 { |
191 LOG(WARNING) << "The Orthanc configuration file doesn't contain a section \"" | 188 LOG(WARNING) << "The Orthanc configuration file doesn't contain a section \"" |
192 << CONFIG_SECTION << "\" to configure the Stone Web viewer: " | 189 << CONFIG_SECTION << "\" to configure the Stone Web viewer: " |
193 << "Will use default settings"; | 190 << "Will use default settings"; |
191 | |
192 std::string s; | |
194 Orthanc::EmbeddedResources::GetDirectoryResource( | 193 Orthanc::EmbeddedResources::GetDirectoryResource( |
195 config, Orthanc::EmbeddedResources::WEB_APPLICATION, "/configuration.json"); | 194 s, Orthanc::EmbeddedResources::WEB_APPLICATION, "/configuration.json"); |
196 } | 195 |
197 | 196 Json::Reader reader; |
198 OrthancPluginAnswerBuffer(context, output, config.c_str(), config.size(), "application/json"); | 197 if (!reader.parse(s, config) || |
198 config.type() != Json::objectValue) | |
199 { | |
200 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat, | |
201 "Cannot read the default configuration"); | |
202 } | |
203 } | |
204 | |
205 config[CONFIG_SECTION]["OrthancApiRoot"] = ".."; | |
206 | |
207 const std::string s = config.toStyledString(); | |
208 OrthancPluginAnswerBuffer(context, output, s.c_str(), s.size(), "application/json"); | |
199 } | 209 } |
200 } | 210 } |
201 | 211 |
202 | 212 |
203 extern "C" | 213 extern "C" |