Mercurial > hg > orthanc
annotate OrthancServer/Sources/OrthancGetRequestHandler.cpp @ 4870:43e613a7756b
upgrade to year 2022
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 11 Jan 2022 11:15:42 +0100 |
parents | 7053502fbf97 |
children | 6eff25f70121 |
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 | |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
3818 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU General Public License as | |
10 * published by the Free Software Foundation, either version 3 of the | |
11 * License, or (at your option) any later version. | |
12 * | |
13 * In addition, as a special exception, the copyright holders of this | |
14 * program give permission to link the code of its release with the | |
15 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
16 * that use the same license as the "OpenSSL" library), and distribute | |
17 * the linked executables. You must obey the GNU General Public License | |
18 * in all respects for all of the code used other than "OpenSSL". If you | |
19 * modify file(s) with this exception, you may extend this exception to | |
20 * your version of the file(s), but you are not obligated to do so. If | |
21 * you do not wish to do so, delete this exception statement from your | |
22 * version. If you delete this exception statement from all source files | |
23 * in the program, then also delete it here. | |
24 * | |
25 * This program is distributed in the hope that it will be useful, but | |
26 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
28 * General Public License for more details. | |
29 * | |
30 * You should have received a copy of the GNU General Public License | |
31 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
32 **/ | |
33 | |
34 #include "PrecompiledHeadersServer.h" | |
35 #include "OrthancGetRequestHandler.h" | |
36 | |
4045 | 37 #include "../../OrthancFramework/Sources/DicomFormat/DicomArray.h" |
38 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" | |
39 #include "../../OrthancFramework/Sources/Logging.h" | |
40 #include "../../OrthancFramework/Sources/MetricsRegistry.h" | |
3818 | 41 #include "OrthancConfiguration.h" |
42 #include "ServerContext.h" | |
43 #include "ServerJobs/DicomModalityStoreJob.h" | |
44 | |
3963 | 45 #include <dcmtk/dcmdata/dcdeftag.h> |
46 #include <dcmtk/dcmdata/dcfilefo.h> | |
47 #include <dcmtk/dcmdata/dcistrmb.h> | |
48 #include <dcmtk/dcmnet/assoc.h> | |
49 #include <dcmtk/dcmnet/dimse.h> | |
50 #include <dcmtk/dcmnet/diutil.h> | |
51 #include <dcmtk/ofstd/ofstring.h> | |
52 | |
3962
d30eb4ae5bb6
trying a fix for msvc2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3959
diff
changeset
|
53 #include <sstream> // For std::stringstream |
d30eb4ae5bb6
trying a fix for msvc2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3959
diff
changeset
|
54 |
3818 | 55 namespace Orthanc |
56 { | |
4286
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
57 static void ProgressCallback(void *callbackData, |
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
58 T_DIMSE_StoreProgress *progress, |
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
59 T_DIMSE_C_StoreRQ *req) |
3818 | 60 { |
4286
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
61 if (req != NULL && |
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
62 progress->state == DIMSE_StoreBegin) |
3818 | 63 { |
4286
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
64 OFString str; |
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
65 CLOG(TRACE, DICOM) << "Sending Store Request following a C-GET:" << std::endl |
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
66 << DIMSE_dumpMessage(str, *req, DIMSE_OUTGOING); |
3818 | 67 } |
68 } | |
69 | |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
70 |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
71 bool OrthancGetRequestHandler::DoNext(T_ASC_Association* assoc) |
3818 | 72 { |
73 if (position_ >= instances_.size()) | |
74 { | |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
75 throw OrthancException(ErrorCode_ParameterOutOfRange); |
3818 | 76 } |
77 | |
78 const std::string& id = instances_[position_++]; | |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
79 |
3818 | 80 std::string dicom; |
81 context_.ReadDicom(dicom, id); | |
82 | |
4204 | 83 if (dicom.empty()) |
3818 | 84 { |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
85 throw OrthancException(ErrorCode_BadFileFormat); |
3818 | 86 } |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
87 |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
88 std::unique_ptr<DcmFileFormat> parsed( |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
89 FromDcmtkBridge::LoadFromMemoryBuffer(dicom.c_str(), dicom.size())); |
3954 | 90 |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
91 if (parsed.get() == NULL || |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
92 parsed->getDataset() == NULL) |
3954 | 93 { |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
94 throw OrthancException(ErrorCode_InternalError); |
3954 | 95 } |
3818 | 96 |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
97 DcmDataset& dataset = *parsed->getDataset(); |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
98 |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
99 OFString a, b; |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
100 if (!dataset.findAndGetOFString(DCM_SOPClassUID, a).good() || |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
101 !dataset.findAndGetOFString(DCM_SOPInstanceUID, b).good()) |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
102 { |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
103 throw OrthancException(ErrorCode_NoSopClassOrInstance, |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
104 "Unable to determine the SOP class/instance for C-STORE with AET " + |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
105 originatorAet_); |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
106 } |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
107 |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
108 std::string sopClassUid(a.c_str()); |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
109 std::string sopInstanceUid(b.c_str()); |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
110 |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
111 return PerformGetSubOp(assoc, sopClassUid, sopInstanceUid, parsed.release()); |
3818 | 112 } |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
113 |
3818 | 114 |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
115 void OrthancGetRequestHandler::AddFailedUIDInstance(const std::string& sopInstance) |
3818 | 116 { |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
117 if (failedUIDs_.empty()) |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
118 { |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
119 failedUIDs_ = sopInstance; |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
120 } |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
121 else |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
122 { |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
123 failedUIDs_ += "\\" + sopInstance; |
3818 | 124 } |
125 } | |
126 | |
127 | |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
128 static bool SelectPresentationContext(T_ASC_PresentationContextID& selectedPresentationId, |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
129 DicomTransferSyntax& selectedSyntax, |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
130 T_ASC_Association* assoc, |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
131 const std::string& sopClassUid, |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
132 DicomTransferSyntax sourceSyntax, |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
133 bool allowTranscoding) |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
134 { |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
135 typedef std::map<DicomTransferSyntax, T_ASC_PresentationContextID> Accepted; |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
136 |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
137 Accepted accepted; |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
138 |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
139 /** |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
140 * 1. Inspect and index all the accepted transfer syntaxes. This |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
141 * is similar to the code from "DicomAssociation::Open()". |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
142 **/ |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
143 |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
144 LST_HEAD **l = &assoc->params->DULparams.acceptedPresentationContext; |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
145 if (*l != NULL) |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
146 { |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
147 DUL_PRESENTATIONCONTEXT* pc = (DUL_PRESENTATIONCONTEXT*) LST_Head(l); |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
148 LST_Position(l, (LST_NODE*)pc); |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
149 while (pc) |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
150 { |
3966
fde1355a625a
c-get compatibility with ginkgocadx
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3963
diff
changeset
|
151 DicomTransferSyntax transferSyntax; |
4669
b14989f9ff8b
fix misleading log message about unknown transfer syntax in C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4482
diff
changeset
|
152 if (pc->result == ASC_P_ACCEPTANCE) |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
153 { |
4669
b14989f9ff8b
fix misleading log message about unknown transfer syntax in C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4482
diff
changeset
|
154 if (LookupTransferSyntax(transferSyntax, pc->acceptedTransferSyntax)) |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
155 { |
4669
b14989f9ff8b
fix misleading log message about unknown transfer syntax in C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4482
diff
changeset
|
156 /*CLOG(TRACE, DICOM) << "C-GET SCP accepted: SOP class " << pc->abstractSyntax |
b14989f9ff8b
fix misleading log message about unknown transfer syntax in C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4482
diff
changeset
|
157 << " with transfer syntax " << GetTransferSyntaxUid(transferSyntax);*/ |
b14989f9ff8b
fix misleading log message about unknown transfer syntax in C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4482
diff
changeset
|
158 if (std::string(pc->abstractSyntax) == sopClassUid) |
b14989f9ff8b
fix misleading log message about unknown transfer syntax in C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4482
diff
changeset
|
159 { |
b14989f9ff8b
fix misleading log message about unknown transfer syntax in C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4482
diff
changeset
|
160 accepted[transferSyntax] = pc->presentationContextID; |
b14989f9ff8b
fix misleading log message about unknown transfer syntax in C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4482
diff
changeset
|
161 } |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
162 } |
4669
b14989f9ff8b
fix misleading log message about unknown transfer syntax in C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4482
diff
changeset
|
163 else |
b14989f9ff8b
fix misleading log message about unknown transfer syntax in C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4482
diff
changeset
|
164 { |
b14989f9ff8b
fix misleading log message about unknown transfer syntax in C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4482
diff
changeset
|
165 CLOG(WARNING, DICOM) << "C-GET: Unknown transfer syntax received: " |
b14989f9ff8b
fix misleading log message about unknown transfer syntax in C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4482
diff
changeset
|
166 << pc->acceptedTransferSyntax; |
b14989f9ff8b
fix misleading log message about unknown transfer syntax in C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4482
diff
changeset
|
167 } |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
168 } |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
169 |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
170 pc = (DUL_PRESENTATIONCONTEXT*) LST_Next(l); |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
171 } |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
172 } |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
173 |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
174 |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
175 /** |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
176 * 2. Select the preferred transfer syntaxes, which corresponds to |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
177 * the source transfer syntax, plus all the uncompressed transfer |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
178 * syntaxes if transcoding is enabled. |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
179 **/ |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
180 |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
181 std::list<DicomTransferSyntax> preferred; |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
182 preferred.push_back(sourceSyntax); |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
183 |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
184 if (allowTranscoding) |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
185 { |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
186 if (sourceSyntax != DicomTransferSyntax_LittleEndianImplicit) |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
187 { |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
188 // Default Transfer Syntax for DICOM |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
189 preferred.push_back(DicomTransferSyntax_LittleEndianImplicit); |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
190 } |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
191 |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
192 if (sourceSyntax != DicomTransferSyntax_LittleEndianExplicit) |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
193 { |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
194 preferred.push_back(DicomTransferSyntax_LittleEndianExplicit); |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
195 } |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
196 |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
197 if (sourceSyntax != DicomTransferSyntax_BigEndianExplicit) |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
198 { |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
199 // Retired |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
200 preferred.push_back(DicomTransferSyntax_BigEndianExplicit); |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
201 } |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
202 } |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
203 |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
204 |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
205 /** |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
206 * 3. Lookup whether one of the preferred transfer syntaxes was |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
207 * accepted. |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
208 **/ |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
209 |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
210 for (std::list<DicomTransferSyntax>::const_iterator |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
211 it = preferred.begin(); it != preferred.end(); ++it) |
3966
fde1355a625a
c-get compatibility with ginkgocadx
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3963
diff
changeset
|
212 { |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
213 Accepted::const_iterator found = accepted.find(*it); |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
214 if (found != accepted.end()) |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
215 { |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
216 selectedPresentationId = found->second; |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
217 selectedSyntax = *it; |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
218 return true; |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
219 } |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
220 } |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
221 |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
222 // No preferred syntax was accepted |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
223 return false; |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
224 } |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
225 |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
226 |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
227 bool OrthancGetRequestHandler::PerformGetSubOp(T_ASC_Association* assoc, |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
228 const std::string& sopClassUid, |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
229 const std::string& sopInstanceUid, |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
230 DcmFileFormat* dicomRaw) |
3818 | 231 { |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
232 assert(dicomRaw != NULL); |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
233 std::unique_ptr<DcmFileFormat> dicom(dicomRaw); |
3818 | 234 |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
235 DicomTransferSyntax sourceSyntax; |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
236 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(sourceSyntax, *dicom)) |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
237 { |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
238 failedCount_++; |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
239 AddFailedUIDInstance(sopInstanceUid); |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
240 throw OrthancException(ErrorCode_NetworkProtocol, |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
241 "C-GET SCP: Unknown transfer syntax: (" + |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
242 std::string(dcmSOPClassUIDToModality(sopClassUid.c_str(), "OT")) + |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
243 ") " + sopClassUid); |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
244 } |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
245 |
3972
7f8b30416d50
minor clarification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3970
diff
changeset
|
246 T_ASC_PresentationContextID presId = 0; // Unnecessary initialization, makes code clearer |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
247 DicomTransferSyntax selectedSyntax; |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
248 if (!SelectPresentationContext(presId, selectedSyntax, assoc, sopClassUid, |
4482
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
249 sourceSyntax, allowTranscoding_) || |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
250 presId == 0) |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
251 { |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
252 failedCount_++; |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
253 AddFailedUIDInstance(sopInstanceUid); |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
254 throw OrthancException(ErrorCode_NetworkProtocol, |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
255 "C-GET SCP: storeSCU: No presentation context for: (" + |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
256 std::string(dcmSOPClassUIDToModality(sopClassUid.c_str(), "OT")) + |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
257 ") " + sopClassUid); |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
258 } |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
259 else |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
260 { |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
261 CLOG(INFO, DICOM) << "C-GET SCP selected transfer syntax " << GetTransferSyntaxUid(selectedSyntax) |
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
262 << ", for source instance with SOP class " << sopClassUid |
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
263 << " and transfer syntax " << GetTransferSyntaxUid(sourceSyntax); |
3966
fde1355a625a
c-get compatibility with ginkgocadx
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3963
diff
changeset
|
264 |
3818 | 265 // make sure that we can send images in this presentation context |
266 T_ASC_PresentationContext pc; | |
267 ASC_findAcceptedPresentationContext(assoc->params, presId, &pc); | |
268 // the acceptedRole is the association requestor role | |
3966
fde1355a625a
c-get compatibility with ginkgocadx
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3963
diff
changeset
|
269 |
fde1355a625a
c-get compatibility with ginkgocadx
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3963
diff
changeset
|
270 if (pc.acceptedRole != ASC_SC_ROLE_DEFAULT && // "DEFAULT" is necessary for GinkgoCADx |
fde1355a625a
c-get compatibility with ginkgocadx
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3963
diff
changeset
|
271 pc.acceptedRole != ASC_SC_ROLE_SCP && |
fde1355a625a
c-get compatibility with ginkgocadx
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3963
diff
changeset
|
272 pc.acceptedRole != ASC_SC_ROLE_SCUSCP) |
3818 | 273 { |
274 // the role is not appropriate | |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
275 failedCount_++; |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
276 AddFailedUIDInstance(sopInstanceUid); |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
277 throw OrthancException(ErrorCode_NetworkProtocol, |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
278 "C-GET SCP: storeSCU: [No presentation context with requestor SCP role for: (" + |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
279 std::string(dcmSOPClassUIDToModality(sopClassUid.c_str(), "OT")) + |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
280 ") " + sopClassUid); |
3818 | 281 } |
282 } | |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
283 |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
284 const DIC_US msgId = assoc->nextMsgID++; |
3818 | 285 |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
286 T_DIMSE_C_StoreRQ req; |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
287 memset(&req, 0, sizeof(req)); |
3818 | 288 req.MessageID = msgId; |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
289 strncpy(req.AffectedSOPClassUID, sopClassUid.c_str(), DIC_UI_LEN); |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
290 strncpy(req.AffectedSOPInstanceUID, sopInstanceUid.c_str(), DIC_UI_LEN); |
3818 | 291 req.DataSetType = DIMSE_DATASET_PRESENT; |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
292 req.Priority = DIMSE_PRIORITY_MEDIUM; |
3818 | 293 req.opts = 0; |
294 | |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
295 T_DIMSE_C_StoreRSP rsp; |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
296 memset(&rsp, 0, sizeof(rsp)); |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
297 |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
298 CLOG(INFO, DICOM) << "Store SCU RQ: MsgID " << msgId << ", (" |
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
299 << dcmSOPClassUIDToModality(sopClassUid.c_str(), "OT") << ")"; |
3818 | 300 |
301 T_DIMSE_DetectedCancelParameters cancelParameters; | |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
302 memset(&cancelParameters, 0, sizeof(cancelParameters)); |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
303 |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
304 std::unique_ptr<DcmDataset> stDetail; |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
305 |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
306 OFCondition cond; |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
307 |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
308 if (sourceSyntax == selectedSyntax) |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
309 { |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
310 // No transcoding is required |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
311 DcmDataset *stDetailTmp = NULL; |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
312 cond = DIMSE_storeUser( |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
313 assoc, presId, &req, NULL /* imageFileName */, dicom->getDataset(), |
4286
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
314 ProgressCallback, NULL /* callbackData */, |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
315 (timeout_ > 0 ? DIMSE_NONBLOCKING : DIMSE_BLOCKING), timeout_, |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
316 &rsp, &stDetailTmp, &cancelParameters); |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
317 stDetail.reset(stDetailTmp); |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
318 } |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
319 else |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
320 { |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
321 // Transcoding to the selected uncompressed transfer syntax |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
322 IDicomTranscoder::DicomImage source, transcoded; |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
323 source.AcquireParsed(dicom.release()); |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
324 |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
325 std::set<DicomTransferSyntax> ts; |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
326 ts.insert(selectedSyntax); |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
327 |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
328 if (context_.Transcode(transcoded, source, ts, true)) |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
329 { |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
330 // Transcoding has succeeded |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
331 DcmDataset *stDetailTmp = NULL; |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
332 cond = DIMSE_storeUser( |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
333 assoc, presId, &req, NULL /* imageFileName */, |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
334 transcoded.GetParsed().getDataset(), |
4286
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
335 ProgressCallback, NULL /* callbackData */, |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
336 (timeout_ > 0 ? DIMSE_NONBLOCKING : DIMSE_BLOCKING), timeout_, |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
337 &rsp, &stDetailTmp, &cancelParameters); |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
338 stDetail.reset(stDetailTmp); |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
339 } |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
340 else |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
341 { |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
342 // Cannot transcode |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
343 failedCount_++; |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
344 AddFailedUIDInstance(sopInstanceUid); |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
345 throw OrthancException(ErrorCode_NotImplemented, |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
346 "C-GET SCP: Cannot transcode " + sopClassUid + |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
347 " from transfer syntax " + GetTransferSyntaxUid(sourceSyntax) + |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
348 " to " + GetTransferSyntaxUid(selectedSyntax)); |
3959
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
349 } |
76a24be12912
c-get: support of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3955
diff
changeset
|
350 } |
4257
c046d559edb3
Fix reporting of client-side store warnings/errors in C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
351 |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
352 bool isContinue; |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
353 |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
354 if (cond.good()) |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
355 { |
4286
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
356 { |
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
357 OFString str; |
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
358 CLOG(TRACE, DICOM) << "Received Store Response following a C-GET:" << std::endl |
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
359 << DIMSE_dumpMessage(str, rsp, DIMSE_INCOMING); |
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
360 } |
526bd8bad850
debug logs for C-MOVE and C-GET SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
361 |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
362 if (cancelParameters.cancelEncountered) |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
363 { |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
364 CLOG(INFO, DICOM) << "C-GET SCP: Received C-Cancel RQ"; |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
365 isContinue = false; |
3818 | 366 } |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
367 else if (rsp.DimseStatus == STATUS_Success) |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
368 { |
3818 | 369 // everything ok |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
370 completedCount_++; |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
371 isContinue = true; |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
372 } |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
373 else if ((rsp.DimseStatus & 0xf000) == 0xb000) |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
374 { |
3818 | 375 // a warning status message |
376 warningCount_++; | |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
377 CLOG(ERROR, DICOM) << "C-GET SCP: Store Warning: Response Status: " |
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
378 << DU_cstoreStatusString(rsp.DimseStatus); |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
379 isContinue = true; |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
380 } |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
381 else |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
382 { |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
383 failedCount_++; |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
384 AddFailedUIDInstance(sopInstanceUid); |
3818 | 385 // print a status message |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
386 CLOG(ERROR, DICOM) << "C-GET SCP: Store Failed: Response Status: " |
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
387 << DU_cstoreStatusString(rsp.DimseStatus); |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
388 isContinue = true; |
3818 | 389 } |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
390 } |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
391 else |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
392 { |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
393 failedCount_++; |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
394 AddFailedUIDInstance(sopInstanceUid); |
3818 | 395 OFString temp_str; |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
396 CLOG(ERROR, DICOM) << "C-GET SCP: storeSCU: Store Request Failed: " |
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
397 << DimseCondition::dump(temp_str, cond); |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
398 isContinue = true; |
3818 | 399 } |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
400 |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
401 if (stDetail.get() != NULL) |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
402 { |
4288 | 403 std::stringstream s; // DcmObject::PrintHelper cannot be used with VS2008 |
404 stDetail->print(s); | |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
405 CLOG(INFO, DICOM) << " Status Detail: " << s.str(); |
3818 | 406 } |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
407 |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
408 return isContinue; |
3818 | 409 } |
410 | |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
411 bool OrthancGetRequestHandler::LookupIdentifiers(std::list<std::string>& publicIds, |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
412 ResourceType level, |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
413 const DicomMap& input) const |
3818 | 414 { |
415 DicomTag tag(0, 0); // Dummy initialization | |
416 | |
417 switch (level) | |
418 { | |
419 case ResourceType_Patient: | |
420 tag = DICOM_TAG_PATIENT_ID; | |
421 break; | |
422 | |
423 case ResourceType_Study: | |
424 tag = (input.HasTag(DICOM_TAG_ACCESSION_NUMBER) ? | |
425 DICOM_TAG_ACCESSION_NUMBER : DICOM_TAG_STUDY_INSTANCE_UID); | |
426 break; | |
427 | |
428 case ResourceType_Series: | |
429 tag = DICOM_TAG_SERIES_INSTANCE_UID; | |
430 break; | |
431 | |
432 case ResourceType_Instance: | |
433 tag = DICOM_TAG_SOP_INSTANCE_UID; | |
434 break; | |
435 | |
436 default: | |
437 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
438 } | |
439 | |
440 if (!input.HasTag(tag)) | |
441 { | |
442 return false; | |
443 } | |
444 | |
445 const DicomValue& value = input.GetValue(tag); | |
446 if (value.IsNull() || | |
447 value.IsBinary()) | |
448 { | |
449 return false; | |
450 } | |
451 else | |
452 { | |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
453 std::vector<std::string> tokens; |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
454 Toolbox::TokenizeString(tokens, value.GetContent(), '\\'); |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
455 |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
456 for (size_t i = 0; i < tokens.size(); i++) |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
457 { |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
458 std::vector<std::string> tmp; |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
459 context_.GetIndex().LookupIdentifierExact(tmp, level, tag, tokens[i]); |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
460 |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
461 if (tmp.empty()) |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
462 { |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
463 CLOG(ERROR, DICOM) << "C-GET: Cannot locate resource \"" << tokens[i] |
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
464 << "\" at the " << EnumerationToString(level) << " level"; |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
465 return false; |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
466 } |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
467 else |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
468 { |
4204 | 469 for (size_t j = 0; j < tmp.size(); j++) |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
470 { |
4204 | 471 publicIds.push_back(tmp[j]); |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
472 } |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
473 } |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
474 } |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
475 |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
476 return true; |
3818 | 477 } |
478 } | |
479 | |
480 | |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
481 OrthancGetRequestHandler::OrthancGetRequestHandler(ServerContext& context) : |
4482
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
482 context_(context), |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
483 position_(0), |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
484 completedCount_ (0), |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
485 warningCount_(0), |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
486 failedCount_(0), |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
487 timeout_(0), |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
488 allowTranscoding_(false) |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
489 { |
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
490 } |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
491 |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
492 |
3818 | 493 bool OrthancGetRequestHandler::Handle(const DicomMap& input, |
494 const std::string& originatorIp, | |
495 const std::string& originatorAet, | |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
496 const std::string& calledAet, |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
497 uint32_t timeout) |
3818 | 498 { |
499 MetricsRegistry::Timer timer(context_.GetMetricsRegistry(), "orthanc_get_scp_duration_ms"); | |
500 | |
4806 | 501 CLOG(INFO, DICOM) << "C-GET-SCU request received from AET \"" << originatorAet << "\""; |
3818 | 502 |
503 { | |
504 DicomArray query(input); | |
505 for (size_t i = 0; i < query.GetSize(); i++) | |
506 { | |
507 if (!query.GetElement(i).GetValue().IsNull()) | |
508 { | |
4313
91554aecff9a
removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4288
diff
changeset
|
509 CLOG(INFO, DICOM) << " (" << query.GetElement(i).GetTag().Format() |
91554aecff9a
removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4288
diff
changeset
|
510 << ") " << FromDcmtkBridge::GetTagName(query.GetElement(i)) |
4376
b002f9abe802
review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4375
diff
changeset
|
511 << " = " << context_.GetDeidentifiedContent(query.GetElement(i)); |
3818 | 512 } |
513 } | |
514 } | |
515 | |
516 /** | |
517 * Retrieve the query level. | |
518 **/ | |
519 | |
520 const DicomValue* levelTmp = input.TestAndGetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL); | |
4376
b002f9abe802
review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4375
diff
changeset
|
521 if (levelTmp == NULL || |
b002f9abe802
review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4375
diff
changeset
|
522 levelTmp->IsNull() || |
b002f9abe802
review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4375
diff
changeset
|
523 levelTmp->IsBinary()) |
b002f9abe802
review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4375
diff
changeset
|
524 { |
b002f9abe802
review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4375
diff
changeset
|
525 throw OrthancException(ErrorCode_BadRequest, |
b002f9abe802
review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4375
diff
changeset
|
526 "C-GET request without the tag 0008,0052 (QueryRetrieveLevel)"); |
b002f9abe802
review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4375
diff
changeset
|
527 } |
3818 | 528 |
529 ResourceType level = StringToResourceType(levelTmp->GetContent().c_str()); | |
530 | |
531 | |
532 /** | |
533 * Lookup for the resource to be sent. | |
534 **/ | |
535 | |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
536 std::list<std::string> publicIds; |
3818 | 537 |
3954 | 538 if (!LookupIdentifiers(publicIds, level, input)) |
539 { | |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
540 CLOG(ERROR, DICOM) << "Cannot determine what resources are requested by C-GET"; |
3954 | 541 return false; |
542 } | |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
543 |
3818 | 544 localAet_ = context_.GetDefaultLocalApplicationEntityTitle(); |
545 position_ = 0; | |
546 originatorAet_ = originatorAet; | |
547 | |
548 { | |
549 OrthancConfiguration::ReaderLock lock; | |
4482
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
550 |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
551 RemoteModalityParameters remote; |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
552 |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
553 if (lock.GetConfiguration().LookupDicomModalityUsingAETitle(remote, originatorAet)) |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
554 { |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
555 allowTranscoding_ = (context_.IsTranscodeDicomProtocol() && |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
556 remote.IsTranscodingAllowed()); |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
557 } |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
558 else if (lock.GetConfiguration().GetBooleanParameter("DicomAlwaysAllowGet", false)) |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
559 { |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
560 CLOG(INFO, DICOM) << "C-GET: Allowing SCU request from unknown modality with AET: " << originatorAet; |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
561 allowTranscoding_ = context_.IsTranscodeDicomProtocol(); |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
562 } |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
563 else |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
564 { |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
565 // This should never happen, given the test at bottom of |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
566 // "OrthancApplicationEntityFilter::IsAllowedRequest()" |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
567 throw OrthancException(ErrorCode_InexistentItem, |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
568 "C-GET: Rejecting SCU request from unknown modality with AET: " + originatorAet); |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
569 } |
3818 | 570 } |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
571 |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
572 for (std::list<std::string>::const_iterator |
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
573 resource = publicIds.begin(); resource != publicIds.end(); ++resource) |
3818 | 574 { |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
575 CLOG(INFO, DICOM) << "C-GET: Sending resource " << *resource |
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4286
diff
changeset
|
576 << " to modality \"" << originatorAet << "\""; |
3818 | 577 |
578 std::list<std::string> tmp; | |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
579 context_.GetIndex().GetChildInstances(tmp, *resource); |
3818 | 580 |
581 instances_.reserve(tmp.size()); | |
582 for (std::list<std::string>::iterator it = tmp.begin(); it != tmp.end(); ++it) | |
583 { | |
584 instances_.push_back(*it); | |
585 } | |
586 } | |
3953
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
587 |
620e87e9e816
c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3859
diff
changeset
|
588 failedUIDs_.clear(); |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
589 |
4258
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
590 completedCount_ = 0; |
6f5d4bfb2c90
C-GET SCP: Fix responses and handling of cancel
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4257
diff
changeset
|
591 failedCount_ = 0; |
3818 | 592 warningCount_ = 0; |
3955
66879215cbf3
C-GET: add timeout, fix uninitalized priority, support multiple resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3954
diff
changeset
|
593 timeout_ = timeout; |
3818 | 594 |
3954 | 595 return true; |
3818 | 596 } |
597 }; |