changeset 4462:da460bef88f8

"/modalities/{...}/query": New string argument "LocalAet"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 Jan 2021 17:02:10 +0100
parents 22abc6851191
children 522e13a60cfc
files NEWS OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp OrthancServer/Sources/QueryRetrieveHandler.cpp OrthancServer/Sources/QueryRetrieveHandler.h
diffstat 4 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Wed Jan 20 14:51:48 2021 +0100
+++ b/NEWS	Wed Jan 20 17:02:10 2021 +0100
@@ -20,6 +20,11 @@
 
 * The DICOM meta-header and the transfer syntax are displayed at the "Instance" level
 
+REST API
+--------
+
+* "/modalities/{...}/query": New string argument "LocalAet"
+
 Plugins
 -------
 
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp	Wed Jan 20 14:51:48 2021 +0100
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp	Wed Jan 20 17:02:10 2021 +0100
@@ -670,6 +670,8 @@
         .SetRequestField(KEY_NORMALIZE, RestApiCallDocumentation::Type_Boolean,
                          "Whether to normalize the query, i.e. whether to wipe out from the query, the DICOM tags "
                          "that are not applicable for the query-retrieve level of interest", false)
+        .SetRequestField(KEY_LOCAL_AET, RestApiCallDocumentation::Type_String,
+                         "Local AET that is used for this commands, defaults to `DicomAet` configuration option", false)
         .SetAnswerField("ID", RestApiCallDocumentation::Type_JsonObject,
                         "Identifier of the query, to be used with `/queries/{id}`")
         .SetAnswerField("Path", RestApiCallDocumentation::Type_JsonObject,
@@ -703,6 +705,12 @@
       throw OrthancException(ErrorCode_BadFileFormat,
                              "The field " + std::string(KEY_QUERY) + " must contain a JSON object");
     }
+    else if (request.isMember(KEY_LOCAL_AET) &&
+             request[KEY_LOCAL_AET].type() != Json::stringValue)
+    {
+      throw OrthancException(ErrorCode_BadFileFormat,
+                             "The field " + std::string(KEY_LOCAL_AET) + " must contain a string");
+    }
     else
     {
       std::unique_ptr<QueryRetrieveHandler>  handler(new QueryRetrieveHandler(context));
@@ -727,6 +735,11 @@
         handler->SetFindNormalized(request[KEY_NORMALIZE].asBool());
       }
 
+      if (request.isMember(KEY_LOCAL_AET))
+      {
+        handler->SetLocalAet(request[KEY_LOCAL_AET].asString());
+      }
+
       AnswerQueryHandler(call, handler);
     }
   }
--- a/OrthancServer/Sources/QueryRetrieveHandler.cpp	Wed Jan 20 14:51:48 2021 +0100
+++ b/OrthancServer/Sources/QueryRetrieveHandler.cpp	Wed Jan 20 17:02:10 2021 +0100
@@ -115,6 +115,13 @@
   }
 
 
+  void QueryRetrieveHandler::SetLocalAet(const std::string& localAet)
+  {
+    Invalidate();
+    localAet_ = localAet;
+  }
+
+
   void QueryRetrieveHandler::SetLevel(ResourceType level)
   {
     Invalidate();
--- a/OrthancServer/Sources/QueryRetrieveHandler.h	Wed Jan 20 14:51:48 2021 +0100
+++ b/OrthancServer/Sources/QueryRetrieveHandler.h	Wed Jan 20 17:02:10 2021 +0100
@@ -65,6 +65,8 @@
       return modality_;
     }
 
+    void SetLocalAet(const std::string& localAet);
+
     const std::string& GetLocalAet() const
     {
       return localAet_;