changeset 5011:c014ab79fca5

fixed /move documentation + improved error reporting
author Alain Mazy <am@osimis.io>
date Tue, 31 May 2022 09:36:00 +0200
parents 88d838c6b4c7
children 6fbff89fd5a4
files OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp
diffstat 3 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Mon May 30 09:08:54 2022 +0200
+++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Tue May 31 09:36:00 2022 +0200
@@ -2296,11 +2296,19 @@
 
 
   void FromDcmtkBridge::FromJson(DicomMap& target,
-                                 const Json::Value& source)
+                                 const Json::Value& source,
+                                 const char* fieldName)
   {
     if (source.type() != Json::objectValue)
     {
-      throw OrthancException(ErrorCode_BadFileFormat);
+      if (fieldName != NULL) 
+      {
+        throw OrthancException(ErrorCode_BadFileFormat, std::string("Expecting an object in field '") + std::string(fieldName) + std::string("'"));
+      }
+      else
+      {
+        throw OrthancException(ErrorCode_BadFileFormat, "Expecting an object");
+      }
     }
 
     target.Clear();
@@ -2313,7 +2321,7 @@
 
       if (value.type() != Json::stringValue)
       {
-        throw OrthancException(ErrorCode_BadFileFormat);
+        throw OrthancException(ErrorCode_BadFileFormat, std::string("Expecting a string in field '") + members[i] + std::string("'"));
       }
       
       target.SetValue(ParseTag(members[i]), value.asString(), false);
@@ -2321,6 +2329,8 @@
   }
 
 
+
+
   void FromDcmtkBridge::ChangeStringEncoding(DcmItem& dataset,
                                              Encoding source,
                                              bool hasSourceCodeExtensions,
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h	Mon May 30 09:08:54 2022 +0200
+++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h	Tue May 31 09:36:00 2022 +0200
@@ -240,7 +240,8 @@
                                                size_t size);
 
     static void FromJson(DicomMap& values,
-                         const Json::Value& result);
+                         const Json::Value& result,
+                         const char* fieldName = NULL);
 
     static void ExtractDicomSummary(DicomMap& target, 
                                     DcmItem& dataset,
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp	Mon May 30 09:08:54 2022 +0200
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp	Tue May 31 09:36:00 2022 +0200
@@ -1523,8 +1523,8 @@
         .SetDescription("Start a C-MOVE SCU command as a job, in order to drive the execution of a sequence of "
                         "C-STORE commands by some remote DICOM modality whose identifier is provided in the URL: "
                         "https://book.orthanc-server.com/users/rest.html#performing-c-move")
-        .SetRequestField(KEY_RESOURCES, RestApiCallDocumentation::Type_JsonListOfStrings,
-                         "List of the Orthanc identifiers of all the DICOM resources to be sent", true)
+        .SetRequestField(KEY_RESOURCES, RestApiCallDocumentation::Type_JsonListOfObjects,
+                         "List of queries identifying all the DICOM resources to be sent", true)
         .SetRequestField(KEY_LEVEL, RestApiCallDocumentation::Type_String,
                          "Level of the query (`Patient`, `Study`, `Series` or `Instance`)", true)
         .SetRequestField(KEY_LOCAL_AET, RestApiCallDocumentation::Type_String,
@@ -1572,7 +1572,7 @@
     for (Json::Value::ArrayIndex i = 0; i < request[KEY_RESOURCES].size(); i++)
     {
       DicomMap resource;
-      FromDcmtkBridge::FromJson(resource, request[KEY_RESOURCES][i]);
+      FromDcmtkBridge::FromJson(resource, request[KEY_RESOURCES][i], "Resources elements");
       
       connection.Move(targetAet, level, resource);
     }