Mercurial > hg > orthanc
annotate OrthancServer/Sources/OrthancRestApi/OrthancRestChanges.cpp @ 5850:1980354c8113 find-refactoring
add level of interest to StatelessDatabaseOperations::LookupAttachment()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 29 Oct 2024 15:03:32 +0000 |
parents | 8a8756b2dd0b |
children |
rev | line source |
---|---|
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1247
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5432
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * This program is free software: you can redistribute it and/or |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * modify it under the terms of the GNU General Public License as |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * published by the Free Software Foundation, either version 3 of the |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * License, or (at your option) any later version. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * This program is distributed in the hope that it will be useful, but |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * General Public License for more details. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * You should have received a copy of the GNU General Public License |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 **/ |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
24 #include "../PrecompiledHeadersServer.h" |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include "OrthancRestApi.h" |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
27 #include "../ServerContext.h" |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
28 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 namespace Orthanc |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 // Changes API -------------------------------------------------------------- |
5757 | 32 static const unsigned int DEFAULT_LIMIT = 100; |
33 static const int64_t DEFAULT_TO = -1; | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
5553
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
35 static void GetSinceToAndLimit(int64_t& since, |
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
36 int64_t& to, |
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
37 unsigned int& limit, |
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
38 bool& last, |
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
39 const RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 if (call.HasArgument("last")) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 last = true; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 last = false; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 try |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 since = boost::lexical_cast<int64_t>(call.GetArgument("since", "0")); |
5553
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
52 to = boost::lexical_cast<int64_t>(call.GetArgument("to", boost::lexical_cast<std::string>(DEFAULT_TO))); |
3560
28ab86c6730e
"/changes": Allow the "limit" argument to be greater than 100
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
53 limit = boost::lexical_cast<unsigned int>(call.GetArgument("limit", boost::lexical_cast<std::string>(DEFAULT_LIMIT))); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 } |
2836
7133ad478eea
fix Debian warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
55 catch (boost::bad_lexical_cast&) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 { |
3560
28ab86c6730e
"/changes": Allow the "limit" argument to be greater than 100
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
57 since = 0; |
5553
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
58 to = DEFAULT_TO; |
3560
28ab86c6730e
"/changes": Allow the "limit" argument to be greater than 100
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
59 limit = DEFAULT_LIMIT; |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
974 | 64 static void GetChanges(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 { |
4403 | 66 if (call.IsDocumentation()) |
67 { | |
68 call.GetDocumentation() | |
69 .SetTag("Tracking changes") | |
70 .SetSummary("List changes") | |
5735 | 71 .SetDescription("Whenever Orthanc receives a new DICOM instance, this event is recorded in the so-called _Changes Log_. This enables remote scripts to react to the arrival of new DICOM resources. A typical application is auto-routing, where an external script waits for a new DICOM instance to arrive into Orthanc, then forward this instance to another modality. Please note that, when resources are deleted, their corresponding change entries are also removed from the Changes Log, which helps ensuring that this log does not grow indefinitely.") |
5757 | 72 .SetHttpGetArgument("last", RestApiCallDocumentation::Type_Number, "Request only the last change id (this argument must be used alone)", false) |
4403 | 73 .SetHttpGetArgument("limit", RestApiCallDocumentation::Type_Number, "Limit the number of results", false) |
5757 | 74 .SetHttpGetArgument("since", RestApiCallDocumentation::Type_Number, "Show only the resources since the provided index excluded", false) |
75 .SetHttpGetArgument("to", RestApiCallDocumentation::Type_Number, "Show only the resources till the provided index included (only available if your DB backend supports ExtendedChanges)", false) | |
76 .SetHttpGetArgument("type", RestApiCallDocumentation::Type_String, "Show only the changes of the provided type (only available if your DB backend supports ExtendedChanges)", false) | |
4403 | 77 .AddAnswerType(MimeType_Json, "The list of changes") |
78 .SetAnswerField("Changes", RestApiCallDocumentation::Type_JsonListOfObjects, "The individual changes") | |
79 .SetAnswerField("Done", RestApiCallDocumentation::Type_Boolean, | |
5757 | 80 "Whether the last reported change is the last of the full history.") |
4403 | 81 .SetAnswerField("Last", RestApiCallDocumentation::Type_Number, |
82 "The index of the last reported change, can be used for the `since` argument in subsequent calls to this route") | |
5757 | 83 .SetAnswerField("First", RestApiCallDocumentation::Type_Number, |
84 "The index of the first reported change, its value-1 can be used for the `to` argument in subsequent calls to this route when browsing the changes in reverse order") | |
5432
59e3b6f8c5be
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
85 .SetHttpGetSample("https://orthanc.uclouvain.be/demo/changes?since=0&limit=2", true); |
4403 | 86 return; |
87 } | |
88 | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 |
5553
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
91 int64_t since, to; |
5805 | 92 std::set<ChangeType> filterType; |
5553
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
93 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 unsigned int limit; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 bool last; |
5553
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
96 GetSinceToAndLimit(since, to, limit, last, call); |
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
97 |
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
98 std::string filterArgument = call.GetArgument("type", "all"); |
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
99 if (filterArgument != "all" && filterArgument != "All") |
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
100 { |
5804
25df40a274fd
/changes: allowing filtering on multiple changes
Alain Mazy <am@orthanc.team>
parents:
5758
diff
changeset
|
101 std::set<std::string> filterTypeStrings; |
25df40a274fd
/changes: allowing filtering on multiple changes
Alain Mazy <am@orthanc.team>
parents:
5758
diff
changeset
|
102 Toolbox::SplitString(filterTypeStrings, filterArgument, ';'); |
25df40a274fd
/changes: allowing filtering on multiple changes
Alain Mazy <am@orthanc.team>
parents:
5758
diff
changeset
|
103 |
25df40a274fd
/changes: allowing filtering on multiple changes
Alain Mazy <am@orthanc.team>
parents:
5758
diff
changeset
|
104 for (std::set<std::string>::const_iterator it = filterTypeStrings.begin(); it != filterTypeStrings.end(); ++it) |
25df40a274fd
/changes: allowing filtering on multiple changes
Alain Mazy <am@orthanc.team>
parents:
5758
diff
changeset
|
105 { |
25df40a274fd
/changes: allowing filtering on multiple changes
Alain Mazy <am@orthanc.team>
parents:
5758
diff
changeset
|
106 filterType.insert(StringToChangeType(*it)); |
25df40a274fd
/changes: allowing filtering on multiple changes
Alain Mazy <am@orthanc.team>
parents:
5758
diff
changeset
|
107 } |
5553
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
108 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 Json::Value result; |
1247 | 111 if (last) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 { |
1247 | 113 context.GetIndex().GetLastChange(result); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 } |
5757 | 115 else if (context.GetIndex().HasExtendedChanges()) |
116 { | |
117 context.GetIndex().GetChangesExtended(result, since, to, limit, filterType); | |
118 } | |
1247 | 119 else |
120 { | |
5804
25df40a274fd
/changes: allowing filtering on multiple changes
Alain Mazy <am@orthanc.team>
parents:
5758
diff
changeset
|
121 if (filterType.size() > 0) |
5553
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
122 { |
5757 | 123 throw OrthancException(ErrorCode_ParameterOutOfRange, "CAPABILITIES: Trying to filter changes while the Database backend does not support it (requires a DB backend with support for ExtendedChanges)"); |
5553
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
124 } |
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
125 |
5757 | 126 if (to != DEFAULT_TO) |
127 { | |
128 throw OrthancException(ErrorCode_ParameterOutOfRange, "CAPABILITIES: Trying to use the 'to' parameter in /changes while the Database backend does not support it (requires a DB backend with support for ExtendedChanges)"); | |
129 } | |
130 | |
1247 | 131 context.GetIndex().GetChanges(result, since, limit); |
132 } | |
133 | |
134 call.GetOutput().AnswerJson(result); | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 |
974 | 138 static void DeleteChanges(RestApiDeleteCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 { |
4403 | 140 if (call.IsDocumentation()) |
141 { | |
142 call.GetDocumentation() | |
143 .SetTag("Tracking changes") | |
144 .SetSummary("Clear changes") | |
145 .SetDescription("Clear the full history stored in the changes log"); | |
146 return; | |
147 } | |
148 | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 OrthancRestApi::GetIndex(call).DeleteChanges(); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
150 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 // Exports API -------------------------------------------------------------- |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 |
974 | 156 static void GetExports(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 { |
4414 | 158 if (call.IsDocumentation()) |
159 { | |
160 call.GetDocumentation() | |
161 .SetTag("Tracking changes") | |
162 .SetSummary("List exports") | |
163 .SetDescription("For medical traceability, Orthanc can be configured to store a log of all the resources " | |
164 "that have been exported to remote modalities. In auto-routing scenarios, it is important " | |
165 "to prevent this log to grow indefinitely as incoming instances are routed. You can either " | |
166 "disable this logging by setting the option `LogExportedResources` to `false` in the " | |
167 "configuration file, or periodically clear this log by `DELETE`-ing this URI. This route " | |
168 "might be removed in future versions of Orthanc.") | |
169 .SetHttpGetArgument("limit", RestApiCallDocumentation::Type_Number, "Limit the number of results", false) | |
170 .SetHttpGetArgument("since", RestApiCallDocumentation::Type_Number, "Show only the resources since the provided index", false) | |
171 .AddAnswerType(MimeType_Json, "The list of exports"); | |
172 return; | |
173 } | |
174 | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 |
5553
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
177 int64_t since, to; |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 unsigned int limit; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 bool last; |
5553
28cc06e4859a
Added ExtendedApiV1: /changes
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
180 GetSinceToAndLimit(since, to, limit, last, call); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 Json::Value result; |
1247 | 183 if (last) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 { |
1247 | 185 context.GetIndex().GetLastExportedResource(result); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 } |
1247 | 187 else |
188 { | |
189 context.GetIndex().GetExportedResources(result, since, limit); | |
190 } | |
191 | |
192 call.GetOutput().AnswerJson(result); | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 |
974 | 196 static void DeleteExports(RestApiDeleteCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 { |
4414 | 198 if (call.IsDocumentation()) |
199 { | |
200 call.GetDocumentation() | |
201 .SetTag("Tracking changes") | |
202 .SetSummary("Clear exports") | |
203 .SetDescription("Clear the full history stored in the exports log"); | |
204 return; | |
205 } | |
206 | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 OrthancRestApi::GetIndex(call).DeleteExportedResources(); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
208 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 void OrthancRestApi::RegisterChanges() |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 Register("/changes", GetChanges); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 Register("/changes", DeleteChanges); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 Register("/exports", GetExports); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 Register("/exports", DeleteExports); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 } |