comparison 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
comparison
equal deleted inserted replaced
1006:649d47854314 1007:871c49c9b11d
36 #include "../OrthancInitialization.h" 36 #include "../OrthancInitialization.h"
37 #include "../../Core/HttpClient.h" 37 #include "../../Core/HttpClient.h"
38 #include "../FromDcmtkBridge.h" 38 #include "../FromDcmtkBridge.h"
39 #include "../Scheduler/ServerJob.h" 39 #include "../Scheduler/ServerJob.h"
40 #include "../Scheduler/StoreScuCommand.h" 40 #include "../Scheduler/StoreScuCommand.h"
41 #include "../Scheduler/StorePeerCommand.h"
41 42
42 #include <glog/logging.h> 43 #include <glog/logging.h>
43 44
44 namespace Orthanc 45 namespace Orthanc
45 { 46 {
329 it = instances.begin(); it != instances.end(); ++it) 330 it = instances.begin(); it != instances.end(); ++it)
330 { 331 {
331 job.AddCommand(new StoreScuCommand(context, p)).AddInput(*it); 332 job.AddCommand(new StoreScuCommand(context, p)).AddInput(*it);
332 } 333 }
333 334
334 job.SetDescription("Store-SCU from HTTP to modality \"" + remote + "\""); 335 job.SetDescription("HTTP request: Store-SCU to peer \"" + remote + "\"");
335 context.GetScheduler().SubmitAndWait(job); 336 context.GetScheduler().SubmitAndWait(job);
336 337
337 call.GetOutput().AnswerBuffer("{}", "application/json"); 338 call.GetOutput().AnswerBuffer("{}", "application/json");
338 } 339 }
339 340
388 } 389 }
389 390
390 OrthancPeerParameters peer; 391 OrthancPeerParameters peer;
391 Configuration::GetOrthancPeer(peer, remote); 392 Configuration::GetOrthancPeer(peer, remote);
392 393
393 // Configure the HTTP client 394 ServerJob job;
394 HttpClient client;
395 if (peer.GetUsername().size() != 0 &&
396 peer.GetPassword().size() != 0)
397 {
398 client.SetCredentials(peer.GetUsername().c_str(),
399 peer.GetPassword().c_str());
400 }
401
402 client.SetUrl(peer.GetUrl() + "instances");
403 client.SetMethod(HttpMethod_Post);
404
405 // Loop over the instances that are to be sent
406 for (std::list<std::string>::const_iterator 395 for (std::list<std::string>::const_iterator
407 it = instances.begin(); it != instances.end(); ++it) 396 it = instances.begin(); it != instances.end(); ++it)
408 { 397 {
409 LOG(INFO) << "Sending resource " << *it << " to peer \"" << remote << "\""; 398 job.AddCommand(new StorePeerCommand(context, peer)).AddInput(*it);
410 399 }
411 context.ReadFile(client.AccessPostData(), *it, FileContentType_Dicom); 400
412 401 job.SetDescription("HTTP request: POST to peer \"" + remote + "\"");
413 std::string answer; 402 context.GetScheduler().SubmitAndWait(job);
414 if (!client.Apply(answer))
415 {
416 LOG(ERROR) << "Unable to send resource " << *it << " to peer \"" << remote << "\"";
417 return;
418 }
419 }
420 403
421 call.GetOutput().AnswerBuffer("{}", "application/json"); 404 call.GetOutput().AnswerBuffer("{}", "application/json");
422 } 405 }
423 406
424 407