annotate Common/StoragePlugin.cpp @ 78:d7295e8678d7

renames
author Alain Mazy <am@osimis.io>
date Fri, 14 Oct 2022 11:00:18 +0200
parents 80792bb9600e
children 431ab61b5760
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
1 /**
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
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
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
4 *
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
6 * modify it under the terms of the GNU Affero General Public License
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
7 * as published by the Free Software Foundation, either version 3 of
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
8 * the License, or (at your option) any later version.
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
9 *
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful, but
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
13 * Affero General Public License for more details.
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
14 *
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
15 * You should have received a copy of the GNU Affero General Public License
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
17 **/
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
18
56
b922ae86bbe1 full static linking against AWS SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 43
diff changeset
19
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
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
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
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
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
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
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
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
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
31 #endif
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
32
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
33 #include <string.h>
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
34 #include <stdio.h>
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
35 #include <string>
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
36
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
37 #include <iostream>
15
2a02b21f0a19 migration + storage structure
Alain Mazy
parents: 8
diff changeset
38 #include <boost/filesystem.hpp>
2a02b21f0a19 migration + storage structure
Alain Mazy
parents: 8
diff changeset
39 #include <boost/filesystem/fstream.hpp>
2a02b21f0a19 migration + storage structure
Alain Mazy
parents: 8
diff changeset
40
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
41 #include "../Common/EncryptionHelpers.h"
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
42 #include "../Common/EncryptionConfigurator.h"
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
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
2a02b21f0a19 migration + storage structure
Alain Mazy
parents: 8
diff changeset
46 #include <SystemToolbox.h>
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
47
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
48 static std::unique_ptr<IStorage> primaryStorage;
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
49 static std::unique_ptr<IStorage> secondaryStorage;
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
50
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
51 static std::unique_ptr<EncryptionHelpers> crypto;
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
52 static bool cryptoEnabled = false;
15
2a02b21f0a19 migration + storage structure
Alain Mazy
parents: 8
diff changeset
53 static std::string fileSystemRootPath;
20
968eb1c78aed Added 'RootPath' configuration
Alain Mazy
parents: 15
diff changeset
54 static std::string objectsRootPath;
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
55 static std::string hybridModeNameForLogs = "";
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
56
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
57 typedef enum
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
58 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
59 HybridMode_WriteToFileSystem, // write to disk, try to read first from disk and then, from object-storage
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
60 HybridMode_WriteToObjectStorage, // write to object storage, try to read first from object storage and then, from disk
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
61 HybridMode_Disabled // read and write only from/to object-storage
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
62 } HybridMode;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
63
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
64 static HybridMode hybridMode = HybridMode_Disabled;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
65
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
66 static bool IsReadFromDisk()
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
67 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
68 return hybridMode != HybridMode_Disabled;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
69 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
70
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
71 static bool IsHybridModeEnabled()
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
72 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
73 return hybridMode != HybridMode_Disabled;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
74 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
75
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
76 typedef void LogErrorFunction(const std::string& message);
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
77
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
78
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
79
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
80 static OrthancPluginErrorCode StorageCreate(const char* uuid,
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
81 const void* content,
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
82 int64_t size,
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
83 OrthancPluginContentType type)
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
84 {
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
85 try
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
86 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
87 OrthancPlugins::LogInfo(primaryStorage->GetNameForLogs() + ": creating attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type));
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
88 std::unique_ptr<IStorage::IWriter> writer(primaryStorage->GetWriterForObject(uuid, type, cryptoEnabled));
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
89
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
90 if (cryptoEnabled)
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
91 {
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
92 std::string encryptedFile;
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
93
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
94 try
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
95 {
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
96 crypto->Encrypt(encryptedFile, (const char*)content, size);
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
97 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
98 catch (EncryptionException& ex)
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
99 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
100 OrthancPlugins::LogError(primaryStorage->GetNameForLogs() + ": error while encrypting object " + std::string(uuid) + ": " + ex.what());
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
101 return OrthancPluginErrorCode_StorageAreaPlugin;
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
102 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
103
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
104 writer->Write(encryptedFile.data(), encryptedFile.size());
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
105 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
106 else
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
107 {
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
108 writer->Write(reinterpret_cast<const char*>(content), size);
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
109 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
110 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
111 catch (StoragePluginException& ex)
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
112 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
113 OrthancPlugins::LogError(primaryStorage->GetNameForLogs() + ": error while creating object " + std::string(uuid) + ": " + ex.what());
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
114 return OrthancPluginErrorCode_StorageAreaPlugin;
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
115 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
116
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
117 return OrthancPluginErrorCode_Success;
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
118 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
119
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
120
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
121 static OrthancPluginErrorCode StorageReadRange(IStorage* storage,
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
122 LogErrorFunction logErrorFunction,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
123 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
124 const char* uuid,
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
125 OrthancPluginContentType type,
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
126 uint64_t rangeStart)
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
127 {
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
128 assert(!cryptoEnabled);
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
129
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
130 try
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
131 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
132 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": reading range of attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type));
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
133
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
134 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
135 reader->ReadRange(reinterpret_cast<char*>(target->data), target->size, rangeStart);
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
136
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
137 return OrthancPluginErrorCode_Success;
39
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
138 }
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
139 catch (StoragePluginException& ex)
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
140 {
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
141 logErrorFunction(std::string(StoragePluginFactory::GetStoragePluginName()) + ": error while reading object " + std::string(uuid) + ": " + std::string(ex.what()));
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
142 return OrthancPluginErrorCode_StorageAreaPlugin;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
143 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
144 }
39
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
145
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
146 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.
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
147 const char* uuid,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
148 OrthancPluginContentType type,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
149 uint64_t rangeStart)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
150 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
151 OrthancPluginErrorCode res = StorageReadRange(primaryStorage.get(),
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
152 (IsHybridModeEnabled() ? OrthancPlugins::LogWarning : OrthancPlugins::LogError), // log errors as warning on first try
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
153 target,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
154 uuid,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
155 type,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
156 rangeStart);
39
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
157
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
158 if (res != OrthancPluginErrorCode_Success && IsHybridModeEnabled())
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
159 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
160 res = StorageReadRange(secondaryStorage.get(),
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
161 OrthancPlugins::LogError, // log errors as errors on second try
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
162 target,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
163 uuid,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
164 type,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
165 rangeStart);
39
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
166 }
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
167 return res;
39
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
168 }
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
169
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
170
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
171
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
172 static OrthancPluginErrorCode StorageReadWhole(IStorage* storage,
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
173 LogErrorFunction logErrorFunction,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
174 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
175 const char* uuid,
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
176 OrthancPluginContentType type)
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
177 {
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
178 try
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
179 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
180 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": reading whole attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type));
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
181 std::unique_ptr<IStorage::IReader> reader(storage->GetReaderForObject(uuid, type, cryptoEnabled));
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
182
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
183 size_t fileSize = reader->GetSize();
39
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
184 size_t size;
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
185
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
186 if (cryptoEnabled)
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
187 {
39
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
188 size = fileSize - crypto->OVERHEAD_SIZE;
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
189 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
190 else
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
191 {
39
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
192 size = fileSize;
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
193 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
194
39
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
195 if (size <= 0)
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
196 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
197 logErrorFunction(storage->GetNameForLogs() + ": error while reading object " + std::string(uuid) + ", size of file is too small: " + boost::lexical_cast<std::string>(fileSize) + " bytes");
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
198 return OrthancPluginErrorCode_StorageAreaPlugin;
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
199 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
200
39
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
201 if (OrthancPluginCreateMemoryBuffer64(OrthancPlugins::GetGlobalContext(), target, size) != OrthancPluginErrorCode_Success)
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
202 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
203 logErrorFunction(storage->GetNameForLogs() + ": error while reading object " + std::string(uuid) + ", cannot allocate memory of size " + boost::lexical_cast<std::string>(size) + " bytes");
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
204 return OrthancPluginErrorCode_StorageAreaPlugin;
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
205 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
206
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
207 if (cryptoEnabled)
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
208 {
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
209 std::vector<char> encrypted(fileSize);
39
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
210 reader->ReadWhole(encrypted.data(), fileSize);
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
211
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
212 try
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
213 {
39
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
214 crypto->Decrypt(reinterpret_cast<char*>(target->data), encrypted.data(), fileSize);
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
215 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
216 catch (EncryptionException& ex)
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
217 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
218 logErrorFunction(storage->GetNameForLogs() + ": error while decrypting object " + std::string(uuid) + ": " + ex.what());
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
219 return OrthancPluginErrorCode_StorageAreaPlugin;
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
220 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
221 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
222 else
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
223 {
39
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
224 reader->ReadWhole(reinterpret_cast<char*>(target->data), fileSize);
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
225 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
226 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
227 catch (StoragePluginException& ex)
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
228 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
229 logErrorFunction(storage->GetNameForLogs() + ": error while decrypting object " + std::string(uuid) + ": " + ex.what());
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
230 return OrthancPluginErrorCode_StorageAreaPlugin;
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
231 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
232
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
233 return OrthancPluginErrorCode_Success;
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
234 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
235
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
236 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.
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
237 const char* uuid,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
238 OrthancPluginContentType type)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
239 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
240 OrthancPluginErrorCode res = StorageReadWhole(primaryStorage.get(),
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
241 (IsHybridModeEnabled() ? OrthancPlugins::LogWarning : OrthancPlugins::LogError), // log errors as warning on first try
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
242 target,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
243 uuid,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
244 type);
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
245
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
246 if (res != OrthancPluginErrorCode_Success && IsHybridModeEnabled())
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
247 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
248 res = StorageReadWhole(secondaryStorage.get(),
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
249 OrthancPlugins::LogError, // log errors as errors on second try
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
250 target,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
251 uuid,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
252 type);
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
253 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
254 return res;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
255 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
256
39
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
257 static OrthancPluginErrorCode StorageReadWholeLegacy(void** content,
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
258 int64_t* size,
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
259 const char* uuid,
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
260 OrthancPluginContentType type)
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
261 {
43
4c71c5e2edce fix memory handling in legacy read
Alain Mazy <am@osimis.io>
parents: 39
diff changeset
262 OrthancPluginMemoryBuffer64 buffer;
4c71c5e2edce fix memory handling in legacy read
Alain Mazy <am@osimis.io>
parents: 39
diff changeset
263 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
264
43
4c71c5e2edce fix memory handling in legacy read
Alain Mazy <am@osimis.io>
parents: 39
diff changeset
265 if (result == OrthancPluginErrorCode_Success)
39
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
266 {
43
4c71c5e2edce fix memory handling in legacy read
Alain Mazy <am@osimis.io>
parents: 39
diff changeset
267 *size = buffer.size;
4c71c5e2edce fix memory handling in legacy read
Alain Mazy <am@osimis.io>
parents: 39
diff changeset
268 *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
269 }
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
270
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
271 return result;
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
272 }
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
273
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
274
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
275 static OrthancPluginErrorCode StorageRemove(IStorage* storage,
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
276 LogErrorFunction logErrorFunction,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
277 const char* uuid,
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
278 OrthancPluginContentType type)
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
279 {
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
280 try
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
281 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
282 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": deleting attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type));
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
283 storage->DeleteObject(uuid, type, cryptoEnabled);
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
284 if ((storage == primaryStorage.get()) && IsHybridModeEnabled())
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
285 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
286 // not 100% sure the file has been deleted, try the secondary plugin
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
287 return OrthancPluginErrorCode_StorageAreaPlugin;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
288 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
289
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
290 return OrthancPluginErrorCode_Success;
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
291 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
292 catch (StoragePluginException& ex)
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
293 {
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
294 logErrorFunction(std::string(StoragePluginFactory::GetStoragePluginName()) + ": error while deleting object " + std::string(uuid) + ": " + std::string(ex.what()));
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
295 return OrthancPluginErrorCode_StorageAreaPlugin;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
296 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
297 }
15
2a02b21f0a19 migration + storage structure
Alain Mazy
parents: 8
diff changeset
298
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
299 static OrthancPluginErrorCode StorageRemove(const char* uuid,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
300 OrthancPluginContentType type)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
301 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
302 OrthancPluginErrorCode res = StorageRemove(primaryStorage.get(),
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
303 (IsHybridModeEnabled() ? OrthancPlugins::LogWarning : OrthancPlugins::LogError), // log errors as warning on first try
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
304 uuid,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
305 type);
15
2a02b21f0a19 migration + storage structure
Alain Mazy
parents: 8
diff changeset
306
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
307 if (res != OrthancPluginErrorCode_Success && IsHybridModeEnabled())
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
308 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
309 res = StorageRemove(secondaryStorage.get(),
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
310 OrthancPlugins::LogError, // log errors as errors on second try
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
311 uuid,
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
312 type);
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
313 }
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
314 return res;
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
315 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
316
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
317
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
318 extern "C"
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
319 {
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
320 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context)
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
321 {
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
322 OrthancPlugins::SetGlobalContext(context);
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
323
57
ba1be668e475 fix initialization of the aws static library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 56
diff changeset
324 Orthanc::InitializeFramework("", false);
15
2a02b21f0a19 migration + storage structure
Alain Mazy
parents: 8
diff changeset
325 Orthanc::Logging::InitializePluginContext(context);
2a02b21f0a19 migration + storage structure
Alain Mazy
parents: 8
diff changeset
326
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
327 OrthancPlugins::OrthancConfiguration orthancConfig;
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
328
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
329 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + " plugin is initializing");
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
330
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
331 /* Check the version of the Orthanc core */
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
332 if (OrthancPluginCheckVersion(context) == 0)
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
333 {
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
334 char info[1024];
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
335 sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin",
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
336 context->orthancVersion,
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
337 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
338 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
339 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
340 OrthancPlugins::LogError(info);
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
341 return -1;
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
342 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
343
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
344 try
8
987cb95c1aee Prevent Orthanc to start if plugin fails to start
Alain Mazy
parents: 1
diff changeset
345 {
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
346 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
347 static const char* const ENCRYPTION_SECTION = "StorageEncryption";
20
968eb1c78aed Added 'RootPath' configuration
Alain Mazy
parents: 15
diff changeset
348
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
349 if (orthancConfig.IsSection(pluginSectionName))
15
2a02b21f0a19 migration + storage structure
Alain Mazy
parents: 8
diff changeset
350 {
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
351 OrthancPlugins::OrthancConfiguration pluginSection;
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
352 orthancConfig.GetSection(pluginSection, pluginSectionName);
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
353
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
354 bool migrationFromFileSystemEnabled = pluginSection.GetBooleanValue("MigrationFromFileSystemEnabled", false);
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
355 std::string hybridModeString = pluginSection.GetStringValue("HybridMode", "Disabled");
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
356
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
357 if (migrationFromFileSystemEnabled && hybridModeString == "Disabled")
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
358 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
359 hybridMode = HybridMode_WriteToObjectStorage;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
360 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": 'MigrationFromFileSystemEnabled' configuration is deprecated, use 'HybridMode': 'WriteToObjectStorage' instead");
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
361 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
362 else if (hybridModeString == "WriteToObjectStorage")
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
363 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
364 hybridMode = HybridMode_WriteToObjectStorage;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
365 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");
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
366 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
367 else if (hybridModeString == "WriteToFileSystem")
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
368 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
369 hybridMode = HybridMode_WriteToFileSystem;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
370 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");
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
371 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
372 else
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
373 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
374 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": HybridMode is disabled enabled: writing to object-storage and reading only from object-storage");
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
375 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
376
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
377 if (IsReadFromDisk())
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
378 {
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
379 fileSystemRootPath = orthancConfig.GetStringValue("StorageDirectory", "OrthancStorageNotDefined");
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
380 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": HybridMode: reading from file system is enabled, source: " + fileSystemRootPath);
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
381 }
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
382
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
383 objectsRootPath = pluginSection.GetStringValue("RootPath", std::string());
33
Alain Mazy
parents: 31 27
diff changeset
384
Alain Mazy
parents: 31 27
diff changeset
385 if (objectsRootPath.size() >= 1 && objectsRootPath[0] == '/')
Alain Mazy
parents: 31 27
diff changeset
386 {
Alain Mazy
parents: 31 27
diff changeset
387 OrthancPlugins::LogError(std::string(StoragePluginFactory::GetStoragePluginName()) + ": The RootPath shall not start with a '/': " + objectsRootPath);
Alain Mazy
parents: 31 27
diff changeset
388 return -1;
Alain Mazy
parents: 31 27
diff changeset
389 }
15
2a02b21f0a19 migration + storage structure
Alain Mazy
parents: 8
diff changeset
390
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
391 std::string objecstStoragePluginName = StoragePluginFactory::GetStoragePluginName();
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
392 if (hybridMode == HybridMode_WriteToFileSystem)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
393 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
394 objecstStoragePluginName += " (Secondary: object-storage)";
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
395 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
396 else if (hybridMode == HybridMode_WriteToObjectStorage)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
397 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
398 objecstStoragePluginName += " (Primary: object-storage)";
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
399 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
400
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
401 std::unique_ptr<IStorage> objectStoragePlugin(StoragePluginFactory::CreateStorage(objecstStoragePluginName, orthancConfig));
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
402
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
403 if (objectStoragePlugin.get() == nullptr)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
404 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
405 return -1;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
406 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
407
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
408 objectStoragePlugin->SetRootPath(objectsRootPath);
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
409
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
410 std::unique_ptr<IStorage> fileSystemStoragePlugin;
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
411 if (IsHybridModeEnabled())
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
412 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
413 bool fsync = orthancConfig.GetBooleanValue("SyncStorageArea", true);
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
414
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
415 std::string filesystemStoragePluginName = StoragePluginFactory::GetStoragePluginName();
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
416 if (hybridMode == HybridMode_WriteToFileSystem)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
417 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
418 filesystemStoragePluginName += " (Primary: file-system)";
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
419 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
420 else if (hybridMode == HybridMode_WriteToObjectStorage)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
421 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
422 filesystemStoragePluginName += " (Secondary: file-system)";
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
423 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
424
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
425 fileSystemStoragePlugin.reset(new FileSystemStoragePlugin(filesystemStoragePluginName, fileSystemRootPath, fsync));
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
426 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
427
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
428 if (hybridMode == HybridMode_Disabled || hybridMode == HybridMode_WriteToObjectStorage)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
429 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
430 primaryStorage.reset(objectStoragePlugin.release());
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
431
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
432 if (hybridMode == HybridMode_WriteToObjectStorage)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
433 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
434 secondaryStorage.reset(fileSystemStoragePlugin.release());
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
435 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
436 }
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
437 else if (hybridMode == HybridMode_WriteToFileSystem)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
438 {
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
439 primaryStorage.reset(fileSystemStoragePlugin.release());
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
440 secondaryStorage.reset(objectStoragePlugin.release());
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
441 }
15
2a02b21f0a19 migration + storage structure
Alain Mazy
parents: 8
diff changeset
442
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
443 if (pluginSection.IsSection(ENCRYPTION_SECTION))
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
444 {
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
445 OrthancPlugins::OrthancConfiguration cryptoSection;
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
446 pluginSection.GetSection(cryptoSection, ENCRYPTION_SECTION);
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
447
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
448 crypto.reset(EncryptionConfigurator::CreateEncryptionHelpers(cryptoSection));
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
449 cryptoEnabled = crypto.get() != nullptr;
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
450 }
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
451
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
452 if (cryptoEnabled)
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
453 {
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
454 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": client-side encryption is enabled");
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
455 }
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
456 else
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
457 {
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
458 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": client-side encryption is disabled");
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
459 }
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
460
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents: 57
diff changeset
461
15
2a02b21f0a19 migration + storage structure
Alain Mazy
parents: 8
diff changeset
462 }
2a02b21f0a19 migration + storage structure
Alain Mazy
parents: 8
diff changeset
463
39
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
464 if (cryptoEnabled)
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
465 {
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
466 // with encrypted file, we do not want to support ReadRange. Therefore, we register the old interface
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
467 OrthancPluginRegisterStorageArea(context, StorageCreate, StorageReadWholeLegacy, StorageRemove);
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
468 }
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
469 else
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
470 {
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
471 OrthancPluginRegisterStorageArea2(context, StorageCreate, StorageReadWhole, StorageReadRange, StorageRemove);
50d0be413c42 implemented ReadRange (only in Azure plugin right now)
Alain Mazy <am@osimis.io>
parents: 37
diff changeset
472 }
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
473 }
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
474 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
475 {
e1f52b851827 Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
476 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
477 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
478 }
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
479
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
480 return 0;
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
481 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
482
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
483
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
484 ORTHANC_PLUGINS_API void OrthancPluginFinalize()
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
485 {
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
486 OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + " plugin is finalizing");
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
487 primaryStorage.reset();
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
488 secondaryStorage.reset();
57
ba1be668e475 fix initialization of the aws static library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 56
diff changeset
489 Orthanc::FinalizeFramework();
1
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
490 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
491
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
492
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
493 ORTHANC_PLUGINS_API const char* OrthancPluginGetName()
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
494 {
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
495 return StoragePluginFactory::GetStoragePluginName();
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
496 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
497
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
498
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
499 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion()
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
500 {
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
501 return PLUGIN_VERSION;
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
502 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
503 }
fc26a8fc54d5 initial release
Alain Mazy <alain@mazy.be>
parents:
diff changeset
504