comparison OrthancFramework/Sources/DicomNetworking/Internals/StoreScp.cpp @ 4502:e3e759cbd19c

refactoring IStoreRequestHandler
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 09 Feb 2021 15:50:14 +0100
parents d9473bd5ed43
children 656784ac6759 94616af363ec
comparison
equal deleted inserted replaced
4501:11c2ddb4e2ca 4502:e3e759cbd19c
152 152
153 // we want to write the received information to a file only if this information 153 // we want to write the received information to a file only if this information
154 // is present and the options opt_bitPreserving and opt_ignore are not set. 154 // is present and the options opt_bitPreserving and opt_ignore are not set.
155 if ((imageDataSet != NULL) && (*imageDataSet != NULL)) 155 if ((imageDataSet != NULL) && (*imageDataSet != NULL))
156 { 156 {
157 DicomMap summary;
158 Json::Value dicomJson;
159 std::string buffer;
160
161 try
162 {
163 std::set<DicomTag> ignoreTagLength;
164
165 // TODO => Parameters in class "DicomServer"
166 FromDcmtkBridge::ExtractDicomSummary(summary, **imageDataSet, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength);
167 FromDcmtkBridge::ExtractDicomAsJson(dicomJson, **imageDataSet, DicomToJsonFormat_Full,
168 DicomToJsonFlags_Default, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength);
169
170 if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, **imageDataSet))
171 {
172 CLOG(ERROR, DICOM) << "cannot write DICOM file to memory";
173 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources;
174 }
175 }
176 catch (...)
177 {
178 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources;
179 }
180
181 // check the image to make sure it is consistent, i.e. that its sopClass and sopInstance correspond 157 // check the image to make sure it is consistent, i.e. that its sopClass and sopInstance correspond
182 // to those mentioned in the request. If not, set the status in the response message variable. 158 // to those mentioned in the request. If not, set the status in the response message variable.
183 if (rsp->DimseStatus == STATUS_Success) 159 if (rsp->DimseStatus == STATUS_Success)
184 { 160 {
185 // which SOP class and SOP instance ? 161 // which SOP class and SOP instance ?
204 } 180 }
205 else 181 else
206 { 182 {
207 try 183 try
208 { 184 {
209 cbdata->handler->Handle(buffer, summary, dicomJson, *cbdata->remoteIp, cbdata->remoteAET, cbdata->calledAET); 185 cbdata->handler->Handle(**imageDataSet, *cbdata->remoteIp, cbdata->remoteAET, cbdata->calledAET);
210 } 186 }
211 catch (OrthancException& e) 187 catch (OrthancException& e)
212 { 188 {
213 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources; 189 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources;
214 190
215 if (e.GetErrorCode() == ErrorCode_InexistentTag) 191 if (e.GetErrorCode() == ErrorCode_InexistentTag)
216 { 192 {
217 summary.LogMissingTagsForStore(); 193 FromDcmtkBridge::LogMissingTagsForStore(**imageDataSet);
218 } 194 }
219 else 195 else
220 { 196 {
221 CLOG(ERROR, DICOM) << "Exception while storing DICOM: " << e.What(); 197 CLOG(ERROR, DICOM) << "Exception while storing DICOM: " << e.What();
222 } 198 }