Mercurial > hg > orthanc-object-storage
annotate Common/StoragePlugin.cpp @ 98:91aeaecf7100
fix message
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 27 Jun 2023 17:46:11 +0200 |
parents | 33790e0000bb |
children | e39aa88ec20e |
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 { | |
78 | 91 OrthancPlugins::LogInfo(primaryStorage->GetNameForLogs() + ": creating attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); |
92 std::unique_ptr<IStorage::IWriter> writer(primaryStorage->GetWriterForObject(uuid, type, cryptoEnabled)); | |
1 | 93 |
94 if (cryptoEnabled) | |
95 { | |
96 std::string encryptedFile; | |
97 | |
98 try | |
99 { | |
100 crypto->Encrypt(encryptedFile, (const char*)content, size); | |
101 } | |
102 catch (EncryptionException& ex) | |
103 { | |
78 | 104 OrthancPlugins::LogError(primaryStorage->GetNameForLogs() + ": error while encrypting object " + std::string(uuid) + ": " + ex.what()); |
1 | 105 return OrthancPluginErrorCode_StorageAreaPlugin; |
106 } | |
107 | |
108 writer->Write(encryptedFile.data(), encryptedFile.size()); | |
109 } | |
110 else | |
111 { | |
112 writer->Write(reinterpret_cast<const char*>(content), size); | |
113 } | |
114 } | |
115 catch (StoragePluginException& ex) | |
116 { | |
78 | 117 OrthancPlugins::LogError(primaryStorage->GetNameForLogs() + ": error while creating object " + std::string(uuid) + ": " + ex.what()); |
1 | 118 return OrthancPluginErrorCode_StorageAreaPlugin; |
119 } | |
120 | |
121 return OrthancPluginErrorCode_Success; | |
122 } | |
123 | |
124 | |
78 | 125 static OrthancPluginErrorCode StorageReadRange(IStorage* storage, |
77 | 126 LogErrorFunction logErrorFunction, |
127 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
|
128 const char* uuid, |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
129 OrthancPluginContentType type, |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
130 uint64_t rangeStart) |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
131 { |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
132 assert(!cryptoEnabled); |
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 try |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
135 { |
78 | 136 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": reading range of attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); |
77 | 137 |
78 | 138 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
|
139 reader->ReadRange(reinterpret_cast<char*>(target->data), target->size, rangeStart); |
77 | 140 |
141 return OrthancPluginErrorCode_Success; | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
142 } |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
143 catch (StoragePluginException& ex) |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
144 { |
77 | 145 logErrorFunction(std::string(StoragePluginFactory::GetStoragePluginName()) + ": error while reading object " + std::string(uuid) + ": " + std::string(ex.what())); |
146 return OrthancPluginErrorCode_StorageAreaPlugin; | |
147 } | |
148 } | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
149 |
77 | 150 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. |
151 const char* uuid, | |
152 OrthancPluginContentType type, | |
153 uint64_t rangeStart) | |
154 { | |
78 | 155 OrthancPluginErrorCode res = StorageReadRange(primaryStorage.get(), |
77 | 156 (IsHybridModeEnabled() ? OrthancPlugins::LogWarning : OrthancPlugins::LogError), // log errors as warning on first try |
157 target, | |
158 uuid, | |
159 type, | |
160 rangeStart); | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
161 |
77 | 162 if (res != OrthancPluginErrorCode_Success && IsHybridModeEnabled()) |
163 { | |
78 | 164 res = StorageReadRange(secondaryStorage.get(), |
77 | 165 OrthancPlugins::LogError, // log errors as errors on second try |
166 target, | |
167 uuid, | |
168 type, | |
169 rangeStart); | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
170 } |
77 | 171 return res; |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
172 } |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
173 |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
174 |
77 | 175 |
78 | 176 static OrthancPluginErrorCode StorageReadWhole(IStorage* storage, |
77 | 177 LogErrorFunction logErrorFunction, |
178 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
|
179 const char* uuid, |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
180 OrthancPluginContentType type) |
1 | 181 { |
182 try | |
183 { | |
78 | 184 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": reading whole attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); |
185 std::unique_ptr<IStorage::IReader> reader(storage->GetReaderForObject(uuid, type, cryptoEnabled)); | |
1 | 186 |
187 size_t fileSize = reader->GetSize(); | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
188 size_t size; |
1 | 189 |
190 if (cryptoEnabled) | |
191 { | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
192 size = fileSize - crypto->OVERHEAD_SIZE; |
1 | 193 } |
194 else | |
195 { | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
196 size = fileSize; |
1 | 197 } |
198 | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
199 if (size <= 0) |
1 | 200 { |
78 | 201 logErrorFunction(storage->GetNameForLogs() + ": error while reading object " + std::string(uuid) + ", size of file is too small: " + boost::lexical_cast<std::string>(fileSize) + " bytes"); |
1 | 202 return OrthancPluginErrorCode_StorageAreaPlugin; |
203 } | |
204 | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
205 if (OrthancPluginCreateMemoryBuffer64(OrthancPlugins::GetGlobalContext(), target, size) != OrthancPluginErrorCode_Success) |
1 | 206 { |
78 | 207 logErrorFunction(storage->GetNameForLogs() + ": error while reading object " + std::string(uuid) + ", cannot allocate memory of size " + boost::lexical_cast<std::string>(size) + " bytes"); |
1 | 208 return OrthancPluginErrorCode_StorageAreaPlugin; |
209 } | |
210 | |
211 if (cryptoEnabled) | |
212 { | |
213 std::vector<char> encrypted(fileSize); | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
214 reader->ReadWhole(encrypted.data(), fileSize); |
1 | 215 |
216 try | |
217 { | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
218 crypto->Decrypt(reinterpret_cast<char*>(target->data), encrypted.data(), fileSize); |
1 | 219 } |
220 catch (EncryptionException& ex) | |
221 { | |
78 | 222 logErrorFunction(storage->GetNameForLogs() + ": error while decrypting object " + std::string(uuid) + ": " + ex.what()); |
1 | 223 return OrthancPluginErrorCode_StorageAreaPlugin; |
224 } | |
225 } | |
226 else | |
227 { | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
228 reader->ReadWhole(reinterpret_cast<char*>(target->data), fileSize); |
1 | 229 } |
230 } | |
231 catch (StoragePluginException& ex) | |
232 { | |
98 | 233 logErrorFunction(storage->GetNameForLogs() + ": error while reading object " + std::string(uuid) + ": " + ex.what()); |
77 | 234 return OrthancPluginErrorCode_StorageAreaPlugin; |
1 | 235 } |
236 | |
237 return OrthancPluginErrorCode_Success; | |
238 } | |
239 | |
77 | 240 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. |
241 const char* uuid, | |
242 OrthancPluginContentType type) | |
243 { | |
78 | 244 OrthancPluginErrorCode res = StorageReadWhole(primaryStorage.get(), |
77 | 245 (IsHybridModeEnabled() ? OrthancPlugins::LogWarning : OrthancPlugins::LogError), // log errors as warning on first try |
246 target, | |
247 uuid, | |
248 type); | |
249 | |
250 if (res != OrthancPluginErrorCode_Success && IsHybridModeEnabled()) | |
251 { | |
78 | 252 res = StorageReadWhole(secondaryStorage.get(), |
77 | 253 OrthancPlugins::LogError, // log errors as errors on second try |
254 target, | |
255 uuid, | |
256 type); | |
257 } | |
258 return res; | |
259 } | |
260 | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
261 static OrthancPluginErrorCode StorageReadWholeLegacy(void** content, |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
262 int64_t* size, |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
263 const char* uuid, |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
264 OrthancPluginContentType type) |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
265 { |
43
4c71c5e2edce
fix memory handling in legacy read
Alain Mazy <am@osimis.io>
parents:
39
diff
changeset
|
266 OrthancPluginMemoryBuffer64 buffer; |
4c71c5e2edce
fix memory handling in legacy read
Alain Mazy <am@osimis.io>
parents:
39
diff
changeset
|
267 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
|
268 |
43
4c71c5e2edce
fix memory handling in legacy read
Alain Mazy <am@osimis.io>
parents:
39
diff
changeset
|
269 if (result == OrthancPluginErrorCode_Success) |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
270 { |
43
4c71c5e2edce
fix memory handling in legacy read
Alain Mazy <am@osimis.io>
parents:
39
diff
changeset
|
271 *size = buffer.size; |
4c71c5e2edce
fix memory handling in legacy read
Alain Mazy <am@osimis.io>
parents:
39
diff
changeset
|
272 *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
|
273 } |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
274 |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
275 return result; |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
276 } |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
277 |
1 | 278 |
78 | 279 static OrthancPluginErrorCode StorageRemove(IStorage* storage, |
77 | 280 LogErrorFunction logErrorFunction, |
281 const char* uuid, | |
1 | 282 OrthancPluginContentType type) |
283 { | |
284 try | |
285 { | |
78 | 286 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": deleting attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); |
287 storage->DeleteObject(uuid, type, cryptoEnabled); | |
288 if ((storage == primaryStorage.get()) && IsHybridModeEnabled()) | |
77 | 289 { |
290 // not 100% sure the file has been deleted, try the secondary plugin | |
291 return OrthancPluginErrorCode_StorageAreaPlugin; | |
292 } | |
293 | |
294 return OrthancPluginErrorCode_Success; | |
1 | 295 } |
296 catch (StoragePluginException& ex) | |
297 { | |
77 | 298 logErrorFunction(std::string(StoragePluginFactory::GetStoragePluginName()) + ": error while deleting object " + std::string(uuid) + ": " + std::string(ex.what())); |
299 return OrthancPluginErrorCode_StorageAreaPlugin; | |
300 } | |
301 } | |
15 | 302 |
77 | 303 static OrthancPluginErrorCode StorageRemove(const char* uuid, |
304 OrthancPluginContentType type) | |
305 { | |
78 | 306 OrthancPluginErrorCode res = StorageRemove(primaryStorage.get(), |
77 | 307 (IsHybridModeEnabled() ? OrthancPlugins::LogWarning : OrthancPlugins::LogError), // log errors as warning on first try |
308 uuid, | |
309 type); | |
15 | 310 |
77 | 311 if (res != OrthancPluginErrorCode_Success && IsHybridModeEnabled()) |
312 { | |
78 | 313 res = StorageRemove(secondaryStorage.get(), |
77 | 314 OrthancPlugins::LogError, // log errors as errors on second try |
315 uuid, | |
316 type); | |
1 | 317 } |
77 | 318 return res; |
1 | 319 } |
320 | |
321 | |
84 | 322 static MoveStorageJob* CreateMoveStorageJob(const std::string& targetStorage, const std::vector<std::string>& instances, const Json::Value& resourcesForJobContent) |
323 { | |
324 std::unique_ptr<MoveStorageJob> job(new MoveStorageJob(targetStorage, instances, resourcesForJobContent, cryptoEnabled)); | |
325 | |
326 if (hybridMode == HybridMode_WriteToFileSystem) | |
327 { | |
328 job->SetStorages(primaryStorage.get(), secondaryStorage.get()); | |
329 } | |
330 else | |
331 { | |
332 job->SetStorages(secondaryStorage.get(), primaryStorage.get()); | |
333 } | |
334 | |
335 return job.release(); | |
336 } | |
337 | |
338 | |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
339 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
|
340 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
341 const char* resourceGroup = Orthanc::GetResourceTypeText(resourceType, true, true); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
342 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
343 if (!resourcesForJobContent.isMember(resourceGroup)) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
344 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
345 resourcesForJobContent[resourceGroup] = Json::arrayValue; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
346 } |
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 resourcesForJobContent[resourceGroup].append(resourceId); |
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 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
351 void MoveStorage(OrthancPluginRestOutput* output, |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
352 const char* /*url*/, |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
353 const OrthancPluginHttpRequest* request) |
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 OrthancPluginContext* context = OrthancPlugins::GetGlobalContext(); |
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 if (request->method != OrthancPluginHttpMethod_Post) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
358 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
359 OrthancPluginSendMethodNotAllowed(context, output, "POST"); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
360 return; |
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 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
363 Json::Value requestPayload; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
364 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
365 if (!OrthancPlugins::ReadJson(requestPayload, request->body, request->bodySize)) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
366 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
367 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
|
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 std::vector<std::string> instances; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
371 Json::Value resourcesForJobContent; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
372 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
373 if (requestPayload.type() != Json::objectValue || |
84 | 374 !requestPayload.isMember(KEY_RESOURCES) || |
375 requestPayload[KEY_RESOURCES].type() != Json::arrayValue) | |
83
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 throw Orthanc::OrthancException( |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
378 Orthanc::ErrorCode_BadFileFormat, |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
379 "A request to the move-storage endpoint must provide a JSON object " |
84 | 380 "with the field \"" + std::string(KEY_RESOURCES) + |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
381 "\" containing an array of resources to be sent"); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
382 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
383 |
84 | 384 if (!requestPayload.isMember(KEY_TARGET_STORAGE) |
385 || requestPayload[KEY_TARGET_STORAGE].type() != Json::stringValue | |
386 || (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
|
387 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
388 throw Orthanc::OrthancException( |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
389 Orthanc::ErrorCode_BadFileFormat, |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
390 "A request to the move-storage endpoint must provide a JSON object " |
84 | 391 "with the field \"" + std::string(KEY_TARGET_STORAGE) + |
392 "\" 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
|
393 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
394 |
84 | 395 const std::string& targetStorage = requestPayload[KEY_TARGET_STORAGE].asString(); |
396 const Json::Value& resources = requestPayload[KEY_RESOURCES]; | |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
397 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
398 // Extract information about all the child instances |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
399 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
|
400 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
401 if (resources[i].type() != Json::stringValue) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
402 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
403 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
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 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
406 std::string resource = resources[i].asString(); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
407 if (resource.empty()) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
408 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
409 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
410 } |
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 // Test whether this resource is an instance |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
413 Json::Value tmpResource; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
414 Json::Value tmpInstances; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
415 if (OrthancPlugins::RestApiGet(tmpResource, "/instances/" + resource, false)) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
416 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
417 instances.push_back(resource); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
418 AddResourceForJobContent(resourcesForJobContent, Orthanc::ResourceType_Instance, resource); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
419 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
420 // 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
|
421 else if ((OrthancPlugins::RestApiGet(tmpResource, "/series/" + resource, false) && |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
422 OrthancPlugins::RestApiGet(tmpInstances, "/series/" + resource + "/instances", false)) || |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
423 (OrthancPlugins::RestApiGet(tmpResource, "/studies/" + resource, false) && |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
424 OrthancPlugins::RestApiGet(tmpInstances, "/studies/" + resource + "/instances", false)) || |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
425 (OrthancPlugins::RestApiGet(tmpResource, "/patients/" + resource, false) && |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
426 OrthancPlugins::RestApiGet(tmpInstances, "/patients/" + resource + "/instances", false))) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
427 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
428 if (tmpInstances.type() != Json::arrayValue) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
429 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
430 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
431 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
432 |
84 | 433 AddResourceForJobContent(resourcesForJobContent, Orthanc::StringToResourceType(tmpResource["Type"].asString().c_str()), resource); |
434 | |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
435 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
|
436 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
437 instances.push_back(tmpInstances[j]["ID"].asString()); |
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 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
440 else |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
441 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
442 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); |
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 } |
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 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
|
447 |
84 | 448 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
|
449 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
450 OrthancPlugins::OrthancJob::SubmitFromRestApiPost(output, requestPayload, job.release()); |
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 |
84 | 453 OrthancPluginJob* JobUnserializer(const char* jobType, |
454 const char* serialized) | |
455 { | |
456 if (jobType == NULL || | |
457 serialized == NULL) | |
458 { | |
459 return NULL; | |
460 } | |
461 | |
462 std::string type(jobType); | |
463 | |
464 if (type != JOB_TYPE_MOVE_STORAGE) | |
465 { | |
466 return NULL; | |
467 } | |
468 | |
469 try | |
470 { | |
471 std::string tmp(serialized); | |
472 | |
473 Json::Value source; | |
474 if (Orthanc::Toolbox::ReadJson(source, tmp)) | |
475 { | |
476 std::unique_ptr<OrthancPlugins::OrthancJob> job; | |
477 | |
478 if (type == JOB_TYPE_MOVE_STORAGE) | |
479 { | |
480 std::vector<std::string> instances; | |
481 | |
482 for (size_t i = 0; i < source[KEY_INSTANCES].size(); ++i) | |
483 { | |
484 instances.push_back(source[KEY_INSTANCES][static_cast<int>(i)].asString()); | |
485 } | |
486 | |
487 job.reset(CreateMoveStorageJob(source[KEY_TARGET_STORAGE].asString(), instances, source[KEY_CONTENT])); | |
488 } | |
489 | |
490 if (job.get() == NULL) | |
491 { | |
492 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
493 } | |
494 else | |
495 { | |
496 return OrthancPlugins::OrthancJob::Create(job.release()); | |
497 } | |
498 } | |
499 else | |
500 { | |
501 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
502 } | |
503 } | |
504 catch (Orthanc::OrthancException& e) | |
505 { | |
506 LOG(ERROR) << "Error while unserializing a job from the " << StoragePluginFactory::GetStoragePluginName() << " plugin: " | |
507 << e.What(); | |
508 return NULL; | |
509 } | |
510 catch (...) | |
511 { | |
512 LOG(ERROR) << "Error while unserializing a job from the " << StoragePluginFactory::GetStoragePluginName() << " plugin"; | |
513 return NULL; | |
514 } | |
515 } | |
516 | |
517 | |
1 | 518 extern "C" |
519 { | |
520 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) | |
521 { | |
522 OrthancPlugins::SetGlobalContext(context); | |
523 | |
57
ba1be668e475
fix initialization of the aws static library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
524 Orthanc::InitializeFramework("", false); |
15 | 525 Orthanc::Logging::InitializePluginContext(context); |
526 | |
1 | 527 OrthancPlugins::OrthancConfiguration orthancConfig; |
528 | |
529 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
|
530 OrthancPluginSetDescription(context, StoragePluginFactory::GetStorageDescription()); |
1 | 531 |
532 /* Check the version of the Orthanc core */ | |
533 if (OrthancPluginCheckVersion(context) == 0) | |
534 { | |
535 char info[1024]; | |
536 sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin", | |
537 context->orthancVersion, | |
538 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, | |
539 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, | |
540 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); | |
541 OrthancPlugins::LogError(info); | |
542 return -1; | |
543 } | |
544 | |
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
|
545 try |
8 | 546 { |
77 | 547 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
|
548 static const char* const ENCRYPTION_SECTION = "StorageEncryption"; |
20 | 549 |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
550 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
|
551 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
552 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
|
553 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
|
554 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
555 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
556 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
|
557 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
|
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 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
|
560 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
|
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 if (migrationFromFileSystemEnabled && hybridModeString == "Disabled") |
15 | 563 { |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
564 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
|
565 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
|
566 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
567 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
|
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 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
|
570 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
|
571 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
572 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
|
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 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
|
575 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
|
576 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
577 else |
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 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
|
580 } |
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
|
581 |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
582 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
|
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 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
|
585 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
|
586 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
587 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
588 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
|
589 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
590 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
|
591 { |
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::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
|
593 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
|
594 } |
77 | 595 |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
596 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
|
597 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
|
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 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
|
600 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
601 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
|
602 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
603 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
|
604 } |
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
|
605 |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
606 std::unique_ptr<IStorage> objectStoragePlugin(StoragePluginFactory::CreateStorage(objecstStoragePluginName, orthancConfig)); |
33 | 607 |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
608 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
|
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 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
|
611 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
612 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
613 objectStoragePlugin->SetRootPath(objectsRootPath); |
15 | 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 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
|
616 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
|
617 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
618 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
|
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 std::string filesystemStoragePluginName = StoragePluginFactory::GetStoragePluginName(); |
77 | 621 if (hybridMode == HybridMode_WriteToFileSystem) |
622 { | |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
623 filesystemStoragePluginName += " (Primary: file-system)"; |
77 | 624 } |
625 else if (hybridMode == HybridMode_WriteToObjectStorage) | |
626 { | |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
627 filesystemStoragePluginName += " (Secondary: file-system)"; |
77 | 628 } |
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 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
|
631 } |
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
|
632 |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
633 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
|
634 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
635 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
|
636 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
637 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
|
638 { |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
639 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
|
640 } |
95
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 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
|
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 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
|
645 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
|
646 } |
77 | 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 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
|
649 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
650 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
|
651 pluginSection.GetSection(cryptoSection, ENCRYPTION_SECTION); |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
78
diff
changeset
|
652 |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
653 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
|
654 cryptoEnabled = crypto.get() != nullptr; |
15 | 655 } |
656 | |
39
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
657 if (cryptoEnabled) |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
658 { |
95
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
659 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
|
660 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
661 else |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
662 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
663 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
|
664 } |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
665 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
666 |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
667 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
|
668 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
669 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
|
670 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
|
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 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
|
674 { |
33790e0000bb
Plugins are now disabled if their section is missing in the configuration file.
Alain Mazy <am@osimis.io>
parents:
94
diff
changeset
|
675 // 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
|
676 OrthancPluginRegisterStorageArea(context, StorageCreate, StorageReadWholeLegacy, StorageRemove); |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
677 } |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
678 else |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
679 { |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
680 OrthancPluginRegisterStorageArea2(context, StorageCreate, StorageReadWhole, StorageReadRange, StorageRemove); |
50d0be413c42
implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents:
37
diff
changeset
|
681 } |
1 | 682 } |
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
|
683 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
|
684 { |
e1f52b851827
Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
20
diff
changeset
|
685 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
|
686 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
|
687 } |
1 | 688 |
689 return 0; | |
690 } | |
691 | |
692 | |
693 ORTHANC_PLUGINS_API void OrthancPluginFinalize() | |
694 { | |
695 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + " plugin is finalizing"); | |
78 | 696 primaryStorage.reset(); |
697 secondaryStorage.reset(); | |
57
ba1be668e475
fix initialization of the aws static library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
698 Orthanc::FinalizeFramework(); |
1 | 699 } |
700 | |
701 | |
702 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() | |
703 { | |
704 return StoragePluginFactory::GetStoragePluginName(); | |
705 } | |
706 | |
707 | |
708 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() | |
709 { | |
710 return PLUGIN_VERSION; | |
711 } | |
712 } | |
713 |