annotate Platforms/Generic/OracleWebService.h @ 1369:aadc374bc006 broker

CMake json config files for msvc builds
author Benjamin Golinvaux <bgo@osimis.io>
date Sat, 18 Apr 2020 14:45:38 +0200
parents 7ec8fea061b9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1270
2d8ab34c8c91 upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
309
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 301
diff changeset
16 *
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #pragma once
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
732
c35e98d22764 move Deprecated classes to a separate folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 726
diff changeset
24 #include "../../Framework/Deprecated/Toolbox/BaseWebService.h"
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "Oracle.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "WebServiceGetCommand.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
87376a645ee1 renaming
am@osimis.io
parents: 288
diff changeset
29 #include "../../Applications/Generic/NativeStoneApplicationContext.h"
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 440
diff changeset
31 namespace Deprecated
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
288
8c8da145fefa renamings and doc
am@osimis.io
parents: 274
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 private:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 Oracle& oracle_;
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 440
diff changeset
40 OrthancStone::NativeStoneApplicationContext& context_;
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 Orthanc::WebServiceParameters parameters_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 public:
1066
b537002f83a9 removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
46 OracleWebService(Oracle& oracle,
271
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 257
diff changeset
47 const Orthanc::WebServiceParameters& parameters,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 440
diff changeset
48 OrthancStone::NativeStoneApplicationContext& context) :
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 oracle_(oracle),
271
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 257
diff changeset
50 context_(context),
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 parameters_(parameters)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
55 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
56 const HttpHeaders& headers,
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
57 const std::string& body,
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
58 Orthanc::IDynamicObject* payload, // takes ownership
1222
21c2b0eee53c deprecating MessageHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
59 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback, // takes ownership
21c2b0eee53c deprecating MessageHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
60 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL, // takes ownership
309
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 301
diff changeset
61 unsigned int timeoutInSeconds = 60)
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 {
1066
b537002f83a9 removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
63 oracle_.Submit(new WebServicePostCommand(successCallback, failureCallback, parameters_, uri, headers, timeoutInSeconds, body, payload, context_));
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 }
242
092db46c6291 improved SDL/Wasm unification
am@osimis.io
parents: 135
diff changeset
65
315
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
66 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
67 const HttpHeaders& headers,
315
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
68 Orthanc::IDynamicObject* payload,
1222
21c2b0eee53c deprecating MessageHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
69 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback,
21c2b0eee53c deprecating MessageHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
70 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL,
315
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
71 unsigned int timeoutInSeconds = 60)
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
72 {
1066
b537002f83a9 removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
73 oracle_.Submit(new WebServiceDeleteCommand(successCallback, failureCallback, parameters_, uri, headers, timeoutInSeconds, payload, context_));
315
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
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 417
diff changeset
76 protected:
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 417
diff changeset
77 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
78 const HttpHeaders& headers,
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 417
diff changeset
79 Orthanc::IDynamicObject* payload, // takes ownership
1222
21c2b0eee53c deprecating MessageHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
80 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback, // takes ownership
21c2b0eee53c deprecating MessageHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
81 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL,// takes ownership
434
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 417
diff changeset
82 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
83 {
1066
b537002f83a9 removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
84 oracle_.Submit(new WebServiceGetCommand(successCallback, failureCallback, parameters_, uri, headers, timeoutInSeconds, payload, context_));
434
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
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 417
diff changeset
87 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
88 Orthanc::IDynamicObject* payload, // takes ownership
1222
21c2b0eee53c deprecating MessageHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
89 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback);
434
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 417
diff changeset
90
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 }