diff Framework/Targets/OrthancTarget.cpp @ 62:f45cec2c32e2

Speed-up in the Web viewer plugin
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Nov 2016 18:21:15 +0100
parents 147bd6dc28db
children ff0ef01c332c
line wrap: on
line diff
--- a/Framework/Targets/OrthancTarget.cpp	Fri Nov 25 17:15:55 2016 +0100
+++ b/Framework/Targets/OrthancTarget.cpp	Fri Nov 25 18:21:15 2016 +0100
@@ -40,14 +40,28 @@
     Json::Value result;
     OrthancPlugins::IOrthancConnection::RestApiPost(result, *orthanc_, "/instances", file);
 
-    std::string instanceId = DicomToolbox::GetMandatoryStringTag(result, "ID");
+    if (result.type() != Json::objectValue ||
+        !result.isMember("ID") ||
+        result["ID"].type() != Json::stringValue)
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
+    }
+
+    std::string instanceId = result["ID"].asString();
 
     if (first_)
     {
       Json::Value instance;
       OrthancPlugins::IOrthancConnection::RestApiGet(instance, *orthanc_, "/instances/" + instanceId);
 
-      std::string seriesId = DicomToolbox::GetMandatoryStringTag(instance, "ParentSeries");
+      if (instance.type() != Json::objectValue ||
+          !instance.isMember("ParentSeries") ||
+          instance["ParentSeries"].type() != Json::stringValue)
+      {
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
+      }
+
+      std::string seriesId = instance["ParentSeries"].asString();
 
       LOG(WARNING) << "ID of the whole-slide image series in Orthanc: " << seriesId;
       first_ = false;