Mercurial > hg > orthanc
comparison OrthancServer/ServerJobs/StorePeerOperation.cpp @ 2608:25225f0b4f33 jobs
simplification wrt. dicom connection manager
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 19 May 2018 15:50:09 +0200 |
parents | f2b9d3256060 |
children | f7a84b551ee4 |
comparison
equal
deleted
inserted
replaced
2607:44e268605478 | 2608:25225f0b4f33 |
---|---|
41 #include "../../Core/HttpClient.h" | 41 #include "../../Core/HttpClient.h" |
42 | 42 |
43 namespace Orthanc | 43 namespace Orthanc |
44 { | 44 { |
45 void StorePeerOperation::Apply(JobOperationValues& outputs, | 45 void StorePeerOperation::Apply(JobOperationValues& outputs, |
46 const JobOperationValue& input) | 46 const JobOperationValue& input, |
47 IDicomConnectionManager& connectionManager) | |
47 { | 48 { |
48 // Configure the HTTP client | 49 // Configure the HTTP client |
49 HttpClient client(peer_, "instances"); | 50 HttpClient client(peer_, "instances"); |
50 client.SetMethod(HttpMethod_Post); | 51 client.SetMethod(HttpMethod_Post); |
51 | 52 |
52 if (input.GetType() != JobOperationValue::Type_DicomInstance) | 53 if (input.GetType() != JobOperationValue::Type_DicomInstance) |
53 { | 54 { |
54 throw OrthancException(ErrorCode_BadParameterType); | 55 throw OrthancException(ErrorCode_BadParameterType); |
55 } | 56 } |
56 | 57 |
57 const DicomInstanceOperationValue& instance = dynamic_cast<const DicomInstanceOperationValue&>(input); | 58 const DicomInstanceOperationValue& instance = |
59 dynamic_cast<const DicomInstanceOperationValue&>(input); | |
58 | 60 |
59 LOG(INFO) << "Lua: Sending instance " << instance.GetId() << " to Orthanc peer \"" | 61 LOG(INFO) << "Lua: Sending instance " << instance.GetId() << " to Orthanc peer \"" |
60 << peer_.GetUrl() << "\""; | 62 << peer_.GetUrl() << "\""; |
61 | 63 |
62 try | 64 try |
64 instance.ReadContent(client.GetBody()); | 66 instance.ReadContent(client.GetBody()); |
65 | 67 |
66 std::string answer; | 68 std::string answer; |
67 if (!client.Apply(answer)) | 69 if (!client.Apply(answer)) |
68 { | 70 { |
69 LOG(ERROR) << "Lua: Unable to send instance " << instance.GetId() << " to Orthanc peer \"" | 71 LOG(ERROR) << "Lua: Unable to send instance " << instance.GetId() |
70 << peer_.GetUrl(); | 72 << " to Orthanc peer \"" << peer_.GetUrl(); |
71 } | 73 } |
72 | 74 |
73 outputs.Append(input.Clone()); | 75 outputs.Append(input.Clone()); |
74 } | 76 } |
75 catch (OrthancException& e) | 77 catch (OrthancException& e) |
76 { | 78 { |
77 LOG(ERROR) << "Lua: Unable to send instance " << instance.GetId() << " to Orthanc peer \"" | 79 LOG(ERROR) << "Lua: Unable to send instance " << instance.GetId() |
78 << peer_.GetUrl() << "\": " << e.What(); | 80 << " to Orthanc peer \"" << peer_.GetUrl() << "\": " << e.What(); |
79 } | 81 } |
80 } | 82 } |
81 } | 83 } |