Mercurial > hg > orthanc
changeset 3824:6762506ef4fb transcoding
reorganization of CheckCondition()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 10 Apr 2020 15:24:02 +0200 |
parents | 897ca3103253 |
children | 638906dcfe32 |
files | UnitTestsSources/FromDcmtkTests.cpp |
diffstat | 1 files changed, 55 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/UnitTestsSources/FromDcmtkTests.cpp Fri Apr 10 14:39:20 2020 +0200 +++ b/UnitTestsSources/FromDcmtkTests.cpp Fri Apr 10 15:24:02 2020 +0200 @@ -2581,54 +2581,6 @@ defaultTimeout_ = seconds; } } - - void CheckCondition(const OFCondition& cond, - const std::string& command) const - { - if (cond.bad()) - { - // Reformat the error message from DCMTK by turning multiline - // errors into a single line - - std::string s(cond.text()); - std::string info; - info.reserve(s.size()); - - bool isMultiline = false; - for (size_t i = 0; i < s.size(); i++) - { - if (s[i] == '\r') - { - // Ignore - } - else if (s[i] == '\n') - { - if (isMultiline) - { - info += "; "; - } - else - { - info += " ("; - isMultiline = true; - } - } - else - { - info.push_back(s[i]); - } - } - - if (isMultiline) - { - info += ")"; - } - - throw OrthancException(ErrorCode_NetworkProtocol, - "DicomUserConnection - " + command + " to AET \"" + - GetRemoteApplicationEntityTitle() + "\": " + info); - } - } }; @@ -2711,7 +2663,7 @@ { try { - parameters.CheckCondition(cond, "connecting"); + CheckCondition(cond, parameters, "connecting"); } catch (OrthancException&) { @@ -3074,6 +3026,56 @@ } } + static void CheckCondition(const OFCondition& cond, + const DicomAssociationParameters& parameters, + const std::string& command) + { + if (cond.bad()) + { + // Reformat the error message from DCMTK by turning multiline + // errors into a single line + + std::string s(cond.text()); + std::string info; + info.reserve(s.size()); + + bool isMultiline = false; + for (size_t i = 0; i < s.size(); i++) + { + if (s[i] == '\r') + { + // Ignore + } + else if (s[i] == '\n') + { + if (isMultiline) + { + info += "; "; + } + else + { + info += " ("; + isMultiline = true; + } + } + else + { + info.push_back(s[i]); + } + } + + if (isMultiline) + { + info += ")"; + } + + throw OrthancException(ErrorCode_NetworkProtocol, + "DicomUserConnection - " + command + " to AET \"" + + parameters.GetRemoteApplicationEntityTitle() + + "\": " + info); + } + } + static void ReportStorageCommitment(const DicomAssociationParameters& parameters, const std::string& transactionUid, @@ -3656,7 +3658,7 @@ delete statusDetail; } - parameters_.CheckCondition(cond, "C-FIND"); + DicomAssociation::CheckCondition(cond, parameters_, "C-FIND"); /** @@ -3758,7 +3760,7 @@ delete responseIdentifiers; } - parameters_.CheckCondition(cond, "C-MOVE"); + DicomAssociation::CheckCondition(cond, parameters_, "C-MOVE"); /** @@ -3807,13 +3809,13 @@ association_.Open(parameters_); DIC_US status; - parameters_.CheckCondition( + DicomAssociation::CheckCondition( DIMSE_echoUser(&association_.GetDcmtkAssociation(), association_.GetDcmtkAssociation().nextMsgID++, /*opt_blockMode*/ (parameters_.HasTimeout() ? DIMSE_NONBLOCKING : DIMSE_BLOCKING), /*opt_dimse_timeout*/ parameters_.GetTimeout(), &status, NULL), - "C-ECHO"); + parameters_, "C-ECHO"); return status == STATUS_Success; }