Mercurial > hg > orthanc-wsi
comparison ViewerPlugin/OrthancPluginConnection.cpp @ 196:b0bd22077cd8
sharing code with orthanc-stone
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 01 Jul 2020 17:57:38 +0200 |
parents | Framework/Inputs/Orthanc/OrthancPluginConnection.cpp@e57e6ca5303d |
children | 1e864138f0da |
comparison
equal
deleted
inserted
replaced
195:fda17c92d784 | 196:b0bd22077cd8 |
---|---|
1 /** | |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
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 #include "OrthancPluginConnection.h" | |
23 | |
24 #include "../../../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" | |
25 | |
26 #include <OrthancException.h> | |
27 | |
28 namespace OrthancWSI | |
29 { | |
30 void OrthancPluginConnection::RestApiGet(std::string& result, | |
31 const std::string& uri) | |
32 { | |
33 OrthancPlugins::MemoryBuffer buffer; | |
34 | |
35 if (buffer.RestApiGet(uri, false)) | |
36 { | |
37 buffer.ToString(result); | |
38 } | |
39 else | |
40 { | |
41 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); | |
42 } | |
43 } | |
44 | |
45 | |
46 void OrthancPluginConnection::RestApiPost(std::string& result, | |
47 const std::string& uri, | |
48 const std::string& body) | |
49 { | |
50 OrthancPlugins::MemoryBuffer buffer; | |
51 | |
52 if (buffer.RestApiPost(uri, body.c_str(), body.size(), false)) | |
53 { | |
54 buffer.ToString(result); | |
55 } | |
56 else | |
57 { | |
58 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); | |
59 } | |
60 } | |
61 | |
62 | |
63 void OrthancPluginConnection::RestApiPut(std::string& result, | |
64 const std::string& uri, | |
65 const std::string& body) | |
66 { | |
67 OrthancPlugins::MemoryBuffer buffer; | |
68 | |
69 if (buffer.RestApiPut(uri, body.c_str(), body.size(), false)) | |
70 { | |
71 buffer.ToString(result); | |
72 } | |
73 else | |
74 { | |
75 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); | |
76 } | |
77 } | |
78 | |
79 | |
80 void OrthancPluginConnection::RestApiDelete(const std::string& uri) | |
81 { | |
82 OrthancPlugins::MemoryBuffer buffer; | |
83 | |
84 if (!::OrthancPlugins::RestApiDelete(uri, false)) | |
85 { | |
86 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); | |
87 } | |
88 } | |
89 } |