Mercurial > hg > orthanc
comparison OrthancServer/ServerContext.cpp @ 236:6d9be2b470b4
compression
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 30 Nov 2012 15:09:16 +0100 |
parents | c11273198cef |
children | f6fdf5abe751 |
comparison
equal
deleted
inserted
replaced
235:1e0595885a81 | 236:6d9be2b470b4 |
---|---|
53 index_(*this, path.string()), | 53 index_(*this, path.string()), |
54 accessor_(storage_) | 54 accessor_(storage_) |
55 { | 55 { |
56 } | 56 } |
57 | 57 |
58 void ServerContext::SetCompressionEnabled(bool enabled) | |
59 { | |
60 if (enabled) | |
61 LOG(WARNING) << "Disk compression is enabled"; | |
62 else | |
63 LOG(WARNING) << "Disk compression is disabled"; | |
64 | |
65 compressionEnabled_ = enabled; | |
66 } | |
67 | |
58 void ServerContext::RemoveFile(const std::string& fileUuid) | 68 void ServerContext::RemoveFile(const std::string& fileUuid) |
59 { | 69 { |
60 storage_.Remove(fileUuid); | 70 storage_.Remove(fileUuid); |
61 } | 71 } |
62 | 72 |
64 size_t dicomSize, | 74 size_t dicomSize, |
65 const DicomMap& dicomSummary, | 75 const DicomMap& dicomSummary, |
66 const Json::Value& dicomJson, | 76 const Json::Value& dicomJson, |
67 const std::string& remoteAet) | 77 const std::string& remoteAet) |
68 { | 78 { |
69 //accessor_.SetCompressionForNextOperations(CompressionType_Zlib); | 79 if (compressionEnabled_) |
80 { | |
81 accessor_.SetCompressionForNextOperations(CompressionType_Zlib); | |
82 } | |
83 else | |
84 { | |
85 accessor_.SetCompressionForNextOperations(CompressionType_None); | |
86 } | |
70 | 87 |
71 FileInfo dicomInfo = accessor_.Write(dicomFile, dicomSize, FileContentType_Dicom); | 88 FileInfo dicomInfo = accessor_.Write(dicomFile, dicomSize, FileContentType_Dicom); |
72 FileInfo jsonInfo = accessor_.Write(dicomJson.toStyledString(), FileContentType_Json); | 89 FileInfo jsonInfo = accessor_.Write(dicomJson.toStyledString(), FileContentType_Json); |
73 | 90 |
74 ServerIndex::Attachments attachments; | 91 ServerIndex::Attachments attachments; |
105 void ServerContext::AnswerFile(RestApiOutput& output, | 122 void ServerContext::AnswerFile(RestApiOutput& output, |
106 const std::string& instancePublicId, | 123 const std::string& instancePublicId, |
107 FileContentType content) | 124 FileContentType content) |
108 { | 125 { |
109 FileInfo attachment; | 126 FileInfo attachment; |
110 if (index_.LookupAttachment(attachment, instancePublicId, FileContentType_Dicom)) | 127 if (!index_.LookupAttachment(attachment, instancePublicId, content)) |
111 { | 128 { |
112 assert(attachment.GetCompressionType() == CompressionType_None); | 129 throw OrthancException(ErrorCode_InternalError); |
113 assert(attachment.GetContentType() == FileContentType_Dicom); | 130 } |
114 | 131 |
115 FilesystemHttpSender sender(storage_, attachment.GetUuid()); | 132 accessor_.SetCompressionForNextOperations(attachment.GetCompressionType()); |
116 sender.SetDownloadFilename(attachment.GetUuid() + ".dcm"); | 133 std::auto_ptr<HttpFileSender> sender(accessor_.ConstructHttpFileSender(attachment.GetUuid())); |
117 sender.SetContentType("application/dicom"); | 134 output.AnswerFile(*sender); |
118 output.AnswerFile(sender); | |
119 } | |
120 } | 135 } |
121 | 136 |
122 | 137 |
123 void ServerContext::ReadJson(Json::Value& result, | 138 void ServerContext::ReadJson(Json::Value& result, |
124 const std::string& instancePublicId) | 139 const std::string& instancePublicId) |