comparison OrthancServer/ServerContext.cpp @ 697:dd1ce9a2844c

access to attachments
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 05 Feb 2014 16:46:59 +0100
parents 4c1860179cc5
children 2929e17f8447
comparison
equal deleted inserted replaced
696:4c1860179cc5 697:dd1ce9a2844c
114 { 114 {
115 accessor_.SetCompressionForNextOperations(CompressionType_None); 115 accessor_.SetCompressionForNextOperations(CompressionType_None);
116 } 116 }
117 117
118 FileInfo dicomInfo = accessor_.Write(dicomInstance, dicomSize, FileContentType_Dicom); 118 FileInfo dicomInfo = accessor_.Write(dicomInstance, dicomSize, FileContentType_Dicom);
119 FileInfo jsonInfo = accessor_.Write(dicomJson.toStyledString(), FileContentType_JsonSummary); 119 FileInfo jsonInfo = accessor_.Write(dicomJson.toStyledString(), FileContentType_DicomAsJson);
120 120
121 ServerIndex::Attachments attachments; 121 ServerIndex::Attachments attachments;
122 attachments.push_back(dicomInfo); 122 attachments.push_back(dicomInfo);
123 attachments.push_back(jsonInfo); 123 attachments.push_back(jsonInfo);
124 124
151 151
152 return status; 152 return status;
153 } 153 }
154 154
155 155
156 void ServerContext::AnswerFile(RestApiOutput& output, 156 void ServerContext::AnswerDicomFile(RestApiOutput& output,
157 const std::string& instancePublicId, 157 const std::string& instancePublicId,
158 FileContentType content) 158 FileContentType content)
159 { 159 {
160 FileInfo attachment; 160 FileInfo attachment;
161 if (!index_.LookupAttachment(attachment, instancePublicId, content)) 161 if (!index_.LookupAttachment(attachment, instancePublicId, content))
162 { 162 {
163 throw OrthancException(ErrorCode_InternalError); 163 throw OrthancException(ErrorCode_InternalError);
174 174
175 void ServerContext::ReadJson(Json::Value& result, 175 void ServerContext::ReadJson(Json::Value& result,
176 const std::string& instancePublicId) 176 const std::string& instancePublicId)
177 { 177 {
178 std::string s; 178 std::string s;
179 ReadFile(s, instancePublicId, FileContentType_JsonSummary); 179 ReadFile(s, instancePublicId, FileContentType_DicomAsJson);
180 180
181 Json::Reader reader; 181 Json::Reader reader;
182 if (!reader.parse(s, result)) 182 if (!reader.parse(s, result))
183 { 183 {
184 throw OrthancException("Corrupted JSON file"); 184 throw OrthancException("Corrupted JSON file");
186 } 186 }
187 187
188 188
189 void ServerContext::ReadFile(std::string& result, 189 void ServerContext::ReadFile(std::string& result,
190 const std::string& instancePublicId, 190 const std::string& instancePublicId,
191 FileContentType content) 191 FileContentType content,
192 bool uncompressIfNeeded)
192 { 193 {
193 FileInfo attachment; 194 FileInfo attachment;
194 if (!index_.LookupAttachment(attachment, instancePublicId, content)) 195 if (!index_.LookupAttachment(attachment, instancePublicId, content))
195 { 196 {
196 throw OrthancException(ErrorCode_InternalError); 197 throw OrthancException(ErrorCode_InternalError);
197 } 198 }
198 199
199 accessor_.SetCompressionForNextOperations(attachment.GetCompressionType()); 200 if (uncompressIfNeeded)
201 {
202 accessor_.SetCompressionForNextOperations(attachment.GetCompressionType());
203 }
204 else
205 {
206 accessor_.SetCompressionForNextOperations(CompressionType_None);
207 }
208
200 accessor_.Read(result, attachment.GetUuid()); 209 accessor_.Read(result, attachment.GetUuid());
201 } 210 }
202 211
203 212
204 IDynamicObject* ServerContext::DicomCacheProvider::Provide(const std::string& instancePublicId) 213 IDynamicObject* ServerContext::DicomCacheProvider::Provide(const std::string& instancePublicId)