Mercurial > hg > orthanc-stone
annotate Platforms/Generic/OracleWebService.h @ 545:e1ba16436d59 dev
set events passive again
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Fri, 29 Mar 2019 15:21:33 +0100 |
parents | a750f11892ec |
children | 4f2416d519b4 |
rev | line source |
---|---|
80 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
80 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
309 | 16 * |
80 | 17 * You should have received a copy of the GNU Affero General Public License |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
434
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
24 #include "../../Framework/Toolbox/BaseWebService.h" |
80 | 25 #include "Oracle.h" |
26 #include "WebServiceGetCommand.h" | |
27 #include "WebServicePostCommand.h" | |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
28 #include "WebServiceDeleteCommand.h" |
291 | 29 #include "../../Applications/Generic/NativeStoneApplicationContext.h" |
80 | 30 |
31 namespace OrthancStone | |
32 { | |
288 | 33 // The OracleWebService performs HTTP requests in a native environment. |
295
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
291
diff
changeset
|
34 // It uses a thread pool to handle multiple HTTP requests in a same time. |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
291
diff
changeset
|
35 // It works asynchronously to mimick the behaviour of the WebService running in a WASM environment. |
434
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
36 class OracleWebService : public BaseWebService |
80 | 37 { |
38 private: | |
39 Oracle& oracle_; | |
291 | 40 NativeStoneApplicationContext& context_; |
80 | 41 Orthanc::WebServiceParameters parameters_; |
42 | |
434
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
43 class WebServiceCachedGetCommand; |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
44 |
80 | 45 public: |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
244
diff
changeset
|
46 OracleWebService(MessageBroker& broker, |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
244
diff
changeset
|
47 Oracle& oracle, |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
257
diff
changeset
|
48 const Orthanc::WebServiceParameters& parameters, |
291 | 49 NativeStoneApplicationContext& context) : |
434
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
50 BaseWebService(broker), |
80 | 51 oracle_(oracle), |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
257
diff
changeset
|
52 context_(context), |
80 | 53 parameters_(parameters) |
54 { | |
55 } | |
56 | |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
57 virtual void PostAsync(const std::string& uri, |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
58 const HttpHeaders& headers, |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
59 const std::string& body, |
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
60 Orthanc::IDynamicObject* payload, // takes ownership |
301 | 61 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback, // takes ownership |
309 | 62 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL, // takes ownership |
63 unsigned int timeoutInSeconds = 60) | |
80 | 64 { |
434
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
65 oracle_.Submit(new WebServicePostCommand(GetBroker(), successCallback, failureCallback, parameters_, uri, headers, timeoutInSeconds, body, payload, context_)); |
80 | 66 } |
242 | 67 |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
68 virtual void DeleteAsync(const std::string& uri, |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
69 const HttpHeaders& headers, |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
70 Orthanc::IDynamicObject* payload, |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
71 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback, |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
72 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL, |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
73 unsigned int timeoutInSeconds = 60) |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
74 { |
434
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
75 oracle_.Submit(new WebServiceDeleteCommand(GetBroker(), successCallback, failureCallback, parameters_, uri, headers, timeoutInSeconds, payload, context_)); |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
76 } |
434
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
77 |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
78 protected: |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
79 virtual void GetAsyncInternal(const std::string& uri, |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
80 const HttpHeaders& headers, |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
81 Orthanc::IDynamicObject* payload, // takes ownership |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
82 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback, // takes ownership |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
83 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL,// takes ownership |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
84 unsigned int timeoutInSeconds = 60) |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
85 { |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
86 oracle_.Submit(new WebServiceGetCommand(GetBroker(), successCallback, failureCallback, parameters_, uri, headers, timeoutInSeconds, payload, context_)); |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
87 } |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
88 |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
89 virtual void NotifyHttpSuccessLater(boost::shared_ptr<BaseWebService::CachedHttpRequestSuccessMessage> cachedHttpMessage, |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
90 Orthanc::IDynamicObject* payload, // takes ownership |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
91 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback); |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
92 |
80 | 93 }; |
94 } |