annotate Plugins/Samples/StorageCommitmentScp/Plugin.cpp @ 3802:6462ecaa045b

fix unit test, reorganization of OpenSSL initialization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 02 Apr 2020 12:54:45 +0200
parents 340bdcc298e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3664
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * General Public License for more details.
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "../Common/OrthancPluginCppWrapper.h"
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include <json/value.h>
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include <json/reader.h>
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 class StorageCommitmentSample : public OrthancPlugins::IStorageCommitmentScpHandler
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 private:
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 int count_;
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 public:
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 StorageCommitmentSample() : count_(0)
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 }
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 virtual OrthancPluginStorageCommitmentFailureReason Lookup(const std::string& sopClassUid,
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 const std::string& sopInstanceUid)
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 printf("?? [%s] [%s]\n", sopClassUid.c_str(), sopInstanceUid.c_str());
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 if (count_++ % 2 == 0)
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 return OrthancPluginStorageCommitmentFailureReason_Success;
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 else
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 return OrthancPluginStorageCommitmentFailureReason_NoSuchObjectInstance;
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 }
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 };
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
3665
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
51 static OrthancPluginErrorCode StorageCommitmentScp(void** handler /* out */,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
52 const char* jobId,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
53 const char* transactionUid,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
54 const char* const* sopClassUids,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
55 const char* const* sopInstanceUids,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
56 uint32_t countInstances,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
57 const char* remoteAet,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
58 const char* calledAet)
3664
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 {
3675
340bdcc298e9 test pausing storage commitment plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3665
diff changeset
60 /*std::string s;
340bdcc298e9 test pausing storage commitment plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3665
diff changeset
61 OrthancPlugins::RestApiPost(s, "/jobs/" + std::string(jobId) + "/pause", NULL, 0, false);*/
340bdcc298e9 test pausing storage commitment plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3665
diff changeset
62
3664
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 printf("[%s] [%s] [%s] [%s]\n", jobId, transactionUid, remoteAet, calledAet);
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 for (uint32_t i = 0; i < countInstances; i++)
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 printf("++ [%s] [%s]\n", sopClassUids[i], sopInstanceUids[i]);
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 }
3665
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
69
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
70 *handler = new StorageCommitmentSample;
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
71 return OrthancPluginErrorCode_Success;
3664
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 }
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 extern "C"
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c)
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 OrthancPlugins::SetGlobalContext(c);
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 /* Check the version of the Orthanc core */
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 if (OrthancPluginCheckVersion(c) == 0)
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 OrthancPlugins::ReportMinimalOrthancVersion(ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 return -1;
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 }
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 OrthancPluginSetDescription(c, "Sample storage commitment SCP plugin.");
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
3665
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
92 OrthancPluginRegisterStorageCommitmentScpCallback(
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
93 c, StorageCommitmentScp,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
94 OrthancPlugins::IStorageCommitmentScpHandler::Destructor,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
95 OrthancPlugins::IStorageCommitmentScpHandler::Lookup);
3664
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 return 0;
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 }
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 ORTHANC_PLUGINS_API void OrthancPluginFinalize()
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 }
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 ORTHANC_PLUGINS_API const char* OrthancPluginGetName()
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 return "storage-commitment-scp";
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 }
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion()
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 return PLUGIN_VERSION;
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 }
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 }