Mercurial > hg > orthanc
diff 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 |
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Fri Aug 07 20:14:49 2015 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Mon Aug 10 10:01:59 2015 +0200 @@ -80,7 +80,31 @@ ServerIndex& index = OrthancRestApi::GetIndex(call); std::list<std::string> result; - index.GetAllUuids(result, resourceType); + + if (call.HasArgument("limit") || + call.HasArgument("since")) + { + if (!call.HasArgument("limit")) + { + LOG(ERROR) << "Missing \"limit\" argument for GET request against: " << call.FlattenUri(); + throw OrthancException(ErrorCode_BadRequest); + } + + if (!call.HasArgument("since")) + { + LOG(ERROR) << "Missing \"since\" argument for GET request against: " << call.FlattenUri(); + throw OrthancException(ErrorCode_BadRequest); + } + + size_t since = boost::lexical_cast<size_t>(call.GetArgument("since", "")); + size_t limit = boost::lexical_cast<size_t>(call.GetArgument("limit", "")); + index.GetAllUuids(result, resourceType, since, limit); + } + else + { + index.GetAllUuids(result, resourceType); + } + AnswerListOfResources(call.GetOutput(), index, result, resourceType, call.HasArgument("expand")); }