changeset 4380:91e5cbacb94d

integration varian->mainline
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 17 Dec 2020 12:48:55 +0100
parents 4770ac7287ec (current diff) 85b5b0e1bac9 (diff)
children e49cf50b54c8
files
diffstat 6 files changed, 35 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Thu Dec 17 11:42:48 2020 +0100
+++ b/NEWS	Thu Dec 17 12:48:55 2020 +0100
@@ -11,6 +11,7 @@
 * New configuration options (contributions by Varian):
   - "DeidentifyLogs" to remove patient identification from the logs (C-GET, C-MOVE, C-FIND)
   - "DeidentifyLogsDicomVersion" to specify the deidentification rules for the logs
+  - "OrthancExplorerEnabled" to enable/disable the Orthanc Explorer Web user interface
 
 REST API
 --------
--- a/OrthancServer/Resources/Configuration.json	Thu Dec 17 11:42:48 2020 +0100
+++ b/OrthancServer/Resources/Configuration.json	Thu Dec 17 12:48:55 2020 +0100
@@ -71,6 +71,11 @@
   // Explorer will not be available.
   "HttpServerEnabled" : true,
 
+  // Enable/disable the Orthanc Explorer Web user interface. This
+  // option is only meaningful if the "HttpServerEnabled" option is
+  // set to "true" (new in Orthanc 1.8.2).
+  "OrthancExplorerEnabled" : true,
+
   // HTTP port for the REST services and for the GUI
   "HttpPort" : 8042,
 
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp	Thu Dec 17 11:42:48 2020 +0100
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp	Thu Dec 17 12:48:55 2020 +0100
@@ -205,7 +205,8 @@
 
   // Registration of the various REST handlers --------------------------------
 
-  OrthancRestApi::OrthancRestApi(ServerContext& context) : 
+  OrthancRestApi::OrthancRestApi(ServerContext& context, 
+                                 bool orthancExplorerEnabled) : 
     context_(context),
     leaveBarrier_(false),
     resetRequestReceived_(false),
@@ -213,7 +214,7 @@
                     "orthanc_rest_api_active_requests", 
                     MetricsType_MaxOver10Seconds)
   {
-    RegisterSystem();
+    RegisterSystem(orthancExplorerEnabled);
 
     RegisterChanges();
     RegisterResources();
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.h	Thu Dec 17 11:42:48 2020 +0100
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.h	Thu Dec 17 12:48:55 2020 +0100
@@ -58,7 +58,7 @@
     bool                            resetRequestReceived_;
     MetricsRegistry::SharedMetrics  activeRequests_;
 
-    void RegisterSystem();
+    void RegisterSystem(bool orthancExplorerEnabled);
 
     void RegisterChanges();
 
@@ -75,7 +75,8 @@
     static void ShutdownOrthanc(RestApiPostCall& call);
 
   public:
-    explicit OrthancRestApi(ServerContext& context);
+    explicit OrthancRestApi(ServerContext& context,
+                            bool orthancExplorerEnabled);
 
     virtual bool Handle(HttpOutput& output,
                         RequestOrigin origin,
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp	Thu Dec 17 11:42:48 2020 +0100
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp	Thu Dec 17 12:48:55 2020 +0100
@@ -556,9 +556,13 @@
   }
 
 
-  void OrthancRestApi::RegisterSystem()
+  void OrthancRestApi::RegisterSystem(bool orthancExplorerEnabled)
   {
-    Register("/", ServeRoot);
+    if (orthancExplorerEnabled)
+    {
+      Register("/", ServeRoot);
+    }
+    
     Register("/system", GetSystemInformation);
     Register("/statistics", GetStatistics);
     Register("/tools/generate-uid", GenerateUid);
--- a/OrthancServer/Sources/main.cpp	Thu Dec 17 11:42:48 2020 +0100
+++ b/OrthancServer/Sources/main.cpp	Thu Dec 17 12:48:55 2020 +0100
@@ -1229,10 +1229,25 @@
   FilesystemHttpHandler staticResources("/app", ORTHANC_PATH "/OrthancExplorer");
 #endif
 
-  context.GetHttpHandler().Register(staticResources, false);
+  // Do not register static resources if orthanc explorer is disabled
+  bool orthancExplorerEnabled = false;
+  {
+    OrthancConfiguration::ReaderLock lock;
+    orthancExplorerEnabled = lock.GetConfiguration().GetBooleanParameter(
+        "OrthancExplorerEnabled", true);
+  }
+
+  if (orthancExplorerEnabled)
+  {
+    context.GetHttpHandler().Register(staticResources, false);
+  }
+  else
+  {
+    LOG(WARNING) << "Orthanc Explorer UI is disabled";
+  }
 
   // Thirdly, consider the built-in REST API of Orthanc
-  OrthancRestApi restApi(context);
+  OrthancRestApi restApi(context, orthancExplorerEnabled);
   context.GetHttpHandler().Register(restApi, true);
 
   context.SetupJobsEngine(false /* not running unit tests */, loadJobsFromDatabase);