diff OrthancServer/OrthancRestApi/OrthancRestModalities.cpp @ 1997:f9f2aa1cc594

"MoveOriginatorID" can be specified for /modalities/.../store
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 25 May 2016 11:50:35 +0200
parents 5011a597b6ce
children 9b61701c35f2
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Wed May 25 07:24:10 2016 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Wed May 25 11:50:35 2016 +0200
@@ -683,10 +683,41 @@
       return;
     }
 
+    static const char* LOCAL_AET = "LocalAet";
     std::string localAet = context.GetDefaultLocalApplicationEntityTitle();
-    if (request.isMember("LocalAet"))
+    if (request.type() == Json::objectValue &&
+        request.isMember(LOCAL_AET))
     {
-      localAet = request["LocalAet"].asString();
+      if (request[LOCAL_AET].type() == Json::stringValue)
+      {
+        localAet = request[LOCAL_AET].asString();
+      }
+      else
+      {
+        throw OrthancException(ErrorCode_BadFileFormat);
+      }
+    }
+
+    uint16_t moveOriginatorID = 0; /* By default, not a C-MOVE */
+
+    static const char* MOVE_ORIGINATOR_ID = "MoveOriginatorID";
+    if (request.type() == Json::objectValue &&
+        request.isMember(MOVE_ORIGINATOR_ID))
+    {
+      if (request[MOVE_ORIGINATOR_ID].type() != Json::intValue)
+      {
+        throw OrthancException(ErrorCode_BadFileFormat);
+      }
+
+      int v = request[MOVE_ORIGINATOR_ID].asInt();
+      if (v <= 0 || v >= 65536)
+      {
+        throw OrthancException(ErrorCode_ParameterOutOfRange);
+      }
+      else
+      {
+        moveOriginatorID = boost::lexical_cast<uint16_t>(v);
+      }
     }
 
     RemoteModalityParameters p = Configuration::GetModalityUsingSymbolicName(remote);
@@ -696,7 +727,7 @@
            it = instances.begin(); it != instances.end(); ++it)
     {
       job.AddCommand(new StoreScuCommand(context, localAet, p, false,
-                                         0 /* not a C-MOVE */)).AddInput(*it);
+                                         moveOriginatorID)).AddInput(*it);
     }
 
     job.SetDescription("HTTP request: Store-SCU to peer \"" + remote + "\"");