# HG changeset patch # User Alain Mazy # Date 1700684296 -3600 # Node ID 99fa307438e1bbae5751b49b0e91785cd9f3df64 # Parent 54b717b1d27ef8c1478d7acab40a92ca3be5c3d9 DicomStoreUserConnection: improved logs diff -r 54b717b1d27e -r 99fa307438e1 OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.cpp --- a/OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.cpp Wed Nov 22 13:10:34 2023 +0100 +++ b/OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.cpp Wed Nov 22 21:18:16 2023 +0100 @@ -254,7 +254,8 @@ DicomTransferSyntax transferSyntax, bool hasPreferred, DicomTransferSyntax preferred, - bool alwaysRenegotiate) + bool alwaysRenegotiate, + bool enableLogs) { /** * Step 1: Check whether this presentation context is already @@ -269,17 +270,25 @@ // The association must be re-negotiated if (association_->IsOpen()) { - CLOG(INFO, DICOM) << "Re-negotiating DICOM association with " - << parameters_.GetRemoteModality().GetApplicationEntityTitle(); + if (enableLogs) + { + CLOG(INFO, DICOM) << "Re-negotiating DICOM association with " + << parameters_.GetRemoteModality().GetApplicationEntityTitle() + << " for SOPClassUID " << sopClassUid; + } // Don't renegociate if we know that the remote modality was // already proposed this individual transfer syntax (**) - if (!alwaysRenegotiate && + if (!alwaysRenegotiate && proposedOriginalClasses_.find(std::make_pair(sopClassUid, transferSyntax)) != proposedOriginalClasses_.end()) { - CLOG(INFO, DICOM) << "The remote modality has already rejected SOP class UID \"" - << sopClassUid << "\" with transfer syntax \"" - << GetTransferSyntaxUid(transferSyntax) << "\", don't renegotiate"; + if (enableLogs) + { + CLOG(INFO, DICOM) << "The remote modality has already rejected SOP class UID \"" + << sopClassUid << "\" with transfer syntax \"" + << GetTransferSyntaxUid(transferSyntax) << "\", don't renegotiate"; + } + return false; } } @@ -378,7 +387,7 @@ uint8_t presID; if (!NegotiatePresentationContext(presID, sopClassUid, transferSyntax, proposeUncompressedSyntaxes_, - DicomTransferSyntax_LittleEndianExplicit, alwaysRenegotiate)) + DicomTransferSyntax_LittleEndianExplicit, alwaysRenegotiate, true)) { throw OrthancException(ErrorCode_NetworkProtocol, "No valid presentation context was negotiated for " @@ -489,7 +498,7 @@ // syntax. We don't use the return code: Transcoding is possible // even if the "sourceSyntax" is not supported. uint8_t presID; - NegotiatePresentationContext(presID, sopClassUid, sourceSyntax, hasPreferred, preferred, alwaysRenegotiate); + NegotiatePresentationContext(presID, sopClassUid, sourceSyntax, hasPreferred, preferred, alwaysRenegotiate, false); std::map contexts; if (association_->LookupAcceptedPresentationContext(contexts, sopClassUid)) @@ -529,6 +538,12 @@ std::set accepted; LookupTranscoding(accepted, sopClassUid, sourceSyntax, true, preferredTransferSyntax, alwaysRenegotiate); + if (accepted.size() == 0) + { + throw OrthancException(ErrorCode_NoPresentationContext, "Cannot store instance of SOPClassUID " + + sopClassUid + ", the destination has not accepted any TransferSyntax for this SOPClassUID."); + } + if (accepted.find(sourceSyntax) != accepted.end()) { // No need for transcoding @@ -634,7 +649,8 @@ s += " " + std::string(GetTransferSyntaxUid(*it)); } - throw OrthancException(ErrorCode_NotImplemented, "Cannot transcode from " + + throw OrthancException(ErrorCode_NotImplemented, "Cannot transcode instance of SOPClassUID " + + sopClassUid + " from " + std::string(GetTransferSyntaxUid(sourceSyntax)) + " to one of [" + s + " ]"); } diff -r 54b717b1d27e -r 99fa307438e1 OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.h --- a/OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.h Wed Nov 22 13:10:34 2023 +0100 +++ b/OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.h Wed Nov 22 21:18:16 2023 +0100 @@ -95,7 +95,8 @@ DicomTransferSyntax transferSyntax, bool hasPreferred, DicomTransferSyntax preferred, - bool alwaysRenegotiate); + bool alwaysRenegotiate, + bool enableLogs); #if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 void LookupTranscoding(std::set& acceptedSyntaxes,