# HG changeset patch # User Sebastien Jodogne # Date 1612882214 -3600 # Node ID e3e759cbd19cde59c555ca214a8398a7a3d2b551 # Parent 11c2ddb4e2ca2ca87a7f8e1c980ed2cb1a0aae10 refactoring IStoreRequestHandler diff -r 11c2ddb4e2ca -r e3e759cbd19c OrthancFramework/Sources/DicomNetworking/IStoreRequestHandler.h --- a/OrthancFramework/Sources/DicomNetworking/IStoreRequestHandler.h Tue Feb 09 15:24:36 2021 +0100 +++ b/OrthancFramework/Sources/DicomNetworking/IStoreRequestHandler.h Tue Feb 09 15:50:14 2021 +0100 @@ -28,6 +28,8 @@ #include #include +class DcmDataset; + namespace Orthanc { class IStoreRequestHandler : public boost::noncopyable @@ -37,9 +39,7 @@ { } - virtual void Handle(const std::string& dicomFile, - const DicomMap& dicomSummary, - const Json::Value& dicomJson, + virtual void Handle(DcmDataset& dicom, const std::string& remoteIp, const std::string& remoteAet, const std::string& calledAet) = 0; diff -r 11c2ddb4e2ca -r e3e759cbd19c OrthancFramework/Sources/DicomNetworking/Internals/StoreScp.cpp --- a/OrthancFramework/Sources/DicomNetworking/Internals/StoreScp.cpp Tue Feb 09 15:24:36 2021 +0100 +++ b/OrthancFramework/Sources/DicomNetworking/Internals/StoreScp.cpp Tue Feb 09 15:50:14 2021 +0100 @@ -154,30 +154,6 @@ // is present and the options opt_bitPreserving and opt_ignore are not set. if ((imageDataSet != NULL) && (*imageDataSet != NULL)) { - DicomMap summary; - Json::Value dicomJson; - std::string buffer; - - try - { - std::set ignoreTagLength; - - // TODO => Parameters in class "DicomServer" - FromDcmtkBridge::ExtractDicomSummary(summary, **imageDataSet, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength); - FromDcmtkBridge::ExtractDicomAsJson(dicomJson, **imageDataSet, DicomToJsonFormat_Full, - DicomToJsonFlags_Default, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength); - - if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, **imageDataSet)) - { - CLOG(ERROR, DICOM) << "cannot write DICOM file to memory"; - rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources; - } - } - catch (...) - { - rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources; - } - // check the image to make sure it is consistent, i.e. that its sopClass and sopInstance correspond // to those mentioned in the request. If not, set the status in the response message variable. if (rsp->DimseStatus == STATUS_Success) @@ -206,7 +182,7 @@ { try { - cbdata->handler->Handle(buffer, summary, dicomJson, *cbdata->remoteIp, cbdata->remoteAET, cbdata->calledAET); + cbdata->handler->Handle(**imageDataSet, *cbdata->remoteIp, cbdata->remoteAET, cbdata->calledAET); } catch (OrthancException& e) { @@ -214,7 +190,7 @@ if (e.GetErrorCode() == ErrorCode_InexistentTag) { - summary.LogMissingTagsForStore(); + FromDcmtkBridge::LogMissingTagsForStore(**imageDataSet); } else { diff -r 11c2ddb4e2ca -r e3e759cbd19c OrthancServer/Sources/main.cpp --- a/OrthancServer/Sources/main.cpp Tue Feb 09 15:24:36 2021 +0100 +++ b/OrthancServer/Sources/main.cpp Tue Feb 09 15:50:14 2021 +0100 @@ -83,13 +83,27 @@ } - virtual void Handle(const std::string& dicomFile, - const DicomMap& dicomSummary, - const Json::Value& dicomJson, + virtual void Handle(DcmDataset& dicom, const std::string& remoteIp, const std::string& remoteAet, const std::string& calledAet) ORTHANC_OVERRIDE { + DicomMap dicomSummary; + Json::Value dicomJson; + std::string dicomFile; + + const std::set ignoreTagLength; + + // TODO => Parameters in class "DicomServer" + FromDcmtkBridge::ExtractDicomSummary(dicomSummary, dicom, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength); + FromDcmtkBridge::ExtractDicomAsJson(dicomJson, dicom, DicomToJsonFormat_Full, + DicomToJsonFlags_Default, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength); + + if (!FromDcmtkBridge::SaveToMemoryBuffer(dicomFile, dicom)) + { + throw OrthancException(ErrorCode_InternalError, "Cannot write DICOM file to memory"); + } + if (dicomFile.size() > 0) { DicomInstanceToStore toStore;