Mercurial > hg > orthanc
annotate OrthancServer/Plugins/Engine/PluginsJob.cpp @ 5848:b8fb95937f22 find-refactoring
fix warnings
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 29 Oct 2024 13:48:39 +0000 |
parents | f7adfb22e20e |
children |
rev | line source |
---|---|
2810 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
2810 | 8 * |
9 * This program is free software: you can redistribute it and/or | |
10 * modify it under the terms of the GNU General Public License as | |
11 * published by the Free Software Foundation, either version 3 of the | |
12 * License, or (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, but | |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 * General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
4045 | 24 #include "../../Sources/PrecompiledHeadersServer.h" |
2810 | 25 #include "PluginsJob.h" |
26 | |
27 #if ORTHANC_ENABLE_PLUGINS != 1 | |
28 #error The plugin support is disabled | |
29 #endif | |
30 | |
31 | |
4045 | 32 #include "../../../OrthancFramework/Sources/Logging.h" |
33 #include "../../../OrthancFramework/Sources/OrthancException.h" | |
4392
3af1d763763a
confining Json::Reader and Json::*Writer into Toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
34 #include "../../../OrthancFramework/Sources/Toolbox.h" |
2810 | 35 |
36 #include <cassert> | |
37 | |
38 namespace Orthanc | |
39 { | |
5138
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
40 void PluginsJob::Setup() |
2810 | 41 { |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
42 if (parameters_.job == NULL) |
2810 | 43 { |
44 throw OrthancException(ErrorCode_NullPointer); | |
45 } | |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
46 |
2815
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2814
diff
changeset
|
47 if (parameters_.target == NULL || |
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2814
diff
changeset
|
48 parameters_.finalize == NULL || |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
49 parameters_.type == NULL || |
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
50 parameters_.getProgress == NULL || |
5138
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
51 (parameters_.getContent == NULL && deprecatedGetContent_ == NULL) || |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
52 (parameters_.getSerialized == NULL && deprecatedGetSerialized_ == NULL) || |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
53 parameters_.step == NULL || |
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
54 parameters_.stop == NULL || |
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
55 parameters_.reset == NULL) |
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
56 { |
5138
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
57 parameters_.finalize(parameters_.job); |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
58 throw OrthancException(ErrorCode_NullPointer); |
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
59 } |
2810 | 60 |
5138
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
61 type_.assign(parameters_.type); |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
62 } |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
63 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
64 PluginsJob::PluginsJob(const _OrthancPluginCreateJob2& parameters) : |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
65 parameters_(parameters), |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
66 deprecatedGetContent_(NULL), |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
67 deprecatedGetSerialized_(NULL) |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
68 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
69 Setup(); |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
70 } |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
71 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
72 PluginsJob::PluginsJob(const _OrthancPluginCreateJob& parameters) |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
73 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
74 LOG(WARNING) << "Your plugin is using the deprecated OrthancPluginCreateJob() function"; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
75 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
76 memset(¶meters_, 0, sizeof(parameters_)); |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
77 parameters_.target = parameters.target; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
78 parameters_.job = parameters.job; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
79 parameters_.finalize = parameters.finalize; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
80 parameters_.type = parameters.type; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
81 parameters_.getProgress = parameters.getProgress; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
82 parameters_.getContent = NULL; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
83 parameters_.getSerialized = NULL; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
84 parameters_.step = parameters.step; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
85 parameters_.stop = parameters.stop; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
86 parameters_.reset = parameters.reset; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
87 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
88 deprecatedGetContent_ = parameters.getContent; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
89 deprecatedGetSerialized_ = parameters.getSerialized; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
90 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
91 Setup(); |
2810 | 92 } |
93 | |
94 PluginsJob::~PluginsJob() | |
95 { | |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
96 assert(parameters_.job != NULL); |
2815
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2814
diff
changeset
|
97 parameters_.finalize(parameters_.job); |
2810 | 98 } |
99 | |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
100 JobStepResult PluginsJob::Step(const std::string& jobId) |
2810 | 101 { |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
102 OrthancPluginJobStepStatus status = parameters_.step(parameters_.job); |
2811
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
103 |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
104 switch (status) |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
105 { |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
106 case OrthancPluginJobStepStatus_Success: |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
107 return JobStepResult::Success(); |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
108 |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
109 case OrthancPluginJobStepStatus_Failure: |
3240
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
110 return JobStepResult::Failure(ErrorCode_Plugin, NULL); |
2811
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
111 |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
112 case OrthancPluginJobStepStatus_Continue: |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
113 return JobStepResult::Continue(); |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
114 |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
115 default: |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
116 throw OrthancException(ErrorCode_ParameterOutOfRange); |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
117 } |
2810 | 118 } |
119 | |
2812
ea7aea6f6a95
improved naming of methods in IJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2811
diff
changeset
|
120 void PluginsJob::Reset() |
2810 | 121 { |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
122 parameters_.reset(parameters_.job); |
2810 | 123 } |
124 | |
2812
ea7aea6f6a95
improved naming of methods in IJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2811
diff
changeset
|
125 void PluginsJob::Stop(JobStopReason reason) |
2810 | 126 { |
2811
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
127 switch (reason) |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
128 { |
2812
ea7aea6f6a95
improved naming of methods in IJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2811
diff
changeset
|
129 case JobStopReason_Success: |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
130 parameters_.stop(parameters_.job, OrthancPluginJobStopReason_Success); |
2811
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
131 break; |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
132 |
2812
ea7aea6f6a95
improved naming of methods in IJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2811
diff
changeset
|
133 case JobStopReason_Failure: |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
134 parameters_.stop(parameters_.job, OrthancPluginJobStopReason_Failure); |
2811
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
135 break; |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
136 |
2812
ea7aea6f6a95
improved naming of methods in IJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2811
diff
changeset
|
137 case JobStopReason_Canceled: |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
138 parameters_.stop(parameters_.job, OrthancPluginJobStopReason_Canceled); |
2811
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
139 break; |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
140 |
2812
ea7aea6f6a95
improved naming of methods in IJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2811
diff
changeset
|
141 case JobStopReason_Paused: |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
142 parameters_.stop(parameters_.job, OrthancPluginJobStopReason_Paused); |
2811
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
143 break; |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
144 |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
145 default: |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
146 throw OrthancException(ErrorCode_ParameterOutOfRange); |
7cfc8d266f41
reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2810
diff
changeset
|
147 } |
2810 | 148 } |
149 | |
150 float PluginsJob::GetProgress() | |
151 { | |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
152 return parameters_.getProgress(parameters_.job); |
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
153 } |
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
154 |
5138
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
155 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
156 namespace |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
157 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
158 class MemoryBufferRaii : public boost::noncopyable |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
159 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
160 private: |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
161 OrthancPluginMemoryBuffer buffer_; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
162 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
163 public: |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
164 MemoryBufferRaii() |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
165 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
166 buffer_.size = 0; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
167 buffer_.data = NULL; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
168 } |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
169 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
170 ~MemoryBufferRaii() |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
171 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
172 if (buffer_.size != 0) |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
173 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
174 free(buffer_.data); |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
175 } |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
176 } |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
177 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
178 OrthancPluginMemoryBuffer* GetObject() |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
179 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
180 return &buffer_; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
181 } |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
182 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
183 void ToJsonObject(Json::Value& target) const |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
184 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
185 if ((buffer_.data == NULL && buffer_.size != 0) || |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
186 (buffer_.data != NULL && buffer_.size == 0) || |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
187 !Toolbox::ReadJson(target, buffer_.data, buffer_.size) || |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
188 target.type() != Json::objectValue) |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
189 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
190 throw OrthancException(ErrorCode_Plugin, |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
191 "A job plugin must provide a JSON object as its public content and as its serialization"); |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
192 } |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
193 } |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
194 }; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
195 } |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
196 |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
197 void PluginsJob::GetPublicContent(Json::Value& value) |
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
198 { |
5138
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
199 if (parameters_.getContent != NULL) |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
200 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
201 MemoryBufferRaii target; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
202 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
203 OrthancPluginErrorCode code = parameters_.getContent(target.GetObject(), parameters_.job); |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
204 |
5138
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
205 if (code != OrthancPluginErrorCode_Success) |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
206 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
207 throw OrthancException(static_cast<ErrorCode>(code)); |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
208 } |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
209 else |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
210 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
211 target.ToJsonObject(value); |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
212 } |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
213 } |
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
214 else |
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
215 { |
5138
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
216 // This was the source code in Orthanc <= 1.11.2 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
217 const char* content = deprecatedGetContent_(parameters_.job); |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
218 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
219 if (content == NULL) |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
220 { |
5138
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
221 value = Json::objectValue; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
222 } |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
223 else |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
224 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
225 if (!Toolbox::ReadJson(value, content) || |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
226 value.type() != Json::objectValue) |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
227 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
228 throw OrthancException(ErrorCode_Plugin, |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
229 "A job plugin must provide a JSON object as its public content"); |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
230 } |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
231 } |
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
232 } |
2810 | 233 } |
234 | |
235 bool PluginsJob::Serialize(Json::Value& value) | |
236 { | |
5138
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
237 if (parameters_.getSerialized != NULL) |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
238 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
239 MemoryBufferRaii target; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
240 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
241 int32_t code = parameters_.getContent(target.GetObject(), parameters_.job); |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
242 |
5138
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
243 if (code < 0) |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
244 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
245 throw OrthancException(ErrorCode_Plugin, "Error during the serialization of a job"); |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
246 } |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
247 else if (code == 0) |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
248 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
249 return false; // Serialization is not implemented |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
250 } |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
251 else |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
252 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
253 target.ToJsonObject(value); |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
254 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
255 static const char* KEY_TYPE = "Type"; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
256 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
257 if (value.isMember(KEY_TYPE)) |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
258 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
259 throw OrthancException(ErrorCode_Plugin, |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
260 "The \"Type\" field is for reserved use for serialized job"); |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
261 } |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
262 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
263 value[KEY_TYPE] = type_; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
264 return true; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
265 } |
2810 | 266 } |
267 else | |
268 { | |
5138
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
269 // This was the source code in Orthanc <= 1.11.2 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
270 const char* serialized = deprecatedGetSerialized_(parameters_.job); |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
271 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
272 if (serialized == NULL) |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
273 { |
5138
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
274 return false; |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
275 } |
5138
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
276 else |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
277 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
278 if (!Toolbox::ReadJson(value, serialized) || |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
279 value.type() != Json::objectValue) |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
280 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
281 throw OrthancException(ErrorCode_Plugin, |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
282 "A job plugin must provide a JSON object as its serialized content"); |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
283 } |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
284 |
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
285 |
5138
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
286 static const char* KEY_TYPE = "Type"; |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
287 |
5138
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
288 if (value.isMember(KEY_TYPE)) |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
289 { |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
290 throw OrthancException(ErrorCode_Plugin, |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
291 "The \"Type\" field is for reserved use for serialized job"); |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
292 } |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
293 |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
294 value[KEY_TYPE] = type_; |
d00db9fb48fb
added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
295 return true; |
2814
7d1d3136f6cf
more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
296 } |
2810 | 297 } |
298 } | |
299 } |