comparison OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 1509:0586ed8897f1

limit and since arguments while retrieving DICOM resources in the REST API
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 10 Aug 2015 10:01:59 +0200
parents f967bdf8534e
children d6a93e12b1c1
comparison
equal deleted inserted replaced
1508:86394eb9f5bb 1509:0586ed8897f1
78 static void ListResources(RestApiGetCall& call) 78 static void ListResources(RestApiGetCall& call)
79 { 79 {
80 ServerIndex& index = OrthancRestApi::GetIndex(call); 80 ServerIndex& index = OrthancRestApi::GetIndex(call);
81 81
82 std::list<std::string> result; 82 std::list<std::string> result;
83 index.GetAllUuids(result, resourceType); 83
84 if (call.HasArgument("limit") ||
85 call.HasArgument("since"))
86 {
87 if (!call.HasArgument("limit"))
88 {
89 LOG(ERROR) << "Missing \"limit\" argument for GET request against: " << call.FlattenUri();
90 throw OrthancException(ErrorCode_BadRequest);
91 }
92
93 if (!call.HasArgument("since"))
94 {
95 LOG(ERROR) << "Missing \"since\" argument for GET request against: " << call.FlattenUri();
96 throw OrthancException(ErrorCode_BadRequest);
97 }
98
99 size_t since = boost::lexical_cast<size_t>(call.GetArgument("since", ""));
100 size_t limit = boost::lexical_cast<size_t>(call.GetArgument("limit", ""));
101 index.GetAllUuids(result, resourceType, since, limit);
102 }
103 else
104 {
105 index.GetAllUuids(result, resourceType);
106 }
107
84 108
85 AnswerListOfResources(call.GetOutput(), index, result, resourceType, call.HasArgument("expand")); 109 AnswerListOfResources(call.GetOutput(), index, result, resourceType, call.HasArgument("expand"));
86 } 110 }
87 111
88 template <enum ResourceType resourceType> 112 template <enum ResourceType resourceType>