Mercurial > hg > orthanc-object-storage
annotate Common/StoragePlugin.cpp @ 136:f22262184474 2.3.1
fix framework
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 20 Dec 2023 16:39:46 +0100 |
parents | 12ea59c97c40 |
children | addccb7ad900 82ab647f7e73 |
rev | line source |
---|---|
1 | 1 /** |
2 * Cloud storage plugins for Orthanc | |
37
f55b2afdf53d
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
35
diff
changeset
|
3 * Copyright (C) 2020-2021 Osimis S.A., Belgium |
1 | 4 * |
5 * This program is free software: you can redistribute it and/or | |
6 * modify it under the terms of the GNU Affero General Public License | |
7 * as published by the Free Software Foundation, either version 3 of | |
8 * the License, or (at your option) any later version. | |
9 * | |
10 * This program is distributed in the hope that it will be useful, but | |
11 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 * Affero General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU Affero General Public License | |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 **/ | |
18 | |
56
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
19 |
1 | 20 #if GOOGLE_STORAGE_PLUGIN==1 |
56
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
21 # include "../Google/GoogleStoragePlugin.h" |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
22 # define StoragePluginFactory GoogleStoragePluginFactory |
1 | 23 #elif AZURE_STORAGE_PLUGIN==1 |
56
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
24 # include "../Azure/AzureBlobStoragePlugin.h" |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
25 # define StoragePluginFactory AzureBlobStoragePluginFactory |
1 | 26 #elif AWS_STORAGE_PLUGIN==1 |
56
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
27 # include "../Aws/AwsS3StoragePlugin.h" |
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
28 # define StoragePluginFactory AwsS3StoragePluginFactory |
1 | 29 #else |
56
b922ae86bbe1
full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
30 # pragma message(error "define a plugin") |
1 | 31 #endif |
32 | |
33 #include <string.h> | |
34 #include <stdio.h> | |
35 #include <string> | |
36 | |
37 #include <iostream> | |
15 | 38 #include <boost/filesystem.hpp> |
39 #include <boost/filesystem/fstream.hpp> | |
40 | |
1 | 41 #include "../Common/EncryptionHelpers.h" |
42 #include "../Common/EncryptionConfigurator.h" | |
78 | 43 #include "../Common/FileSystemStorage.h" |
35
8a7a5defd5d0
upgrade orthanc framework to 1.8.2 in AWS S3 plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
33
diff
changeset
|
44 |
8a7a5defd5d0
upgrade orthanc framework to 1.8.2 in AWS S3 plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
33
diff
changeset
|
45 #include <Logging.h> |
15 | 46 #include <SystemToolbox.h> |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
47 #include "MoveStorageJob.h" |
84 | 48 #include "StoragePlugin.h" |
49 #include <Toolbox.h> | |
50 | |
1 | 51 |
78 | 52 static std::unique_ptr<IStorage> primaryStorage; |
53 static std::unique_ptr<IStorage> secondaryStorage; | |
1 | 54 |
55 static std::unique_ptr<EncryptionHelpers> crypto; | |
56 static bool cryptoEnabled = false; | |
15 | 57 static std::string fileSystemRootPath; |
20 | 58 static std::string objectsRootPath; |
77 | 59 static std::string hybridModeNameForLogs = ""; |
60 | |
61 typedef enum | |
62 { | |
63 HybridMode_WriteToFileSystem, // write to disk, try to read first from disk and then, from object-storage | |
64 HybridMode_WriteToObjectStorage, // write to object storage, try to read first from object storage and then, from disk | |
65 HybridMode_Disabled // read and write only from/to object-storage | |
66 } HybridMode; | |
67 | |
68 static HybridMode hybridMode = HybridMode_Disabled; | |
69 | |
70 static bool IsReadFromDisk() | |
71 { | |
72 return hybridMode != HybridMode_Disabled; | |
73 } | |
74 | |
75 static bool IsHybridModeEnabled() | |
76 { | |
77 return hybridMode != HybridMode_Disabled; | |
78 } | |
79 | |
80 typedef void LogErrorFunction(const std::string& message); | |
81 | |
1 | 82 |
83 | |
84 static OrthancPluginErrorCode StorageCreate(const char* uuid, | |
85 const void* content, | |
86 int64_t size, | |
87 OrthancPluginContentType type) | |
88 { | |
89 try | |
90 { | |
120
12ea59c97c40
sync orthanc folder + show timings + EnableAwsSdkLogs
Alain Mazy <am@osimis.io>
parents:
98
diff
changeset
|
91 Orthanc::Toolbox::ElapsedTimer timer; |
78 | 92 OrthancPlugins::LogInfo(primaryStorage->GetNameForLogs() + ": creating attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); |
93 std::unique_ptr<IStorage::IWriter> writer(primaryStorage->GetWriterForObject(uuid, type, cryptoEnabled)); | |
1 | 94 |
95 if (cryptoEnabled) | |
96 { | |
97 std::string encryptedFile; | |
98 | |
99 try | |
100 { | |
101 crypto->Encrypt(encryptedFile, (const char*)content, size); | |
102 } | |
103 catch (EncryptionException& ex) | |
104 { | |
78 | 105 OrthancPlugins::LogError(primaryStorage->GetNameForLogs() + ": error while encrypting object " + std::string(uuid) + ": " + ex.what()); |
1 | 106 return OrthancPluginErrorCode_StorageAreaPlugin; |
107 } | |
108 | |
109 writer->Write(encryptedFile.data(), encryptedFile.size()); | |
110 } | |
111 else | |
112 { | |
113 writer->Write(reinterpret_cast<const char*>(content), size); | |
114 } | |
120
12ea59c97c40
sync orthanc folder + show timings + EnableAwsSdkLogs
Alain Mazy <am@osimis.io>
parents:
98
diff
changeset
|
115 OrthancPlugins::LogInfo(primaryStorage->GetNameForLogs() + ": created attachment " + std::string(uuid) + " (" + timer.GetHumanTransferSpeed(true, size) + ")"); |
1 | 116 } |
117 catch (StoragePluginException& ex) | |
118 { | |
78 | 119 OrthancPlugins::LogError(primaryStorage->GetNameForLogs() + ": error while creating object " + std::string(uuid) + ": " + ex.what()); |
1 | 120 return OrthancPluginErrorCode_StorageAreaPlugin; |
121 } | |
122 | |
123 return OrthancPluginErrorCode_Success; | |
124 } | |
125 | |
126 | |
78 | 127 static OrthancPluginErrorCode StorageReadRange(IStorage* storage, |
77 | 128 LogErrorFunction logErrorFunction, |
129 OrthancPluginMemoryBuffer64* target, // Memory buffer where to store the content of the range. The memory buffer is allocated and freed by Orthanc. The length of the range of interest corresponds to the size of this buffer. | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
130 const char* uuid, |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
131 OrthancPluginContentType type, |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
132 uint64_t rangeStart) |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
133 { |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
134 assert(!cryptoEnabled); |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
135 |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
136 try |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
137 { |
120
12ea59c97c40
sync orthanc folder + show timings + EnableAwsSdkLogs
Alain Mazy <am@osimis.io>
parents:
98
diff
changeset
|
138 Orthanc::Toolbox::ElapsedTimer timer; |
78 | 139 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": reading range of attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); |
77 | 140 |
78 | 141 std::unique_ptr<IStorage::IReader> reader(storage->GetReaderForObject(uuid, type, cryptoEnabled)); |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
142 reader->ReadRange(reinterpret_cast<char*>(target->data), target->size, rangeStart); |
77 | 143 |
120
12ea59c97c40
sync orthanc folder + show timings + EnableAwsSdkLogs
Alain Mazy <am@osimis.io>
parents:
98
diff
changeset
|
144 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": read range of attachment " + std::string(uuid) + " (" + timer.GetHumanTransferSpeed(true, target->size) + ")"); |
77 | 145 return OrthancPluginErrorCode_Success; |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
146 } |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
147 catch (StoragePluginException& ex) |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
148 { |
77 | 149 logErrorFunction(std::string(StoragePluginFactory::GetStoragePluginName()) + ": error while reading object " + std::string(uuid) + ": " + std::string(ex.what())); |
150 return OrthancPluginErrorCode_StorageAreaPlugin; | |
151 } | |
152 } | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
153 |
77 | 154 static OrthancPluginErrorCode StorageReadRange(OrthancPluginMemoryBuffer64* target, // Memory buffer where to store the content of the range. The memory buffer is allocated and freed by Orthanc. The length of the range of interest corresponds to the size of this buffer. |
155 const char* uuid, | |
156 OrthancPluginContentType type, | |
157 uint64_t rangeStart) | |
158 { | |
78 | 159 OrthancPluginErrorCode res = StorageReadRange(primaryStorage.get(), |
77 | 160 (IsHybridModeEnabled() ? OrthancPlugins::LogWarning : OrthancPlugins::LogError), // log errors as warning on first try |
161 target, | |
162 uuid, | |
163 type, | |
164 rangeStart); | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
165 |
77 | 166 if (res != OrthancPluginErrorCode_Success && IsHybridModeEnabled()) |
167 { | |
78 | 168 res = StorageReadRange(secondaryStorage.get(), |
77 | 169 OrthancPlugins::LogError, // log errors as errors on second try |
170 target, | |
171 uuid, | |
172 type, | |
173 rangeStart); | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
174 } |
77 | 175 return res; |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
176 } |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
177 |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
178 |
77 | 179 |
78 | 180 static OrthancPluginErrorCode StorageReadWhole(IStorage* storage, |
77 | 181 LogErrorFunction logErrorFunction, |
182 OrthancPluginMemoryBuffer64* target, // Memory buffer where to store the content of the file. It must be allocated by the plugin using OrthancPluginCreateMemoryBuffer64(). The core of Orthanc will free it. | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
183 const char* uuid, |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
184 OrthancPluginContentType type) |
1 | 185 { |
186 try | |
187 { | |
120
12ea59c97c40
sync orthanc folder + show timings + EnableAwsSdkLogs
Alain Mazy <am@osimis.io>
parents:
98
diff
changeset
|
188 Orthanc::Toolbox::ElapsedTimer timer; |
78 | 189 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": reading whole attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); |
190 std::unique_ptr<IStorage::IReader> reader(storage->GetReaderForObject(uuid, type, cryptoEnabled)); | |
1 | 191 |
192 size_t fileSize = reader->GetSize(); | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
193 size_t size; |
1 | 194 |
195 if (cryptoEnabled) | |
196 { | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
197 size = fileSize - crypto->OVERHEAD_SIZE; |
1 | 198 } |
199 else | |
200 { | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
201 size = fileSize; |
1 | 202 } |
203 | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
204 if (size <= 0) |
1 | 205 { |
78 | 206 logErrorFunction(storage->GetNameForLogs() + ": error while reading object " + std::string(uuid) + ", size of file is too small: " + boost::lexical_cast<std::string>(fileSize) + " bytes"); |
1 | 207 return OrthancPluginErrorCode_StorageAreaPlugin; |
208 } | |
209 | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
210 if (OrthancPluginCreateMemoryBuffer64(OrthancPlugins::GetGlobalContext(), target, size) != OrthancPluginErrorCode_Success) |
1 | 211 { |
78 | 212 logErrorFunction(storage->GetNameForLogs() + ": error while reading object " + std::string(uuid) + ", cannot allocate memory of size " + boost::lexical_cast<std::string>(size) + " bytes"); |
1 | 213 return OrthancPluginErrorCode_StorageAreaPlugin; |
214 } | |
215 | |
216 if (cryptoEnabled) | |
217 { | |
218 std::vector<char> encrypted(fileSize); | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
219 reader->ReadWhole(encrypted.data(), fileSize); |
1 | 220 |
221 try | |
222 { | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
223 crypto->Decrypt(reinterpret_cast<char*>(target->data), encrypted.data(), fileSize); |
1 | 224 } |
225 catch (EncryptionException& ex) | |
226 { | |
78 | 227 logErrorFunction(storage->GetNameForLogs() + ": error while decrypting object " + std::string(uuid) + ": " + ex.what()); |
1 | 228 return OrthancPluginErrorCode_StorageAreaPlugin; |
229 } | |
230 } | |
231 else | |
232 { | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
233 reader->ReadWhole(reinterpret_cast<char*>(target->data), fileSize); |
1 | 234 } |
120
12ea59c97c40
sync orthanc folder + show timings + EnableAwsSdkLogs
Alain Mazy <am@osimis.io>
parents:
98
diff
changeset
|
235 |
12ea59c97c40
sync orthanc folder + show timings + EnableAwsSdkLogs
Alain Mazy <am@osimis.io>
parents:
98
diff
changeset
|
236 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": read whole attachment " + std::string(uuid) + " (" + timer.GetHumanTransferSpeed(true, fileSize) + ")"); |
1 | 237 } |
238 catch (StoragePluginException& ex) | |
239 { | |
98 | 240 logErrorFunction(storage->GetNameForLogs() + ": error while reading object " + std::string(uuid) + ": " + ex.what()); |
77 | 241 return OrthancPluginErrorCode_StorageAreaPlugin; |
1 | 242 } |
243 | |
244 return OrthancPluginErrorCode_Success; | |
245 } | |
246 | |
77 | 247 static OrthancPluginErrorCode StorageReadWhole(OrthancPluginMemoryBuffer64* target, // Memory buffer where to store the content of the file. It must be allocated by the plugin using OrthancPluginCreateMemoryBuffer64(). The core of Orthanc will free it. |
248 const char* uuid, | |
249 OrthancPluginContentType type) | |
250 { | |
78 | 251 OrthancPluginErrorCode res = StorageReadWhole(primaryStorage.get(), |
77 | 252 (IsHybridModeEnabled() ? OrthancPlugins::LogWarning : OrthancPlugins::LogError), // log errors as warning on first try |
253 target, | |
254 uuid, | |
255 type); | |
256 | |
257 if (res != OrthancPluginErrorCode_Success && IsHybridModeEnabled()) | |
258 { | |
78 | 259 res = StorageReadWhole(secondaryStorage.get(), |
77 | 260 OrthancPlugins::LogError, // log errors as errors on second try |
261 target, | |
262 uuid, | |
263 type); | |
264 } | |
265 return res; | |
266 } | |
267 | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
268 static OrthancPluginErrorCode StorageReadWholeLegacy(void** content, |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
269 int64_t* size, |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
270 const char* uuid, |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
271 OrthancPluginContentType type) |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
272 { |
43
4c71c5e2edce
fix memory handling in legacy read
Alain Mazy <am@osimis.io>
parents:
39
diff
changeset
|
273 OrthancPluginMemoryBuffer64 buffer; |
4c71c5e2edce
fix memory handling in legacy read
Alain Mazy <am@osimis.io>
parents:
39
diff
changeset
|
274 OrthancPluginErrorCode result = StorageReadWhole(&buffer, uuid, type); // will allocate OrthancPluginMemoryBuffer64 |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
275 |
43
4c71c5e2edce
fix memory handling in legacy read
Alain Mazy <am@osimis.io>
parents:
39
diff
changeset
|
276 if (result == OrthancPluginErrorCode_Success) |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
277 { |
43
4c71c5e2edce
fix memory handling in legacy read
Alain Mazy <am@osimis.io>
parents:
39
diff
changeset
|
278 *size = buffer.size; |
4c71c5e2edce
fix memory handling in legacy read
Alain Mazy <am@osimis.io>
parents:
39
diff
changeset
|
279 *content = buffer.data; // orthanc will free the buffer (we don't have to delete it ourselves) |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
280 } |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
281 |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
282 return result; |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
283 } |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
284 |
1 | 285 |
78 | 286 static OrthancPluginErrorCode StorageRemove(IStorage* storage, |
77 | 287 LogErrorFunction logErrorFunction, |
288 const char* uuid, | |
1 | 289 OrthancPluginContentType type) |
290 { | |
291 try | |
292 { | |
78 | 293 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": deleting attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); |
294 storage->DeleteObject(uuid, type, cryptoEnabled); | |
295 if ((storage == primaryStorage.get()) && IsHybridModeEnabled()) | |
77 | 296 { |
297 // not 100% sure the file has been deleted, try the secondary plugin | |
298 return OrthancPluginErrorCode_StorageAreaPlugin; | |
299 } | |
300 | |
301 return OrthancPluginErrorCode_Success; | |
1 | 302 } |
303 catch (StoragePluginException& ex) | |
304 { | |
77 | 305 logErrorFunction(std::string(StoragePluginFactory::GetStoragePluginName()) + ": error while deleting object " + std::string(uuid) + ": " + std::string(ex.what())); |
306 return OrthancPluginErrorCode_StorageAreaPlugin; | |
307 } | |
308 } | |
15 | 309 |
77 | 310 static OrthancPluginErrorCode StorageRemove(const char* uuid, |
311 OrthancPluginContentType type) | |
312 { | |
78 | 313 OrthancPluginErrorCode res = StorageRemove(primaryStorage.get(), |
77 | 314 (IsHybridModeEnabled() ? OrthancPlugins::LogWarning : OrthancPlugins::LogError), // log errors as warning on first try |
315 uuid, | |
316 type); | |
15 | 317 |
77 | 318 if (res != OrthancPluginErrorCode_Success && IsHybridModeEnabled()) |
319 { | |
78 | 320 res = StorageRemove(secondaryStorage.get(), |
77 | 321 OrthancPlugins::LogError, // log errors as errors on second try |
322 uuid, | |
323 type); | |
1 | 324 } |
77 | 325 return res; |
1 | 326 } |
327 | |
328 | |
84 | 329 static MoveStorageJob* CreateMoveStorageJob(const std::string& targetStorage, const std::vector<std::string>& instances, const Json::Value& resourcesForJobContent) |
330 { | |
331 std::unique_ptr<MoveStorageJob> job(new MoveStorageJob(targetStorage, instances, resourcesForJobContent, cryptoEnabled)); | |
332 | |
333 if (hybridMode == HybridMode_WriteToFileSystem) | |
334 { | |
335 job->SetStorages(primaryStorage.get(), secondaryStorage.get()); | |
336 } | |
337 else | |
338 { | |
339 job->SetStorages(secondaryStorage.get(), primaryStorage.get()); | |
340 } | |
341 | |
342 return job.release(); | |
343 } | |
344 | |
345 | |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
346 static void AddResourceForJobContent(Json::Value& resourcesForJobContent /* out */, Orthanc::ResourceType resourceType, const std::string& resourceId) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
347 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
348 const char* resourceGroup = Orthanc::GetResourceTypeText(resourceType, true, true); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
349 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
350 if (!resourcesForJobContent.isMember(resourceGroup)) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
351 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
352 resourcesForJobContent[resourceGroup] = Json::arrayValue; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
353 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
354 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
355 resourcesForJobContent[resourceGroup].append(resourceId); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
356 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
357 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
358 void MoveStorage(OrthancPluginRestOutput* output, |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
359 const char* /*url*/, |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
360 const OrthancPluginHttpRequest* request) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
361 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
362 OrthancPluginContext* context = OrthancPlugins::GetGlobalContext(); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
363 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
364 if (request->method != OrthancPluginHttpMethod_Post) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
365 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
366 OrthancPluginSendMethodNotAllowed(context, output, "POST"); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
367 return; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
368 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
369 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
370 Json::Value requestPayload; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
371 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
372 if (!OrthancPlugins::ReadJson(requestPayload, request->body, request->bodySize)) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
373 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
374 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat, "A JSON payload was expected"); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
375 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
376 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
377 std::vector<std::string> instances; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
378 Json::Value resourcesForJobContent; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
379 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
380 if (requestPayload.type() != Json::objectValue || |
84 | 381 !requestPayload.isMember(KEY_RESOURCES) || |
382 requestPayload[KEY_RESOURCES].type() != Json::arrayValue) | |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
383 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
384 throw Orthanc::OrthancException( |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
385 Orthanc::ErrorCode_BadFileFormat, |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
386 "A request to the move-storage endpoint must provide a JSON object " |
84 | 387 "with the field \"" + std::string(KEY_RESOURCES) + |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
388 "\" containing an array of resources to be sent"); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
389 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
390 |
84 | 391 if (!requestPayload.isMember(KEY_TARGET_STORAGE) |
392 || requestPayload[KEY_TARGET_STORAGE].type() != Json::stringValue | |
393 || (requestPayload[KEY_TARGET_STORAGE].asString() != STORAGE_TYPE_FILE_SYSTEM && requestPayload[KEY_TARGET_STORAGE].asString() != STORAGE_TYPE_OBJECT_STORAGE)) | |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
394 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
395 throw Orthanc::OrthancException( |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
396 Orthanc::ErrorCode_BadFileFormat, |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
397 "A request to the move-storage endpoint must provide a JSON object " |
84 | 398 "with the field \"" + std::string(KEY_TARGET_STORAGE) + |
399 "\" set to \"" + std::string(STORAGE_TYPE_FILE_SYSTEM) + "\" or \"" + std::string(STORAGE_TYPE_OBJECT_STORAGE) + "\""); | |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
400 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
401 |
84 | 402 const std::string& targetStorage = requestPayload[KEY_TARGET_STORAGE].asString(); |
403 const Json::Value& resources = requestPayload[KEY_RESOURCES]; | |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
404 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
405 // Extract information about all the child instances |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
406 for (Json::Value::ArrayIndex i = 0; i < resources.size(); i++) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
407 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
408 if (resources[i].type() != Json::stringValue) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
409 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
410 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
411 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
412 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
413 std::string resource = resources[i].asString(); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
414 if (resource.empty()) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
415 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
416 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
417 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
418 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
419 // Test whether this resource is an instance |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
420 Json::Value tmpResource; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
421 Json::Value tmpInstances; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
422 if (OrthancPlugins::RestApiGet(tmpResource, "/instances/" + resource, false)) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
423 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
424 instances.push_back(resource); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
425 AddResourceForJobContent(resourcesForJobContent, Orthanc::ResourceType_Instance, resource); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
426 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
427 // This was not an instance, successively try with series/studies/patients |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
428 else if ((OrthancPlugins::RestApiGet(tmpResource, "/series/" + resource, false) && |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
429 OrthancPlugins::RestApiGet(tmpInstances, "/series/" + resource + "/instances", false)) || |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
430 (OrthancPlugins::RestApiGet(tmpResource, "/studies/" + resource, false) && |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
431 OrthancPlugins::RestApiGet(tmpInstances, "/studies/" + resource + "/instances", false)) || |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
432 (OrthancPlugins::RestApiGet(tmpResource, "/patients/" + resource, false) && |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
433 OrthancPlugins::RestApiGet(tmpInstances, "/patients/" + resource + "/instances", false))) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
434 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
435 if (tmpInstances.type() != Json::arrayValue) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
436 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
437 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
438 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
439 |
84 | 440 AddResourceForJobContent(resourcesForJobContent, Orthanc::StringToResourceType(tmpResource["Type"].asString().c_str()), resource); |
441 | |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
442 for (Json::Value::ArrayIndex j = 0; j < tmpInstances.size(); j++) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
443 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
444 instances.push_back(tmpInstances[j]["ID"].asString()); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
445 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
446 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
447 else |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
448 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
449 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
450 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
451 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
452 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
453 OrthancPlugins::LogInfo("Moving " + boost::lexical_cast<std::string>(instances.size()) + " instances to " + targetStorage); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
454 |
84 | 455 std::unique_ptr<MoveStorageJob> job(CreateMoveStorageJob(targetStorage, instances, resourcesForJobContent)); |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
456 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
457 OrthancPlugins::OrthancJob::SubmitFromRestApiPost(output, requestPayload, job.release()); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
458 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
459 |
84 | 460 OrthancPluginJob* JobUnserializer(const char* jobType, |
461 const char* serialized) | |
462 { | |
463 if (jobType == NULL || | |
464 serialized == NULL) | |
465 { | |
466 return NULL; | |
467 } | |
468 | |
469 std::string type(jobType); | |
470 | |
471 if (type != JOB_TYPE_MOVE_STORAGE) | |
472 { | |
473 return NULL; | |
474 } | |
475 | |
476 try | |
477 { | |
478 std::string tmp(serialized); | |
479 | |
480 Json::Value source; | |
481 if (Orthanc::Toolbox::ReadJson(source, tmp)) | |
482 { | |
483 std::unique_ptr<OrthancPlugins::OrthancJob> job; | |
484 | |
485 if (type == JOB_TYPE_MOVE_STORAGE) | |
486 { | |
487 std::vector<std::string> instances; | |
488 | |
489 for (size_t i = 0; i < source[KEY_INSTANCES].size(); ++i) | |
490 { | |
491 instances.push_back(source[KEY_INSTANCES][static_cast<int>(i)].asString()); | |
492 } | |
493 | |
494 job.reset(CreateMoveStorageJob(source[KEY_TARGET_STORAGE].asString(), instances, source[KEY_CONTENT])); | |
495 } | |
496 | |
497 if (job.get() == NULL) | |
498 { | |
499 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
500 } | |
501 else | |
502 { | |
503 return OrthancPlugins::OrthancJob::Create(job.release()); | |
504 } | |
505 } | |
506 else | |
507 { | |
508 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
509 } | |
510 } | |
511 catch (Orthanc::OrthancException& e) | |
512 { | |
513 LOG(ERROR) << "Error while unserializing a job from the " << StoragePluginFactory::GetStoragePluginName() << " plugin: " | |
514 << e.What(); | |
515 return NULL; | |
516 } | |
517 catch (...) | |
518 { | |
519 LOG(ERROR) << "Error while unserializing a job from the " << StoragePluginFactory::GetStoragePluginName() << " plugin"; | |
520 return NULL; | |
521 } | |
522 } | |
523 | |
524 | |
1 | 525 extern "C" |
526 { | |
527 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) | |
528 { | |
529 OrthancPlugins::SetGlobalContext(context); | |
530 | |
57
ba1be668e475
fix initialization of the aws static library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
531 Orthanc::InitializeFramework("", false); |
15 | 532 Orthanc::Logging::InitializePluginContext(context); |
533 | |
1 | 534 OrthancPlugins::OrthancConfiguration orthancConfig; |
535 | |
536 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + " plugin is initializing"); | |
94
1bc055199cd2
Added a description for all plugins
Alain Mazy <am@osimis.io>
parents:
87
diff
changeset
|
537 OrthancPluginSetDescription(context, StoragePluginFactory::GetStorageDescription()); |
1 | 538 |
539 /* Check the version of the Orthanc core */ | |
540 if (OrthancPluginCheckVersion(context) == 0) | |
541 { | |
542 char info[1024]; | |
543 sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin", | |
544 context->orthancVersion, | |
545 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, | |
546 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, | |
547 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); | |
548 OrthancPlugins::LogError(info); | |
549 return -1; | |
550 } | |
551 | |
27
e1f52b851827
Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
20
diff
changeset
|
552 try |
8 | 553 { |
77 | 554 const char* pluginSectionName = StoragePluginFactory::GetConfigurationSectionName(); |
27
e1f52b851827
Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
20
diff
changeset
|
555 static const char* const ENCRYPTION_SECTION = "StorageEncryption"; |
20 | 556 |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
557 if (!orthancConfig.IsSection(pluginSectionName)) |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
558 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
559 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": no \"" + pluginSectionName + "\" section found in configuration, plugin is disabled"); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
560 return 0; |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
561 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
562 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
563 OrthancPlugins::OrthancConfiguration pluginSection; |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
564 orthancConfig.GetSection(pluginSection, pluginSectionName); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
565 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
566 bool migrationFromFileSystemEnabled = pluginSection.GetBooleanValue("MigrationFromFileSystemEnabled", false); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
567 std::string hybridModeString = pluginSection.GetStringValue("HybridMode", "Disabled"); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
568 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
569 if (migrationFromFileSystemEnabled && hybridModeString == "Disabled") |
15 | 570 { |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
571 hybridMode = HybridMode_WriteToObjectStorage; |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
572 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": 'MigrationFromFileSystemEnabled' configuration is deprecated, use 'HybridMode': 'WriteToObjectStorage' instead"); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
573 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
574 else if (hybridModeString == "WriteToObjectStorage") |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
575 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
576 hybridMode = HybridMode_WriteToObjectStorage; |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
577 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": WriteToObjectStorage HybridMode is enabled: writing to object-storage, try reading first from object-storage and, then, from file system"); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
578 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
579 else if (hybridModeString == "WriteToFileSystem") |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
580 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
581 hybridMode = HybridMode_WriteToFileSystem; |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
582 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": WriteToFileSystem HybridMode is enabled: writing to file system, try reading first from file system and, then, from object-storage"); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
583 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
584 else |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
585 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
586 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": HybridMode is disabled: writing to object-storage and reading only from object-storage"); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
587 } |
27
e1f52b851827
Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
20
diff
changeset
|
588 |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
589 if (IsReadFromDisk()) |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
590 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
591 fileSystemRootPath = orthancConfig.GetStringValue("StorageDirectory", "OrthancStorageNotDefined"); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
592 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": HybridMode: reading from file system is enabled, source: " + fileSystemRootPath); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
593 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
594 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
595 objectsRootPath = pluginSection.GetStringValue("RootPath", std::string()); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
596 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
597 if (objectsRootPath.size() >= 1 && objectsRootPath[0] == '/') |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
598 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
599 OrthancPlugins::LogError(std::string(StoragePluginFactory::GetStoragePluginName()) + ": The RootPath shall not start with a '/': " + objectsRootPath); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
600 return -1; |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
601 } |
77 | 602 |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
603 std::string objecstStoragePluginName = StoragePluginFactory::GetStoragePluginName(); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
604 if (hybridMode == HybridMode_WriteToFileSystem) |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
605 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
606 objecstStoragePluginName += " (Secondary: object-storage)"; |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
607 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
608 else if (hybridMode == HybridMode_WriteToObjectStorage) |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
609 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
610 objecstStoragePluginName += " (Primary: object-storage)"; |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
611 } |
27
e1f52b851827
Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
20
diff
changeset
|
612 |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
613 std::unique_ptr<IStorage> objectStoragePlugin(StoragePluginFactory::CreateStorage(objecstStoragePluginName, orthancConfig)); |
33 | 614 |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
615 if (objectStoragePlugin.get() == nullptr) |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
616 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
617 return -1; |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
618 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
619 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
620 objectStoragePlugin->SetRootPath(objectsRootPath); |
15 | 621 |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
622 std::unique_ptr<IStorage> fileSystemStoragePlugin; |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
623 if (IsHybridModeEnabled()) |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
624 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
625 bool fsync = orthancConfig.GetBooleanValue("SyncStorageArea", true); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
626 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
627 std::string filesystemStoragePluginName = StoragePluginFactory::GetStoragePluginName(); |
77 | 628 if (hybridMode == HybridMode_WriteToFileSystem) |
629 { | |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
630 filesystemStoragePluginName += " (Primary: file-system)"; |
77 | 631 } |
632 else if (hybridMode == HybridMode_WriteToObjectStorage) | |
633 { | |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
634 filesystemStoragePluginName += " (Secondary: file-system)"; |
77 | 635 } |
636 | |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
637 fileSystemStoragePlugin.reset(new FileSystemStoragePlugin(filesystemStoragePluginName, fileSystemRootPath, fsync)); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
638 } |
27
e1f52b851827
Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
20
diff
changeset
|
639 |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
640 if (hybridMode == HybridMode_Disabled || hybridMode == HybridMode_WriteToObjectStorage) |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
641 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
642 primaryStorage.reset(objectStoragePlugin.release()); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
643 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
644 if (hybridMode == HybridMode_WriteToObjectStorage) |
27
e1f52b851827
Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
20
diff
changeset
|
645 { |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
646 secondaryStorage.reset(fileSystemStoragePlugin.release()); |
27
e1f52b851827
Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
20
diff
changeset
|
647 } |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
648 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
649 else if (hybridMode == HybridMode_WriteToFileSystem) |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
650 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
651 primaryStorage.reset(fileSystemStoragePlugin.release()); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
652 secondaryStorage.reset(objectStoragePlugin.release()); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
653 } |
77 | 654 |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
655 if (pluginSection.IsSection(ENCRYPTION_SECTION)) |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
656 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
657 OrthancPlugins::OrthancConfiguration cryptoSection; |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
658 pluginSection.GetSection(cryptoSection, ENCRYPTION_SECTION); |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
659 |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
660 crypto.reset(EncryptionConfigurator::CreateEncryptionHelpers(cryptoSection)); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
661 cryptoEnabled = crypto.get() != nullptr; |
15 | 662 } |
663 | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
664 if (cryptoEnabled) |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
665 { |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
666 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": client-side encryption is enabled"); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
667 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
668 else |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
669 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
670 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": client-side encryption is disabled"); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
671 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
672 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
673 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
674 if (IsHybridModeEnabled()) |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
675 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
676 OrthancPlugins::RegisterRestCallback<MoveStorage>("/move-storage", true); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
677 OrthancPluginRegisterJobsUnserializer(context, JobUnserializer); |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
678 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
679 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
680 if (cryptoEnabled) |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
681 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
682 // with encrypted file, we can not support ReadRange. Therefore, we register the old interface |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
683 OrthancPluginRegisterStorageArea(context, StorageCreate, StorageReadWholeLegacy, StorageRemove); |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
684 } |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
685 else |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
686 { |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
687 OrthancPluginRegisterStorageArea2(context, StorageCreate, StorageReadWhole, StorageReadRange, StorageRemove); |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
688 } |
1 | 689 } |
27
e1f52b851827
Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
20
diff
changeset
|
690 catch (Orthanc::OrthancException& e) |
e1f52b851827
Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
20
diff
changeset
|
691 { |
e1f52b851827
Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
20
diff
changeset
|
692 LOG(ERROR) << "Exception while creating the object storage plugin: " << e.What(); |
e1f52b851827
Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
20
diff
changeset
|
693 return -1; |
e1f52b851827
Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
20
diff
changeset
|
694 } |
1 | 695 |
696 return 0; | |
697 } | |
698 | |
699 | |
700 ORTHANC_PLUGINS_API void OrthancPluginFinalize() | |
701 { | |
702 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + " plugin is finalizing"); | |
78 | 703 primaryStorage.reset(); |
704 secondaryStorage.reset(); | |
57
ba1be668e475
fix initialization of the aws static library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
705 Orthanc::FinalizeFramework(); |
1 | 706 } |
707 | |
708 | |
709 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() | |
710 { | |
711 return StoragePluginFactory::GetStoragePluginName(); | |
712 } | |
713 | |
714 | |
715 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() | |
716 { | |
717 return PLUGIN_VERSION; | |
718 } | |
719 } | |
720 |