Mercurial > hg > orthanc
diff OrthancServer/Sources/ServerContext.cpp @ 4513:1f455b86b054
simplification in ServerContext
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 12 Feb 2021 12:13:19 +0100 |
parents | 1ec156a0da38 |
children | 5b929e6b3c36 |
line wrap: on
line diff
--- a/OrthancServer/Sources/ServerContext.cpp Fri Feb 12 11:33:16 2021 +0100 +++ b/OrthancServer/Sources/ServerContext.cpp Fri Feb 12 12:13:19 2021 +0100 @@ -807,42 +807,6 @@ } - void ServerContext::ReadDicomAsJson(std::string& result, - const std::string& instancePublicId) - { - FileInfo attachment; - if (index_.LookupAttachment(attachment, instancePublicId, FileContentType_DicomAsJson)) - { - StorageAccessor accessor(area_, GetMetricsRegistry()); - accessor.Read(result, attachment); - } - else - { - // The "DICOM as JSON" summary is not available from the Orthanc - // store (most probably deleted), reconstruct it from the DICOM file - std::string dicom; - ReadDicom(dicom, instancePublicId); - - LOG(INFO) << "Reconstructing the missing DICOM-as-JSON summary for instance: " - << instancePublicId; - - ParsedDicomFile parsed(dicom); - - Json::Value summary; - OrthancConfiguration::DefaultDicomDatasetToJson(summary, parsed); - - result = summary.toStyledString(); - - if (!AddAttachment(instancePublicId, FileContentType_DicomAsJson, - result.c_str(), result.size())) - { - throw OrthancException(ErrorCode_InternalError, - "Cannot associate the DICOM-as-JSON summary to instance: " + instancePublicId); - } - } - } - - void ServerContext::ReadDicomAsJson(Json::Value& result, const std::string& instancePublicId, const std::set<DicomTag>& ignoreTagLength) @@ -850,7 +814,39 @@ if (ignoreTagLength.empty()) { std::string tmp; - ReadDicomAsJson(tmp, instancePublicId); + + { + FileInfo attachment; + if (index_.LookupAttachment(attachment, instancePublicId, FileContentType_DicomAsJson)) + { + StorageAccessor accessor(area_, GetMetricsRegistry()); + accessor.Read(tmp, attachment); + } + else + { + // The "DICOM as JSON" summary is not available from the Orthanc + // store (most probably deleted), reconstruct it from the DICOM file + std::string dicom; + ReadDicom(dicom, instancePublicId); + + LOG(INFO) << "Reconstructing the missing DICOM-as-JSON summary for instance: " + << instancePublicId; + + ParsedDicomFile parsed(dicom); + + Json::Value summary; + OrthancConfiguration::DefaultDicomDatasetToJson(summary, parsed); + + tmp = summary.toStyledString(); + + if (!AddAttachment(instancePublicId, FileContentType_DicomAsJson, + tmp.c_str(), tmp.size())) + { + throw OrthancException(ErrorCode_InternalError, + "Cannot associate the DICOM-as-JSON summary to instance: " + instancePublicId); + } + } + } if (!Toolbox::ReadJson(result, tmp)) {