changeset 5247:eb2684260c19 db-protobuf

support labels for mysql
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 07 Apr 2023 15:44:12 +0200
parents b36f82260f41
children a7d95f951f8a
files NEWS OrthancServer/OrthancExplorer/explorer.html OrthancServer/Sources/ServerToolbox.cpp OrthancServer/UnitTestsSources/ServerIndexTests.cpp
diffstat 4 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Fri Apr 07 12:20:53 2023 +0200
+++ b/NEWS	Fri Apr 07 15:44:12 2023 +0200
@@ -25,6 +25,7 @@
 Orthanc Explorer
 ----------------
 
+* Added support for labels
 * Added buttons to copy the URL of ZIP archives and DICOM files to the clipboard
 
 Maintenance
--- a/OrthancServer/OrthancExplorer/explorer.html	Fri Apr 07 12:20:53 2023 +0200
+++ b/OrthancServer/OrthancExplorer/explorer.html	Fri Apr 07 15:44:12 2023 +0200
@@ -434,8 +434,8 @@
                 <a href="#" id="instance-modified-from">Before modification</a>
               </li>
               <li data-icon="arrow-d"><a href="#" id="instance-download-dicom">Download the DICOM file</a></li>
-              <li data-icon="arrow-d"><a href="#" id="instance-download-link">Copy link to the DICOM file</a></li>
               <li data-icon="arrow-d"><a href="#" id="instance-download-json">Download the JSON file</a></li>
+              <li data-icon="gear"><a href="#" id="instance-download-link">Copy link to the DICOM file</a></li>
               <li data-icon="search"><a href="#" id="instance-preview">Preview the instance</a></li>
             </ul>
           </div>
--- a/OrthancServer/Sources/ServerToolbox.cpp	Fri Apr 07 12:20:53 2023 +0200
+++ b/OrthancServer/Sources/ServerToolbox.cpp	Fri Apr 07 15:44:12 2023 +0200
@@ -295,6 +295,13 @@
       {
         return false;
       }
+
+      if (label.size() > 64)
+      {
+        // This limitation is for MySQL, which cannot use a TEXT
+        // column of undefined length as a primary key
+        return false;
+      }
       
       for (size_t i = 0; i < label.size(); i++)
       {
@@ -319,7 +326,8 @@
       {
         throw OrthancException(ErrorCode_ParameterOutOfRange,
                                "A label must be a non-empty, alphanumeric string, "
-                               "possibly with '.', '_', or '-' characters, but got: " + label);
+                               "possibly with '.', '_', or '-' characters, "
+                               "with maximum 64 characters, but got: " + label);
       }
     }
   }
--- a/OrthancServer/UnitTestsSources/ServerIndexTests.cpp	Fri Apr 07 12:20:53 2023 +0200
+++ b/OrthancServer/UnitTestsSources/ServerIndexTests.cpp	Fri Apr 07 15:44:12 2023 +0200
@@ -1045,8 +1045,8 @@
 TEST(ServerToolbox, ValidLabels)
 {
   ASSERT_TRUE(ServerToolbox::IsValidLabel("abcdefghijklmnopqrstuvwxyz"
-                                          "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                                          "0123456789-_."));
+                                          "ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
+  ASSERT_TRUE(ServerToolbox::IsValidLabel("0123456789-_."));
   ASSERT_FALSE(ServerToolbox::IsValidLabel(""));
   ASSERT_FALSE(ServerToolbox::IsValidLabel(" "));
   ASSERT_FALSE(ServerToolbox::IsValidLabel("&"));