Mercurial > hg > orthanc-stone
comparison Deprecated/Platforms/Generic/OracleWebService.h @ 1400:419d0320c344
moved Platforms into Deprecated
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Wed, 29 Apr 2020 20:45:14 +0200 |
parents | Platforms/Generic/OracleWebService.h@7ec8fea061b9 |
children |
comparison
equal
deleted
inserted
replaced
1399:ff8d2e46ac63 | 1400:419d0320c344 |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium | |
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. | |
16 * | |
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 | |
24 #include "../../Framework/Deprecated/Toolbox/BaseWebService.h" | |
25 #include "Oracle.h" | |
26 #include "WebServiceGetCommand.h" | |
27 #include "WebServicePostCommand.h" | |
28 #include "WebServiceDeleteCommand.h" | |
29 #include "../../Applications/Generic/NativeStoneApplicationContext.h" | |
30 | |
31 namespace Deprecated | |
32 { | |
33 // The OracleWebService performs HTTP requests in a native environment. | |
34 // It uses a thread pool to handle multiple HTTP requests in a same time. | |
35 // It works asynchronously to mimick the behaviour of the WebService running in a WASM environment. | |
36 class OracleWebService : public BaseWebService | |
37 { | |
38 private: | |
39 Oracle& oracle_; | |
40 OrthancStone::NativeStoneApplicationContext& context_; | |
41 Orthanc::WebServiceParameters parameters_; | |
42 | |
43 class WebServiceCachedGetCommand; | |
44 | |
45 public: | |
46 OracleWebService(Oracle& oracle, | |
47 const Orthanc::WebServiceParameters& parameters, | |
48 OrthancStone::NativeStoneApplicationContext& context) : | |
49 oracle_(oracle), | |
50 context_(context), | |
51 parameters_(parameters) | |
52 { | |
53 } | |
54 | |
55 virtual void PostAsync(const std::string& uri, | |
56 const HttpHeaders& headers, | |
57 const std::string& body, | |
58 Orthanc::IDynamicObject* payload, // takes ownership | |
59 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback, // takes ownership | |
60 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL, // takes ownership | |
61 unsigned int timeoutInSeconds = 60) | |
62 { | |
63 oracle_.Submit(new WebServicePostCommand(successCallback, failureCallback, parameters_, uri, headers, timeoutInSeconds, body, payload, context_)); | |
64 } | |
65 | |
66 virtual void DeleteAsync(const std::string& uri, | |
67 const HttpHeaders& headers, | |
68 Orthanc::IDynamicObject* payload, | |
69 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback, | |
70 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL, | |
71 unsigned int timeoutInSeconds = 60) | |
72 { | |
73 oracle_.Submit(new WebServiceDeleteCommand(successCallback, failureCallback, parameters_, uri, headers, timeoutInSeconds, payload, context_)); | |
74 } | |
75 | |
76 protected: | |
77 virtual void GetAsyncInternal(const std::string& uri, | |
78 const HttpHeaders& headers, | |
79 Orthanc::IDynamicObject* payload, // takes ownership | |
80 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback, // takes ownership | |
81 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL,// takes ownership | |
82 unsigned int timeoutInSeconds = 60) | |
83 { | |
84 oracle_.Submit(new WebServiceGetCommand(successCallback, failureCallback, parameters_, uri, headers, timeoutInSeconds, payload, context_)); | |
85 } | |
86 | |
87 virtual void NotifyHttpSuccessLater(boost::shared_ptr<BaseWebService::CachedHttpRequestSuccessMessage> cachedHttpMessage, | |
88 Orthanc::IDynamicObject* payload, // takes ownership | |
89 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback); | |
90 | |
91 }; | |
92 } |