Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomNetworking/Internals/GetScp.cpp @ 4273:0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 03 Nov 2020 12:24:50 +0100 |
parents | 6f5d4bfb2c90 |
children | 756126cd2219 |
rev | line source |
---|---|
3818 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
3970
4d1dcdf5c57e
fix date in some files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3959
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
3818 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
10 * the License, or (at your option) any later version. |
3818 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
15 * Lesser General Public License for more details. |
3818 | 16 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
18 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
3818 | 20 **/ |
21 | |
22 | |
23 | |
24 | |
25 /*========================================================================= | |
26 | |
27 This file is based on portions of the following project: | |
28 | |
29 Program: DCMTK 3.6.0 | |
30 Module: http://dicom.offis.de/dcmtk.php.en | |
31 | |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
32 Copyright (C) 1994-2011, OFFIS e.V. |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
33 All rights reserved. |
3818 | 34 |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
35 This software and supporting documentation were developed by |
3818 | 36 |
37 OFFIS e.V. | |
38 R&D Division Health | |
39 Escherweg 2 | |
40 26121 Oldenburg, Germany | |
41 | |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
42 Redistribution and use in source and binary forms, with or without |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
43 modification, are permitted provided that the following conditions |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
44 are met: |
3818 | 45 |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
46 - Redistributions of source code must retain the above copyright |
3818 | 47 notice, this list of conditions and the following disclaimer. |
48 | |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
49 - Redistributions in binary form must reproduce the above copyright |
3818 | 50 notice, this list of conditions and the following disclaimer in the |
51 documentation and/or other materials provided with the distribution. | |
52 | |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
53 - Neither the name of OFFIS nor the names of its contributors may be |
3818 | 54 used to endorse or promote products derived from this software |
55 without specific prior written permission. | |
56 | |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
57 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
58 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
59 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
60 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
61 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
62 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
63 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
64 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
65 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
66 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
67 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
3818 | 68 |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
69 =========================================================================*/ |
3818 | 70 |
71 | |
72 #include "../../PrecompiledHeaders.h" | |
73 #include <dcmtk/dcmnet/diutil.h> | |
74 #include <dcmtk/dcmdata/dcdeftag.h> | |
75 #include "GetScp.h" | |
76 | |
77 #include <memory> | |
78 | |
79 #include "../../DicomParsing/FromDcmtkBridge.h" | |
80 #include "../../DicomParsing/ToDcmtkBridge.h" | |
81 #include "../../Logging.h" | |
82 #include "../../OrthancException.h" | |
83 | |
84 #include <boost/lexical_cast.hpp> | |
85 | |
86 | |
87 namespace Orthanc | |
88 { | |
89 namespace | |
90 { | |
91 struct GetScpData | |
92 { | |
93 // Handle returns void. | |
94 IGetRequestHandler* handler_; | |
95 DcmDataset* lastRequest_; | |
96 T_ASC_Association * assoc_; | |
97 | |
98 std::string remoteIp_; | |
99 std::string remoteAet_; | |
100 std::string calledAet_; | |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
101 int timeout_; |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
102 bool canceled_; |
3818 | 103 |
4200 | 104 GetScpData() : |
105 handler_(NULL), | |
106 lastRequest_(NULL), | |
107 assoc_(NULL), | |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
108 timeout_(0), |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
109 canceled_(false) |
3818 | 110 { |
111 }; | |
112 }; | |
113 | |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
114 static DcmDataset *BuildFailedInstanceList(const std::string& failedUIDs) |
3818 | 115 { |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
116 if (failedUIDs.empty()) |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
117 { |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
118 return NULL; |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
119 } |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
120 else |
3818 | 121 { |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
122 std::unique_ptr<DcmDataset> rspIds(new DcmDataset()); |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
123 |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
124 if (!DU_putStringDOElement(rspIds.get(), DCM_FailedSOPInstanceUIDList, failedUIDs.c_str())) |
3818 | 125 { |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
126 throw OrthancException(ErrorCode_InternalError, |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
127 "getSCP: failed to build DCM_FailedSOPInstanceUIDList"); |
3818 | 128 } |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
129 |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
130 return rspIds.release(); |
3818 | 131 } |
132 } | |
133 | |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
134 |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
135 static void FillResponse(T_DIMSE_C_GetRSP& response, |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
136 DcmDataset** failedIdentifiers, |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
137 const IGetRequestHandler& handler) |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
138 { |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
139 response.DimseStatus = STATUS_Success; |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
140 |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
141 size_t processedCount = (handler.GetCompletedCount() + |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
142 handler.GetFailedCount() + |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
143 handler.GetWarningCount()); |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
144 |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
145 if (processedCount > handler.GetSubOperationCount()) |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
146 { |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
147 throw OrthancException(ErrorCode_InternalError); |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
148 } |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
149 |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
150 response.NumberOfRemainingSubOperations = (handler.GetSubOperationCount() - processedCount); |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
151 response.NumberOfCompletedSubOperations = handler.GetCompletedCount(); |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
152 response.NumberOfFailedSubOperations = handler.GetFailedCount(); |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
153 response.NumberOfWarningSubOperations = handler.GetWarningCount(); |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
154 |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
155 // http://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_C.4.3.3.html |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
156 |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
157 if (handler.GetFailedCount() > 0 || |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
158 handler.GetWarningCount() > 0) |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
159 { |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
160 /** |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
161 * "Warning if one or more sub-operations were successfully |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
162 * completed and one or more sub-operations were unsuccessful |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
163 * or had a status of warning. Warning if all sub-operations |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
164 * had a status of Warning" |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
165 **/ |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
166 response.DimseStatus = STATUS_GET_Warning_SubOperationsCompleteOneOrMoreFailures; |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
167 } |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
168 |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
169 if (handler.GetFailedCount() > 0 && |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
170 handler.GetFailedCount() == handler.GetSubOperationCount()) |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
171 { |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
172 /** |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
173 * "Failure or Refused if all sub-operations were |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
174 * unsuccessful." => We choose to generate a "Refused - Out |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
175 * of Resources - Unable to perform suboperations" status. |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
176 */ |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
177 response.DimseStatus = STATUS_GET_Refused_OutOfResourcesSubOperations; |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
178 } |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
179 |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
180 *failedIdentifiers = BuildFailedInstanceList(handler.GetFailedUids()); |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
181 } |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
182 |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
183 |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
184 static void GetScpCallback( |
3818 | 185 /* in */ |
186 void *callbackData, | |
187 OFBool cancelled, | |
188 T_DIMSE_C_GetRQ *request, | |
189 DcmDataset *requestIdentifiers, | |
190 int responseCount, | |
191 /* out */ | |
192 T_DIMSE_C_GetRSP *response, | |
193 DcmDataset **responseIdentifiers, | |
194 DcmDataset **statusDetail) | |
195 { | |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
196 assert(response != NULL); |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
197 assert(responseIdentifiers != NULL); |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
198 |
3818 | 199 bzero(response, sizeof(T_DIMSE_C_GetRSP)); |
200 *statusDetail = NULL; | |
201 *responseIdentifiers = NULL; | |
202 | |
203 GetScpData& data = *reinterpret_cast<GetScpData*>(callbackData); | |
204 if (data.lastRequest_ == NULL) | |
205 { | |
206 DicomMap input; | |
4137
6774605d4341
keep only one signature for FromDcmtkBridge::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4136
diff
changeset
|
207 std::set<DicomTag> ignoreTagLength; |
6774605d4341
keep only one signature for FromDcmtkBridge::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4136
diff
changeset
|
208 FromDcmtkBridge::ExtractDicomSummary(input, *requestIdentifiers, 0 /* don't truncate tags */, ignoreTagLength); |
3818 | 209 |
210 try | |
211 { | |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
212 if (!data.handler_->Handle( |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
213 input, data.remoteIp_, data.remoteAet_, data.calledAet_, |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
214 data.timeout_ < 0 ? 0 : static_cast<uint32_t>(data.timeout_))) |
3818 | 215 { |
216 response->DimseStatus = STATUS_GET_Failed_UnableToProcess; | |
217 return; | |
218 } | |
219 } | |
220 catch (OrthancException& e) | |
221 { | |
222 // Internal error! | |
223 LOG(ERROR) << "IGetRequestHandler Failed: " << e.What(); | |
224 response->DimseStatus = STATUS_GET_Failed_UnableToProcess; | |
225 return; | |
226 } | |
227 | |
228 data.lastRequest_ = requestIdentifiers; | |
229 } | |
230 else if (data.lastRequest_ != requestIdentifiers) | |
231 { | |
232 // Internal error! | |
233 LOG(ERROR) << "IGetRequestHandler Failed: Internal error lastRequestIdentifier"; | |
234 response->DimseStatus = STATUS_GET_Failed_UnableToProcess; | |
235 return; | |
236 } | |
237 | |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
238 if (data.canceled_) |
3818 | 239 { |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
240 LOG(ERROR) << "IGetRequestHandler Failed: Cannot pursue a request that was canceled by the SCU"; |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
241 response->DimseStatus = STATUS_GET_Failed_UnableToProcess; |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
242 return; |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
243 } |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
244 |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
245 if (data.handler_->GetSubOperationCount() == |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
246 data.handler_->GetCompletedCount() + |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
247 data.handler_->GetFailedCount() + |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
248 data.handler_->GetWarningCount()) |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
249 { |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
250 // We're all done |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
251 FillResponse(*response, responseIdentifiers, *data.handler_); |
3818 | 252 } |
253 else | |
254 { | |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
255 bool isContinue; |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
256 |
3818 | 257 try |
258 { | |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
259 isContinue = data.handler_->DoNext(data.assoc_); |
3818 | 260 } |
261 catch (OrthancException& e) | |
262 { | |
263 // Internal error! | |
264 LOG(ERROR) << "IGetRequestHandler Failed: " << e.What(); | |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
265 FillResponse(*response, responseIdentifiers, *data.handler_); |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
266 |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
267 // Fix the status code that is computed by "FillResponse()" |
3818 | 268 response->DimseStatus = STATUS_GET_Failed_UnableToProcess; |
269 return; | |
270 } | |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
271 |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
272 FillResponse(*response, responseIdentifiers, *data.handler_); |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
273 |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
274 if (isContinue) |
3818 | 275 { |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
276 response->DimseStatus = STATUS_Pending; |
3818 | 277 } |
278 else | |
279 { | |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
280 response->DimseStatus = STATUS_GET_Cancel_SubOperationsTerminatedDueToCancelIndication; |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
281 data.canceled_ = true; |
3818 | 282 } |
283 } | |
284 } | |
285 } | |
286 | |
287 OFCondition Internals::getScp(T_ASC_Association * assoc, | |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
288 T_DIMSE_Message * msg, |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
289 T_ASC_PresentationContextID presID, |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
290 IGetRequestHandler& handler, |
4200 | 291 const std::string& remoteIp, |
292 const std::string& remoteAet, | |
293 const std::string& calledAet, | |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
294 int timeout) |
3818 | 295 { |
296 GetScpData data; | |
297 data.lastRequest_ = NULL; | |
298 data.handler_ = &handler; | |
299 data.assoc_ = assoc; | |
300 data.remoteIp_ = remoteIp; | |
301 data.remoteAet_ = remoteAet; | |
302 data.calledAet_ = calledAet; | |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
303 data.timeout_ = timeout; |
3818 | 304 |
305 OFCondition cond = DIMSE_getProvider(assoc, presID, &msg->msg.CGetRQ, | |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
306 GetScpCallback, &data, |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
307 /*opt_blockMode*/ (timeout ? DIMSE_NONBLOCKING : DIMSE_BLOCKING), |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
308 /*opt_dimse_timeout*/ timeout); |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3818
diff
changeset
|
309 |
3818 | 310 // if some error occured, dump corresponding information and remove the outfile if necessary |
311 if (cond.bad()) | |
312 { | |
313 OFString temp_str; | |
314 LOG(ERROR) << "Get SCP Failed: " << cond.text(); | |
315 } | |
316 | |
317 return cond; | |
318 } | |
319 } |