Mercurial > hg > orthanc-databases
annotate PostgreSQL/Plugins/IndexPlugin.cpp @ 369:557bc5ba3a5c
fix warnings
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 01 Feb 2023 16:25:37 +0100 |
parents | 16aac0287485 |
children | 9cde77ca9ad9 |
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 | |
359
16aac0287485
copyright upgraded to 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
16aac0287485
copyright upgraded to 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
6 * Copyright (C) 2021-2022 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 "PostgreSQLIndex.h" | |
24
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
11
diff
changeset
|
24 #include "../../Framework/Plugins/PluginInitialization.h" |
0 | 25 |
152 | 26 #include <Logging.h> |
267 | 27 #include <Toolbox.h> |
0 | 28 |
29 | |
30 extern "C" | |
31 { | |
32 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) | |
33 { | |
28
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
34 if (!OrthancDatabases::InitializePlugin(context, "PostgreSQL", true)) |
0 | 35 { |
36 return -1; | |
37 } | |
38 | |
267 | 39 Orthanc::Toolbox::InitializeOpenSsl(); |
40 | |
62
eedd082355f9
fix for compatibility with simplified OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
41 OrthancPlugins::OrthancConfiguration configuration; |
0 | 42 |
43 if (!configuration.IsSection("PostgreSQL")) | |
44 { | |
45 LOG(WARNING) << "No available configuration for the PostgreSQL index plugin"; | |
46 return 0; | |
47 } | |
48 | |
49 OrthancPlugins::OrthancConfiguration postgresql; | |
50 configuration.GetSection(postgresql, "PostgreSQL"); | |
51 | |
52 bool enable; | |
53 if (!postgresql.LookupBooleanValue(enable, "EnableIndex") || | |
54 !enable) | |
55 { | |
56 LOG(WARNING) << "The PostgreSQL index is currently disabled, set \"EnableIndex\" " | |
57 << "to \"true\" in the \"PostgreSQL\" section of the configuration file of Orthanc"; | |
58 return 0; | |
59 } | |
60 | |
61 try | |
62 { | |
253
3bc442765b88
new configuration option: "IndexConnectionsCount"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
63 const size_t countConnections = postgresql.GetUnsignedIntegerValue("IndexConnectionsCount", 1); |
3bc442765b88
new configuration option: "IndexConnectionsCount"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
64 |
0 | 65 OrthancDatabases::PostgreSQLParameters parameters(postgresql); |
234
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
66 OrthancDatabases::IndexBackend::Register( |
253
3bc442765b88
new configuration option: "IndexConnectionsCount"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
67 new OrthancDatabases::PostgreSQLIndex(context, parameters), countConnections, |
3bc442765b88
new configuration option: "IndexConnectionsCount"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
68 parameters.GetMaxConnectionRetries()); |
0 | 69 } |
2
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
70 catch (Orthanc::OrthancException& e) |
0 | 71 { |
2
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
72 LOG(ERROR) << e.What(); |
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
73 return -1; |
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
74 } |
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
75 catch (...) |
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
76 { |
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
77 LOG(ERROR) << "Native exception while initializing the plugin"; |
0 | 78 return -1; |
79 } | |
80 | |
81 return 0; | |
82 } | |
83 | |
84 | |
85 ORTHANC_PLUGINS_API void OrthancPluginFinalize() | |
86 { | |
11 | 87 LOG(WARNING) << "PostgreSQL index is finalizing"; |
222
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
213
diff
changeset
|
88 OrthancDatabases::IndexBackend::Finalize(); |
267 | 89 Orthanc::Toolbox::FinalizeOpenSsl(); |
0 | 90 } |
91 | |
92 | |
93 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() | |
94 { | |
95 return "postgresql-index"; | |
96 } | |
97 | |
98 | |
99 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() | |
100 { | |
101 return ORTHANC_PLUGIN_VERSION; | |
102 } | |
103 } |