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