Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 4698:d16c3c7f11ef
new route "/tools/bulk-content" to get the content of a set of resources
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 18 Jun 2021 16:37:12 +0200 |
parents | 569d9ef165b1 |
children | facea16b055b |
comparison
equal
deleted
inserted
replaced
4697:569d9ef165b1 | 4698:d16c3c7f11ef |
---|---|
3090 | 3090 |
3091 call.GetOutput().AnswerBuffer("", MimeType_PlainText); | 3091 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
3092 } | 3092 } |
3093 | 3093 |
3094 | 3094 |
3095 static void BulkContent(RestApiPostCall& call) | |
3096 { | |
3097 if (call.IsDocumentation()) | |
3098 { | |
3099 OrthancRestApi::DocumentDicomFormat(call, DicomToJsonFormat_Human); | |
3100 | |
3101 call.GetDocumentation() | |
3102 .SetTag("System") | |
3103 .SetSummary("Describe a set of instances") | |
3104 .SetRequestField("Resources", RestApiCallDocumentation::Type_JsonListOfStrings, | |
3105 "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", false) | |
3106 .SetDescription("Get the content all the DICOM patients, studies, series or instances " | |
3107 "whose identifiers are provided in the `Resources` field, in one single call."); | |
3108 return; | |
3109 } | |
3110 | |
3111 Json::Value request; | |
3112 if (!call.ParseJsonRequest(request) || | |
3113 request.type() != Json::objectValue) | |
3114 { | |
3115 throw OrthancException(ErrorCode_BadRequest, | |
3116 "The body must contain a JSON object"); | |
3117 } | |
3118 else | |
3119 { | |
3120 const DicomToJsonFormat format = OrthancRestApi::GetDicomFormat(request, DicomToJsonFormat_Human); | |
3121 | |
3122 ServerIndex& index = OrthancRestApi::GetIndex(call); | |
3123 | |
3124 std::list<std::string> resources; | |
3125 SerializationToolbox::ReadListOfStrings(resources, request, "Resources"); | |
3126 | |
3127 Json::Value answer = Json::arrayValue; | |
3128 for (std::list<std::string>::const_iterator | |
3129 it = resources.begin(); it != resources.end(); ++it) | |
3130 { | |
3131 ResourceType type; | |
3132 Json::Value item; | |
3133 if (index.LookupResourceType(type, *it) && | |
3134 index.ExpandResource(item, *it, type, format)) | |
3135 { | |
3136 answer.append(item); | |
3137 } | |
3138 else | |
3139 { | |
3140 CLOG(INFO, HTTP) << "Unknown resource during a bulk content retrieval: " << *it; | |
3141 } | |
3142 } | |
3143 | |
3144 call.GetOutput().AnswerJson(answer); | |
3145 } | |
3146 } | |
3147 | |
3148 | |
3095 static void BulkDelete(RestApiPostCall& call) | 3149 static void BulkDelete(RestApiPostCall& call) |
3096 { | 3150 { |
3097 if (call.IsDocumentation()) | 3151 if (call.IsDocumentation()) |
3098 { | 3152 { |
3099 call.GetDocumentation() | 3153 call.GetDocumentation() |
3100 .SetTag("System") | 3154 .SetTag("System") |
3101 .SetSummary("Delete a set of instances") | 3155 .SetSummary("Delete a set of instances") |
3102 .SetRequestField("Resources", RestApiCallDocumentation::Type_JsonListOfStrings, | 3156 .SetRequestField("Resources", RestApiCallDocumentation::Type_JsonListOfStrings, |
3103 "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", false) | 3157 "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", false) |
3104 .SetDescription("Dellete all the DICOM patients, studies, series or instances " | 3158 .SetDescription("Delete all the DICOM patients, studies, series or instances " |
3105 "whose identifiers are provided in the `Resources` field."); | 3159 "whose identifiers are provided in the `Resources` field."); |
3106 return; | 3160 return; |
3107 } | 3161 } |
3108 | 3162 |
3109 ServerContext& context = OrthancRestApi::GetContext(call); | 3163 ServerContext& context = OrthancRestApi::GetContext(call); |
3255 Register("/studies/{id}/reconstruct", ReconstructResource<ResourceType_Study>); | 3309 Register("/studies/{id}/reconstruct", ReconstructResource<ResourceType_Study>); |
3256 Register("/series/{id}/reconstruct", ReconstructResource<ResourceType_Series>); | 3310 Register("/series/{id}/reconstruct", ReconstructResource<ResourceType_Series>); |
3257 Register("/instances/{id}/reconstruct", ReconstructResource<ResourceType_Instance>); | 3311 Register("/instances/{id}/reconstruct", ReconstructResource<ResourceType_Instance>); |
3258 Register("/tools/reconstruct", ReconstructAllResources); | 3312 Register("/tools/reconstruct", ReconstructAllResources); |
3259 | 3313 |
3314 Register("/tools/bulk-content", BulkContent); | |
3260 Register("/tools/bulk-delete", BulkDelete); | 3315 Register("/tools/bulk-delete", BulkDelete); |
3261 } | 3316 } |
3262 } | 3317 } |