Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomNetworking/Internals/MoveScp.cpp @ 4224:38d446c9ee1d
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 30 Sep 2020 17:59:09 +0200 |
parents | 6774605d4341 |
children | 756126cd2219 |
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 |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
0 | 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. |
136 | 11 * |
0 | 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. |
0 | 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/>. |
0 | 20 **/ |
21 | |
22 | |
766
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
23 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
24 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
25 /*========================================================================= |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
26 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
27 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
|
28 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
29 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
|
30 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
|
31 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
32 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
|
33 All rights reserved. |
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 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
|
36 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
37 OFFIS e.V. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
38 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
|
39 Escherweg 2 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
40 26121 Oldenburg, Germany |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
41 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
42 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
|
43 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
|
44 are met: |
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 - 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
|
47 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
|
48 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
49 - 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
|
50 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
|
51 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
|
52 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
53 - 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
|
54 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
|
55 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
|
56 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
57 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
|
58 "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
|
59 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
|
60 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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 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
|
66 (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
|
67 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
|
68 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
69 =========================================================================*/ |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
70 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
71 |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
72 #include "../../PrecompiledHeaders.h" |
0 | 73 #include "MoveScp.h" |
74 | |
75 #include <memory> | |
76 | |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
77 #include "../../DicomParsing/FromDcmtkBridge.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
78 #include "../../DicomParsing/ToDcmtkBridge.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
79 #include "../../Logging.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
80 #include "../../OrthancException.h" |
0 | 81 |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
82 #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
|
83 |
0 | 84 |
2723 | 85 /** |
86 * Macro specifying whether to apply the patch suggested in issue 66: | |
87 * "Orthanc responses C-MOVE with zero Move Originator Message ID" | |
88 * https://bitbucket.org/sjodogne/orthanc/issues/66/ | |
89 **/ | |
90 | |
91 #define APPLY_FIX_ISSUE_66 1 | |
92 | |
93 | |
62 | 94 namespace Orthanc |
0 | 95 { |
96 namespace | |
97 { | |
98 struct MoveScpData | |
99 { | |
100 std::string target_; | |
101 IMoveRequestHandler* handler_; | |
102 DcmDataset* lastRequest_; | |
103 unsigned int subOperationCount_; | |
104 unsigned int failureCount_; | |
105 unsigned int warningCount_; | |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3704
diff
changeset
|
106 std::unique_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
|
107 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
|
108 const std::string* remoteAet_; |
1799
4f01c9d73f02
calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1786
diff
changeset
|
109 const std::string* calledAet_; |
0 | 110 }; |
111 | |
112 | |
2723 | 113 #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
|
114 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
|
115 { |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
116 /** |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
117 * 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
|
118 * 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
|
119 * 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
|
120 * 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
|
121 **/ |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
122 |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
123 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
|
124 |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
125 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
|
126 !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
|
127 !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
|
128 { |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
129 try |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
130 { |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
131 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
|
132 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
|
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 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
|
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 } |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
137 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
|
138 { |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
139 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
|
140 << "\") 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
|
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 } |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
143 |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
144 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
|
145 } |
2723 | 146 #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
|
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 |
0 | 149 void MoveScpCallback( |
150 /* in */ | |
151 void *callbackData, | |
152 OFBool cancelled, | |
153 T_DIMSE_C_MoveRQ *request, | |
154 DcmDataset *requestIdentifiers, | |
155 int responseCount, | |
156 /* out */ | |
157 T_DIMSE_C_MoveRSP *response, | |
158 DcmDataset **responseIdentifiers, | |
159 DcmDataset **statusDetail) | |
160 { | |
161 bzero(response, sizeof(T_DIMSE_C_MoveRSP)); | |
162 *statusDetail = NULL; | |
163 *responseIdentifiers = NULL; | |
164 | |
656 | 165 MoveScpData& data = *reinterpret_cast<MoveScpData*>(callbackData); |
0 | 166 if (data.lastRequest_ == NULL) |
167 { | |
1786
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
168 DicomMap input; |
4137
6774605d4341
keep only one signature for FromDcmtkBridge::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4136
diff
changeset
|
169 std::set<DicomTag> ignoreTagLength; |
6774605d4341
keep only one signature for FromDcmtkBridge::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4136
diff
changeset
|
170 FromDcmtkBridge::ExtractDicomSummary(input, *requestIdentifiers, 0 /* don't truncate tags */, ignoreTagLength); |
0 | 171 |
172 try | |
173 { | |
2723 | 174 #if APPLY_FIX_ISSUE_66 == 1 |
175 uint16_t messageId = request->MessageID; | |
176 #else | |
177 // The line below was the implementation for Orthanc <= 1.3.2 | |
178 uint16_t messageId = GetMessageId(input); | |
179 #endif | |
180 | |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
181 data.iterator_.reset(data.handler_->Handle(data.target_, input, *data.remoteIp_, *data.remoteAet_, |
2723 | 182 *data.calledAet_, messageId)); |
722 | 183 |
613 | 184 if (data.iterator_.get() == NULL) |
185 { | |
186 // Internal error! | |
187 response->DimseStatus = STATUS_MOVE_Failed_UnableToProcess; | |
188 return; | |
189 } | |
190 | |
0 | 191 data.subOperationCount_ = data.iterator_->GetSubOperationCount(); |
192 data.failureCount_ = 0; | |
193 data.warningCount_ = 0; | |
194 } | |
62 | 195 catch (OrthancException& e) |
0 | 196 { |
197 // Internal error! | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
198 LOG(ERROR) << "IMoveRequestHandler Failed: " << e.What(); |
0 | 199 response->DimseStatus = STATUS_MOVE_Failed_UnableToProcess; |
200 return; | |
201 } | |
202 | |
203 data.lastRequest_ = requestIdentifiers; | |
204 } | |
205 else if (data.lastRequest_ != requestIdentifiers) | |
206 { | |
207 // Internal error! | |
208 response->DimseStatus = STATUS_MOVE_Failed_UnableToProcess; | |
209 return; | |
210 } | |
211 | |
212 if (data.subOperationCount_ == 0) | |
213 { | |
214 response->DimseStatus = STATUS_Success; | |
215 } | |
216 else | |
217 { | |
218 IMoveRequestIterator::Status status; | |
219 | |
220 try | |
221 { | |
222 status = data.iterator_->DoNext(); | |
223 } | |
62 | 224 catch (OrthancException& e) |
0 | 225 { |
226 // Internal error! | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
227 LOG(ERROR) << "IMoveRequestHandler Failed: " << e.What(); |
0 | 228 response->DimseStatus = STATUS_MOVE_Failed_UnableToProcess; |
229 return; | |
230 } | |
231 | |
232 if (status == IMoveRequestIterator::Status_Failure) | |
233 { | |
234 data.failureCount_++; | |
235 } | |
236 else if (status == IMoveRequestIterator::Status_Warning) | |
237 { | |
238 data.warningCount_++; | |
239 } | |
240 | |
241 if (responseCount < static_cast<int>(data.subOperationCount_)) | |
242 { | |
243 response->DimseStatus = STATUS_Pending; | |
244 } | |
245 else | |
246 { | |
247 response->DimseStatus = STATUS_Success; | |
248 } | |
249 } | |
250 | |
251 response->NumberOfRemainingSubOperations = data.subOperationCount_ - responseCount; | |
252 response->NumberOfCompletedSubOperations = responseCount; | |
253 response->NumberOfFailedSubOperations = data.failureCount_; | |
254 response->NumberOfWarningSubOperations = data.warningCount_; | |
255 } | |
256 } | |
257 | |
258 | |
259 OFCondition Internals::moveScp(T_ASC_Association * assoc, | |
260 T_DIMSE_Message * msg, | |
261 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
|
262 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
|
263 const std::string& remoteIp, |
1799
4f01c9d73f02
calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1786
diff
changeset
|
264 const std::string& remoteAet, |
3704
58f92b1c8061
Fix issue #167 (Job can't be cancelled - Handling of timeouts after established association)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
265 const std::string& calledAet, |
58f92b1c8061
Fix issue #167 (Job can't be cancelled - Handling of timeouts after established association)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
266 int timeout) |
0 | 267 { |
268 MoveScpData data; | |
269 data.target_ = std::string(msg->msg.CMoveRQ.MoveDestination); | |
270 data.lastRequest_ = NULL; | |
271 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
|
272 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
|
273 data.remoteAet_ = &remoteAet; |
1799
4f01c9d73f02
calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1786
diff
changeset
|
274 data.calledAet_ = &calledAet; |
0 | 275 |
276 OFCondition cond = DIMSE_moveProvider(assoc, presID, &msg->msg.CMoveRQ, | |
277 MoveScpCallback, &data, | |
3704
58f92b1c8061
Fix issue #167 (Job can't be cancelled - Handling of timeouts after established association)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
278 /*opt_blockMode*/ (timeout ? DIMSE_NONBLOCKING : DIMSE_BLOCKING), |
58f92b1c8061
Fix issue #167 (Job can't be cancelled - Handling of timeouts after established association)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
279 /*opt_dimse_timeout*/ timeout); |
0 | 280 |
281 // if some error occured, dump corresponding information and remove the outfile if necessary | |
282 if (cond.bad()) | |
283 { | |
284 OFString temp_str; | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
285 LOG(ERROR) << "Move SCP Failed: " << cond.text(); |
0 | 286 } |
287 | |
288 return cond; | |
289 } | |
290 } |