Mercurial > hg > orthanc
annotate OrthancServer/Internals/StoreScp.cpp @ 2323:f5fc61337bdf
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 14 Jul 2017 10:50:00 +0200 |
parents | a3a65de1840f |
children | 96b3ec054b69 |
rev | line source |
---|---|
0 | 1 /** |
62 | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1285
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
2244
a3a65de1840f
shared copyright with osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
5 * Copyright (C) 2017 Osimis, Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
136 | 11 * |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
0 | 23 * |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
766
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
34 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
35 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
36 /*========================================================================= |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
37 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
38 This file is based on portions of the following project: |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
39 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
40 Program: DCMTK 3.6.0 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
41 Module: http://dicom.offis.de/dcmtk.php.en |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
42 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
43 Copyright (C) 1994-2011, OFFIS e.V. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
44 All rights reserved. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
45 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
46 This software and supporting documentation were developed by |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
47 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
48 OFFIS e.V. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
49 R&D Division Health |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
50 Escherweg 2 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
51 26121 Oldenburg, Germany |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
52 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
53 Redistribution and use in source and binary forms, with or without |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
54 modification, are permitted provided that the following conditions |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
55 are met: |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
56 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
57 - Redistributions of source code must retain the above copyright |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
58 notice, this list of conditions and the following disclaimer. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
59 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
60 - Redistributions in binary form must reproduce the above copyright |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
61 notice, this list of conditions and the following disclaimer in the |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
62 documentation and/or other materials provided with the distribution. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
63 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
64 - Neither the name of OFFIS nor the names of its contributors may be |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
65 used to endorse or promote products derived from this software |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
66 without specific prior written permission. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
67 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
68 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
69 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
70 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
71 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
72 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
73 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
74 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
75 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
76 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
77 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
78 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
79 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
80 =========================================================================*/ |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
81 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
82 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
83 #include "../PrecompiledHeadersServer.h" |
0 | 84 #include "StoreScp.h" |
85 | |
86 #include "../FromDcmtkBridge.h" | |
730
309e686b41e7
better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
87 #include "../ServerToolbox.h" |
0 | 88 #include "../ToDcmtkBridge.h" |
1928
84c7eaeb5244
Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
89 #include "../OrthancInitialization.h" |
62 | 90 #include "../../Core/OrthancException.h" |
1486
f967bdf8534e
refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1333
diff
changeset
|
91 #include "../../Core/Logging.h" |
0 | 92 |
93 #include <dcmtk/dcmdata/dcfilefo.h> | |
94 #include <dcmtk/dcmdata/dcmetinf.h> | |
95 #include <dcmtk/dcmdata/dcostrmb.h> | |
96 #include <dcmtk/dcmdata/dcdeftag.h> | |
97 #include <dcmtk/dcmnet/diutil.h> | |
98 | |
99 | |
62 | 100 namespace Orthanc |
0 | 101 { |
102 namespace | |
103 { | |
104 struct StoreCallbackData | |
105 { | |
106 IStoreRequestHandler* handler; | |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
107 const std::string* remoteIp; |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1004
diff
changeset
|
108 const char* remoteAET; |
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1004
diff
changeset
|
109 const char* calledAET; |
0 | 110 const char* modality; |
111 const char* affectedSOPInstanceUID; | |
112 uint32_t messageID; | |
113 }; | |
114 | |
730
309e686b41e7
better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
115 |
0 | 116 static void |
117 storeScpCallback( | |
118 void *callbackData, | |
119 T_DIMSE_StoreProgress *progress, | |
120 T_DIMSE_C_StoreRQ *req, | |
121 char * /*imageFileName*/, DcmDataset **imageDataSet, | |
122 T_DIMSE_C_StoreRSP *rsp, | |
123 DcmDataset **statusDetail) | |
124 /* | |
125 * This function.is used to indicate progress when storescp receives instance data over the | |
126 * network. On the final call to this function (identified by progress->state == DIMSE_StoreEnd) | |
127 * this function will store the data set which was received over the network to a file. | |
128 * Earlier calls to this function will simply cause some information to be dumped to stdout. | |
129 * | |
130 * Parameters: | |
131 * callbackData - [in] data for this callback function | |
132 * progress - [in] The state of progress. (identifies if this is the initial or final call | |
133 * to this function, or a call in between these two calls. | |
134 * req - [in] The original store request message. | |
135 * imageFileName - [in] The path to and name of the file the information shall be written to. | |
136 * imageDataSet - [in] The data set which shall be stored in the image file | |
137 * rsp - [inout] the C-STORE-RSP message (will be sent after the call to this function) | |
138 * statusDetail - [inout] This variable can be used to capture detailed information with regard to | |
139 * the status information which is captured in the status element (0000,0900). Note | |
140 * that this function does specify any such information, the pointer will be set to NULL. | |
141 */ | |
142 { | |
143 StoreCallbackData *cbdata = OFstatic_cast(StoreCallbackData *, callbackData); | |
144 | |
145 DIC_UI sopClass; | |
146 DIC_UI sopInstance; | |
147 | |
148 // if this is the final call of this function, save the data which was received to a file | |
149 // (note that we could also save the image somewhere else, put it in database, etc.) | |
150 if (progress->state == DIMSE_StoreEnd) | |
151 { | |
152 OFString tmpStr; | |
153 | |
154 // do not send status detail information | |
155 *statusDetail = NULL; | |
156 | |
157 // Concerning the following line: an appropriate status code is already set in the resp structure, | |
158 // it need not be success. For example, if the caller has already detected an out of resources problem | |
159 // then the status will reflect this. The callback function is still called to allow cleanup. | |
160 //rsp->DimseStatus = STATUS_Success; | |
161 | |
162 // we want to write the received information to a file only if this information | |
163 // is present and the options opt_bitPreserving and opt_ignore are not set. | |
164 if ((imageDataSet != NULL) && (*imageDataSet != NULL)) | |
165 { | |
166 DicomMap summary; | |
167 Json::Value dicomJson; | |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
168 std::string buffer; |
0 | 169 |
170 try | |
171 { | |
2131 | 172 Configuration::ExtractDicomSummary(summary, **imageDataSet); |
173 Configuration::ExtractDicomAsJson(dicomJson, **imageDataSet); | |
0 | 174 |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
175 if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, **imageDataSet)) |
0 | 176 { |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
177 LOG(ERROR) << "cannot write DICOM file to memory"; |
0 | 178 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources; |
179 } | |
180 } | |
181 catch (...) | |
182 { | |
183 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources; | |
184 } | |
185 | |
186 // check the image to make sure it is consistent, i.e. that its sopClass and sopInstance correspond | |
187 // to those mentioned in the request. If not, set the status in the response message variable. | |
1333
732b6a4ed541
clang warning removal
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
188 if (rsp->DimseStatus == STATUS_Success) |
0 | 189 { |
190 // which SOP class and SOP instance ? | |
191 if (!DU_findSOPClassAndInstanceInDataSet(*imageDataSet, sopClass, sopInstance, /*opt_correctUIDPadding*/ OFFalse)) | |
192 { | |
101 | 193 //LOG4CPP_ERROR(Internals::GetLogger(), "bad DICOM file: " << fileName); |
0 | 194 rsp->DimseStatus = STATUS_STORE_Error_CannotUnderstand; |
195 } | |
196 else if (strcmp(sopClass, req->AffectedSOPClassUID) != 0) | |
197 { | |
198 rsp->DimseStatus = STATUS_STORE_Error_DataSetDoesNotMatchSOPClass; | |
199 } | |
200 else if (strcmp(sopInstance, req->AffectedSOPInstanceUID) != 0) | |
201 { | |
202 rsp->DimseStatus = STATUS_STORE_Error_DataSetDoesNotMatchSOPClass; | |
203 } | |
204 else | |
205 { | |
206 try | |
207 { | |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
208 cbdata->handler->Handle(buffer, summary, dicomJson, *cbdata->remoteIp, cbdata->remoteAET, cbdata->calledAET); |
0 | 209 } |
62 | 210 catch (OrthancException& e) |
0 | 211 { |
212 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources; | |
730
309e686b41e7
better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
213 |
309e686b41e7
better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
214 if (e.GetErrorCode() == ErrorCode_InexistentTag) |
309e686b41e7
better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
215 { |
2120 | 216 ServerToolbox::LogMissingRequiredTag(summary); |
730
309e686b41e7
better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
217 } |
309e686b41e7
better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
218 else |
309e686b41e7
better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
219 { |
309e686b41e7
better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
220 LOG(ERROR) << "Exception while storing DICOM: " << e.What(); |
309e686b41e7
better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
221 } |
0 | 222 } |
223 } | |
224 } | |
225 } | |
226 } | |
227 } | |
228 } | |
229 | |
230 /* | |
231 * This function processes a DIMSE C-STORE-RQ commmand that was | |
232 * received over the network connection. | |
233 * | |
234 * Parameters: | |
235 * assoc - [in] The association (network connection to another DICOM application). | |
236 * msg - [in] The DIMSE C-STORE-RQ message that was received. | |
237 * presID - [in] The ID of the presentation context which was specified in the PDV which contained | |
238 * the DIMSE command. | |
239 */ | |
240 OFCondition Internals::storeScp(T_ASC_Association * assoc, | |
241 T_DIMSE_Message * msg, | |
242 T_ASC_PresentationContextID presID, | |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
243 IStoreRequestHandler& handler, |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
244 const std::string& remoteIp) |
0 | 245 { |
246 OFCondition cond = EC_Normal; | |
247 T_DIMSE_C_StoreRQ *req; | |
248 | |
249 // assign the actual information of the C-STORE-RQ command to a local variable | |
250 req = &msg->msg.CStoreRQ; | |
251 | |
252 // intialize some variables | |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
253 StoreCallbackData data; |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
254 data.handler = &handler; |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
255 data.remoteIp = &remoteIp; |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
256 data.modality = dcmSOPClassUIDToModality(req->AffectedSOPClassUID/*, "UNKNOWN"*/); |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
257 if (data.modality == NULL) |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
258 data.modality = "UNKNOWN"; |
101 | 259 |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
260 data.affectedSOPInstanceUID = req->AffectedSOPInstanceUID; |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
261 data.messageID = req->MessageID; |
0 | 262 if (assoc && assoc->params) |
263 { | |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
264 data.remoteAET = assoc->params->DULparams.callingAPTitle; |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
265 data.calledAET = assoc->params->DULparams.calledAPTitle; |
0 | 266 } |
267 else | |
268 { | |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
269 data.remoteAET = ""; |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
270 data.calledAET = ""; |
0 | 271 } |
272 | |
273 DcmFileFormat dcmff; | |
274 | |
275 // store SourceApplicationEntityTitle in metaheader | |
276 if (assoc && assoc->params) | |
277 { | |
278 const char *aet = assoc->params->DULparams.callingAPTitle; | |
279 if (aet) dcmff.getMetaInfo()->putAndInsertString(DCM_SourceApplicationEntityTitle, aet); | |
280 } | |
281 | |
282 // define an address where the information which will be received over the network will be stored | |
283 DcmDataset *dset = dcmff.getDataset(); | |
284 | |
285 cond = DIMSE_storeProvider(assoc, presID, req, NULL, /*opt_useMetaheader*/OFFalse, &dset, | |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
286 storeScpCallback, &data, |
0 | 287 /*opt_blockMode*/ DIMSE_BLOCKING, |
288 /*opt_dimse_timeout*/ 0); | |
289 | |
290 // if some error occured, dump corresponding information and remove the outfile if necessary | |
291 if (cond.bad()) | |
292 { | |
293 OFString temp_str; | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
294 LOG(ERROR) << "Store SCP Failed: " << cond.text(); |
0 | 295 } |
296 | |
297 // return return value | |
298 return cond; | |
299 } | |
300 } |