# HG changeset patch # User Sebastien Jodogne # Date 1624027032 -7200 # Node ID d16c3c7f11efe4babcd98a4e749ce95e6f5f27c4 # Parent 569d9ef165b1341b24e4c4dca45e0d33265546da new route "/tools/bulk-content" to get the content of a set of resources diff -r 569d9ef165b1 -r d16c3c7f11ef NEWS --- a/NEWS Fri Jun 18 16:08:35 2021 +0200 +++ b/NEWS Fri Jun 18 16:37:12 2021 +0200 @@ -18,10 +18,11 @@ -------- * API version upgraded to 13 -* New routes: - - "/tools/bulk-anonymize" to anonymize a group of multiple, unrelated resources at once - - "/tools/bulk-delete" to delete a group of multiple, unrelated resources at once - - "/tools/bulk-modify" to modify a group of multiple, unrelated resources at once +* New routes to handle groups of multiple, unrelated DICOM resources at once: + - "/tools/bulk-anonymize" to anonymize a set of resources + - "/tools/bulk-content" to get the content of a set of resources + - "/tools/bulk-delete" to delete a set of resources + - "/tools/bulk-modify" to modify a set of resources * ZIP archive/media generated in synchronous mode are now streamed by default * "Replace" tags in "/modify" and "/anonymize" now supports value representation AT * "/jobs/..." has new field "ErrorDetails" to help identify the cause of an error diff -r 569d9ef165b1 -r d16c3c7f11ef OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp Fri Jun 18 16:08:35 2021 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp Fri Jun 18 16:37:12 2021 +0200 @@ -471,11 +471,10 @@ static const std::string POST_SHORT = "Short"; static const std::string DOCUMENT_SIMPLIFY = - "report the DICOM tags indexed in human-readable format " - "(using the symbolic name of the tags)"; + "report the DICOM tags in human-readable format (using the symbolic name of the tags)"; static const std::string DOCUMENT_SHORT = - "report the DICOM tags indexed in hexadecimal format"; + "report the DICOM tags in hexadecimal format"; static const std::string DOCUMENT_FULL = "report the DICOM tags in full format (tags indexed by their hexadecimal " @@ -564,13 +563,13 @@ if (defaultFormat != DicomToJsonFormat_Short) { call.GetDocumentation().SetRequestField(POST_SHORT, RestApiCallDocumentation::Type_Boolean, - "If set to `true`, " + DOCUMENT_SIMPLIFY, false); + "If set to `true`, " + DOCUMENT_SHORT, false); } if (defaultFormat != DicomToJsonFormat_Full) { call.GetDocumentation().SetRequestField(POST_FULL, RestApiCallDocumentation::Type_Boolean, - "If set to `true`, " + DOCUMENT_SIMPLIFY, false); + "If set to `true`, " + DOCUMENT_FULL, false); } } } diff -r 569d9ef165b1 -r d16c3c7f11ef OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Fri Jun 18 16:08:35 2021 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Fri Jun 18 16:37:12 2021 +0200 @@ -3092,6 +3092,60 @@ } + static void BulkContent(RestApiPostCall& call) + { + if (call.IsDocumentation()) + { + OrthancRestApi::DocumentDicomFormat(call, DicomToJsonFormat_Human); + + call.GetDocumentation() + .SetTag("System") + .SetSummary("Describe a set of instances") + .SetRequestField("Resources", RestApiCallDocumentation::Type_JsonListOfStrings, + "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", false) + .SetDescription("Get the content all the DICOM patients, studies, series or instances " + "whose identifiers are provided in the `Resources` field, in one single call."); + return; + } + + Json::Value request; + if (!call.ParseJsonRequest(request) || + request.type() != Json::objectValue) + { + throw OrthancException(ErrorCode_BadRequest, + "The body must contain a JSON object"); + } + else + { + const DicomToJsonFormat format = OrthancRestApi::GetDicomFormat(request, DicomToJsonFormat_Human); + + ServerIndex& index = OrthancRestApi::GetIndex(call); + + std::list resources; + SerializationToolbox::ReadListOfStrings(resources, request, "Resources"); + + Json::Value answer = Json::arrayValue; + for (std::list::const_iterator + it = resources.begin(); it != resources.end(); ++it) + { + ResourceType type; + Json::Value item; + if (index.LookupResourceType(type, *it) && + index.ExpandResource(item, *it, type, format)) + { + answer.append(item); + } + else + { + CLOG(INFO, HTTP) << "Unknown resource during a bulk content retrieval: " << *it; + } + } + + call.GetOutput().AnswerJson(answer); + } + } + + static void BulkDelete(RestApiPostCall& call) { if (call.IsDocumentation()) @@ -3101,7 +3155,7 @@ .SetSummary("Delete a set of instances") .SetRequestField("Resources", RestApiCallDocumentation::Type_JsonListOfStrings, "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", false) - .SetDescription("Dellete all the DICOM patients, studies, series or instances " + .SetDescription("Delete all the DICOM patients, studies, series or instances " "whose identifiers are provided in the `Resources` field."); return; } @@ -3257,6 +3311,7 @@ Register("/instances/{id}/reconstruct", ReconstructResource); Register("/tools/reconstruct", ReconstructAllResources); + Register("/tools/bulk-content", BulkContent); Register("/tools/bulk-delete", BulkDelete); } }