Mercurial > hg > orthanc
annotate OrthancServer/Plugins/Samples/StorageCommitmentScp/Plugin.cpp @ 4403:ad646ff506d0
cont openapi
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 Dec 2020 18:32:13 +0100 |
parents | 3c400d3c11ef |
children | d9473bd5ed43 |
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 |
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 class StorageCommitmentSample : public OrthancPlugins::IStorageCommitmentScpHandler |
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 private: |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 int count_; |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 public: |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 StorageCommitmentSample() : count_(0) |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 { |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 } |
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 virtual OrthancPluginStorageCommitmentFailureReason Lookup(const std::string& sopClassUid, |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 const std::string& sopInstanceUid) |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 { |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 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
|
41 if (count_++ % 2 == 0) |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 return OrthancPluginStorageCommitmentFailureReason_Success; |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 else |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 return OrthancPluginStorageCommitmentFailureReason_NoSuchObjectInstance; |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 } |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 }; |
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 |
3665
4c1d2ff7ddd0
handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3664
diff
changeset
|
49 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
|
50 const char* jobId, |
4c1d2ff7ddd0
handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3664
diff
changeset
|
51 const char* transactionUid, |
4c1d2ff7ddd0
handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3664
diff
changeset
|
52 const char* const* sopClassUids, |
4c1d2ff7ddd0
handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3664
diff
changeset
|
53 const char* const* sopInstanceUids, |
4c1d2ff7ddd0
handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3664
diff
changeset
|
54 uint32_t countInstances, |
4c1d2ff7ddd0
handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3664
diff
changeset
|
55 const char* remoteAet, |
4c1d2ff7ddd0
handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3664
diff
changeset
|
56 const char* calledAet) |
3664
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 { |
3675
340bdcc298e9
test pausing storage commitment plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3665
diff
changeset
|
58 /*std::string s; |
340bdcc298e9
test pausing storage commitment plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3665
diff
changeset
|
59 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
|
60 |
3664
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 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
|
62 |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 for (uint32_t i = 0; i < countInstances; i++) |
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 printf("++ [%s] [%s]\n", sopClassUids[i], sopInstanceUids[i]); |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 } |
3665
4c1d2ff7ddd0
handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3664
diff
changeset
|
67 |
4c1d2ff7ddd0
handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3664
diff
changeset
|
68 *handler = new StorageCommitmentSample; |
4c1d2ff7ddd0
handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3664
diff
changeset
|
69 return OrthancPluginErrorCode_Success; |
3664
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 } |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 |
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 extern "C" |
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 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* 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 OrthancPlugins::SetGlobalContext(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 /* Check the version of the Orthanc core */ |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 if (OrthancPluginCheckVersion(c) == 0) |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 { |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 OrthancPlugins::ReportMinimalOrthancVersion(ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 return -1; |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 } |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 OrthancPluginSetDescription(c, "Sample storage commitment SCP plugin."); |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 |
3665
4c1d2ff7ddd0
handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3664
diff
changeset
|
90 OrthancPluginRegisterStorageCommitmentScpCallback( |
4c1d2ff7ddd0
handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3664
diff
changeset
|
91 c, StorageCommitmentScp, |
4c1d2ff7ddd0
handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3664
diff
changeset
|
92 OrthancPlugins::IStorageCommitmentScpHandler::Destructor, |
4c1d2ff7ddd0
handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3664
diff
changeset
|
93 OrthancPlugins::IStorageCommitmentScpHandler::Lookup); |
3664
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 |
85acfcc15829
sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 return 0; |
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 |
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 ORTHANC_PLUGINS_API void OrthancPluginFinalize() |
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 } |
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 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() |
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 return "storage-commitment-scp"; |
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 |
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 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() |
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 return PLUGIN_VERSION; |
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 } |