Mercurial > hg > orthanc
annotate Core/DicomNetworking/Internals/MoveScp.cpp @ 3634:103ee029982e storage-commitment
integration default->storage-commitment
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 29 Jan 2020 08:51:31 +0100 |
parents | 4e43e67f8ecf |
children | 94f4a18a79cc |
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:
831
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
3060
4e43e67f8ecf
preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2723
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., 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:
722
diff
changeset
|
34 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
35 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
36 /*========================================================================= |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
37 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
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:
722
diff
changeset
|
39 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
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:
722
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:
722
diff
changeset
|
42 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
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:
722
diff
changeset
|
44 All rights reserved. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
45 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
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:
722
diff
changeset
|
47 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
48 OFFIS e.V. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
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:
722
diff
changeset
|
50 Escherweg 2 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
51 26121 Oldenburg, Germany |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
52 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
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:
722
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:
722
diff
changeset
|
55 are met: |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
56 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
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:
722
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:
722
diff
changeset
|
59 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
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:
722
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:
722
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:
722
diff
changeset
|
63 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
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:
722
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:
722
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:
722
diff
changeset
|
67 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
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:
722
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:
722
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:
722
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:
722
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:
722
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:
722
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:
722
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:
722
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:
722
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:
722
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:
722
diff
changeset
|
79 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
80 =========================================================================*/ |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
81 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
82 |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
83 #include "../../PrecompiledHeaders.h" |
0 | 84 #include "MoveScp.h" |
85 | |
86 #include <memory> | |
87 | |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
88 #include "../../DicomParsing/FromDcmtkBridge.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
89 #include "../../DicomParsing/ToDcmtkBridge.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
90 #include "../../Logging.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
91 #include "../../OrthancException.h" |
0 | 92 |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
93 #include <boost/lexical_cast.hpp> |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
94 |
0 | 95 |
2723 | 96 /** |
97 * Macro specifying whether to apply the patch suggested in issue 66: | |
98 * "Orthanc responses C-MOVE with zero Move Originator Message ID" | |
99 * https://bitbucket.org/sjodogne/orthanc/issues/66/ | |
100 **/ | |
101 | |
102 #define APPLY_FIX_ISSUE_66 1 | |
103 | |
104 | |
62 | 105 namespace Orthanc |
0 | 106 { |
107 namespace | |
108 { | |
109 struct MoveScpData | |
110 { | |
111 std::string target_; | |
112 IMoveRequestHandler* handler_; | |
113 DcmDataset* lastRequest_; | |
114 unsigned int subOperationCount_; | |
115 unsigned int failureCount_; | |
116 unsigned int warningCount_; | |
117 std::auto_ptr<IMoveRequestIterator> iterator_; | |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
118 const std::string* remoteIp_; |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
119 const std::string* remoteAet_; |
1799
4f01c9d73f02
calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1786
diff
changeset
|
120 const std::string* calledAet_; |
0 | 121 }; |
122 | |
123 | |
2723 | 124 #if APPLY_FIX_ISSUE_66 != 1 |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
125 static uint16_t GetMessageId(const DicomMap& message) |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
126 { |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
127 /** |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
128 * Retrieve the Message ID (0000,0110) for this C-MOVE request, if |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
129 * any. If present, this Message ID will be stored in the Move |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
130 * Originator Message ID (0000,1031) field of the C-MOVE response. |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
131 * http://dicom.nema.org/dicom/2013/output/chtml/part07/chapter_E.html |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
132 **/ |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
133 |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
134 const DicomValue* value = message.TestAndGetValue(DICOM_TAG_MESSAGE_ID); |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
135 |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
136 if (value != NULL && |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
137 !value->IsNull() && |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
138 !value->IsBinary()) |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
139 { |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
140 try |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
141 { |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
142 int tmp = boost::lexical_cast<int>(value->GetContent()); |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
143 if (tmp >= 0 && tmp <= 0xffff) |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
144 { |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
145 return static_cast<uint16_t>(tmp); |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
146 } |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
147 } |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
148 catch (boost::bad_lexical_cast&) |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
149 { |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
150 LOG(WARNING) << "Cannot convert the Message ID (\"" << value->GetContent() |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
151 << "\") of an incoming C-MOVE request to an integer, assuming zero"; |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
152 } |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
153 } |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
154 |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
155 return 0; |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
156 } |
2723 | 157 #endif |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
158 |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
159 |
0 | 160 void MoveScpCallback( |
161 /* in */ | |
162 void *callbackData, | |
163 OFBool cancelled, | |
164 T_DIMSE_C_MoveRQ *request, | |
165 DcmDataset *requestIdentifiers, | |
166 int responseCount, | |
167 /* out */ | |
168 T_DIMSE_C_MoveRSP *response, | |
169 DcmDataset **responseIdentifiers, | |
170 DcmDataset **statusDetail) | |
171 { | |
172 bzero(response, sizeof(T_DIMSE_C_MoveRSP)); | |
173 *statusDetail = NULL; | |
174 *responseIdentifiers = NULL; | |
175 | |
656 | 176 MoveScpData& data = *reinterpret_cast<MoveScpData*>(callbackData); |
0 | 177 if (data.lastRequest_ == NULL) |
178 { | |
1786
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
179 DicomMap input; |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
180 FromDcmtkBridge::ExtractDicomSummary(input, *requestIdentifiers); |
0 | 181 |
182 try | |
183 { | |
2723 | 184 #if APPLY_FIX_ISSUE_66 == 1 |
185 uint16_t messageId = request->MessageID; | |
186 #else | |
187 // The line below was the implementation for Orthanc <= 1.3.2 | |
188 uint16_t messageId = GetMessageId(input); | |
189 #endif | |
190 | |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
191 data.iterator_.reset(data.handler_->Handle(data.target_, input, *data.remoteIp_, *data.remoteAet_, |
2723 | 192 *data.calledAet_, messageId)); |
722 | 193 |
613 | 194 if (data.iterator_.get() == NULL) |
195 { | |
196 // Internal error! | |
197 response->DimseStatus = STATUS_MOVE_Failed_UnableToProcess; | |
198 return; | |
199 } | |
200 | |
0 | 201 data.subOperationCount_ = data.iterator_->GetSubOperationCount(); |
202 data.failureCount_ = 0; | |
203 data.warningCount_ = 0; | |
204 } | |
62 | 205 catch (OrthancException& e) |
0 | 206 { |
207 // Internal error! | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
208 LOG(ERROR) << "IMoveRequestHandler Failed: " << e.What(); |
0 | 209 response->DimseStatus = STATUS_MOVE_Failed_UnableToProcess; |
210 return; | |
211 } | |
212 | |
213 data.lastRequest_ = requestIdentifiers; | |
214 } | |
215 else if (data.lastRequest_ != requestIdentifiers) | |
216 { | |
217 // Internal error! | |
218 response->DimseStatus = STATUS_MOVE_Failed_UnableToProcess; | |
219 return; | |
220 } | |
221 | |
222 if (data.subOperationCount_ == 0) | |
223 { | |
224 response->DimseStatus = STATUS_Success; | |
225 } | |
226 else | |
227 { | |
228 IMoveRequestIterator::Status status; | |
229 | |
230 try | |
231 { | |
232 status = data.iterator_->DoNext(); | |
233 } | |
62 | 234 catch (OrthancException& e) |
0 | 235 { |
236 // Internal error! | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
237 LOG(ERROR) << "IMoveRequestHandler Failed: " << e.What(); |
0 | 238 response->DimseStatus = STATUS_MOVE_Failed_UnableToProcess; |
239 return; | |
240 } | |
241 | |
242 if (status == IMoveRequestIterator::Status_Failure) | |
243 { | |
244 data.failureCount_++; | |
245 } | |
246 else if (status == IMoveRequestIterator::Status_Warning) | |
247 { | |
248 data.warningCount_++; | |
249 } | |
250 | |
251 if (responseCount < static_cast<int>(data.subOperationCount_)) | |
252 { | |
253 response->DimseStatus = STATUS_Pending; | |
254 } | |
255 else | |
256 { | |
257 response->DimseStatus = STATUS_Success; | |
258 } | |
259 } | |
260 | |
261 response->NumberOfRemainingSubOperations = data.subOperationCount_ - responseCount; | |
262 response->NumberOfCompletedSubOperations = responseCount; | |
263 response->NumberOfFailedSubOperations = data.failureCount_; | |
264 response->NumberOfWarningSubOperations = data.warningCount_; | |
265 } | |
266 } | |
267 | |
268 | |
269 OFCondition Internals::moveScp(T_ASC_Association * assoc, | |
270 T_DIMSE_Message * msg, | |
271 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
|
272 IMoveRequestHandler& handler, |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
273 const std::string& remoteIp, |
1799
4f01c9d73f02
calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1786
diff
changeset
|
274 const std::string& remoteAet, |
4f01c9d73f02
calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1786
diff
changeset
|
275 const std::string& calledAet) |
0 | 276 { |
277 MoveScpData data; | |
278 data.target_ = std::string(msg->msg.CMoveRQ.MoveDestination); | |
279 data.lastRequest_ = NULL; | |
280 data.handler_ = &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
|
281 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
|
282 data.remoteAet_ = &remoteAet; |
1799
4f01c9d73f02
calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1786
diff
changeset
|
283 data.calledAet_ = &calledAet; |
0 | 284 |
285 OFCondition cond = DIMSE_moveProvider(assoc, presID, &msg->msg.CMoveRQ, | |
286 MoveScpCallback, &data, | |
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) << "Move SCP Failed: " << cond.text(); |
0 | 295 } |
296 | |
297 return cond; | |
298 } | |
299 } |