comparison OrthancServer/ServerContext.cpp @ 791:381f90e2b69d

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 05 May 2014 22:44:34 +0200
parents aebf0071020e
children 111a1738e11e
comparison
equal deleted inserted replaced
790:331eaf9d9d69 791:381f90e2b69d
245 #endif 245 #endif
246 } 246 }
247 247
248 248
249 StoreStatus ServerContext::Store(std::string& resultPublicId, 249 StoreStatus ServerContext::Store(std::string& resultPublicId,
250 DcmFileFormat& dicomInstance, 250 ParsedDicomFile& dicomInstance,
251 const char* dicomBuffer, 251 const char* dicomBuffer,
252 size_t dicomSize) 252 size_t dicomSize)
253 { 253 {
254 DicomMap dicomSummary; 254 DicomMap dicomSummary;
255 FromDcmtkBridge::Convert(dicomSummary, *dicomInstance.getDataset()); 255 FromDcmtkBridge::Convert(dicomSummary, *dicomInstance.GetDicom().getDataset());
256 256
257 try 257 try
258 { 258 {
259 DicomInstanceHasher hasher(dicomSummary); 259 DicomInstanceHasher hasher(dicomSummary);
260 resultPublicId = hasher.HashInstance(); 260 resultPublicId = hasher.HashInstance();
261 261
262 Json::Value dicomJson; 262 Json::Value dicomJson;
263 FromDcmtkBridge::ToJson(dicomJson, *dicomInstance.getDataset()); 263 FromDcmtkBridge::ToJson(dicomJson, *dicomInstance.GetDicom().getDataset());
264 264
265 StoreStatus status = StoreStatus_Failure; 265 StoreStatus status = StoreStatus_Failure;
266 if (dicomSize > 0) 266 if (dicomSize > 0)
267 { 267 {
268 status = Store(dicomBuffer, dicomSize, dicomSummary, dicomJson, ""); 268 status = Store(dicomBuffer, dicomSize, dicomSummary, dicomJson, "");
281 } 281 }
282 } 282 }
283 283
284 284
285 StoreStatus ServerContext::Store(std::string& resultPublicId, 285 StoreStatus ServerContext::Store(std::string& resultPublicId,
286 DcmFileFormat& dicomInstance) 286 ParsedDicomFile& dicomInstance)
287 { 287 {
288 std::string buffer; 288 std::string buffer;
289 if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, dicomInstance.getDataset())) 289 if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, dicomInstance.GetDicom().getDataset()))
290 { 290 {
291 throw OrthancException(ErrorCode_InternalError); 291 throw OrthancException(ErrorCode_InternalError);
292 } 292 }
293 293
294 if (buffer.size() == 0) 294 if (buffer.size() == 0)
301 StoreStatus ServerContext::Store(std::string& resultPublicId, 301 StoreStatus ServerContext::Store(std::string& resultPublicId,
302 const char* dicomBuffer, 302 const char* dicomBuffer,
303 size_t dicomSize) 303 size_t dicomSize)
304 { 304 {
305 ParsedDicomFile dicom(dicomBuffer, dicomSize); 305 ParsedDicomFile dicom(dicomBuffer, dicomSize);
306 return Store(resultPublicId, dicom.GetDicom(), dicomBuffer, dicomSize); 306 return Store(resultPublicId, dicom, dicomBuffer, dicomSize);
307 } 307 }
308
309
310 StoreStatus ServerContext::Store(std::string& resultPublicId,
311 const std::string& dicomContent)
312 {
313 if (dicomContent.size() == 0)
314 {
315 return Store(resultPublicId, NULL, 0);
316 }
317 else
318 {
319 return Store(resultPublicId, &dicomContent[0], dicomContent.size());
320 }
321 }
322
308 323
309 void ServerContext::SetStoreMD5ForAttachments(bool storeMD5) 324 void ServerContext::SetStoreMD5ForAttachments(bool storeMD5)
310 { 325 {
311 LOG(INFO) << "Storing MD5 for attachments: " << (storeMD5 ? "yes" : "no"); 326 LOG(INFO) << "Storing MD5 for attachments: " << (storeMD5 ? "yes" : "no");
312 accessor_.SetStoreMD5(storeMD5); 327 accessor_.SetStoreMD5(storeMD5);