annotate Framework/Toolbox/OrthancApiClient.cpp @ 625:2eeb5857eb43

DicomInstanceParameters
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 May 2019 18:11:52 +0200
parents 3ae7563b4fe1
children 4f2416d519b4
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
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
23 #include "MessagingToolbox.h"
309
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 301
diff changeset
24 #include "Framework/Toolbox/MessagingToolbox.h"
270
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
25
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
26 #include <Core/OrthancException.h>
270
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
27
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
28 namespace OrthancStone
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
29 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
30 const Orthanc::IDynamicObject& OrthancApiClient::JsonResponseReadyMessage::GetPayload() const
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
31 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
32 if (HasPayload())
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
33 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
34 return *payload_;
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
35 }
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
36 else
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
37 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
38 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
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
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
43 const Orthanc::IDynamicObject& OrthancApiClient::BinaryResponseReadyMessage::GetPayload() const
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
44 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
45 if (HasPayload())
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
46 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
47 return *payload_;
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
48 }
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
49 else
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
50 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
51 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
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
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
56 const Orthanc::IDynamicObject& OrthancApiClient::EmptyResponseReadyMessage::GetPayload() const
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
57 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
58 if (HasPayload())
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
59 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
60 return *payload_;
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
61 }
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
62 else
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
63 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
64 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
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
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
68
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
69 class OrthancApiClient::WebServicePayload : public Orthanc::IDynamicObject
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
70 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
71 private:
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
72 std::auto_ptr< MessageHandler<EmptyResponseReadyMessage> > emptyHandler_;
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
73 std::auto_ptr< MessageHandler<JsonResponseReadyMessage> > jsonHandler_;
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
74 std::auto_ptr< MessageHandler<BinaryResponseReadyMessage> > binaryHandler_;
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
75 std::auto_ptr< MessageHandler<IWebService::HttpRequestErrorMessage> > failureHandler_;
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
76 std::auto_ptr< Orthanc::IDynamicObject > userPayload_;
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 void NotifyConversionError(const IWebService::HttpRequestSuccessMessage& message) const
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 if (failureHandler_.get() != NULL)
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
81 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
82 failureHandler_->Apply(IWebService::HttpRequestErrorMessage
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
83 (message.GetUri(), userPayload_.get()));
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
84 }
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
85 }
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
86
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
87 public:
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
88 WebServicePayload(MessageHandler<EmptyResponseReadyMessage>* handler,
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
89 MessageHandler<IWebService::HttpRequestErrorMessage>* failureHandler,
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
90 Orthanc::IDynamicObject* userPayload) :
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
91 emptyHandler_(handler),
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
92 failureHandler_(failureHandler),
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
93 userPayload_(userPayload)
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
94 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
95 if (handler == NULL)
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
96 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
97 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
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 }
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
100
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
101 WebServicePayload(MessageHandler<BinaryResponseReadyMessage>* handler,
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
102 MessageHandler<IWebService::HttpRequestErrorMessage>* failureHandler,
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
103 Orthanc::IDynamicObject* userPayload) :
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
104 binaryHandler_(handler),
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
105 failureHandler_(failureHandler),
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
106 userPayload_(userPayload)
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
107 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
108 if (handler == NULL)
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
109 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
110 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
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 }
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
113
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
114 WebServicePayload(MessageHandler<JsonResponseReadyMessage>* handler,
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
115 MessageHandler<IWebService::HttpRequestErrorMessage>* failureHandler,
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
116 Orthanc::IDynamicObject* userPayload) :
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
117 jsonHandler_(handler),
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
118 failureHandler_(failureHandler),
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
119 userPayload_(userPayload)
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
120 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
121 if (handler == NULL)
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
122 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
123 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
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
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
127 void HandleSuccess(const IWebService::HttpRequestSuccessMessage& message) const
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
128 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
129 if (emptyHandler_.get() != NULL)
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
130 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
131 emptyHandler_->Apply(OrthancApiClient::EmptyResponseReadyMessage
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
132 (message.GetUri(), userPayload_.get()));
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
133 }
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
134 else if (binaryHandler_.get() != NULL)
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 binaryHandler_->Apply(OrthancApiClient::BinaryResponseReadyMessage
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
137 (message.GetUri(), message.GetAnswer(),
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
138 message.GetAnswerSize(), userPayload_.get()));
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
139 }
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
140 else if (jsonHandler_.get() != NULL)
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
141 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
142 Json::Value response;
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
143 if (MessagingToolbox::ParseJson(response, message.GetAnswer(), message.GetAnswerSize()))
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 jsonHandler_->Apply(OrthancApiClient::JsonResponseReadyMessage
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
146 (message.GetUri(), response, userPayload_.get()));
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
147 }
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
148 else
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
149 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
150 NotifyConversionError(message);
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 }
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
153 else
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
154 {
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
155 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
156 }
422
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
157 }
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
158
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
159 void HandleFailure(const IWebService::HttpRequestErrorMessage& message) const
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 if (failureHandler_.get() != NULL)
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 failureHandler_->Apply(IWebService::HttpRequestErrorMessage
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
164 (message.GetUri(), userPayload_.get()));
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
165 }
422
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
166 }
383
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
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
169
382
dd4c7e82b4be removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
170 OrthancApiClient::OrthancApiClient(MessageBroker& broker,
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
171 IWebService& web,
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
172 const std::string& baseUrl) :
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
173 IObservable(broker),
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
174 IObserver(broker),
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
175 web_(web),
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
176 baseUrl_(baseUrl)
270
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
177 {
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
178 }
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
179
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
180
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
181 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
182 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
183 MessageHandler<JsonResponseReadyMessage>* successCallback,
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
184 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback,
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
185 Orthanc::IDynamicObject* payload)
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
186 {
422
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
187 IWebService::HttpHeaders emptyHeaders;
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
188 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
189 emptyHeaders,
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
190 new WebServicePayload(successCallback, failureCallback, payload),
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
191 new Callable<OrthancApiClient, IWebService::HttpRequestSuccessMessage>
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
192 (*this, &OrthancApiClient::NotifyHttpSuccess),
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
193 new Callable<OrthancApiClient, IWebService::HttpRequestErrorMessage>
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
194 (*this, &OrthancApiClient::NotifyHttpError));
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 271
diff changeset
195 }
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 271
diff changeset
196
382
dd4c7e82b4be removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
197
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
198 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
199 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
200 const std::string& contentType,
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
201 MessageHandler<BinaryResponseReadyMessage>* successCallback,
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
202 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback,
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
203 Orthanc::IDynamicObject* payload)
382
dd4c7e82b4be removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
204 {
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
205 IWebService::HttpHeaders headers;
382
dd4c7e82b4be removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
206 headers["Accept"] = contentType;
dd4c7e82b4be removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
207 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
208 }
dd4c7e82b4be removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
209
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
210 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
211 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
212 const IWebService::HttpHeaders& headers,
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
213 MessageHandler<BinaryResponseReadyMessage>* successCallback,
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
214 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback,
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
215 Orthanc::IDynamicObject* payload)
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
216 {
422
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
217 // 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
218
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
219 web_.GetAsync(baseUrl_ + uri, headers,
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
220 new WebServicePayload(successCallback, failureCallback, payload),
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
221 new Callable<OrthancApiClient, IWebService::HttpRequestSuccessMessage>
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
222 (*this, &OrthancApiClient::NotifyHttpSuccess),
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
223 new Callable<OrthancApiClient, IWebService::HttpRequestErrorMessage>
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
224 (*this, &OrthancApiClient::NotifyHttpError));
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
225 }
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
226
382
dd4c7e82b4be removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
227
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
228 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
229 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
230 const std::string& body,
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
231 MessageHandler<JsonResponseReadyMessage>* successCallback,
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
232 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback,
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
233 Orthanc::IDynamicObject* payload)
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
234 {
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
235 web_.PostAsync(baseUrl_ + uri, IWebService::HttpHeaders(), body,
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
236 new WebServicePayload(successCallback, failureCallback, payload),
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
237 new Callable<OrthancApiClient, IWebService::HttpRequestSuccessMessage>
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
238 (*this, &OrthancApiClient::NotifyHttpSuccess),
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
239 new Callable<OrthancApiClient, IWebService::HttpRequestErrorMessage>
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
240 (*this, &OrthancApiClient::NotifyHttpError));
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
241
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
242 }
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
243
424
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
244 void OrthancApiClient::PostBinaryAsync(
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
245 const std::string& uri,
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
246 const std::string& body)
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
247 {
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
248 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
249 }
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
250
502
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
251 void OrthancApiClient::PostBinaryAsync(
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
252 const std::string& uri,
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
253 const std::string& body,
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
254 MessageHandler<EmptyResponseReadyMessage>* successCallback,
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
255 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback,
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
256 Orthanc::IDynamicObject* payload /* takes ownership */)
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
257 {
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
258 web_.PostAsync(baseUrl_ + uri, IWebService::HttpHeaders(), body,
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
259 new WebServicePayload(successCallback, failureCallback, payload),
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
260 new Callable<OrthancApiClient, IWebService::HttpRequestSuccessMessage>
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
261 (*this, &OrthancApiClient::NotifyHttpSuccess),
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
262 new Callable<OrthancApiClient, IWebService::HttpRequestErrorMessage>
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
263 (*this, &OrthancApiClient::NotifyHttpError));
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
264 }
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
265
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
266 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
267 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
268 const Json::Value& data,
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
269 MessageHandler<JsonResponseReadyMessage>* successCallback,
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
270 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback,
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
271 Orthanc::IDynamicObject* payload)
309
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 std::string body;
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 301
diff changeset
274 MessagingToolbox::JsonToString(body, data);
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 301
diff changeset
275 return PostBinaryAsyncExpectJson(uri, body, successCallback, failureCallback, payload);
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 301
diff changeset
276 }
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 301
diff changeset
277
424
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
278 void OrthancApiClient::PostJsonAsync(
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
279 const std::string& uri,
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
280 const Json::Value& data)
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 std::string body;
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
283 MessagingToolbox::JsonToString(body, data);
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
284 return PostBinaryAsync(uri, body);
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
285 }
bb573a52fc63 allow POST messages with success and failure handlers
am@osimis.io
parents: 422
diff changeset
286
502
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
287 void OrthancApiClient::PostJsonAsync(
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
288 const std::string& uri,
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
289 const Json::Value& data,
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
290 MessageHandler<EmptyResponseReadyMessage>* successCallback,
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
291 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback,
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
292 Orthanc::IDynamicObject* payload /* takes ownership */)
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
293 {
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
294 std::string body;
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
295 MessagingToolbox::JsonToString(body, data);
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
296 return PostBinaryAsync(uri, body, successCallback, failureCallback, payload);
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
297 }
3ae7563b4fe1 more orthancApiClient overloads
amazy
parents: 440
diff changeset
298
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
299 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
300 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
301 MessageHandler<EmptyResponseReadyMessage>* successCallback,
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
302 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback,
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
303 Orthanc::IDynamicObject* payload)
315
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
304 {
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
305 web_.DeleteAsync(baseUrl_ + uri, IWebService::HttpHeaders(),
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
306 new WebServicePayload(successCallback, failureCallback, payload),
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
307 new Callable<OrthancApiClient, IWebService::HttpRequestSuccessMessage>
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
308 (*this, &OrthancApiClient::NotifyHttpSuccess),
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
309 new Callable<OrthancApiClient, IWebService::HttpRequestErrorMessage>
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 383
diff changeset
310 (*this, &OrthancApiClient::NotifyHttpError));
315
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
311 }
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
312
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
313
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
314 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
315 {
383
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
316 if (message.HasPayload())
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 dynamic_cast<const WebServicePayload&>(message.GetPayload()).HandleSuccess(message);
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 else
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
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 }
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 void OrthancApiClient::NotifyHttpError(const IWebService::HttpRequestErrorMessage& 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 if (message.HasPayload())
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 dynamic_cast<const WebServicePayload&>(message.GetPayload()).HandleFailure(message);
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 else
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
939f626eb6d7 removing converters in OrthancApiClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 382
diff changeset
335 }
422
4fe42ae3653a introduced a basic cache at OrthancApiClient level so it can be used with the RadiographyScene
am@osimis.io
parents: 418
diff changeset
336 }
270
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
337 }