# HG changeset patch # User Alain Mazy # Date 1599480769 -7200 # Node ID 968eb1c78aed08050f6aee8a75d3fbc9b991ff87 # Parent 44de9edf2443047c81bdacbe44f678d4823bb90a Added 'RootPath' configuration diff -r 44de9edf2443 -r 968eb1c78aed Common/BaseStoragePlugin.cpp --- a/Common/BaseStoragePlugin.cpp Wed Sep 02 18:15:45 2020 +0200 +++ b/Common/BaseStoragePlugin.cpp Mon Sep 07 14:12:49 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(); } } diff -r 44de9edf2443 -r 968eb1c78aed Common/BaseStoragePlugin.h --- a/Common/BaseStoragePlugin.h Wed Sep 02 18:15:45 2020 +0200 +++ b/Common/BaseStoragePlugin.h Mon Sep 07 14:12:49 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); diff -r 44de9edf2443 -r 968eb1c78aed Common/IStoragePlugin.h --- a/Common/IStoragePlugin.h Wed Sep 02 18:15:45 2020 +0200 +++ b/Common/IStoragePlugin.h Mon Sep 07 14:12:49 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; diff -r 44de9edf2443 -r 968eb1c78aed Common/StoragePlugin.cpp --- a/Common/StoragePlugin.cpp Wed Sep 02 18:15:45 2020 +0200 +++ b/Common/StoragePlugin.cpp Mon Sep 07 14:12:49 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; diff -r 44de9edf2443 -r 968eb1c78aed NEWS --- a/NEWS Wed Sep 02 18:15:45 2020 +0200 +++ b/NEWS Mon Sep 07 14:12:49 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 ==================== diff -r 44de9edf2443 -r 968eb1c78aed README.md --- a/README.md Wed Sep 02 18:15:45 2020 +0200 +++ b/README.md Mon Sep 07 14:12:49 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