Mercurial > hg > orthanc
diff OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 2128:9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 07 Nov 2016 15:13:16 +0100 |
parents | bfa92c9328d7 |
children | 0c09d1af22f3 |
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Mon Nov 07 13:59:36 2016 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Mon Nov 07 15:13:16 2016 +0100 @@ -565,6 +565,10 @@ OrthancRestApi::GetIndex(call).DeleteMetadata(publicId, metadata); call.GetOutput().AnswerBuffer("", "text/plain"); } + else + { + call.GetOutput().SignalError(HttpStatus_403_Forbidden); + } } @@ -585,6 +589,10 @@ OrthancRestApi::GetIndex(call).SetMetadata(publicId, metadata, value); call.GetOutput().AnswerBuffer("", "text/plain"); } + else + { + call.GetOutput().SignalError(HttpStatus_403_Forbidden); + } } @@ -679,7 +687,7 @@ { // Return the raw data (possibly compressed), as stored on the filesystem std::string content; - context.ReadFile(content, publicId, type, false); + context.ReadAttachment(content, publicId, type, false); call.GetOutput().AnswerBuffer(content, "application/octet-stream"); } } @@ -748,7 +756,7 @@ // First check whether the compressed data is correctly stored in the disk std::string data; - context.ReadFile(data, publicId, StringToContentType(name), false); + context.ReadAttachment(data, publicId, StringToContentType(name), false); std::string actualMD5; Toolbox::ComputeMD5(actualMD5, data); @@ -763,7 +771,7 @@ } else { - context.ReadFile(data, publicId, StringToContentType(name), true); + context.ReadAttachment(data, publicId, StringToContentType(name), true); Toolbox::ComputeMD5(actualMD5, data); ok = (actualMD5 == info.GetUncompressedMD5()); } @@ -795,6 +803,10 @@ { call.GetOutput().AnswerBuffer("{}", "application/json"); } + else + { + call.GetOutput().SignalError(HttpStatus_403_Forbidden); + } } @@ -806,11 +818,33 @@ std::string name = call.GetUriComponent("name", ""); FileContentType contentType = StringToContentType(name); - if (IsUserContentType(contentType)) // It is forbidden to delete internal attachments + bool allowed; + if (IsUserContentType(contentType)) + { + allowed = true; + } + else if (Configuration::GetGlobalBoolParameter("StoreDicom", true) && + contentType == FileContentType_DicomAsJson) + { + allowed = true; + } + else + { + // It is forbidden to delete internal attachments, except for + // the "DICOM as JSON" summary as of Orthanc 1.2.0 (this summary + // would be automatically reconstructed on the next GET call) + allowed = false; + } + + if (allowed) { OrthancRestApi::GetIndex(call).DeleteAttachment(publicId, contentType); call.GetOutput().AnswerBuffer("{}", "application/json"); } + else + { + call.GetOutput().SignalError(HttpStatus_403_Forbidden); + } }