Mercurial > hg > orthanc
diff OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 5405:62bb63346185
All 'expand' GET arguments now accepts expand=true and expand=false values + /studies/../instances now supports expand=false
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 17 Oct 2023 15:06:11 +0200 |
parents | c5c00bee291a |
children | 630d0195e3bb |
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Tue Oct 17 10:31:21 2023 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Tue Oct 17 15:06:11 2023 +0200 @@ -254,7 +254,7 @@ index.GetAllUuids(result, resourceType); } - AnswerListOfResources(call.GetOutput(), context, result, resourceType, call.HasArgument("expand"), + AnswerListOfResources(call.GetOutput(), context, result, resourceType, call.HasArgument("expand") && call.GetBooleanArgument("expand", true), OrthancRestApi::GetDicomFormat(call, DicomToJsonFormat_Human), requestedTags, true /* allowStorageAccess */); @@ -1701,7 +1701,7 @@ bool isNumeric = call.HasArgument("numeric"); - if (call.HasArgument("expand")) + if (call.HasArgument("expand") && call.GetBooleanArgument("expand", true)) { result = Json::objectValue; @@ -3324,12 +3324,15 @@ .SetDescription("Get detailed information about the child " + children + " of the DICOM " + resource + " whose Orthanc identifier is provided in the URL") .SetUriArgument("id", "Orthanc identifier of the " + resource + " of interest") + .SetHttpGetArgument("expand", RestApiCallDocumentation::Type_String, + "If false or missing, only retrieve the list of child " + children, false) .AddAnswerType(MimeType_Json, "JSON array containing information about the child DICOM " + children) .SetTruncatedJsonHttpGetSample(GetDocumentationSampleResource(start) + "/" + children, 5); return; } ServerIndex& index = OrthancRestApi::GetIndex(call); + ServerContext& context = OrthancRestApi::GetContext(call); std::set<DicomTag> requestedTags; OrthancRestApi::GetRequestedTags(requestedTags, call); @@ -3355,21 +3358,10 @@ a.splice(a.begin(), b); } - Json::Value result = Json::arrayValue; - - const DicomToJsonFormat format = OrthancRestApi::GetDicomFormat(call, DicomToJsonFormat_Human); - - for (std::list<std::string>::const_iterator - it = a.begin(); it != a.end(); ++it) - { - Json::Value resource; - if (OrthancRestApi::GetContext(call).ExpandResource(resource, *it, end, format, requestedTags, true /* allowStorageAccess */)) - { - result.append(resource); - } - } - - call.GetOutput().AnswerJson(result); + AnswerListOfResources(call.GetOutput(), context, a, type, !call.HasArgument("expand") || call.GetBooleanArgument("expand", false), // this "expand" is the only one to have a false default value to keep backward compatibility + OrthancRestApi::GetDicomFormat(call, DicomToJsonFormat_Human), + requestedTags, + true /* allowStorageAccess */); }