Mercurial > hg > orthanc-transfers
comparison Framework/DownloadArea.cpp @ 8:4c3437217518
fix for compatibility with simplified OrthancPluginCppWrapper
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 05 Dec 2018 09:16:51 +0100 |
parents | 95226b754d9e |
children | 7e207ade2f1a |
comparison
equal
deleted
inserted
replaced
7:151e29acbb13 | 8:4c3437217518 |
---|---|
95 writer.Write(offset, data, size); | 95 writer.Write(offset, data, size); |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 | 99 |
100 void DownloadArea::Instance::Commit(OrthancPluginContext* context, | 100 void DownloadArea::Instance::Commit(bool simulate) const |
101 bool simulate) const | |
102 { | 101 { |
103 std::string content; | 102 std::string content; |
104 Orthanc::SystemToolbox::ReadFile(content, file_.GetPath()); | 103 Orthanc::SystemToolbox::ReadFile(content, file_.GetPath()); |
105 | 104 |
106 std::string md5; | 105 std::string md5; |
108 | 107 |
109 if (md5 == info_.GetMD5()) | 108 if (md5 == info_.GetMD5()) |
110 { | 109 { |
111 if (!simulate) | 110 if (!simulate) |
112 { | 111 { |
113 if (context == NULL) | |
114 { | |
115 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | |
116 } | |
117 | |
118 Json::Value result; | 112 Json::Value result; |
119 if (!RestApiPost(result, context, "/instances", | 113 if (!RestApiPost(result, "/instances", |
120 content.empty() ? NULL : content.c_str(), content.size(), | 114 content.empty() ? NULL : content.c_str(), content.size(), |
121 false)) | 115 false)) |
122 { | 116 { |
123 LOG(ERROR) << "Cannot import a transfered DICOM instance into Orthanc: " | 117 LOG(ERROR) << "Cannot import a transfered DICOM instance into Orthanc: " |
124 << info_.GetId(); | 118 << info_.GetId(); |
223 totalSize_ += instances[i].GetSize(); | 217 totalSize_ += instances[i].GetSize(); |
224 } | 218 } |
225 } | 219 } |
226 | 220 |
227 | 221 |
228 void DownloadArea::CommitInternal(OrthancPluginContext* context, | 222 void DownloadArea::CommitInternal(bool simulate) |
229 bool simulate) | |
230 { | 223 { |
231 boost::mutex::scoped_lock lock(mutex_); | 224 boost::mutex::scoped_lock lock(mutex_); |
232 | 225 |
233 for (Instances::iterator it = instances_.begin(); | 226 for (Instances::iterator it = instances_.begin(); |
234 it != instances_.end(); ++it) | 227 it != instances_.end(); ++it) |
235 { | 228 { |
236 if (it->second != NULL) | 229 if (it->second != NULL) |
237 { | 230 { |
238 it->second->Commit(context, simulate); | 231 it->second->Commit(simulate); |
239 delete it->second; | 232 delete it->second; |
240 it->second = NULL; | 233 it->second = NULL; |
241 } | 234 } |
242 else | 235 else |
243 { | 236 { |
311 | 304 |
312 | 305 |
313 void DownloadArea::CheckMD5() | 306 void DownloadArea::CheckMD5() |
314 { | 307 { |
315 LOG(INFO) << "Checking MD5 sum without committing (testing)"; | 308 LOG(INFO) << "Checking MD5 sum without committing (testing)"; |
316 CommitInternal(NULL, true); | 309 CommitInternal(true); |
317 } | 310 } |
318 | 311 |
319 | 312 |
320 void DownloadArea::Commit(OrthancPluginContext* context) | 313 void DownloadArea::Commit() |
321 { | 314 { |
322 LOG(INFO) << "Importing transfered DICOM files from the temporary download area into Orthanc"; | 315 LOG(INFO) << "Importing transfered DICOM files from the temporary download area into Orthanc"; |
323 CommitInternal(context, false); | 316 CommitInternal(false); |
324 } | 317 } |
325 } | 318 } |