changeset 23:e48acd7bc577

merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 07 Sep 2020 14:18:00 +0200
parents 319d41a22de4 (current diff) 968eb1c78aed (diff)
children 84c4ca822a13
files
diffstat 6 files changed, 34 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/Common/BaseStoragePlugin.cpp	Mon Sep 07 14:17:43 2020 +0200
+++ b/Common/BaseStoragePlugin.cpp	Mon Sep 07 14:18:00 2020 +0200
@@ -19,30 +19,33 @@
 {
   if (enableLegacyStorageStructure_)
   {
-    return GetOrthancFileSystemPath(uuid, std::string()); // there's no "root" path in an object store
+    return GetOrthancFileSystemPath(uuid, rootPath_);
   }
   else
   {
-    std::string path = std::string(uuid);
+    boost::filesystem::path path = rootPath_;
+    std::string filename = std::string(uuid);
 
     if (type == OrthancPluginContentType_Dicom)
     {
-      path += ".dcm";
+      filename += ".dcm";
     }
     else if (type == OrthancPluginContentType_DicomAsJson)
     {
-      path += ".json";
+      filename += ".json";
     }
     else
     {
-      path += ".unk";
+      filename += ".unk";
     }
 
     if (encryptionEnabled)
     {
-      path += ".enc";
+      filename += ".enc";
     }
-    return path;
+    path /= filename;
+
+    return path.string();
   }
 }
 
--- a/Common/BaseStoragePlugin.h	Mon Sep 07 14:17:43 2020 +0200
+++ b/Common/BaseStoragePlugin.h	Mon Sep 07 14:18:00 2020 +0200
@@ -4,7 +4,8 @@
 
 class BaseStoragePlugin : public IStoragePlugin
 {
-  bool enableLegacyStorageStructure_;
+  bool        enableLegacyStorageStructure_;
+  std::string rootPath_;
 
 protected:
 
@@ -15,6 +16,11 @@
   std::string GetPath(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled);
 
 public:
+  virtual void SetRootPath(const std::string& rootPath)
+  {
+    rootPath_ = rootPath;
+  }
+
   static std::string GetPath(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled, bool legacyFileStructure, const std::string& rootFolder);
   static std::string GetOrthancFileSystemPath(const std::string& uuid, const std::string& fileSystemRootPath);
 
--- a/Common/IStoragePlugin.h	Mon Sep 07 14:17:43 2020 +0200
+++ b/Common/IStoragePlugin.h	Mon Sep 07 14:18:00 2020 +0200
@@ -66,6 +66,7 @@
   };
 
 public:
+  virtual void SetRootPath(const std::string& rootPath) = 0;
 
   virtual IWriter* GetWriterForObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled) = 0;
   virtual IReader* GetReaderForObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled) = 0;
--- a/Common/StoragePlugin.cpp	Mon Sep 07 14:17:43 2020 +0200
+++ b/Common/StoragePlugin.cpp	Mon Sep 07 14:18:00 2020 +0200
@@ -47,6 +47,7 @@
 static bool cryptoEnabled = false;
 static std::string fileSystemRootPath;
 static bool migrationFromFileSystemEnabled = false;
+static std::string objectsRootPath;
 
 // class to free memory allocated by malloc if an exception occurs
 // This is to avoid an issue in which the blob storage read method
@@ -323,6 +324,9 @@
         OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": migration from file system enabled, source: " + fileSystemRootPath);
       }
 
+      objectsRootPath = pluginSection.GetStringValue("RootPath", std::string());
+      plugin->SetRootPath(objectsRootPath);
+
       if (pluginSection.IsSection(ENCRYPTION_SECTION))
       {
         OrthancPlugins::OrthancConfiguration cryptoSection;
--- a/NEWS	Mon Sep 07 14:17:43 2020 +0200
+++ b/NEWS	Mon Sep 07 14:18:00 2020 +0200
@@ -1,12 +1,17 @@
 Pending changes in the mainline
 ===============================
 
+2020-09-07 - v 1.1.0
+====================
+
+* Added "RootPath" configuration
+
+
 2020-09-02 - v 1.0.1
 ====================
 
 * Internal change: fix compilation to avoid exposing internal symbols which caused a crash at Orthanc startup
 
-
 2020-09-01 - v 1.0.0
 ====================
 
--- a/README.md	Mon Sep 07 14:17:43 2020 +0200
+++ b/README.md	Mon Sep 07 14:18:00 2020 +0200
@@ -39,6 +39,7 @@
     "GoogleCloudStorage" : {
         "ServiceAccountFile" : "/.../googleServiceAccountFile.json",
         "BucketName": "test-orthanc-storage-plugin",
+        "RootPath": "",                 // optional: folder in which files are stored (ex: my/path/to/myfolder)
         "StorageEncryption" : {...},
         "StorageStructure" : "flat",
         "MigrationFromFileSystemEnabled" : false
@@ -66,6 +67,7 @@
     "AzureBlobStorage" : {
     	"ConnectionString": "DefaultEndpointsProtocol=https;AccountName=xxxxxxxxx;AccountKey=yyyyyyyy===;EndpointSuffix=core.windows.net",
     	"ContainerName" : "test-orthanc-storage-plugin",
+        "RootPath": "",                 // optional: folder in which files are stored (ex: my/path/to/myfolder)
         "StorageEncryption" : {...},
         "StorageStructure" : "flat",
         "MigrationFromFileSystemEnabled" : false
@@ -112,8 +114,9 @@
         "Endpoint": "",                 // optional: custom endpoint
         "ConnectionTimeout": 30,        // optional: connection timeout in seconds
         "RequestTimeout": 1200,         // optional: request timeout in seconds (max time to upload/download a file)
-        "StorageEncryption" : {...},
-        "StorageStructure" : "flat",
-        "MigrationFromFileSystemEnabled" : false
+        "RootPath": "",                 // optional: folder in which files are stored (ex: my/path/to/myfolder)
+        "StorageEncryption" : {...},    // optional
+        "StorageStructure" : "flat",    // optional
+        "MigrationFromFileSystemEnabled" : false // optional
     }
 ```
\ No newline at end of file