diff OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 5841:57ab63fe9108 find-refactoring tip

tools/find: Limit and Since are now forbidden when filtering on DICOM tags that are not stored in DB
author Alain Mazy <am@orthanc.team>
date Thu, 24 Oct 2024 15:08:43 +0200
parents 82fc95cc168c
children
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Mon Oct 21 18:24:09 2024 +0200
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Thu Oct 24 15:08:43 2024 +0200
@@ -3465,6 +3465,8 @@
 
       ResourceFinder finder(level, responseContent);
 
+      DatabaseLookup dicomTagLookup;
+
       { // common query code
         bool caseSensitive = false;
         if (request.isMember(KEY_CASE_SENSITIVE))
@@ -3473,7 +3475,6 @@
         }
 
         { // DICOM Tag query
-          DatabaseLookup dicomTagLookup;
 
           Json::Value::Members members = request[KEY_QUERY].getMemberNames();
           for (size_t i = 0; i < members.size(); i++)
@@ -3601,6 +3602,13 @@
 
         finder.SetDatabaseLimits(context.GetDatabaseLimits(level));
 
+        if ((request.isMember(KEY_LIMIT) || request.isMember(KEY_SINCE)) &&
+          !dicomTagLookup.HasOnlyMainDicomTags())
+        {
+            throw OrthancException(ErrorCode_BadRequest,
+                                  "Unable to use " + std::string(KEY_LIMIT) + " or " + std::string(KEY_SINCE) + " in tools/find when querying tags that are not stored as MainDicomTags in the Database");
+        }
+
         if (request.isMember(KEY_LIMIT))
         {
           int64_t tmp = request[KEY_LIMIT].asInt64();