annotate Framework/Deprecated/Toolbox/OrthancApiClient.cpp @ 1271:0ca50d275b9a broker

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