Mercurial > hg > orthanc-object-storage
annotate Common/BaseStorage.cpp @ 136:f22262184474 2.3.1
fix framework
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 20 Dec 2023 16:39:46 +0100 |
parents | d7295e8678d7 |
children | 3c7e0374f28e |
rev | line source |
---|---|
56
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1 /** |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
2 * Cloud storage plugins for Orthanc |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
3 * Copyright (C) 2020-2021 Osimis S.A., Belgium |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
4 * |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
5 * This program is free software: you can redistribute it and/or |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
6 * modify it under the terms of the GNU Affero General Public License |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
7 * as published by the Free Software Foundation, either version 3 of |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
8 * the License, or (at your option) any later version. |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
9 * |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, but |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
11 * WITHOUT ANY WARRANTY; without even the implied warranty of |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
13 * Affero General Public License for more details. |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
14 * |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
15 * You should have received a copy of the GNU Affero General Public License |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
17 **/ |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
18 |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
19 |
78 | 20 #include "BaseStorage.h" |
15 | 21 #include <boost/filesystem/fstream.hpp> |
22 | |
78 | 23 boost::filesystem::path BaseStorage::GetOrthancFileSystemPath(const std::string& uuid, const std::string& fileSystemRootPath) |
15 | 24 { |
25 boost::filesystem::path path = fileSystemRootPath; | |
26 | |
27 path /= std::string(&uuid[0], &uuid[2]); | |
28 path /= std::string(&uuid[2], &uuid[4]); | |
29 path /= uuid; | |
30 | |
31 path.make_preferred(); | |
32 | |
77 | 33 return path; |
15 | 34 } |
35 | |
36 | |
78 | 37 std::string BaseStorage::GetPath(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled, bool useAlternateExtension) |
15 | 38 { |
39 if (enableLegacyStorageStructure_) | |
40 { | |
77 | 41 return GetOrthancFileSystemPath(uuid, rootPath_).string(); |
15 | 42 } |
43 else | |
44 { | |
20 | 45 boost::filesystem::path path = rootPath_; |
46 std::string filename = std::string(uuid); | |
15 | 47 |
48 if (type == OrthancPluginContentType_Dicom) | |
49 { | |
20 | 50 filename += ".dcm"; |
15 | 51 } |
52 else if (type == OrthancPluginContentType_DicomAsJson) | |
53 { | |
20 | 54 filename += ".json"; |
15 | 55 } |
64
c4f56973a279
Fix reading/deleting DCM header files that were saved with plugin v 1.2.0 and Orthanc 1.9.3 which had a .unk extension
Alain Mazy <am@osimis.io>
parents:
56
diff
changeset
|
56 else if (type == OrthancPluginContentType_DicomUntilPixelData && !useAlternateExtension) // for some time, header files were saved with .unk (happened with S3 storage plugin between version 1.2.0 and 1.3.0 - 21.5.1 and 21.6.2) |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
20
diff
changeset
|
57 { |
55 | 58 filename += ".dcm.head"; |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
20
diff
changeset
|
59 } |
15 | 60 else |
61 { | |
20 | 62 filename += ".unk"; |
15 | 63 } |
64 | |
65 if (encryptionEnabled) | |
66 { | |
20 | 67 filename += ".enc"; |
15 | 68 } |
20 | 69 path /= filename; |
70 | |
71 return path.string(); | |
15 | 72 } |
73 } | |
74 | |
78 | 75 bool BaseStorage::ReadCommonConfiguration(bool& enableLegacyStorageStructure, bool& storageContainsUnknownFiles, const OrthancPlugins::OrthancConfiguration& pluginSection) |
15 | 76 { |
77 std::string storageStructure = pluginSection.GetStringValue("StorageStructure", "flat"); | |
78 if (storageStructure == "flat") | |
79 { | |
80 enableLegacyStorageStructure = false; | |
81 } | |
82 else | |
83 { | |
84 enableLegacyStorageStructure = true; | |
85 if (storageStructure != "legacy") | |
86 { | |
87 OrthancPlugins::LogError("ObjectStorage/StorageStructure configuration invalid value: " + storageStructure + ", allowed values are 'flat' and 'legacy'"); | |
88 return false; | |
89 } | |
90 } | |
91 | |
70
16e419fe80c5
Google & Azure: Added the "EnableLegacyUnknownFiles" configuration option
Alain Mazy <am@osimis.io>
parents:
64
diff
changeset
|
92 storageContainsUnknownFiles = pluginSection.GetBooleanValue("EnableLegacyUnknownFiles", false); |
16e419fe80c5
Google & Azure: Added the "EnableLegacyUnknownFiles" configuration option
Alain Mazy <am@osimis.io>
parents:
64
diff
changeset
|
93 |
15 | 94 return true; |
95 } |