diff OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 4473:68f52897c119

new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 26 Jan 2021 14:48:10 +0100
parents 6831de40acd9
children 1f455b86b054
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Tue Jan 26 10:18:50 2021 +0100
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Tue Jan 26 14:48:10 2021 +0100
@@ -321,24 +321,8 @@
 
     std::string publicId = call.GetUriComponent("id", "");
 
-    std::string body;
-    call.BodyToString(body);
-    body = Toolbox::StripSpaces(body);
-
-    if (body == "0")
-    {
-      context.GetIndex().SetProtectedPatient(publicId, false);
-      call.GetOutput().AnswerBuffer("", MimeType_PlainText);
-    }
-    else if (body == "1")
-    {
-      context.GetIndex().SetProtectedPatient(publicId, true);
-      call.GetOutput().AnswerBuffer("", MimeType_PlainText);
-    }
-    else
-    {
-      // Bad request
-    }
+    context.GetIndex().SetProtectedPatient(publicId, call.ParseBooleanBody());
+    call.GetOutput().AnswerBuffer("", MimeType_PlainText);
   }
 
 
@@ -1039,22 +1023,7 @@
 
         if (call.HasArgument(ARG_SMOOTH))
         {
-          std::string value = call.GetArgument(ARG_SMOOTH, "");
-          if (value == "0" ||
-              value == "false")
-          {
-            smooth = false;
-          }
-          else if (value == "1" ||
-                   value == "true")
-          {
-            smooth = true;
-          }
-          else
-          {
-            throw OrthancException(ErrorCode_ParameterOutOfRange,
-                                   "Argument must be Boolean: " + std::string(ARG_SMOOTH));
-          }
+          smooth = RestApiCall::ParseBoolean(call.GetArgument(ARG_SMOOTH, ""));
         }        
       }