Mercurial > hg > orthanc-databases
annotate MySQL/Plugins/IndexPlugin.cpp @ 492:af6998ed73dd
fix deprecated calls
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 22 Mar 2024 15:03:26 +0100 |
parents | ecd0b719cff5 |
children | 54d518dcd74a |
rev | line source |
---|---|
0 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
459
ecd0b719cff5
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium |
ecd0b719cff5
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
0 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU Affero General Public License | |
10 * as published by the Free Software Foundation, either version 3 of | |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Affero General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Affero General Public License | |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 **/ | |
21 | |
22 | |
23 #include "MySQLIndex.h" | |
24 #include "../../Framework/MySQL/MySQLDatabase.h" | |
24
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
25 #include "../../Framework/Plugins/PluginInitialization.h" |
0 | 26 |
152 | 27 #include <HttpClient.h> |
28 #include <Logging.h> | |
29 #include <Toolbox.h> | |
0 | 30 |
381
9cde77ca9ad9
initializing and finalizing protobuf
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
31 #include <google/protobuf/any.h> |
9cde77ca9ad9
initializing and finalizing protobuf
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
32 |
492
af6998ed73dd
fix deprecated calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
459
diff
changeset
|
33 #define ORTHANC_PLUGIN_NAME "mysql-index" |
0 | 34 |
35 extern "C" | |
36 { | |
37 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) | |
38 { | |
381
9cde77ca9ad9
initializing and finalizing protobuf
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
39 GOOGLE_PROTOBUF_VERIFY_VERSION; |
9cde77ca9ad9
initializing and finalizing protobuf
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
40 |
492
af6998ed73dd
fix deprecated calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
459
diff
changeset
|
41 if (!OrthancDatabases::InitializePlugin(context, ORTHANC_PLUGIN_NAME, "MySQL", true)) |
0 | 42 { |
43 return -1; | |
44 } | |
45 | |
42 | 46 Orthanc::Toolbox::InitializeOpenSsl(); |
40
5600949bfb12
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
47 Orthanc::HttpClient::GlobalInitialize(); |
5600949bfb12
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
48 |
62
eedd082355f9
fix for compatibility with simplified OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
49 OrthancPlugins::OrthancConfiguration configuration; |
0 | 50 |
51 if (!configuration.IsSection("MySQL")) | |
52 { | |
53 LOG(WARNING) << "No available configuration for the MySQL index plugin"; | |
54 return 0; | |
55 } | |
56 | |
57 OrthancPlugins::OrthancConfiguration mysql; | |
58 configuration.GetSection(mysql, "MySQL"); | |
59 | |
60 bool enable; | |
61 if (!mysql.LookupBooleanValue(enable, "EnableIndex") || | |
62 !enable) | |
63 { | |
64 LOG(WARNING) << "The MySQL index is currently disabled, set \"EnableIndex\" " | |
65 << "to \"true\" in the \"MySQL\" section of the configuration file of Orthanc"; | |
66 return 0; | |
67 } | |
68 | |
69 try | |
70 { | |
253
3bc442765b88
new configuration option: "IndexConnectionsCount"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
71 const size_t countConnections = mysql.GetUnsignedIntegerValue("IndexConnectionsCount", 1); |
3bc442765b88
new configuration option: "IndexConnectionsCount"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
72 |
163
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
157
diff
changeset
|
73 OrthancDatabases::MySQLParameters parameters(mysql, configuration); |
234
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
74 OrthancDatabases::IndexBackend::Register( |
253
3bc442765b88
new configuration option: "IndexConnectionsCount"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
75 new OrthancDatabases::MySQLIndex(context, parameters), countConnections, |
3bc442765b88
new configuration option: "IndexConnectionsCount"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
76 parameters.GetMaxConnectionRetries()); |
0 | 77 } |
2
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
78 catch (Orthanc::OrthancException& e) |
0 | 79 { |
2
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
80 LOG(ERROR) << e.What(); |
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
81 return -1; |
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
82 } |
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
83 catch (...) |
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
84 { |
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
85 LOG(ERROR) << "Native exception while initializing the plugin"; |
0 | 86 return -1; |
87 } | |
88 | |
89 return 0; | |
90 } | |
91 | |
92 | |
93 ORTHANC_PLUGINS_API void OrthancPluginFinalize() | |
94 { | |
2
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
95 LOG(WARNING) << "MySQL index is finalizing"; |
222
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
213
diff
changeset
|
96 OrthancDatabases::IndexBackend::Finalize(); |
2
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
97 |
0 | 98 OrthancDatabases::MySQLDatabase::GlobalFinalization(); |
40
5600949bfb12
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
99 Orthanc::HttpClient::GlobalFinalize(); |
42 | 100 Orthanc::Toolbox::FinalizeOpenSsl(); |
381
9cde77ca9ad9
initializing and finalizing protobuf
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
101 google::protobuf::ShutdownProtobufLibrary(); |
0 | 102 } |
103 | |
104 | |
105 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() | |
106 { | |
492
af6998ed73dd
fix deprecated calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
459
diff
changeset
|
107 return ORTHANC_PLUGIN_NAME; |
0 | 108 } |
109 | |
110 | |
111 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() | |
112 { | |
113 return ORTHANC_PLUGIN_VERSION; | |
114 } | |
115 } |