Mercurial > hg > orthanc
comparison OrthancFramework/Sources/DicomNetworking/Internals/StoreScp.cpp @ 4284:756126cd2219
moving all logs from DicomNetworking folder into the "dicom" category
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 04 Nov 2020 15:01:47 +0100 |
parents | 0ddc5297a8ab |
children | d9473bd5ed43 |
comparison
equal
deleted
inserted
replaced
4283:6b58ceed959e | 4284:756126cd2219 |
---|---|
27 This file is based on portions of the following project: | 27 This file is based on portions of the following project: |
28 | 28 |
29 Program: DCMTK 3.6.0 | 29 Program: DCMTK 3.6.0 |
30 Module: http://dicom.offis.de/dcmtk.php.en | 30 Module: http://dicom.offis.de/dcmtk.php.en |
31 | 31 |
32 Copyright (C) 1994-2011, OFFIS e.V. | 32 Copyright (C) 1994-2011, OFFIS e.V. |
33 All rights reserved. | 33 All rights reserved. |
34 | 34 |
35 This software and supporting documentation were developed by | 35 This software and supporting documentation were developed by |
36 | 36 |
37 OFFIS e.V. | 37 OFFIS e.V. |
38 R&D Division Health | 38 R&D Division Health |
39 Escherweg 2 | 39 Escherweg 2 |
40 26121 Oldenburg, Germany | 40 26121 Oldenburg, Germany |
41 | 41 |
42 Redistribution and use in source and binary forms, with or without | 42 Redistribution and use in source and binary forms, with or without |
43 modification, are permitted provided that the following conditions | 43 modification, are permitted provided that the following conditions |
44 are met: | 44 are met: |
45 | 45 |
46 - Redistributions of source code must retain the above copyright | 46 - Redistributions of source code must retain the above copyright |
47 notice, this list of conditions and the following disclaimer. | 47 notice, this list of conditions and the following disclaimer. |
48 | 48 |
49 - Redistributions in binary form must reproduce the above copyright | 49 - Redistributions in binary form must reproduce the above copyright |
50 notice, this list of conditions and the following disclaimer in the | 50 notice, this list of conditions and the following disclaimer in the |
51 documentation and/or other materials provided with the distribution. | 51 documentation and/or other materials provided with the distribution. |
52 | 52 |
53 - Neither the name of OFFIS nor the names of its contributors may be | 53 - Neither the name of OFFIS nor the names of its contributors may be |
54 used to endorse or promote products derived from this software | 54 used to endorse or promote products derived from this software |
55 without specific prior written permission. | 55 without specific prior written permission. |
56 | 56 |
57 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 57 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
58 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 58 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
59 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 59 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
60 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 60 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
61 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 61 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
62 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 62 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
63 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 63 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
64 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 64 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
65 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 65 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
66 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 66 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
67 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 67 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
68 | 68 |
69 =========================================================================*/ | 69 =========================================================================*/ |
70 | 70 |
71 | 71 |
72 #include "../../PrecompiledHeaders.h" | 72 #include "../../PrecompiledHeaders.h" |
73 #include "StoreScp.h" | 73 #include "StoreScp.h" |
74 | 74 |
167 FromDcmtkBridge::ExtractDicomAsJson(dicomJson, **imageDataSet, DicomToJsonFormat_Full, | 167 FromDcmtkBridge::ExtractDicomAsJson(dicomJson, **imageDataSet, DicomToJsonFormat_Full, |
168 DicomToJsonFlags_Default, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength); | 168 DicomToJsonFlags_Default, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength); |
169 | 169 |
170 if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, **imageDataSet)) | 170 if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, **imageDataSet)) |
171 { | 171 { |
172 LOG(ERROR) << "cannot write DICOM file to memory"; | 172 CLOG(ERROR, DICOM) << "cannot write DICOM file to memory"; |
173 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources; | 173 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources; |
174 } | 174 } |
175 } | 175 } |
176 catch (...) | 176 catch (...) |
177 { | 177 { |
186 | 186 |
187 #if DCMTK_VERSION_NUMBER >= 364 | 187 #if DCMTK_VERSION_NUMBER >= 364 |
188 if (!DU_findSOPClassAndInstanceInDataSet(*imageDataSet, sopClass, sizeof(sopClass), | 188 if (!DU_findSOPClassAndInstanceInDataSet(*imageDataSet, sopClass, sizeof(sopClass), |
189 sopInstance, sizeof(sopInstance), /*opt_correctUIDPadding*/ OFFalse)) | 189 sopInstance, sizeof(sopInstance), /*opt_correctUIDPadding*/ OFFalse)) |
190 #else | 190 #else |
191 if (!DU_findSOPClassAndInstanceInDataSet(*imageDataSet, sopClass, sopInstance, /*opt_correctUIDPadding*/ OFFalse)) | 191 if (!DU_findSOPClassAndInstanceInDataSet(*imageDataSet, sopClass, sopInstance, /*opt_correctUIDPadding*/ OFFalse)) |
192 #endif | 192 #endif |
193 { | 193 { |
194 //LOG4CPP_ERROR(Internals::GetLogger(), "bad DICOM file: " << fileName); | 194 //LOG4CPP_ERROR(Internals::GetLogger(), "bad DICOM file: " << fileName); |
195 rsp->DimseStatus = STATUS_STORE_Error_CannotUnderstand; | 195 rsp->DimseStatus = STATUS_STORE_Error_CannotUnderstand; |
196 } | 196 } |
197 else if (strcmp(sopClass, req->AffectedSOPClassUID) != 0) | 197 else if (strcmp(sopClass, req->AffectedSOPClassUID) != 0) |
198 { | |
199 rsp->DimseStatus = STATUS_STORE_Error_DataSetDoesNotMatchSOPClass; | |
200 } | |
201 else if (strcmp(sopInstance, req->AffectedSOPInstanceUID) != 0) | |
202 { | |
203 rsp->DimseStatus = STATUS_STORE_Error_DataSetDoesNotMatchSOPClass; | |
204 } | |
205 else | |
206 { | |
207 try | |
208 { | 198 { |
209 cbdata->handler->Handle(buffer, summary, dicomJson, *cbdata->remoteIp, cbdata->remoteAET, cbdata->calledAET); | 199 rsp->DimseStatus = STATUS_STORE_Error_DataSetDoesNotMatchSOPClass; |
210 } | 200 } |
211 catch (OrthancException& e) | 201 else if (strcmp(sopInstance, req->AffectedSOPInstanceUID) != 0) |
212 { | 202 { |
213 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources; | 203 rsp->DimseStatus = STATUS_STORE_Error_DataSetDoesNotMatchSOPClass; |
214 | 204 } |
215 if (e.GetErrorCode() == ErrorCode_InexistentTag) | 205 else |
206 { | |
207 try | |
216 { | 208 { |
217 summary.LogMissingTagsForStore(); | 209 cbdata->handler->Handle(buffer, summary, dicomJson, *cbdata->remoteIp, cbdata->remoteAET, cbdata->calledAET); |
218 } | 210 } |
219 else | 211 catch (OrthancException& e) |
220 { | 212 { |
221 LOG(ERROR) << "Exception while storing DICOM: " << e.What(); | 213 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources; |
214 | |
215 if (e.GetErrorCode() == ErrorCode_InexistentTag) | |
216 { | |
217 summary.LogMissingTagsForStore(); | |
218 } | |
219 else | |
220 { | |
221 CLOG(ERROR, DICOM) << "Exception while storing DICOM: " << e.What(); | |
222 } | |
222 } | 223 } |
223 } | 224 } |
224 } | |
225 } | 225 } |
226 } | 226 } |
227 } | 227 } |
228 } | 228 } |
229 } | 229 } |
291 | 291 |
292 // if some error occured, dump corresponding information and remove the outfile if necessary | 292 // if some error occured, dump corresponding information and remove the outfile if necessary |
293 if (cond.bad()) | 293 if (cond.bad()) |
294 { | 294 { |
295 OFString temp_str; | 295 OFString temp_str; |
296 LOG(ERROR) << "Store SCP Failed: " << cond.text(); | 296 CLOG(ERROR, DICOM) << "Store SCP Failed: " << cond.text(); |
297 } | 297 } |
298 | 298 |
299 // return return value | 299 // return return value |
300 return cond; | 300 return cond; |
301 } | 301 } |