comparison OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.cpp @ 5440:99fa307438e1 debug-telemis

DicomStoreUserConnection: improved logs
author Alain Mazy <am@osimis.io>
date Wed, 22 Nov 2023 21:18:16 +0100
parents 7a20ee948676
children ac68a4383e51
comparison
equal deleted inserted replaced
5439:54b717b1d27e 5440:99fa307438e1
252 uint8_t& presentationContextId, 252 uint8_t& presentationContextId,
253 const std::string& sopClassUid, 253 const std::string& sopClassUid,
254 DicomTransferSyntax transferSyntax, 254 DicomTransferSyntax transferSyntax,
255 bool hasPreferred, 255 bool hasPreferred,
256 DicomTransferSyntax preferred, 256 DicomTransferSyntax preferred,
257 bool alwaysRenegotiate) 257 bool alwaysRenegotiate,
258 bool enableLogs)
258 { 259 {
259 /** 260 /**
260 * Step 1: Check whether this presentation context is already 261 * Step 1: Check whether this presentation context is already
261 * available in the previously negotiated assocation. 262 * available in the previously negotiated assocation.
262 **/ 263 **/
267 } 268 }
268 269
269 // The association must be re-negotiated 270 // The association must be re-negotiated
270 if (association_->IsOpen()) 271 if (association_->IsOpen())
271 { 272 {
272 CLOG(INFO, DICOM) << "Re-negotiating DICOM association with " 273 if (enableLogs)
273 << parameters_.GetRemoteModality().GetApplicationEntityTitle(); 274 {
275 CLOG(INFO, DICOM) << "Re-negotiating DICOM association with "
276 << parameters_.GetRemoteModality().GetApplicationEntityTitle()
277 << " for SOPClassUID " << sopClassUid;
278 }
274 279
275 // Don't renegociate if we know that the remote modality was 280 // Don't renegociate if we know that the remote modality was
276 // already proposed this individual transfer syntax (**) 281 // already proposed this individual transfer syntax (**)
277 if (!alwaysRenegotiate && 282 if (!alwaysRenegotiate &&
278 proposedOriginalClasses_.find(std::make_pair(sopClassUid, transferSyntax)) != proposedOriginalClasses_.end()) 283 proposedOriginalClasses_.find(std::make_pair(sopClassUid, transferSyntax)) != proposedOriginalClasses_.end())
279 { 284 {
280 CLOG(INFO, DICOM) << "The remote modality has already rejected SOP class UID \"" 285 if (enableLogs)
281 << sopClassUid << "\" with transfer syntax \"" 286 {
282 << GetTransferSyntaxUid(transferSyntax) << "\", don't renegotiate"; 287 CLOG(INFO, DICOM) << "The remote modality has already rejected SOP class UID \""
288 << sopClassUid << "\" with transfer syntax \""
289 << GetTransferSyntaxUid(transferSyntax) << "\", don't renegotiate";
290 }
291
283 return false; 292 return false;
284 } 293 }
285 } 294 }
286 295
287 association_->ClearPresentationContexts(); 296 association_->ClearPresentationContexts();
376 DicomTransferSyntax transferSyntax; 385 DicomTransferSyntax transferSyntax;
377 LookupParameters(sopClassUid, sopInstanceUid, transferSyntax, dicom); 386 LookupParameters(sopClassUid, sopInstanceUid, transferSyntax, dicom);
378 387
379 uint8_t presID; 388 uint8_t presID;
380 if (!NegotiatePresentationContext(presID, sopClassUid, transferSyntax, proposeUncompressedSyntaxes_, 389 if (!NegotiatePresentationContext(presID, sopClassUid, transferSyntax, proposeUncompressedSyntaxes_,
381 DicomTransferSyntax_LittleEndianExplicit, alwaysRenegotiate)) 390 DicomTransferSyntax_LittleEndianExplicit, alwaysRenegotiate, true))
382 { 391 {
383 throw OrthancException(ErrorCode_NetworkProtocol, 392 throw OrthancException(ErrorCode_NetworkProtocol,
384 "No valid presentation context was negotiated for " 393 "No valid presentation context was negotiated for "
385 "SOP class UID [" + sopClassUid + "] and transfer " 394 "SOP class UID [" + sopClassUid + "] and transfer "
386 "syntax [" + GetTransferSyntaxUid(transferSyntax) + "] " 395 "syntax [" + GetTransferSyntaxUid(transferSyntax) + "] "
487 496
488 // Make sure a negotiation has already occurred for this transfer 497 // Make sure a negotiation has already occurred for this transfer
489 // syntax. We don't use the return code: Transcoding is possible 498 // syntax. We don't use the return code: Transcoding is possible
490 // even if the "sourceSyntax" is not supported. 499 // even if the "sourceSyntax" is not supported.
491 uint8_t presID; 500 uint8_t presID;
492 NegotiatePresentationContext(presID, sopClassUid, sourceSyntax, hasPreferred, preferred, alwaysRenegotiate); 501 NegotiatePresentationContext(presID, sopClassUid, sourceSyntax, hasPreferred, preferred, alwaysRenegotiate, false);
493 502
494 std::map<DicomTransferSyntax, uint8_t> contexts; 503 std::map<DicomTransferSyntax, uint8_t> contexts;
495 if (association_->LookupAcceptedPresentationContext(contexts, sopClassUid)) 504 if (association_->LookupAcceptedPresentationContext(contexts, sopClassUid))
496 { 505 {
497 for (std::map<DicomTransferSyntax, uint8_t>::const_iterator 506 for (std::map<DicomTransferSyntax, uint8_t>::const_iterator
527 LookupParameters(sopClassUid, sopInstanceUid, sourceSyntax, *dicom); 536 LookupParameters(sopClassUid, sopInstanceUid, sourceSyntax, *dicom);
528 537
529 std::set<DicomTransferSyntax> accepted; 538 std::set<DicomTransferSyntax> accepted;
530 LookupTranscoding(accepted, sopClassUid, sourceSyntax, true, preferredTransferSyntax, alwaysRenegotiate); 539 LookupTranscoding(accepted, sopClassUid, sourceSyntax, true, preferredTransferSyntax, alwaysRenegotiate);
531 540
541 if (accepted.size() == 0)
542 {
543 throw OrthancException(ErrorCode_NoPresentationContext, "Cannot store instance of SOPClassUID " +
544 sopClassUid + ", the destination has not accepted any TransferSyntax for this SOPClassUID.");
545 }
546
532 if (accepted.find(sourceSyntax) != accepted.end()) 547 if (accepted.find(sourceSyntax) != accepted.end())
533 { 548 {
534 // No need for transcoding 549 // No need for transcoding
535 Store(sopClassUid, sopInstanceUid, *dicom, 550 Store(sopClassUid, sopInstanceUid, *dicom,
536 hasMoveOriginator, moveOriginatorAET, moveOriginatorID, alwaysRenegotiate); 551 hasMoveOriginator, moveOriginatorAET, moveOriginatorID, alwaysRenegotiate);
632 it = attemptedSyntaxes.begin(); it != attemptedSyntaxes.end(); ++it) 647 it = attemptedSyntaxes.begin(); it != attemptedSyntaxes.end(); ++it)
633 { 648 {
634 s += " " + std::string(GetTransferSyntaxUid(*it)); 649 s += " " + std::string(GetTransferSyntaxUid(*it));
635 } 650 }
636 651
637 throw OrthancException(ErrorCode_NotImplemented, "Cannot transcode from " + 652 throw OrthancException(ErrorCode_NotImplemented, "Cannot transcode instance of SOPClassUID " +
653 sopClassUid + " from " +
638 std::string(GetTransferSyntaxUid(sourceSyntax)) + 654 std::string(GetTransferSyntaxUid(sourceSyntax)) +
639 " to one of [" + s + " ]"); 655 " to one of [" + s + " ]");
640 } 656 }
641 } 657 }
642 } 658 }