annotate OrthancServer/OrthancGetRequestHandler.cpp @ 3953:620e87e9e816 c-get

c-get: fixing memory with failedUIDs_
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 May 2020 09:19:35 +0200
parents d30bce4bdae9
children 67b457283499
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
1 /**
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
6 *
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
11 *
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
22 * in the program, then also delete it here.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
23 *
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
27 * General Public License for more details.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
28 *
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
31 **/
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
32
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
33 #include "PrecompiledHeadersServer.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
34 #include "OrthancGetRequestHandler.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
35
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
36 #include <dcmtk/dcmnet/assoc.h>
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
37 #include <dcmtk/dcmnet/dimse.h>
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
38 #include <dcmtk/dcmdata/dcdeftag.h>
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
39 #include <dcmtk/dcmdata/dcistrmb.h>
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
40 #include <dcmtk/dcmnet/diutil.h>
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
41
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
42 #include "../../Core/DicomParsing/FromDcmtkBridge.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
43 #include "../Core/DicomFormat/DicomArray.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
44 #include "../Core/Logging.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
45 #include "../Core/MetricsRegistry.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
46 #include "OrthancConfiguration.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
47 #include "ServerContext.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
48 #include "ServerJobs/DicomModalityStoreJob.h"
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
49
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
50
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
51
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
52 namespace Orthanc
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
53 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
54 namespace
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
55 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
56 // Anonymous namespace to avoid clashes between compilation modules
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
57
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
58 static void getSubOpProgressCallback(void * /* callbackData */,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
59 T_DIMSE_StoreProgress *progress,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
60 T_DIMSE_C_StoreRQ * /*req*/)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
61 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
62 // SBL - no logging to be done here.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
63 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
64 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
65
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
66 OrthancGetRequestHandler::Status OrthancGetRequestHandler::DoNext(T_ASC_Association* assoc)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
67 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
68 if (position_ >= instances_.size())
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
69 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
70 return Status_Failure;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
71 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
72
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
73 const std::string& id = instances_[position_++];
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
74
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
75 std::string dicom;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
76 context_.ReadDicom(dicom, id);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
77
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
78 if (dicom.size() <= 0)
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
79 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
80 return Status_Failure;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
81 }
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
82
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
83 std::unique_ptr<DcmFileFormat> parsed(
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
84 FromDcmtkBridge::LoadFromMemoryBuffer(dicom.c_str(), dicom.size()));
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
85
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
86 // Determine the storage SOP class UID for this instance
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
87 DIC_UI sopClass;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
88 DIC_UI sopInstance;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
89
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
90 #if DCMTK_VERSION_NUMBER >= 364
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
91 if (!DU_findSOPClassAndInstanceInDataSet(static_cast<DcmItem *> (parsed->getDataset()),
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
92 sopClass, sizeof(sopClass),
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
93 sopInstance, sizeof(sopInstance)))
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
94 #else
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
95 if (!DU_findSOPClassAndInstanceInDataSet(parsed->getDataset(), sopClass, sopInstance))
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
96 #endif
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
97 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
98 throw OrthancException(ErrorCode_NoSopClassOrInstance,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
99 "Unable to determine the SOP class/instance for C-STORE with AET " +
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
100 originatorAet_);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
101 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
102
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
103 OFCondition cond = performGetSubOp(assoc, sopClass, sopInstance, parsed->getDataset());
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
104 if (getCancelled_)
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
105 {
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
106 LOG(INFO) << "Get SCP: Received C-Cancel RQ";
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
107 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
108
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
109 if (cond.bad() || getCancelled_)
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
110 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
111 return Status_Failure;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
112 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
113
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
114 return Status_Success;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
115 }
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
116
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
117
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
118 void OrthancGetRequestHandler::addFailedUIDInstance(const char *sopInstance)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
119 {
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
120 if (failedUIDs_.empty())
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
121 {
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
122 failedUIDs_ = sopInstance;
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
123 }
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
124 else
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
125 {
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
126 failedUIDs_ += "\\" + std::string(sopInstance);
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
127 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
128 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
129
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
130
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
131 OFCondition OrthancGetRequestHandler::performGetSubOp(T_ASC_Association* assoc,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
132 DIC_UI sopClass,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
133 DIC_UI sopInstance,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
134 DcmDataset *dataset)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
135 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
136 OFCondition cond = EC_Normal;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
137 T_DIMSE_C_StoreRQ req;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
138 T_DIMSE_C_StoreRSP rsp;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
139 DIC_US msgId;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
140 T_ASC_PresentationContextID presId;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
141 DcmDataset *stDetail = NULL;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
142
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
143 msgId = assoc->nextMsgID++;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
144
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
145 // which presentation context should be used
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
146 presId = ASC_findAcceptedPresentationContextID(assoc, sopClass);
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
147
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
148 if (presId == 0)
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
149 {
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
150 nFailed_++;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
151 addFailedUIDInstance(sopInstance);
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
152 LOG(ERROR) << "Get SCP: storeSCU: No presentation context for: ("
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
153 << dcmSOPClassUIDToModality(sopClass, "OT") << ") " << sopClass;
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
154 return DIMSE_NOVALIDPRESENTATIONCONTEXTID;
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
155 }
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
156 else
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
157 {
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
158 // make sure that we can send images in this presentation context
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
159 T_ASC_PresentationContext pc;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
160 ASC_findAcceptedPresentationContext(assoc->params, presId, &pc);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
161 // the acceptedRole is the association requestor role
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
162 if ((pc.acceptedRole != ASC_SC_ROLE_SCP) && (pc.acceptedRole != ASC_SC_ROLE_SCUSCP))
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
163 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
164 // the role is not appropriate
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
165 nFailed_++;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
166 addFailedUIDInstance(sopInstance);
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
167 LOG(ERROR) <<"Get SCP: storeSCU: [No presentation context with requestor SCP role for: ("
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
168 << dcmSOPClassUIDToModality(sopClass, "OT") << ") " << sopClass;
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
169 return DIMSE_NOVALIDPRESENTATIONCONTEXTID;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
170 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
171 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
172
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
173 req.MessageID = msgId;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
174 strcpy(req.AffectedSOPClassUID, sopClass);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
175 strcpy(req.AffectedSOPInstanceUID, sopInstance);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
176 req.DataSetType = DIMSE_DATASET_PRESENT;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
177 req.Priority = priority_;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
178 req.opts = 0;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
179
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
180 LOG(INFO) << "Store SCU RQ: MsgID " << msgId << ", ("
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
181 << dcmSOPClassUIDToModality(sopClass, "OT") << ")";
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
182
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
183 T_DIMSE_DetectedCancelParameters cancelParameters;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
184
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
185 cond = DIMSE_storeUser(assoc, presId, &req,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
186 NULL, dataset, getSubOpProgressCallback, this, DIMSE_BLOCKING, 0,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
187 &rsp, &stDetail, &cancelParameters);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
188
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
189 if (cond.good())
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
190 {
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
191 if (cancelParameters.cancelEncountered)
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
192 {
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
193 if (origPresId == cancelParameters.presId &&
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
194 origMsgId == cancelParameters.req.MessageIDBeingRespondedTo)
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
195 {
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
196 getCancelled_ = OFTrue;
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
197 }
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
198 else
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
199 {
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
200 LOG(ERROR) << "Get SCP: Unexpected C-Cancel-RQ encountered: pid=" << (int)cancelParameters.presId
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
201 << ", mid=" << (int)cancelParameters.req.MessageIDBeingRespondedTo;
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
202 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
203 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
204
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
205 if (rsp.DimseStatus == STATUS_Success)
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
206 {
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
207 // everything ok
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
208 nCompleted_++;
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
209 }
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
210 else if ((rsp.DimseStatus & 0xf000) == 0xb000)
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
211 {
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
212 // a warning status message
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
213 warningCount_++;
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
214 LOG(ERROR) << "Get SCP: Store Warning: Response Status: "
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
215 << DU_cstoreStatusString(rsp.DimseStatus);
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
216 }
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
217 else
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
218 {
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
219 nFailed_++;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
220 addFailedUIDInstance(sopInstance);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
221 // print a status message
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
222 LOG(ERROR) << "Get SCP: Store Failed: Response Status: "
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
223 << DU_cstoreStatusString(rsp.DimseStatus);
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
224 }
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
225 }
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
226 else
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
227 {
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
228 nFailed_++;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
229 addFailedUIDInstance(sopInstance);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
230 OFString temp_str;
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
231 LOG(ERROR) << "Get SCP: storeSCU: Store Request Failed: " << DimseCondition::dump(temp_str, cond);
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
232 }
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
233
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
234 if (stDetail)
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
235 {
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
236 LOG(INFO) << " Status Detail:" << OFendl << DcmObject::PrintHelper(*stDetail);
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
237 delete stDetail;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
238 }
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
239
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
240 return cond;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
241 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
242
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
243 bool OrthancGetRequestHandler::LookupIdentifiers(std::vector<std::string>& publicIds,
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
244 ResourceType level,
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
245 const DicomMap& input)
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
246 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
247 DicomTag tag(0, 0); // Dummy initialization
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
248
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
249 switch (level)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
250 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
251 case ResourceType_Patient:
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
252 tag = DICOM_TAG_PATIENT_ID;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
253 break;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
254
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
255 case ResourceType_Study:
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
256 tag = (input.HasTag(DICOM_TAG_ACCESSION_NUMBER) ?
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
257 DICOM_TAG_ACCESSION_NUMBER : DICOM_TAG_STUDY_INSTANCE_UID);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
258 break;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
259
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
260 case ResourceType_Series:
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
261 tag = DICOM_TAG_SERIES_INSTANCE_UID;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
262 break;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
263
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
264 case ResourceType_Instance:
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
265 tag = DICOM_TAG_SOP_INSTANCE_UID;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
266 break;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
267
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
268 default:
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
269 throw OrthancException(ErrorCode_ParameterOutOfRange);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
270 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
271
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
272 if (!input.HasTag(tag))
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
273 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
274 return false;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
275 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
276
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
277 const DicomValue& value = input.GetValue(tag);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
278 if (value.IsNull() ||
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
279 value.IsBinary())
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
280 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
281 return false;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
282 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
283 else
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
284 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
285 const std::string& content = value.GetContent();
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
286 context_.GetIndex().LookupIdentifierExact(publicIds, level, tag, content);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
287 return true;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
288 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
289 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
290
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
291
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
292 OrthancGetRequestHandler::OrthancGetRequestHandler(ServerContext& context) :
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
293 context_(context)
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
294 {
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
295 position_ = 0;
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
296 nRemaining_ = 0;
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
297 nCompleted_ = 0;
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
298 warningCount_ = 0;
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
299 nFailed_ = 0;
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
300 }
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
301
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
302
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
303 bool OrthancGetRequestHandler::Handle(const DicomMap& input,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
304 const std::string& originatorIp,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
305 const std::string& originatorAet,
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
306 const std::string& calledAet)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
307 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
308 MetricsRegistry::Timer timer(context_.GetMetricsRegistry(), "orthanc_get_scp_duration_ms");
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
309
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
310 LOG(WARNING) << "Get-SCU request received from AET \"" << originatorAet << "\"";
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
311
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
312 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
313 DicomArray query(input);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
314 for (size_t i = 0; i < query.GetSize(); i++)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
315 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
316 if (!query.GetElement(i).GetValue().IsNull())
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
317 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
318 LOG(INFO) << " " << query.GetElement(i).GetTag()
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
319 << " " << FromDcmtkBridge::GetTagName(query.GetElement(i))
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
320 << " = " << query.GetElement(i).GetValue().GetContent();
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
321 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
322 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
323 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
324
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
325 /**
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
326 * Retrieve the query level.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
327 **/
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
328
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
329 const DicomValue* levelTmp = input.TestAndGetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
330
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
331 assert(levelTmp != NULL);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
332 ResourceType level = StringToResourceType(levelTmp->GetContent().c_str());
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
333
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
334
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
335 /**
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
336 * Lookup for the resource to be sent.
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
337 **/
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
338
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
339 std::vector<std::string> publicIds;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
340
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
341 bool retVal = LookupIdentifiers(publicIds, level, input);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
342 localAet_ = context_.GetDefaultLocalApplicationEntityTitle();
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
343 position_ = 0;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
344 originatorAet_ = originatorAet;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
345
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
346 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
347 OrthancConfiguration::ReaderLock lock;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
348 remote_ = lock.GetConfiguration().GetModalityUsingAet(originatorAet);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
349 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
350
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
351 for (size_t i = 0; i < publicIds.size(); i++)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
352 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
353 LOG(INFO) << "Sending resource " << publicIds[i] << " to modality \""
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
354 << originatorAet << "\" in synchronous mode";
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
355
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
356 std::list<std::string> tmp;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
357 context_.GetIndex().GetChildInstances(tmp, publicIds[i]);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
358
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
359 instances_.reserve(tmp.size());
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
360 for (std::list<std::string>::iterator it = tmp.begin(); it != tmp.end(); ++it)
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
361 {
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
362 instances_.push_back(*it);
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
363 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
364 }
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
365
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
366 failedUIDs_.clear();
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
367 getCancelled_ = OFFalse;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
368
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
369 nRemaining_ = GetSubOperationCount();
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
370 nCompleted_ = 0;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
371 nFailed_ = 0;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
372 warningCount_ = 0;
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
373
3953
620e87e9e816 c-get: fixing memory with failedUIDs_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3859
diff changeset
374 return retVal;
3818
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
375 }
4f78da5613a1 Add C-GET SCP support
Stacy Loesch <stacy.loesch@varian.com>
parents:
diff changeset
376 };