Mercurial > hg > orthanc
comparison OrthancServer/Internals/FindScp.cpp @ 941:83489fddd8c5
Options to limit the number of results for an incoming C-FIND query
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 25 Jun 2014 11:08:11 +0200 |
parents | 84513f2ee1f3 |
children | 6e7e5ed91c2d |
comparison
equal
deleted
inserted
replaced
940:4864b3e304be | 941:83489fddd8c5 |
---|---|
98 IFindRequestHandler* handler_; | 98 IFindRequestHandler* handler_; |
99 DicomMap input_; | 99 DicomMap input_; |
100 DicomFindAnswers answers_; | 100 DicomFindAnswers answers_; |
101 DcmDataset* lastRequest_; | 101 DcmDataset* lastRequest_; |
102 const std::string* callingAETitle_; | 102 const std::string* callingAETitle_; |
103 bool noCroppingOfResults_; | |
103 }; | 104 }; |
104 | 105 |
105 | 106 |
106 void FindScpCallback( | 107 void FindScpCallback( |
107 /* in */ | 108 /* in */ |
123 { | 124 { |
124 FromDcmtkBridge::Convert(data.input_, *requestIdentifiers); | 125 FromDcmtkBridge::Convert(data.input_, *requestIdentifiers); |
125 | 126 |
126 try | 127 try |
127 { | 128 { |
128 data.handler_->Handle(data.answers_, data.input_, *data.callingAETitle_); | 129 data.noCroppingOfResults_ = data.handler_->Handle(data.answers_, data.input_, *data.callingAETitle_); |
129 } | 130 } |
130 catch (OrthancException& e) | 131 catch (OrthancException& e) |
131 { | 132 { |
132 // Internal error! | 133 // Internal error! |
133 LOG(ERROR) << "IFindRequestHandler Failed: " << e.What(); | 134 LOG(ERROR) << "C-FIND request handler has failed: " << e.What(); |
134 response->DimseStatus = STATUS_FIND_Failed_UnableToProcess; | 135 response->DimseStatus = STATUS_FIND_Failed_UnableToProcess; |
135 *responseIdentifiers = NULL; | 136 *responseIdentifiers = NULL; |
136 return; | 137 return; |
137 } | 138 } |
138 | 139 |
146 return; | 147 return; |
147 } | 148 } |
148 | 149 |
149 if (responseCount <= static_cast<int>(data.answers_.GetSize())) | 150 if (responseCount <= static_cast<int>(data.answers_.GetSize())) |
150 { | 151 { |
152 // There are pending results that are still to be sent | |
151 response->DimseStatus = STATUS_Pending; | 153 response->DimseStatus = STATUS_Pending; |
152 *responseIdentifiers = ToDcmtkBridge::Convert(data.answers_.GetAnswer(responseCount - 1)); | 154 *responseIdentifiers = ToDcmtkBridge::Convert(data.answers_.GetAnswer(responseCount - 1)); |
153 } | 155 } |
156 else if (data.noCroppingOfResults_) | |
157 { | |
158 // Success: All the results have been sent | |
159 response->DimseStatus = STATUS_Success; | |
160 *responseIdentifiers = NULL; | |
161 } | |
154 else | 162 else |
155 { | 163 { |
156 response->DimseStatus = STATUS_Success; | 164 // Success, but the results were too numerous and had to be cropped |
165 LOG(WARNING) << "Too many results for an incoming C-FIND query"; | |
166 response->DimseStatus = STATUS_FIND_Cancel_MatchingTerminatedDueToCancelRequest; | |
157 *responseIdentifiers = NULL; | 167 *responseIdentifiers = NULL; |
158 } | 168 } |
159 } | 169 } |
160 } | 170 } |
161 | 171 |
168 { | 178 { |
169 FindScpData data; | 179 FindScpData data; |
170 data.lastRequest_ = NULL; | 180 data.lastRequest_ = NULL; |
171 data.handler_ = &handler; | 181 data.handler_ = &handler; |
172 data.callingAETitle_ = &callingAETitle; | 182 data.callingAETitle_ = &callingAETitle; |
183 data.noCroppingOfResults_ = true; | |
173 | 184 |
174 OFCondition cond = DIMSE_findProvider(assoc, presID, &msg->msg.CFindRQ, | 185 OFCondition cond = DIMSE_findProvider(assoc, presID, &msg->msg.CFindRQ, |
175 FindScpCallback, &data, | 186 FindScpCallback, &data, |
176 /*opt_blockMode*/ DIMSE_BLOCKING, | 187 /*opt_blockMode*/ DIMSE_BLOCKING, |
177 /*opt_dimse_timeout*/ 0); | 188 /*opt_dimse_timeout*/ 0); |