annotate Framework/Deprecated/Toolbox/OrthancApiClient.cpp @ 1060:e146743f6cdc broker

removing file MessageBroker.h
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 11 Oct 2019 17:20:41 +0200
parents 861c080ef47b
children b537002f83a9
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
439
b70e9be013e4 preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 418
diff changeset
5 * Copyright (C) 2017-2019 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:
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_;
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:
1060
e146743f6cdc removing file MessageBroker.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 940
diff changeset
86 WebServicePayload(OrthancStone::MessageHandler<EmptyResponseReadyMessage>* handler,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
87 OrthancStone::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
1060
e146743f6cdc removing file MessageBroker.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 940
diff changeset
100 WebServicePayload(OrthancStone::MessageHandler<BinaryResponseReadyMessage>* handler,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
101 OrthancStone::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
1060
e146743f6cdc removing file MessageBroker.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 940
diff changeset
113 WebServicePayload(OrthancStone::MessageHandler<JsonResponseReadyMessage>* handler,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
114 OrthancStone::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 {
874
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
130 if (broker_.IsActive(*(emptyHandler_->GetObserver())))
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
131 {
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
132 emptyHandler_->Apply(OrthancApiClient::EmptyResponseReadyMessage
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
133 (message.GetUri(), userPayload_.get()));
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
134 }
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
135 }
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
136 else if (binaryHandler_.get() != NULL)
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
137 {
874
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
138 if (broker_.IsActive(*(binaryHandler_->GetObserver())))
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
139 {
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
140 binaryHandler_->Apply(OrthancApiClient::BinaryResponseReadyMessage
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
141 (message.GetUri(), message.GetAnswer(),
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
142 message.GetAnswerSize(), userPayload_.get()));
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
143 }
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
144 }
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
145 else if (jsonHandler_.get() != NULL)
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
146 {
874
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
147 if (broker_.IsActive(*(jsonHandler_->GetObserver())))
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
148 {
874
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
149 Json::Value response;
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
150 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
151 {
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
152 jsonHandler_->Apply(OrthancApiClient::JsonResponseReadyMessage
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
153 (message.GetUri(), response, userPayload_.get()));
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
154 }
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
155 else
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
156 {
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
157 NotifyConversionError(message);
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
158 }
383
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 }
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
161 else
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
162 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
163 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
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 void HandleFailure(const IWebService::HttpRequestErrorMessage& message) const
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
168 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
169 if (failureHandler_.get() != NULL)
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
170 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
171 failureHandler_->Apply(IWebService::HttpRequestErrorMessage
940
861c080ef47b handling httpStatus in WebService error messages
Alain Mazy <alain@mazy.be>
parents: 874
diff changeset
172 (message.GetUri(), message.GetHttpStatus(), userPayload_.get()));
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
173 }
422
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
174 }
383
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
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
177
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
178 OrthancApiClient::OrthancApiClient(OrthancStone::MessageBroker& broker,
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
179 IWebService& web,
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
180 const std::string& baseUrl) :
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
181 IObservable(broker),
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
182 IObserver(broker),
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
183 web_(web),
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
184 baseUrl_(baseUrl)
270
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
185 {
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
186 }
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
187
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
188
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
189 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
190 const std::string& uri,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
191 OrthancStone::MessageHandler<JsonResponseReadyMessage>* successCallback,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
192 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
193 Orthanc::IDynamicObject* payload)
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
194 {
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 IWebService::HttpHeaders emptyHeaders;
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
196 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
197 emptyHeaders,
874
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
198 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
199 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestSuccessMessage>
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
200 (*this, &OrthancApiClient::NotifyHttpSuccess),
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
201 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestErrorMessage>
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
202 (*this, &OrthancApiClient::NotifyHttpError));
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 271
diff changeset
203 }
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 271
diff changeset
204
382
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 std::string& contentType,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
209 OrthancStone::MessageHandler<BinaryResponseReadyMessage>* successCallback,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
210 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
211 Orthanc::IDynamicObject* payload)
382
dd4c7e82b4be removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
212 {
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
213 IWebService::HttpHeaders headers;
382
dd4c7e82b4be removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
214 headers["Accept"] = contentType;
dd4c7e82b4be removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
215 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
216 }
dd4c7e82b4be removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
217
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
218 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
219 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
220 const IWebService::HttpHeaders& headers,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
221 OrthancStone::MessageHandler<BinaryResponseReadyMessage>* successCallback,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
222 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
223 Orthanc::IDynamicObject* payload)
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
224 {
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 // 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
226
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
227 web_.GetAsync(baseUrl_ + uri, headers,
874
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
228 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
229 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestSuccessMessage>
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
230 (*this, &OrthancApiClient::NotifyHttpSuccess),
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
231 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestErrorMessage>
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
232 (*this, &OrthancApiClient::NotifyHttpError));
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
233 }
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
234
382
dd4c7e82b4be removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
235
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
236 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
237 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
238 const std::string& body,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
239 OrthancStone::MessageHandler<JsonResponseReadyMessage>* successCallback,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
240 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
241 Orthanc::IDynamicObject* payload)
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
242 {
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
243 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
244 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
245 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestSuccessMessage>
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
246 (*this, &OrthancApiClient::NotifyHttpSuccess),
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
247 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestErrorMessage>
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
248 (*this, &OrthancApiClient::NotifyHttpError));
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
249
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
250 }
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
251
424
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
252 void OrthancApiClient::PostBinaryAsync(
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
253 const std::string& uri,
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
254 const std::string& body)
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
255 {
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
256 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
257 }
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
258
502
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
259 void OrthancApiClient::PostBinaryAsync(
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
260 const std::string& uri,
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
261 const std::string& body,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
262 OrthancStone::MessageHandler<EmptyResponseReadyMessage>* successCallback,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
263 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback,
502
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
264 Orthanc::IDynamicObject* payload /* takes ownership */)
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
265 {
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
266 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
267 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
268 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestSuccessMessage>
502
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
269 (*this, &OrthancApiClient::NotifyHttpSuccess),
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
270 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestErrorMessage>
502
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
271 (*this, &OrthancApiClient::NotifyHttpError));
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
272 }
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
273
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
274 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
275 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
276 const Json::Value& data,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
277 OrthancStone::MessageHandler<JsonResponseReadyMessage>* successCallback,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
278 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
279 Orthanc::IDynamicObject* payload)
309
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 301
diff changeset
280 {
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 301
diff changeset
281 std::string body;
792
4fe4b221a31f deprecating MessagingToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
282 MessagingToolbox::JsonToString(body, data);
309
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 301
diff changeset
283 return PostBinaryAsyncExpectJson(uri, body, successCallback, failureCallback, payload);
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 301
diff changeset
284 }
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 301
diff changeset
285
424
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
286 void OrthancApiClient::PostJsonAsync(
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
287 const std::string& uri,
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
288 const Json::Value& data)
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
289 {
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
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);
424
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
292 return PostBinaryAsync(uri, body);
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
293 }
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
294
502
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
295 void OrthancApiClient::PostJsonAsync(
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
296 const std::string& uri,
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
297 const Json::Value& data,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
298 OrthancStone::MessageHandler<EmptyResponseReadyMessage>* successCallback,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
299 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback,
502
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
300 Orthanc::IDynamicObject* payload /* takes ownership */)
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
301 {
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
302 std::string body;
792
4fe4b221a31f deprecating MessagingToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
303 MessagingToolbox::JsonToString(body, data);
502
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
304 return PostBinaryAsync(uri, body, successCallback, failureCallback, payload);
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
305 }
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
306
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
307 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
308 const std::string& uri,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
309 OrthancStone::MessageHandler<EmptyResponseReadyMessage>* successCallback,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
310 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
311 Orthanc::IDynamicObject* payload)
315
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
312 {
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
313 web_.DeleteAsync(baseUrl_ + uri, IWebService::HttpHeaders(),
874
debb70fa10b5 correct handling of deleted observers in OrthancApiClient
Alain Mazy <alain@mazy.be>
parents: 792
diff changeset
314 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
315 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestSuccessMessage>
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
316 (*this, &OrthancApiClient::NotifyHttpSuccess),
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 502
diff changeset
317 new OrthancStone::Callable<OrthancApiClient, IWebService::HttpRequestErrorMessage>
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
318 (*this, &OrthancApiClient::NotifyHttpError));
315
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
319 }
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
320
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
321
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
322 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
323 {
383
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()).HandleSuccess(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 }
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
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
334 void OrthancApiClient::NotifyHttpError(const IWebService::HttpRequestErrorMessage& message)
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
335 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
336 if (message.HasPayload())
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
337 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
338 dynamic_cast<const WebServicePayload&>(message.GetPayload()).HandleFailure(message);
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 else
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
341 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
342 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
343 }
422
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
344 }
270
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
345 }