Mercurial > hg > orthanc
changeset 6418:5a8dd2508358
using ErrorPayload in MakeDimseErrorStatusPayload()
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Sat, 15 Nov 2025 10:51:57 +0100 |
| parents | bbeacd71831b |
| children | 9aa989b6ce31 |
| files | OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.cpp OrthancFramework/Sources/DicomNetworking/DimseErrorPayload.cpp OrthancFramework/Sources/DicomNetworking/DimseErrorPayload.h OrthancFramework/Sources/OrthancException.cpp OrthancFramework/Sources/OrthancException.h OrthancServer/Sources/ServerJobs/DicomRetrieveScuBaseJob.cpp |
| diffstat | 7 files changed, 31 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp Sat Nov 15 10:34:10 2025 +0100 +++ b/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp Sat Nov 15 10:51:57 2025 +0100 @@ -395,14 +395,14 @@ "\" has failed with DIMSE status " + DimseToHexString(response.DimseStatus) + " (unable to process - invalid query ?)") .SetHttpStatus(HttpStatus_422_UnprocessableEntity) - .SetPayload(ErrorPayloadType_Dimse, MakeDimseErrorStatusPayload(response.DimseStatus)); + .SetPayload(MakeDimseErrorStatusPayload(response.DimseStatus)); } else { throw OrthancException(ErrorCode_NetworkProtocol, "C-FIND SCU to AET \"" + parameters_.GetRemoteModality().GetApplicationEntityTitle() + "\" has failed with DIMSE status " + DimseToHexString(response.DimseStatus)) - .SetPayload(ErrorPayloadType_Dimse, MakeDimseErrorStatusPayload(response.DimseStatus)); + .SetPayload(MakeDimseErrorStatusPayload(response.DimseStatus)); } } } @@ -525,14 +525,14 @@ "\" has failed with DIMSE status " + DimseToHexString(response.DimseStatus) + " (unable to process - resource not found ?)") .SetHttpStatus(HttpStatus_422_UnprocessableEntity) - .SetPayload(ErrorPayloadType_Dimse, MakeDimseErrorStatusPayload(response.DimseStatus)); + .SetPayload(MakeDimseErrorStatusPayload(response.DimseStatus)); } else { throw OrthancException(ErrorCode_NetworkProtocol, "C-MOVE SCU to AET \"" + parameters_.GetRemoteModality().GetApplicationEntityTitle() + "\" has failed with DIMSE status " + DimseToHexString(response.DimseStatus)) - .SetPayload(ErrorPayloadType_Dimse, MakeDimseErrorStatusPayload(response.DimseStatus)); + .SetPayload(MakeDimseErrorStatusPayload(response.DimseStatus)); } } } @@ -668,7 +668,7 @@ "C-GET SCU to AET \"" + parameters_.GetRemoteModality().GetApplicationEntityTitle() + "\" has failed with DIMSE status " + DimseToHexString(rsp.msg.CGetRSP.DimseStatus)) - .SetPayload(ErrorPayloadType_Dimse, MakeDimseErrorStatusPayload(rsp.msg.CGetRSP.DimseStatus)); + .SetPayload(MakeDimseErrorStatusPayload(rsp.msg.CGetRSP.DimseStatus)); } } // Handle C-STORE Request
--- a/OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.cpp Sat Nov 15 10:34:10 2025 +0100 +++ b/OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.cpp Sat Nov 15 10:51:57 2025 +0100 @@ -465,7 +465,7 @@ "C-STORE SCU to AET \"" + GetParameters().GetRemoteModality().GetApplicationEntityTitle() + "\" has failed with DIMSE status " + DimseToHexString(response.DimseStatus)) - .SetPayload(ErrorPayloadType_Dimse, MakeDimseErrorStatusPayload(response.DimseStatus)); + .SetPayload(MakeDimseErrorStatusPayload(response.DimseStatus)); } }
--- a/OrthancFramework/Sources/DicomNetworking/DimseErrorPayload.cpp Sat Nov 15 10:34:10 2025 +0100 +++ b/OrthancFramework/Sources/DicomNetworking/DimseErrorPayload.cpp Sat Nov 15 10:51:57 2025 +0100 @@ -32,25 +32,35 @@ static const char* const DIMSE_ERROR_STATUS = "DimseErrorStatus"; // uint16_t - Json::Value MakeDimseErrorStatusPayload(uint16_t dimseErrorStatus) + ErrorPayload MakeDimseErrorStatusPayload(uint16_t dimseErrorStatus) { - Json::Value payload; - payload[DIMSE_ERROR_STATUS] = dimseErrorStatus; + Json::Value content; + content[DIMSE_ERROR_STATUS] = dimseErrorStatus; + + ErrorPayload payload; + payload.SetContent(ErrorPayloadType_Dimse, content); return payload; } - uint16_t GetDimseErrorStatusFromPayload(const Json::Value& payload) + uint16_t GetDimseErrorStatusFromPayload(const ErrorPayload& payload) { - unsigned int status = SerializationToolbox::ReadUnsignedInteger(payload, DIMSE_ERROR_STATUS); + if (payload.GetType() == ErrorPayloadType_Dimse) + { + unsigned int status = SerializationToolbox::ReadUnsignedInteger(payload.GetContent(), DIMSE_ERROR_STATUS); - if (status <= 65535) - { - return static_cast<uint16_t>(status); + if (status <= 65535) + { + return static_cast<uint16_t>(status); + } + else + { + throw OrthancException(ErrorCode_BadFileFormat); + } } else { - throw OrthancException(ErrorCode_BadFileFormat); + throw OrthancException(ErrorCode_BadParameterType); } } }
--- a/OrthancFramework/Sources/DicomNetworking/DimseErrorPayload.h Sat Nov 15 10:34:10 2025 +0100 +++ b/OrthancFramework/Sources/DicomNetworking/DimseErrorPayload.h Sat Nov 15 10:51:57 2025 +0100 @@ -33,7 +33,7 @@ namespace Orthanc { - Json::Value MakeDimseErrorStatusPayload(uint16_t dimseErrorStatus); + ErrorPayload MakeDimseErrorStatusPayload(uint16_t dimseErrorStatus); - uint16_t GetDimseErrorStatusFromPayload(/* TODO PAYLOAD */ const Json::Value& payload); + uint16_t GetDimseErrorStatusFromPayload(const ErrorPayload& payload); }
--- a/OrthancFramework/Sources/OrthancException.cpp Sat Nov 15 10:34:10 2025 +0100 +++ b/OrthancFramework/Sources/OrthancException.cpp Sat Nov 15 10:51:57 2025 +0100 @@ -114,7 +114,7 @@ OrthancException::OrthancException(const OrthancException& other) : errorCode_(other.errorCode_), httpStatus_(other.httpStatus_), - logged_(false), + logged_(other.logged_), payload_(other.payload_) { if (other.details_.get() != NULL)
--- a/OrthancFramework/Sources/OrthancException.h Sat Nov 15 10:34:10 2025 +0100 +++ b/OrthancFramework/Sources/OrthancException.h Sat Nov 15 10:51:57 2025 +0100 @@ -45,7 +45,7 @@ { } - explicit ErrorPayload(const ErrorPayload& other); + ErrorPayload(const ErrorPayload& other); ErrorPayload& operator= (const ErrorPayload& other); @@ -85,7 +85,7 @@ // New in Orthanc 1.12.10 ErrorPayload payload_; - + public: OrthancException(const OrthancException& other); @@ -129,11 +129,6 @@ return *this; } - ErrorPayload& GetPayload() - { - return payload_; - } - const ErrorPayload& GetPayload() const { return payload_;
--- a/OrthancServer/Sources/ServerJobs/DicomRetrieveScuBaseJob.cpp Sat Nov 15 10:34:10 2025 +0100 +++ b/OrthancServer/Sources/ServerJobs/DicomRetrieveScuBaseJob.cpp Sat Nov 15 10:51:57 2025 +0100 @@ -104,7 +104,7 @@ if (e.GetPayload().HasContent() && e.GetPayload().GetType() == ErrorPayloadType_Dimse) { - dimseErrorStatus_ = GetDimseErrorStatusFromPayload(e.GetPayload().GetContent()); + dimseErrorStatus_ = GetDimseErrorStatusFromPayload(e.GetPayload()); } throw;
