Mercurial > hg > orthanc
comparison OrthancServer/OrthancMoveRequestHandler.cpp @ 2222:21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 13 Dec 2016 14:34:33 +0100 |
parents | 2b1520efa282 |
children | a3a65de1840f |
comparison
equal
deleted
inserted
replaced
2221:e7beca979562 | 2222:21713ce8717b |
---|---|
50 ServerContext& context_; | 50 ServerContext& context_; |
51 const std::string& localAet_; | 51 const std::string& localAet_; |
52 std::vector<std::string> instances_; | 52 std::vector<std::string> instances_; |
53 size_t position_; | 53 size_t position_; |
54 RemoteModalityParameters remote_; | 54 RemoteModalityParameters remote_; |
55 uint16_t moveRequestID_; | 55 std::string originatorAet_; |
56 uint16_t originatorId_; | |
56 | 57 |
57 public: | 58 public: |
58 OrthancMoveRequestIterator(ServerContext& context, | 59 OrthancMoveRequestIterator(ServerContext& context, |
59 const std::string& aet, | 60 const std::string& aet, |
60 const std::string& publicId, | 61 const std::string& publicId, |
61 uint16_t moveRequestID) : | 62 const std::string& originatorAet, |
63 uint16_t originatorId) : | |
62 context_(context), | 64 context_(context), |
63 localAet_(context.GetDefaultLocalApplicationEntityTitle()), | 65 localAet_(context.GetDefaultLocalApplicationEntityTitle()), |
64 position_(0), | 66 position_(0), |
65 moveRequestID_(moveRequestID) | 67 originatorAet_(originatorAet), |
68 originatorId_(originatorId) | |
66 { | 69 { |
67 LOG(INFO) << "Sending resource " << publicId << " to modality \"" << aet << "\""; | 70 LOG(INFO) << "Sending resource " << publicId << " to modality \"" << aet << "\""; |
68 | 71 |
69 std::list<std::string> tmp; | 72 std::list<std::string> tmp; |
70 context_.GetIndex().GetChildInstances(tmp, publicId); | 73 context_.GetIndex().GetChildInstances(tmp, publicId); |
96 context_.ReadDicom(dicom, id); | 99 context_.ReadDicom(dicom, id); |
97 | 100 |
98 { | 101 { |
99 ReusableDicomUserConnection::Locker locker | 102 ReusableDicomUserConnection::Locker locker |
100 (context_.GetReusableDicomUserConnection(), localAet_, remote_); | 103 (context_.GetReusableDicomUserConnection(), localAet_, remote_); |
101 locker.GetConnection().Store(dicom, moveRequestID_); | 104 locker.GetConnection().Store(dicom, originatorAet_, originatorId_); |
102 } | 105 } |
103 | 106 |
104 return Status_Success; | 107 return Status_Success; |
105 } | 108 } |
106 }; | 109 }; |
165 } | 168 } |
166 | 169 |
167 | 170 |
168 IMoveRequestIterator* OrthancMoveRequestHandler::Handle(const std::string& targetAet, | 171 IMoveRequestIterator* OrthancMoveRequestHandler::Handle(const std::string& targetAet, |
169 const DicomMap& input, | 172 const DicomMap& input, |
170 const std::string& remoteIp, | 173 const std::string& originatorIp, |
171 const std::string& remoteAet, | 174 const std::string& originatorAet, |
172 const std::string& calledAet, | 175 const std::string& calledAet, |
173 uint16_t messageId) | 176 uint16_t originatorId) |
174 { | 177 { |
175 LOG(WARNING) << "Move-SCU request received for AET \"" << targetAet << "\""; | 178 LOG(WARNING) << "Move-SCU request received for AET \"" << targetAet << "\""; |
176 | 179 |
177 { | 180 { |
178 DicomArray query(input); | 181 DicomArray query(input); |
184 << " " << FromDcmtkBridge::GetTagName(query.GetElement(i)) | 187 << " " << FromDcmtkBridge::GetTagName(query.GetElement(i)) |
185 << " = " << query.GetElement(i).GetValue().GetContent(); | 188 << " = " << query.GetElement(i).GetValue().GetContent(); |
186 } | 189 } |
187 } | 190 } |
188 } | 191 } |
189 | |
190 | |
191 #if 0 | |
192 /** | |
193 * Retrieve the Message ID (0000,0110) for this C-MOVE request, if | |
194 * any. If present, this Message ID will be stored in the Move | |
195 * Originator Message ID (0000,1031) field of the C-MOVE response. | |
196 * http://dicom.nema.org/medical/dicom/current/output/html/part07.html#sect_9.3.1 | |
197 **/ | |
198 | |
199 static const DicomTag MESSAGE_ID(0x0000, 0x0110); | |
200 const DicomValue* messageIdTmp = input.TestAndGetValue(MESSAGE_ID); | |
201 | |
202 messageId = 0; | |
203 | |
204 if (messageIdTmp != NULL && | |
205 !messageIdTmp->IsNull() && | |
206 !messageIdTmp->IsBinary()) | |
207 { | |
208 try | |
209 { | |
210 messageId = boost::lexical_cast<uint16_t>(messageIdTmp->GetContent()); | |
211 } | |
212 catch (boost::bad_lexical_cast&) | |
213 { | |
214 LOG(WARNING) << "Cannot convert the Message ID (\"" << messageIdTmp ->GetContent() | |
215 << "\") of an incoming C-MOVE request to an integer, assuming zero"; | |
216 } | |
217 } | |
218 #endif | |
219 | 192 |
220 | 193 |
221 /** | 194 /** |
222 * Retrieve the query level. | 195 * Retrieve the query level. |
223 **/ | 196 **/ |
239 if (LookupIdentifier(publicId, ResourceType_Instance, input) || | 212 if (LookupIdentifier(publicId, ResourceType_Instance, input) || |
240 LookupIdentifier(publicId, ResourceType_Series, input) || | 213 LookupIdentifier(publicId, ResourceType_Series, input) || |
241 LookupIdentifier(publicId, ResourceType_Study, input) || | 214 LookupIdentifier(publicId, ResourceType_Study, input) || |
242 LookupIdentifier(publicId, ResourceType_Patient, input)) | 215 LookupIdentifier(publicId, ResourceType_Patient, input)) |
243 { | 216 { |
244 return new OrthancMoveRequestIterator(context_, targetAet, publicId, messageId); | 217 return new OrthancMoveRequestIterator(context_, targetAet, publicId, originatorAet, originatorId); |
245 } | 218 } |
246 else | 219 else |
247 { | 220 { |
248 // No identifier is present in the request. | 221 // No identifier is present in the request. |
249 throw OrthancException(ErrorCode_BadRequest); | 222 throw OrthancException(ErrorCode_BadRequest); |
260 | 233 |
261 std::string publicId; | 234 std::string publicId; |
262 | 235 |
263 if (LookupIdentifier(publicId, level, input)) | 236 if (LookupIdentifier(publicId, level, input)) |
264 { | 237 { |
265 return new OrthancMoveRequestIterator(context_, targetAet, publicId, messageId); | 238 return new OrthancMoveRequestIterator(context_, targetAet, publicId, originatorAet, originatorId); |
266 } | 239 } |
267 else | 240 else |
268 { | 241 { |
269 throw OrthancException(ErrorCode_BadRequest); | 242 throw OrthancException(ErrorCode_BadRequest); |
270 } | 243 } |