diff OrthancServer/OrthancRestApi/OrthancRestModalities.cpp @ 1007:871c49c9b11d lua-scripting

lua routing is working
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 08 Jul 2014 17:35:00 +0200
parents 13e230bbd882
children bd2cb95003da
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Tue Jul 08 15:11:00 2014 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Tue Jul 08 17:35:00 2014 +0200
@@ -38,6 +38,7 @@
 #include "../FromDcmtkBridge.h"
 #include "../Scheduler/ServerJob.h"
 #include "../Scheduler/StoreScuCommand.h"
+#include "../Scheduler/StorePeerCommand.h"
 
 #include <glog/logging.h>
 
@@ -331,7 +332,7 @@
       job.AddCommand(new StoreScuCommand(context, p)).AddInput(*it);
     }
 
-    job.SetDescription("Store-SCU from HTTP to modality \"" + remote + "\"");
+    job.SetDescription("HTTP request: Store-SCU to peer \"" + remote + "\"");
     context.GetScheduler().SubmitAndWait(job);
 
     call.GetOutput().AnswerBuffer("{}", "application/json");
@@ -390,33 +391,15 @@
     OrthancPeerParameters peer;
     Configuration::GetOrthancPeer(peer, remote);
 
-    // Configure the HTTP client
-    HttpClient client;
-    if (peer.GetUsername().size() != 0 && 
-        peer.GetPassword().size() != 0)
-    {
-      client.SetCredentials(peer.GetUsername().c_str(), 
-                            peer.GetPassword().c_str());
-    }
-
-    client.SetUrl(peer.GetUrl() + "instances");
-    client.SetMethod(HttpMethod_Post);
-
-    // Loop over the instances that are to be sent
+    ServerJob job;
     for (std::list<std::string>::const_iterator 
            it = instances.begin(); it != instances.end(); ++it)
     {
-      LOG(INFO) << "Sending resource " << *it << " to peer \"" << remote << "\"";
-
-      context.ReadFile(client.AccessPostData(), *it, FileContentType_Dicom);
+      job.AddCommand(new StorePeerCommand(context, peer)).AddInput(*it);
+    }
 
-      std::string answer;
-      if (!client.Apply(answer))
-      {
-        LOG(ERROR) << "Unable to send resource " << *it << " to peer \"" << remote << "\"";
-        return;
-      }
-    }
+    job.SetDescription("HTTP request: POST to peer \"" + remote + "\"");
+    context.GetScheduler().SubmitAndWait(job);
 
     call.GetOutput().AnswerBuffer("{}", "application/json");
   }