comparison OrthancServer/ServerContext.cpp @ 1126:bf67431a7383

handling of file content type in IStorageArea
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 05 Sep 2014 17:01:42 +0200
parents 790ff7a5b3bf
children 8dabdc0d3007
comparison
equal deleted inserted replaced
1125:20ddab7e9ae8 1126:bf67431a7383
71 71
72 namespace Orthanc 72 namespace Orthanc
73 { 73 {
74 ServerContext::ServerContext(IStorageArea& storage, 74 ServerContext::ServerContext(IStorageArea& storage,
75 const boost::filesystem::path& indexPath) : 75 const boost::filesystem::path& indexPath) :
76 storage_(storage),
77 index_(*this, indexPath.string()), 76 index_(*this, indexPath.string()),
78 accessor_(storage_), 77 accessor_(storage),
79 compressionEnabled_(false), 78 compressionEnabled_(false),
80 provider_(*this), 79 provider_(*this),
81 dicomCache_(provider_, DICOM_CACHE_SIZE), 80 dicomCache_(provider_, DICOM_CACHE_SIZE),
82 scheduler_(Configuration::GetGlobalIntegerParameter("LimitJobs", 10)), 81 scheduler_(Configuration::GetGlobalIntegerParameter("LimitJobs", 10)),
83 plugins_(NULL) 82 plugins_(NULL)
96 LOG(WARNING) << "Disk compression is disabled"; 95 LOG(WARNING) << "Disk compression is disabled";
97 96
98 compressionEnabled_ = enabled; 97 compressionEnabled_ = enabled;
99 } 98 }
100 99
101 void ServerContext::RemoveFile(const std::string& fileUuid) 100 void ServerContext::RemoveFile(const std::string& fileUuid,
102 { 101 FileContentType type)
103 storage_.Remove(fileUuid); 102 {
103 accessor_.Remove(fileUuid, type);
104 } 104 }
105 105
106 106
107 bool ServerContext::ApplyReceivedInstanceFilter(const Json::Value& simplified, 107 bool ServerContext::ApplyReceivedInstanceFilter(const Json::Value& simplified,
108 const std::string& remoteAet) 108 const std::string& remoteAet)
320 it->second)); 320 it->second));
321 } 321 }
322 322
323 if (status != StoreStatus_Success) 323 if (status != StoreStatus_Success)
324 { 324 {
325 storage_.Remove(dicomInfo.GetUuid()); 325 accessor_.Remove(dicomInfo.GetUuid(), FileContentType_Dicom);
326 storage_.Remove(jsonInfo.GetUuid()); 326 accessor_.Remove(jsonInfo.GetUuid(), FileContentType_DicomAsJson);
327 } 327 }
328 328
329 switch (status) 329 switch (status)
330 { 330 {
331 case StoreStatus_Success: 331 case StoreStatus_Success:
403 throw OrthancException(ErrorCode_InternalError); 403 throw OrthancException(ErrorCode_InternalError);
404 } 404 }
405 405
406 accessor_.SetCompressionForNextOperations(attachment.GetCompressionType()); 406 accessor_.SetCompressionForNextOperations(attachment.GetCompressionType());
407 407
408 std::auto_ptr<HttpFileSender> sender(accessor_.ConstructHttpFileSender(attachment.GetUuid())); 408 std::auto_ptr<HttpFileSender> sender(accessor_.ConstructHttpFileSender(attachment.GetUuid(), attachment.GetContentType()));
409 sender->SetContentType("application/dicom"); 409 sender->SetContentType("application/dicom");
410 sender->SetDownloadFilename(instancePublicId + ".dcm"); 410 sender->SetDownloadFilename(instancePublicId + ".dcm");
411 output.AnswerFile(*sender); 411 output.AnswerFile(*sender);
412 } 412 }
413 413
444 else 444 else
445 { 445 {
446 accessor_.SetCompressionForNextOperations(CompressionType_None); 446 accessor_.SetCompressionForNextOperations(CompressionType_None);
447 } 447 }
448 448
449 accessor_.Read(result, attachment.GetUuid()); 449 accessor_.Read(result, attachment.GetUuid(), attachment.GetContentType());
450 } 450 }
451 451
452 452
453 IDynamicObject* ServerContext::DicomCacheProvider::Provide(const std::string& instancePublicId) 453 IDynamicObject* ServerContext::DicomCacheProvider::Provide(const std::string& instancePublicId)
454 { 454 {
508 FileInfo info = accessor_.Write(data, size, attachmentType); 508 FileInfo info = accessor_.Write(data, size, attachmentType);
509 StoreStatus status = index_.AddAttachment(info, resourceId); 509 StoreStatus status = index_.AddAttachment(info, resourceId);
510 510
511 if (status != StoreStatus_Success) 511 if (status != StoreStatus_Success)
512 { 512 {
513 storage_.Remove(info.GetUuid()); 513 accessor_.Remove(info.GetUuid(), info.GetContentType());
514 return false; 514 return false;
515 } 515 }
516 else 516 else
517 { 517 {
518 return true; 518 return true;