comparison OrthancServer/QueryRetrieveHandler.cpp @ 2843:4ee3a759afea

Fix: Closing DICOM associations after running query/retrieve from REST API
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 27 Sep 2018 13:22:57 +0200
parents 912a767911b0
children 251614c2edac
comparison
equal deleted inserted replaced
2842:ff0ed5ea9e4e 2843:4ee3a759afea
77 77
78 void QueryRetrieveHandler::Invalidate() 78 void QueryRetrieveHandler::Invalidate()
79 { 79 {
80 done_ = false; 80 done_ = false;
81 answers_.Clear(); 81 answers_.Clear();
82 connection_.reset(NULL);
83 }
84
85
86 DicomUserConnection& QueryRetrieveHandler::GetConnection()
87 {
88 if (connection_.get() == NULL)
89 {
90 connection_.reset(new DicomUserConnection(localAet_, modality_));
91 connection_->Open();
92 }
93
94 return *connection_;
95 } 82 }
96 83
97 84
98 void QueryRetrieveHandler::Run() 85 void QueryRetrieveHandler::Run()
99 { 86 {
105 FixQueryBuiltin(fixed, modality_.GetManufacturer()); 92 FixQueryBuiltin(fixed, modality_.GetManufacturer());
106 93
107 // Secondly, possibly fix the query with the user-provider Lua callback 94 // Secondly, possibly fix the query with the user-provider Lua callback
108 FixQueryLua(fixed, context_, modality_.GetApplicationEntityTitle()); 95 FixQueryLua(fixed, context_, modality_.GetApplicationEntityTitle());
109 96
110 GetConnection().Find(answers_, level_, fixed); 97 {
98 DicomUserConnection connection(localAet_, modality_);
99 connection.Open();
100 connection.Find(answers_, level_, fixed);
101 }
111 102
112 done_ = true; 103 done_ = true;
113 } 104 }
114 } 105 }
115 106
160 Run(); 151 Run();
161 answers_.GetAnswer(i).ExtractDicomSummary(target); 152 answers_.GetAnswer(i).ExtractDicomSummary(target);
162 } 153 }
163 154
164 155
156 void QueryRetrieveHandler::RetrieveInternal(DicomUserConnection& connection,
157 const std::string& target,
158 size_t i)
159 {
160 DicomMap map;
161 GetAnswer(map, i);
162 connection.Move(target, map);
163 }
164
165
165 void QueryRetrieveHandler::Retrieve(const std::string& target, 166 void QueryRetrieveHandler::Retrieve(const std::string& target,
166 size_t i) 167 size_t i)
167 { 168 {
168 DicomMap map; 169 DicomUserConnection connection(localAet_, modality_);
169 GetAnswer(map, i); 170 connection.Open();
170 GetConnection().Move(target, map); 171
172 RetrieveInternal(connection, target, i);
171 } 173 }
172 174
173 175
174 void QueryRetrieveHandler::Retrieve(const std::string& target) 176 void QueryRetrieveHandler::Retrieve(const std::string& target)
175 { 177 {
178 DicomUserConnection connection(localAet_, modality_);
179 connection.Open();
180
176 for (size_t i = 0; i < GetAnswerCount(); i++) 181 for (size_t i = 0; i < GetAnswerCount(); i++)
177 { 182 {
178 Retrieve(target, i); 183 RetrieveInternal(connection, target, i);
179 } 184 }
180 } 185 }
181 } 186 }