Mercurial > hg > orthanc
comparison OrthancServer/Sources/ResourceFinder.cpp @ 5856:d1dea8ad74a6 find-refactoring
implement StorageAccessOnFind for answers
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Mon, 04 Nov 2024 21:51:24 +0100 |
parents | aeb9f63923b1 |
children | 66fd63b8601e |
comparison
equal
deleted
inserted
replaced
5855:aeb9f63923b1 | 5856:d1dea8ad74a6 |
---|---|
542 } | 542 } |
543 } | 543 } |
544 | 544 |
545 | 545 |
546 ResourceFinder::ResourceFinder(ResourceType level, | 546 ResourceFinder::ResourceFinder(ResourceType level, |
547 ResponseContentFlags responseContent) : | 547 ResponseContentFlags responseContent, |
548 FindStorageAccessMode storageAccessMode) : | |
548 request_(level), | 549 request_(level), |
549 databaseLimits_(0), | 550 databaseLimits_(0), |
550 isSimpleLookup_(true), | 551 isSimpleLookup_(true), |
551 pagingMode_(PagingMode_FullManual), | 552 pagingMode_(PagingMode_FullManual), |
552 hasLimitsSince_(false), | 553 hasLimitsSince_(false), |
553 hasLimitsCount_(false), | 554 hasLimitsCount_(false), |
554 limitsSince_(0), | 555 limitsSince_(0), |
555 limitsCount_(0), | 556 limitsCount_(0), |
556 responseContent_(responseContent), | 557 responseContent_(responseContent), |
557 allowStorageAccess_(true), | 558 storageAccessMode_(storageAccessMode), |
558 isWarning002Enabled_(false), | 559 isWarning002Enabled_(false), |
559 isWarning004Enabled_(false), | 560 isWarning004Enabled_(false), |
560 isWarning005Enabled_(false) | 561 isWarning005Enabled_(false) |
561 { | 562 { |
562 { | 563 { |
1021 UpdateRequestLimits(context); | 1022 UpdateRequestLimits(context); |
1022 | 1023 |
1023 bool isWarning002Enabled = false; | 1024 bool isWarning002Enabled = false; |
1024 bool isWarning004Enabled = false; | 1025 bool isWarning004Enabled = false; |
1025 bool isWarning006Enabled = false; | 1026 bool isWarning006Enabled = false; |
1027 bool isWarning007Enabled = false; | |
1026 | 1028 |
1027 { | 1029 { |
1028 OrthancConfiguration::ReaderLock lock; | 1030 OrthancConfiguration::ReaderLock lock; |
1029 isWarning002Enabled = lock.GetConfiguration().IsWarningEnabled(Warnings_002_InconsistentDicomTagsInDb); | 1031 isWarning002Enabled = lock.GetConfiguration().IsWarningEnabled(Warnings_002_InconsistentDicomTagsInDb); |
1030 isWarning004Enabled = lock.GetConfiguration().IsWarningEnabled(Warnings_004_NoMainDicomTagsSignature); | 1032 isWarning004Enabled = lock.GetConfiguration().IsWarningEnabled(Warnings_004_NoMainDicomTagsSignature); |
1031 isWarning006Enabled = lock.GetConfiguration().IsWarningEnabled(Warnings_006_RequestingTagFromMetaHeader); | 1033 isWarning006Enabled = lock.GetConfiguration().IsWarningEnabled(Warnings_006_RequestingTagFromMetaHeader); |
1034 isWarning007Enabled = lock.GetConfiguration().IsWarningEnabled(Warnings_007_MissingRequestedTagsNotReadFromDisk); | |
1032 } | 1035 } |
1033 | 1036 |
1034 FindResponse response; | 1037 FindResponse response; |
1035 context.GetIndex().ExecuteFind(response, request_); | 1038 context.GetIndex().ExecuteFind(response, request_); |
1036 | 1039 |
1109 | 1112 |
1110 | 1113 |
1111 if (!remainingRequestedTags.empty() && | 1114 if (!remainingRequestedTags.empty() && |
1112 !DicomMap::HasOnlyComputedTags(remainingRequestedTags)) // if the only remaining tags are computed tags, it is worthless to read them from disk | 1115 !DicomMap::HasOnlyComputedTags(remainingRequestedTags)) // if the only remaining tags are computed tags, it is worthless to read them from disk |
1113 { | 1116 { |
1114 if (!allowStorageAccess_) | 1117 if (IsStorageAccessAllowedOnAnswers()) |
1115 { | |
1116 throw OrthancException(ErrorCode_BadSequenceOfCalls, | |
1117 "Cannot add missing requested tags, as access to file storage is disallowed"); | |
1118 } | |
1119 else | |
1120 { | 1118 { |
1121 ReadMissingTagsFromStorageArea(outRequestedTags, context, request_, resource, remainingRequestedTags); | 1119 ReadMissingTagsFromStorageArea(outRequestedTags, context, request_, resource, remainingRequestedTags); |
1120 } | |
1121 else if (isWarning007Enabled) | |
1122 { | |
1123 std::string joinedTags; | |
1124 FromDcmtkBridge::FormatListOfTags(joinedTags, remainingRequestedTags); | |
1125 LOG(WARNING) << "W007: Unable to include requested tags since 'StorageAccessOnFind' does not allow accessing the storage to build answers: " << joinedTags; | |
1122 } | 1126 } |
1123 } | 1127 } |
1124 | 1128 |
1125 std::string mainDicomTagsSignature; | 1129 std::string mainDicomTagsSignature; |
1126 if (isWarning002Enabled && | 1130 if (isWarning002Enabled && |
1189 { | 1193 { |
1190 visitor.MarkAsComplete(); | 1194 visitor.MarkAsComplete(); |
1191 } | 1195 } |
1192 } | 1196 } |
1193 | 1197 |
1198 bool ResourceFinder::IsStorageAccessAllowedOnAnswers() | |
1199 { | |
1200 switch (storageAccessMode_) | |
1201 { | |
1202 case FindStorageAccessMode_DiskOnAnswer: | |
1203 case FindStorageAccessMode_DiskOnLookupAndAnswer: | |
1204 return true; | |
1205 case FindStorageAccessMode_DatabaseOnly: | |
1206 return false; | |
1207 default: | |
1208 throw OrthancException(ErrorCode_InternalError); | |
1209 } | |
1210 } | |
1211 | |
1212 | |
1213 bool ResourceFinder::IsStorageAccessOnLookup() | |
1214 { | |
1215 switch (storageAccessMode_) | |
1216 { | |
1217 case FindStorageAccessMode_DiskOnAnswer: | |
1218 return false; | |
1219 case FindStorageAccessMode_DiskOnLookupAndAnswer: | |
1220 case FindStorageAccessMode_DatabaseOnly: | |
1221 return true; | |
1222 default: | |
1223 throw OrthancException(ErrorCode_InternalError); | |
1224 } | |
1225 } | |
1194 | 1226 |
1195 void ResourceFinder::Execute(Json::Value& target, | 1227 void ResourceFinder::Execute(Json::Value& target, |
1196 ServerContext& context, | 1228 ServerContext& context, |
1197 DicomToJsonFormat format, | 1229 DicomToJsonFormat format, |
1198 bool includeAllMetadata) | 1230 bool includeAllMetadata) |