diff OrthancServer/OrthancRestApi/OrthancRestSystem.cpp @ 2940:4767d36679ed

refactoring access to Orthanc configuration
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Nov 2018 11:47:00 +0100
parents 9d277f8ad698
children cb5d75143da0
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestSystem.cpp	Wed Nov 28 14:48:14 2018 +0100
+++ b/OrthancServer/OrthancRestApi/OrthancRestSystem.cpp	Thu Nov 29 11:47:00 2018 +0100
@@ -34,7 +34,7 @@
 #include "../PrecompiledHeadersServer.h"
 #include "OrthancRestApi.h"
 
-#include "../OrthancInitialization.h"
+#include "../OrthancConfiguration.h"
 #include "../../Core/DicomParsing/FromDcmtkBridge.h"
 #include "../../Plugins/Engine/PluginsManager.h"
 #include "../../Plugins/Engine/OrthancPlugins.h"
@@ -55,12 +55,16 @@
     Json::Value result = Json::objectValue;
 
     result["ApiVersion"] = ORTHANC_API_VERSION;
+    result["Version"] = ORTHANC_VERSION;
     result["DatabaseVersion"] = OrthancRestApi::GetIndex(call).GetDatabaseVersion();
-    result["DicomAet"] = Configuration::GetGlobalStringParameter("DicomAet", "ORTHANC");
-    result["DicomPort"] = Configuration::GetGlobalUnsignedIntegerParameter("DicomPort", 4242);
-    result["HttpPort"] = Configuration::GetGlobalUnsignedIntegerParameter("HttpPort", 8042);
-    result["Name"] = Configuration::GetGlobalStringParameter("Name", "");
-    result["Version"] = ORTHANC_VERSION;
+
+    {
+      OrthancConfiguration::ReaderLock lock;
+      result["DicomAet"] = lock.GetConfiguration().GetStringParameter("DicomAet", "ORTHANC");
+      result["DicomPort"] = lock.GetConfiguration().GetUnsignedIntegerParameter("DicomPort", 4242);
+      result["HttpPort"] = lock.GetConfiguration().GetUnsignedIntegerParameter("HttpPort", 8042);
+      result["Name"] = lock.GetConfiguration().GetStringParameter("Name", "");
+    }
 
     result["StorageAreaPlugin"] = Json::nullValue;
     result["DatabaseBackendPlugin"] = Json::nullValue;
@@ -157,7 +161,10 @@
   {
     Encoding encoding = StringToEncoding(call.GetBodyData());
 
-    Configuration::SetDefaultEncoding(encoding);
+    {
+      OrthancConfiguration::WriterLock lock;
+      lock.GetConfiguration().SetDefaultEncoding(encoding);
+    }
 
     call.GetOutput().AnswerBuffer(EnumerationToString(encoding), MimeType_PlainText);
   }