annotate Core/DicomNetworking/Internals/GetScp.cpp @ 3920:82e88ff003d7 c-get

merge default -> c-get
author Alain Mazy <alain@mazy.be>
date Tue, 12 May 2020 14:58:24 +0200
parents 4f78da5613a1
children 620e87e9e816
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
1 /**
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
6 *
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
11 *
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
22 * in the program, then also delete it here.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
23 *
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
27 * General Public License for more details.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
28 *
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
31 **/
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
32
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
33
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
34
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
35
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
36 /*=========================================================================
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
37
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
38 This file is based on portions of the following project:
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
39
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
40 Program: DCMTK 3.6.0
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
41 Module: http://dicom.offis.de/dcmtk.php.en
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
42
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
43 Copyright (C) 1994-2011, OFFIS e.V.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
44 All rights reserved.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
45
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
46 This software and supporting documentation were developed by
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
47
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
48 OFFIS e.V.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
49 R&D Division Health
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
50 Escherweg 2
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
51 26121 Oldenburg, Germany
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
52
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
53 Redistribution and use in source and binary forms, with or without
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
54 modification, are permitted provided that the following conditions
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
55 are met:
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
56
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
57 - Redistributions of source code must retain the above copyright
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
58 notice, this list of conditions and the following disclaimer.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
59
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
60 - Redistributions in binary form must reproduce the above copyright
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
61 notice, this list of conditions and the following disclaimer in the
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
62 documentation and/or other materials provided with the distribution.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
63
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
64 - Neither the name of OFFIS nor the names of its contributors may be
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
65 used to endorse or promote products derived from this software
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
66 without specific prior written permission.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
67
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
68 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
69 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
70 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
71 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
72 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
73 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
74 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
75 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
76 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
77 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
78 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
79
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
80 =========================================================================*/
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
81
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
82
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
83 #include "../../PrecompiledHeaders.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
84 #include <dcmtk/dcmnet/diutil.h>
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
85 #include <dcmtk/dcmdata/dcdeftag.h>
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
86 #include "GetScp.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
87
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
88 #include <memory>
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
89
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
90 #include "../../DicomParsing/FromDcmtkBridge.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
91 #include "../../DicomParsing/ToDcmtkBridge.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
92 #include "../../Logging.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
93 #include "../../OrthancException.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
94
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
95 #include <boost/lexical_cast.hpp>
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
96
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
97 /**
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
98 * Macro specifying whether to apply the patch suggested in issue 66:
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
99 * "Orthanc responses C-GET with zero Get Originator Message ID"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
100 * https://bitbucket.org/sjodogne/orthanc/issues/66/
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
101 **/
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
102
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
103 namespace Orthanc
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
104 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
105 namespace
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
106 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
107 struct GetScpData
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
108 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
109 // Handle returns void.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
110 IGetRequestHandler* handler_;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
111 DcmDataset* lastRequest_;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
112 T_ASC_Association * assoc_;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
113
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
114 std::string remoteIp_;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
115 std::string remoteAet_;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
116 std::string calledAet_;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
117
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
118 GetScpData()
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
119 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
120 handler_ = NULL;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
121 lastRequest_ = NULL;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
122 assoc_ = NULL;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
123 };
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
124 };
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
125
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
126 void BuildFailedInstanceList(const char* failedUIDs, DcmDataset ** rspIds)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
127 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
128 OFBool ok;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
129
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
130 if (failedUIDs != NULL)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
131 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
132 *rspIds = new DcmDataset();
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
133 ok = DU_putStringDOElement(*rspIds, DCM_FailedSOPInstanceUIDList, failedUIDs);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
134 if (!ok)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
135 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
136 LOG (ERROR) << "getSCP: failed to build DCM_FailedSOPInstanceUIDList";
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
137 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
138
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
139 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
140 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
141
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
142 void GetScpCallback(
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
143 /* in */
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
144 void *callbackData,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
145 OFBool cancelled,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
146 T_DIMSE_C_GetRQ *request,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
147 DcmDataset *requestIdentifiers,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
148 int responseCount,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
149 /* out */
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
150 T_DIMSE_C_GetRSP *response,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
151 DcmDataset **responseIdentifiers,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
152 DcmDataset **statusDetail)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
153 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
154 bzero(response, sizeof(T_DIMSE_C_GetRSP));
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
155 *statusDetail = NULL;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
156 *responseIdentifiers = NULL;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
157
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
158 GetScpData& data = *reinterpret_cast<GetScpData*>(callbackData);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
159 if (data.lastRequest_ == NULL)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
160 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
161 DicomMap input;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
162 FromDcmtkBridge::ExtractDicomSummary(input, *requestIdentifiers);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
163
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
164 try
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
165 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
166 if(!data.handler_->Handle(input, data.remoteIp_, data.remoteAet_,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
167 data.calledAet_))
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
168 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
169 response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
170 return;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
171 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
172 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
173 catch (OrthancException& e)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
174 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
175 // Internal error!
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
176 LOG(ERROR) << "IGetRequestHandler Failed: " << e.What();
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
177 response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
178 return;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
179 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
180
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
181 data.lastRequest_ = requestIdentifiers;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
182 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
183 else if (data.lastRequest_ != requestIdentifiers)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
184 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
185 // Internal error!
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
186 LOG(ERROR) << "IGetRequestHandler Failed: Internal error lastRequestIdentifier";
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
187 response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
188 return;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
189 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
190
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
191 if (data.handler_->nRemaining() == 0)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
192 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
193 response->DimseStatus = STATUS_Success;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
194 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
195 else
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
196 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
197 IGetRequestHandler::Status status;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
198
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
199 try
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
200 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
201 status = data.handler_->DoNext(data.assoc_);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
202 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
203 catch (OrthancException& e)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
204 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
205 // Internal error!
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
206 LOG(ERROR) << "IGetRequestHandler Failed: " << e.What();
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
207 response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
208 return;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
209 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
210
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
211 if (status == STATUS_Success)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
212 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
213 if (responseCount < static_cast<int>(data.handler_->nRemaining()))
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
214 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
215 response->DimseStatus = STATUS_Pending;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
216 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
217 else
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
218 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
219 response->DimseStatus = STATUS_Success;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
220 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
221 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
222 else
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
223 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
224 response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
225
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
226 if (data.handler_->nFailed() > 0 || data.handler_->warningCount() > 0)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
227 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
228 response->DimseStatus = STATUS_GET_Warning_SubOperationsCompleteOneOrMoreFailures;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
229 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
230 /*
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
231 * if all the sub-operations failed then we need to generate a failed or refused status.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
232 * cf. DICOM part 4, C.4.3.3.1
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
233 * we choose to generate a "Refused - Out of Resources - Unable to perform suboperations" status.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
234 */
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
235 if ((data.handler_->nFailed() > 0) && ((data.handler_->nCompleted() + data.handler_->warningCount()) == 0))
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
236 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
237 response->DimseStatus = STATUS_GET_Refused_OutOfResourcesSubOperations;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
238 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
239
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
240 BuildFailedInstanceList(data.handler_->failedUids(), responseIdentifiers);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
241 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
242 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
243
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
244 response->NumberOfRemainingSubOperations = data.handler_->nRemaining();
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
245 response->NumberOfCompletedSubOperations = data.handler_->nCompleted();
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
246 response->NumberOfFailedSubOperations = data.handler_->nFailed();
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
247 response->NumberOfWarningSubOperations = data.handler_->warningCount();
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
248 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
249
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
250 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
251
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
252 OFCondition Internals::getScp(T_ASC_Association * assoc,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
253 T_DIMSE_Message * msg,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
254 T_ASC_PresentationContextID presID,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
255 IGetRequestHandler& handler,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
256 std::string remoteIp,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
257 std::string remoteAet,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
258 std::string calledAet)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
259 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
260
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
261 GetScpData data;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
262 data.lastRequest_ = NULL;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
263 data.handler_ = &handler;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
264 data.assoc_ = assoc;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
265 data.remoteIp_ = remoteIp;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
266 data.remoteAet_ = remoteAet;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
267 data.calledAet_ = calledAet;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
268
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
269
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
270 OFCondition cond = DIMSE_getProvider(assoc, presID, &msg->msg.CGetRQ,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
271 GetScpCallback, &data,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
272 /*opt_blockMode*/ DIMSE_BLOCKING,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
273 /*opt_dimse_timeout*/ 0);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
274
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
275 // if some error occured, dump corresponding information and remove the outfile if necessary
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
276 if (cond.bad())
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
277 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
278 OFString temp_str;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
279 LOG(ERROR) << "Get SCP Failed: " << cond.text();
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
280 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
281
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
282 return cond;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
283 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
284 }