Mercurial > hg > orthanc-dicomweb
changeset 138:37252e4959b2 dev
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 24 Jun 2016 17:56:50 +0200 |
parents | c2b39472a1ff |
children | a56a59896dcb |
files | Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Plugin/DicomWebClient.cpp Plugin/StowRs.cpp |
diffstat | 3 files changed, 23 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Fri Jun 24 17:26:03 2016 +0200 +++ b/Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Fri Jun 24 17:56:50 2016 +0200 @@ -88,7 +88,6 @@ if (buffer_.data == NULL || buffer_.size == 0) { - OrthancPluginLogError(context_, "Cannot convert an empty memory buffer to JSON"); throw PluginException(OrthancPluginErrorCode_InternalError); }
--- a/Plugin/DicomWebClient.cpp Fri Jun 24 17:26:03 2016 +0200 +++ b/Plugin/DicomWebClient.cpp Fri Jun 24 17:56:50 2016 +0200 @@ -100,6 +100,8 @@ static const char* RESOURCES = "Resources"; static const char* HTTP_HEADERS = "HttpHeaders"; + OrthancPluginContext* context = OrthancPlugins::Configuration::GetContext(); + Json::Value body; Json::Reader reader; if (!reader.parse(request->body, request->body + request->bodySize, body) || @@ -131,17 +133,27 @@ throw OrthancPlugins::PluginException(OrthancPluginErrorCode_UnknownResource); } + // Assume that this is an instance Json::Value tmp; - if (OrthancPlugins::RestApiGetJson(tmp, OrthancPlugins::Configuration::GetContext(), "/instances/" + resource, false)) + try { - AddInstance(instances, tmp); + if (OrthancPlugins::RestApiGetJson(tmp, context, "/instances/" + resource, false)) + { + AddInstance(instances, tmp); + continue; // Success, go to the next item + } } - else if ((OrthancPlugins::RestApiGetJson(tmp, OrthancPlugins::Configuration::GetContext(), "/series/" + resource, false) && - OrthancPlugins::RestApiGetJson(tmp, OrthancPlugins::Configuration::GetContext(), "/series/" + resource + "/instances", false)) || - (OrthancPlugins::RestApiGetJson(tmp, OrthancPlugins::Configuration::GetContext(), "/studies/" + resource, false) && - OrthancPlugins::RestApiGetJson(tmp, OrthancPlugins::Configuration::GetContext(), "/studies/" + resource + "/instances", false)) || - (OrthancPlugins::RestApiGetJson(tmp, OrthancPlugins::Configuration::GetContext(), "/patients/" + resource, false) && - OrthancPlugins::RestApiGetJson(tmp, OrthancPlugins::Configuration::GetContext(), "/patients/" + resource + "/instances", false))) + catch (OrthancPlugins::PluginException&) + { + } + + // This was not an instance, try with series/studies/patients + if ((OrthancPlugins::RestApiGetJson(tmp, context, "/series/" + resource, false) && + OrthancPlugins::RestApiGetJson(tmp, context, "/series/" + resource + "/instances", false)) || + (OrthancPlugins::RestApiGetJson(tmp, context, "/studies/" + resource, false) && + OrthancPlugins::RestApiGetJson(tmp, context, "/studies/" + resource + "/instances", false)) || + (OrthancPlugins::RestApiGetJson(tmp, context, "/patients/" + resource, false) && + OrthancPlugins::RestApiGetJson(tmp, context, "/patients/" + resource + "/instances", false))) { if (tmp.type() != Json::arrayValue) {
--- a/Plugin/StowRs.cpp Fri Jun 24 17:26:03 2016 +0200 +++ b/Plugin/StowRs.cpp Fri Jun 24 17:56:50 2016 +0200 @@ -194,9 +194,9 @@ isFirst = false; } - OrthancPluginMemoryBuffer result; - bool ok = OrthancPluginRestApiPost(OrthancPlugins::Configuration::GetContext(), &result, "/instances", items[i].data_, items[i].size_) == 0; - OrthancPluginFreeMemoryBuffer(OrthancPlugins::Configuration::GetContext(), &result); + OrthancPlugins::MemoryBuffer tmp(OrthancPlugins::Configuration::GetContext()); + bool ok = tmp.RestApiPost("/instances", items[i].data_, items[i].size_, false); + tmp.Clear(); if (ok) {