Mercurial > hg > orthanc
comparison OrthancServer/Sources/ServerContext.cpp @ 5850:1980354c8113 find-refactoring
add level of interest to StatelessDatabaseOperations::LookupAttachment()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 29 Oct 2024 15:03:32 +0000 |
parents | 58c549b881ae |
children |
comparison
equal
deleted
inserted
replaced
5849:0f4345cbe558 | 5850:1980354c8113 |
---|---|
960 } | 960 } |
961 } | 961 } |
962 | 962 |
963 | 963 |
964 void ServerContext::AnswerAttachment(RestApiOutput& output, | 964 void ServerContext::AnswerAttachment(RestApiOutput& output, |
965 ResourceType level, | |
965 const std::string& resourceId, | 966 const std::string& resourceId, |
966 FileContentType content) | 967 FileContentType content) |
967 { | 968 { |
968 FileInfo attachment; | 969 FileInfo attachment; |
969 int64_t revision; | 970 int64_t revision; |
970 if (!index_.LookupAttachment(attachment, revision, resourceId, content)) | 971 if (!index_.LookupAttachment(attachment, revision, level, resourceId, content)) |
971 { | 972 { |
972 throw OrthancException(ErrorCode_UnknownResource); | 973 throw OrthancException(ErrorCode_UnknownResource); |
973 } | 974 } |
974 else | 975 else |
975 { | 976 { |
977 accessor.AnswerFile(output, attachment, GetFileContentMime(content)); | 978 accessor.AnswerFile(output, attachment, GetFileContentMime(content)); |
978 } | 979 } |
979 } | 980 } |
980 | 981 |
981 | 982 |
982 void ServerContext::ChangeAttachmentCompression(const std::string& resourceId, | 983 void ServerContext::ChangeAttachmentCompression(ResourceType level, |
984 const std::string& resourceId, | |
983 FileContentType attachmentType, | 985 FileContentType attachmentType, |
984 CompressionType compression) | 986 CompressionType compression) |
985 { | 987 { |
986 LOG(INFO) << "Changing compression type for attachment " | 988 LOG(INFO) << "Changing compression type for attachment " |
987 << EnumerationToString(attachmentType) | 989 << EnumerationToString(attachmentType) |
988 << " of resource " << resourceId << " to " | 990 << " of resource " << resourceId << " to " |
989 << compression; | 991 << compression; |
990 | 992 |
991 FileInfo attachment; | 993 FileInfo attachment; |
992 int64_t revision; | 994 int64_t revision; |
993 if (!index_.LookupAttachment(attachment, revision, resourceId, attachmentType)) | 995 if (!index_.LookupAttachment(attachment, revision, level, resourceId, attachmentType)) |
994 { | 996 { |
995 throw OrthancException(ErrorCode_UnknownResource); | 997 throw OrthancException(ErrorCode_UnknownResource); |
996 } | 998 } |
997 | 999 |
998 if (attachment.GetCompressionType() == compression) | 1000 if (attachment.GetCompressionType() == compression) |
1090 std::map<FileContentType, FileInfo> attachments; | 1092 std::map<FileContentType, FileInfo> attachments; |
1091 | 1093 |
1092 FileInfo attachment; | 1094 FileInfo attachment; |
1093 int64_t revision; // Ignored | 1095 int64_t revision; // Ignored |
1094 | 1096 |
1095 if (index_.LookupAttachment(attachment, revision, instancePublicId, FileContentType_Dicom)) | 1097 if (index_.LookupAttachment(attachment, revision, ResourceType_Instance, instancePublicId, FileContentType_Dicom)) |
1096 { | 1098 { |
1097 attachments[FileContentType_Dicom] = attachment; | 1099 attachments[FileContentType_Dicom] = attachment; |
1098 } | 1100 } |
1099 | 1101 |
1100 if (index_.LookupAttachment(attachment, revision, instancePublicId, FileContentType_DicomUntilPixelData)) | 1102 if (index_.LookupAttachment(attachment, revision, ResourceType_Instance, instancePublicId, FileContentType_DicomUntilPixelData)) |
1101 { | 1103 { |
1102 attachments[FileContentType_DicomUntilPixelData] = attachment; | 1104 attachments[FileContentType_DicomUntilPixelData] = attachment; |
1103 } | 1105 } |
1104 | 1106 |
1105 if (index_.LookupAttachment(attachment, revision, instancePublicId, FileContentType_DicomAsJson)) | 1107 if (index_.LookupAttachment(attachment, revision, ResourceType_Instance, instancePublicId, FileContentType_DicomAsJson)) |
1106 { | 1108 { |
1107 attachments[FileContentType_DicomAsJson] = attachment; | 1109 attachments[FileContentType_DicomAsJson] = attachment; |
1108 } | 1110 } |
1109 | 1111 |
1110 std::string s; | 1112 std::string s; |
1293 void ServerContext::ReadDicom(std::string& dicom, | 1295 void ServerContext::ReadDicom(std::string& dicom, |
1294 std::string& attachmentId, | 1296 std::string& attachmentId, |
1295 const std::string& instancePublicId) | 1297 const std::string& instancePublicId) |
1296 { | 1298 { |
1297 int64_t revision; | 1299 int64_t revision; |
1298 ReadAttachment(dicom, revision, attachmentId, instancePublicId, FileContentType_Dicom, true /* uncompress */); | 1300 ReadAttachment(dicom, revision, attachmentId, ResourceType_Instance, instancePublicId, FileContentType_Dicom, true /* uncompress */); |
1299 } | 1301 } |
1300 | 1302 |
1301 | 1303 |
1302 void ServerContext::ReadDicom(std::string& dicom, | 1304 void ServerContext::ReadDicom(std::string& dicom, |
1303 const std::string& instancePublicId) | 1305 const std::string& instancePublicId) |
1318 bool ServerContext::ReadDicomUntilPixelData(std::string& dicom, | 1320 bool ServerContext::ReadDicomUntilPixelData(std::string& dicom, |
1319 const std::string& instancePublicId) | 1321 const std::string& instancePublicId) |
1320 { | 1322 { |
1321 FileInfo attachment; | 1323 FileInfo attachment; |
1322 int64_t revision; // Ignored | 1324 int64_t revision; // Ignored |
1323 if (index_.LookupAttachment(attachment, revision, instancePublicId, FileContentType_DicomUntilPixelData)) | 1325 if (index_.LookupAttachment(attachment, revision, ResourceType_Instance, instancePublicId, FileContentType_DicomUntilPixelData)) |
1324 { | 1326 { |
1325 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry()); | 1327 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry()); |
1326 | 1328 |
1327 accessor.Read(dicom, attachment); | 1329 accessor.Read(dicom, attachment); |
1328 assert(dicom.size() == attachment.GetUncompressedSize()); | 1330 assert(dicom.size() == attachment.GetUncompressedSize()); |
1333 if (!area_.HasReadRange()) | 1335 if (!area_.HasReadRange()) |
1334 { | 1336 { |
1335 return false; | 1337 return false; |
1336 } | 1338 } |
1337 | 1339 |
1338 if (!index_.LookupAttachment(attachment, revision, instancePublicId, FileContentType_Dicom)) | 1340 if (!index_.LookupAttachment(attachment, revision, ResourceType_Instance, instancePublicId, FileContentType_Dicom)) |
1339 { | 1341 { |
1340 throw OrthancException(ErrorCode_InternalError, | 1342 throw OrthancException(ErrorCode_InternalError, |
1341 "Unable to read the DICOM file of instance " + instancePublicId); | 1343 "Unable to read the DICOM file of instance " + instancePublicId); |
1342 } | 1344 } |
1343 | 1345 |
1370 | 1372 |
1371 | 1373 |
1372 void ServerContext::ReadAttachment(std::string& result, | 1374 void ServerContext::ReadAttachment(std::string& result, |
1373 int64_t& revision, | 1375 int64_t& revision, |
1374 std::string& attachmentId, | 1376 std::string& attachmentId, |
1377 ResourceType level, | |
1375 const std::string& instancePublicId, | 1378 const std::string& instancePublicId, |
1376 FileContentType content, | 1379 FileContentType content, |
1377 bool uncompressIfNeeded, | 1380 bool uncompressIfNeeded, |
1378 bool skipCache) | 1381 bool skipCache) |
1379 { | 1382 { |
1380 FileInfo attachment; | 1383 FileInfo attachment; |
1381 if (!index_.LookupAttachment(attachment, revision, instancePublicId, content)) | 1384 if (!index_.LookupAttachment(attachment, revision, level, instancePublicId, content)) |
1382 { | 1385 { |
1383 throw OrthancException(ErrorCode_InternalError, | 1386 throw OrthancException(ErrorCode_InternalError, |
1384 "Unable to read attachment " + EnumerationToString(content) + | 1387 "Unable to read attachment " + EnumerationToString(content) + |
1385 " of instance " + instancePublicId); | 1388 " of instance " + instancePublicId); |
1386 } | 1389 } |