Mercurial > hg > orthanc-stone
annotate Framework/Deprecated/Toolbox/OrthancApiClient.cpp @ 1012:050f01d7951b
Ugly fix for VS2008 (pre-C++11 vector initialization)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Fri, 20 Sep 2019 13:59:36 +0200 |
parents | 861c080ef47b |
children | e146743f6cdc 2d8ab34c8c91 |
rev | line source |
---|---|
270 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
270 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 #include "OrthancApiClient.h" | |
22 | |
792
4fe4b221a31f
deprecating MessagingToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
23 #include "../Toolbox/MessagingToolbox.h" |
270 | 24 |
377 | 25 #include <Core/OrthancException.h> |
270 | 26 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
27 namespace Deprecated |
377 | 28 { |
29 const Orthanc::IDynamicObject& OrthancApiClient::JsonResponseReadyMessage::GetPayload() const | |
30 { | |
31 if (HasPayload()) | |
32 { | |
33 return *payload_; | |
34 } | |
35 else | |
36 { | |
37 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
38 } | |
39 } | |
40 | |
41 | |
42 const Orthanc::IDynamicObject& OrthancApiClient::BinaryResponseReadyMessage::GetPayload() const | |
43 { | |
44 if (HasPayload()) | |
45 { | |
46 return *payload_; | |
47 } | |
48 else | |
49 { | |
50 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
51 } | |
52 } | |
53 | |
54 | |
55 const Orthanc::IDynamicObject& OrthancApiClient::EmptyResponseReadyMessage::GetPayload() const | |
56 { | |
57 if (HasPayload()) | |
58 { | |
59 return *payload_; | |
60 } | |
61 else | |
62 { | |
63 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
64 } | |
65 } | |
66 | |
67 | |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
68 class OrthancApiClient::WebServicePayload : public Orthanc::IDynamicObject |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
69 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
70 private: |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
71 std::auto_ptr< OrthancStone::MessageHandler<EmptyResponseReadyMessage> > emptyHandler_; |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
72 std::auto_ptr< OrthancStone::MessageHandler<JsonResponseReadyMessage> > jsonHandler_; |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
73 std::auto_ptr< OrthancStone::MessageHandler<BinaryResponseReadyMessage> > binaryHandler_; |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
74 std::auto_ptr< OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage> > failureHandler_; |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
75 std::auto_ptr< Orthanc::IDynamicObject > userPayload_; |
874
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
76 OrthancStone::MessageBroker& broker_; |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
77 void NotifyConversionError(const IWebService::HttpRequestSuccessMessage& message) const |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
78 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
79 if (failureHandler_.get() != NULL) |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
80 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
81 failureHandler_->Apply(IWebService::HttpRequestErrorMessage |
940
861c080ef47b
handling httpStatus in WebService error messages
Alain Mazy <alain@mazy.be>
parents:
874
diff
changeset
|
82 (message.GetUri(), Orthanc::HttpStatus_None, userPayload_.get())); |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
83 } |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
84 } |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
85 |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
86 public: |
874
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
87 WebServicePayload(OrthancStone::MessageBroker& broker, |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
88 OrthancStone::MessageHandler<EmptyResponseReadyMessage>* handler, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
89 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureHandler, |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
90 Orthanc::IDynamicObject* userPayload) : |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
91 emptyHandler_(handler), |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
92 failureHandler_(failureHandler), |
874
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
93 userPayload_(userPayload), |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
94 broker_(broker) |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
95 |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
96 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
97 if (handler == NULL) |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
98 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
99 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
100 } |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
101 } |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
102 |
874
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
103 WebServicePayload(OrthancStone::MessageBroker& broker, |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
104 OrthancStone::MessageHandler<BinaryResponseReadyMessage>* handler, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
105 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureHandler, |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
106 Orthanc::IDynamicObject* userPayload) : |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
107 binaryHandler_(handler), |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
108 failureHandler_(failureHandler), |
874
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
109 userPayload_(userPayload), |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
110 broker_(broker) |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
111 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
112 if (handler == NULL) |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
113 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
114 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
115 } |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
116 } |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
117 |
874
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
118 WebServicePayload(OrthancStone::MessageBroker& broker, |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
119 OrthancStone::MessageHandler<JsonResponseReadyMessage>* handler, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
120 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureHandler, |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
121 Orthanc::IDynamicObject* userPayload) : |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
122 jsonHandler_(handler), |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
123 failureHandler_(failureHandler), |
874
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
124 userPayload_(userPayload), |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
125 broker_(broker) |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
126 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
127 if (handler == NULL) |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
128 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
129 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
130 } |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
131 } |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
132 |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
133 void HandleSuccess(const IWebService::HttpRequestSuccessMessage& message) const |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
134 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
135 if (emptyHandler_.get() != NULL) |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
136 { |
874
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
137 if (broker_.IsActive(*(emptyHandler_->GetObserver()))) |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
138 { |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
139 emptyHandler_->Apply(OrthancApiClient::EmptyResponseReadyMessage |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
140 (message.GetUri(), userPayload_.get())); |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
141 } |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
142 } |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
143 else if (binaryHandler_.get() != NULL) |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
144 { |
874
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
145 if (broker_.IsActive(*(binaryHandler_->GetObserver()))) |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
146 { |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
147 binaryHandler_->Apply(OrthancApiClient::BinaryResponseReadyMessage |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
148 (message.GetUri(), message.GetAnswer(), |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
149 message.GetAnswerSize(), userPayload_.get())); |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
150 } |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
151 } |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
152 else if (jsonHandler_.get() != NULL) |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
153 { |
874
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
154 if (broker_.IsActive(*(jsonHandler_->GetObserver()))) |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
155 { |
874
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
156 Json::Value response; |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
157 if (MessagingToolbox::ParseJson(response, message.GetAnswer(), message.GetAnswerSize())) |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
158 { |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
159 jsonHandler_->Apply(OrthancApiClient::JsonResponseReadyMessage |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
160 (message.GetUri(), response, userPayload_.get())); |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
161 } |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
162 else |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
163 { |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
164 NotifyConversionError(message); |
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
165 } |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
166 } |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
167 } |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
168 else |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
169 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
170 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
171 } |
422
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
172 } |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
173 |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
174 void HandleFailure(const IWebService::HttpRequestErrorMessage& message) const |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
175 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
176 if (failureHandler_.get() != NULL) |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
177 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
178 failureHandler_->Apply(IWebService::HttpRequestErrorMessage |
940
861c080ef47b
handling httpStatus in WebService error messages
Alain Mazy <alain@mazy.be>
parents:
874
diff
changeset
|
179 (message.GetUri(), message.GetHttpStatus(), userPayload_.get())); |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
180 } |
422
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
181 } |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
182 }; |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
183 |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
184 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
185 OrthancApiClient::OrthancApiClient(OrthancStone::MessageBroker& broker, |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
186 IWebService& web, |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
187 const std::string& baseUrl) : |
377 | 188 IObservable(broker), |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
189 IObserver(broker), |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
190 web_(web), |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
191 baseUrl_(baseUrl) |
270 | 192 { |
193 } | |
194 | |
334
c34784e5f299
compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
195 |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
196 void OrthancApiClient::GetJsonAsync( |
422
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
197 const std::string& uri, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
198 OrthancStone::MessageHandler<JsonResponseReadyMessage>* successCallback, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
199 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback, |
422
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
200 Orthanc::IDynamicObject* payload) |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
201 { |
422
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
202 IWebService::HttpHeaders emptyHeaders; |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
203 web_.GetAsync(baseUrl_ + uri, |
434
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
430
diff
changeset
|
204 emptyHeaders, |
874
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
205 new WebServicePayload(IObservable::GetBroker(), successCallback, failureCallback, payload), |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
206 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestSuccessMessage> |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
207 (*this, &OrthancApiClient::NotifyHttpSuccess), |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
208 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestErrorMessage> |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
209 (*this, &OrthancApiClient::NotifyHttpError)); |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
271
diff
changeset
|
210 } |
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
271
diff
changeset
|
211 |
382
dd4c7e82b4be
removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
212 |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
213 void OrthancApiClient::GetBinaryAsync( |
422
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
214 const std::string& uri, |
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
215 const std::string& contentType, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
216 OrthancStone::MessageHandler<BinaryResponseReadyMessage>* successCallback, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
217 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback, |
422
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
218 Orthanc::IDynamicObject* payload) |
382
dd4c7e82b4be
removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
219 { |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
220 IWebService::HttpHeaders headers; |
382
dd4c7e82b4be
removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
221 headers["Accept"] = contentType; |
dd4c7e82b4be
removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
222 GetBinaryAsync(uri, headers, successCallback, failureCallback, payload); |
dd4c7e82b4be
removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
223 } |
dd4c7e82b4be
removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
224 |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
225 void OrthancApiClient::GetBinaryAsync( |
422
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
226 const std::string& uri, |
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
227 const IWebService::HttpHeaders& headers, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
228 OrthancStone::MessageHandler<BinaryResponseReadyMessage>* successCallback, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
229 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback, |
422
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
230 Orthanc::IDynamicObject* payload) |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
231 { |
422
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
232 // printf("GET [%s] [%s]\n", baseUrl_.c_str(), uri.c_str()); |
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
233 |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
234 web_.GetAsync(baseUrl_ + uri, headers, |
874
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
235 new WebServicePayload(IObservable::GetBroker(), successCallback, failureCallback, payload), |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
236 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestSuccessMessage> |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
237 (*this, &OrthancApiClient::NotifyHttpSuccess), |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
238 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestErrorMessage> |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
239 (*this, &OrthancApiClient::NotifyHttpError)); |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
240 } |
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
241 |
382
dd4c7e82b4be
removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
242 |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
243 void OrthancApiClient::PostBinaryAsyncExpectJson( |
422
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
244 const std::string& uri, |
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
245 const std::string& body, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
246 OrthancStone::MessageHandler<JsonResponseReadyMessage>* successCallback, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
247 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback, |
422
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
248 Orthanc::IDynamicObject* payload) |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
249 { |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
250 web_.PostAsync(baseUrl_ + uri, IWebService::HttpHeaders(), body, |
874
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
251 new WebServicePayload(IObservable::GetBroker(), successCallback, failureCallback, payload), |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
252 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestSuccessMessage> |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
253 (*this, &OrthancApiClient::NotifyHttpSuccess), |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
254 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestErrorMessage> |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
255 (*this, &OrthancApiClient::NotifyHttpError)); |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
256 |
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
257 } |
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
258 |
424
bb573a52fc63
allow POST messages with success and failure handlers
am@osimis.io
parents:
422
diff
changeset
|
259 void OrthancApiClient::PostBinaryAsync( |
bb573a52fc63
allow POST messages with success and failure handlers
am@osimis.io
parents:
422
diff
changeset
|
260 const std::string& uri, |
bb573a52fc63
allow POST messages with success and failure handlers
am@osimis.io
parents:
422
diff
changeset
|
261 const std::string& body) |
bb573a52fc63
allow POST messages with success and failure handlers
am@osimis.io
parents:
422
diff
changeset
|
262 { |
bb573a52fc63
allow POST messages with success and failure handlers
am@osimis.io
parents:
422
diff
changeset
|
263 web_.PostAsync(baseUrl_ + uri, IWebService::HttpHeaders(), body, NULL, NULL, NULL); |
bb573a52fc63
allow POST messages with success and failure handlers
am@osimis.io
parents:
422
diff
changeset
|
264 } |
bb573a52fc63
allow POST messages with success and failure handlers
am@osimis.io
parents:
422
diff
changeset
|
265 |
502 | 266 void OrthancApiClient::PostBinaryAsync( |
267 const std::string& uri, | |
268 const std::string& body, | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
269 OrthancStone::MessageHandler<EmptyResponseReadyMessage>* successCallback, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
270 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback, |
502 | 271 Orthanc::IDynamicObject* payload /* takes ownership */) |
272 { | |
273 web_.PostAsync(baseUrl_ + uri, IWebService::HttpHeaders(), body, | |
874
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
274 new WebServicePayload(IObservable::GetBroker(), successCallback, failureCallback, payload), |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
275 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestSuccessMessage> |
502 | 276 (*this, &OrthancApiClient::NotifyHttpSuccess), |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
277 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestErrorMessage> |
502 | 278 (*this, &OrthancApiClient::NotifyHttpError)); |
279 } | |
280 | |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
281 void OrthancApiClient::PostJsonAsyncExpectJson( |
422
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
282 const std::string& uri, |
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
283 const Json::Value& data, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
284 OrthancStone::MessageHandler<JsonResponseReadyMessage>* successCallback, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
285 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback, |
422
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
286 Orthanc::IDynamicObject* payload) |
309 | 287 { |
288 std::string body; | |
792
4fe4b221a31f
deprecating MessagingToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
289 MessagingToolbox::JsonToString(body, data); |
309 | 290 return PostBinaryAsyncExpectJson(uri, body, successCallback, failureCallback, payload); |
291 } | |
292 | |
424
bb573a52fc63
allow POST messages with success and failure handlers
am@osimis.io
parents:
422
diff
changeset
|
293 void OrthancApiClient::PostJsonAsync( |
bb573a52fc63
allow POST messages with success and failure handlers
am@osimis.io
parents:
422
diff
changeset
|
294 const std::string& uri, |
bb573a52fc63
allow POST messages with success and failure handlers
am@osimis.io
parents:
422
diff
changeset
|
295 const Json::Value& data) |
bb573a52fc63
allow POST messages with success and failure handlers
am@osimis.io
parents:
422
diff
changeset
|
296 { |
bb573a52fc63
allow POST messages with success and failure handlers
am@osimis.io
parents:
422
diff
changeset
|
297 std::string body; |
792
4fe4b221a31f
deprecating MessagingToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
298 MessagingToolbox::JsonToString(body, data); |
424
bb573a52fc63
allow POST messages with success and failure handlers
am@osimis.io
parents:
422
diff
changeset
|
299 return PostBinaryAsync(uri, body); |
bb573a52fc63
allow POST messages with success and failure handlers
am@osimis.io
parents:
422
diff
changeset
|
300 } |
bb573a52fc63
allow POST messages with success and failure handlers
am@osimis.io
parents:
422
diff
changeset
|
301 |
502 | 302 void OrthancApiClient::PostJsonAsync( |
303 const std::string& uri, | |
304 const Json::Value& data, | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
305 OrthancStone::MessageHandler<EmptyResponseReadyMessage>* successCallback, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
306 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback, |
502 | 307 Orthanc::IDynamicObject* payload /* takes ownership */) |
308 { | |
309 std::string body; | |
792
4fe4b221a31f
deprecating MessagingToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
310 MessagingToolbox::JsonToString(body, data); |
502 | 311 return PostBinaryAsync(uri, body, successCallback, failureCallback, payload); |
312 } | |
313 | |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
314 void OrthancApiClient::DeleteAsync( |
422
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
315 const std::string& uri, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
316 OrthancStone::MessageHandler<EmptyResponseReadyMessage>* successCallback, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
317 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback, |
422
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
318 Orthanc::IDynamicObject* payload) |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
319 { |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
320 web_.DeleteAsync(baseUrl_ + uri, IWebService::HttpHeaders(), |
874
debb70fa10b5
correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents:
792
diff
changeset
|
321 new WebServicePayload(IObservable::GetBroker(), successCallback, failureCallback, payload), |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
322 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestSuccessMessage> |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
323 (*this, &OrthancApiClient::NotifyHttpSuccess), |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
502
diff
changeset
|
324 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestErrorMessage> |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
325 (*this, &OrthancApiClient::NotifyHttpError)); |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
326 } |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
327 |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
328 |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
329 void OrthancApiClient::NotifyHttpSuccess(const IWebService::HttpRequestSuccessMessage& message) |
382
dd4c7e82b4be
removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
330 { |
383
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
331 if (message.HasPayload()) |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
332 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
333 dynamic_cast<const WebServicePayload&>(message.GetPayload()).HandleSuccess(message); |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
334 } |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
335 else |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
336 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
337 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
338 } |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
339 } |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
340 |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
341 void OrthancApiClient::NotifyHttpError(const IWebService::HttpRequestErrorMessage& message) |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
342 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
343 if (message.HasPayload()) |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
344 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
345 dynamic_cast<const WebServicePayload&>(message.GetPayload()).HandleFailure(message); |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
346 } |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
347 else |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
348 { |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
349 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
939f626eb6d7
removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
350 } |
422
4fe42ae3653a
introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents:
418
diff
changeset
|
351 } |
270 | 352 } |