comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 4892:6eff25f70121 openssl-3.x

integration mainline->openssl-3.x
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 20 Feb 2022 11:14:34 +0100
parents 3e9a76464e8a 504624b0a062
children df86d2505df8
comparison
equal deleted inserted replaced
4869:e1944053cbef 4892:6eff25f70121
1 /** 1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store 2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium 4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium 5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
6 * Copyright (C) 2021-2021 Sebastien Jodogne, ICTEAM UCLouvain, Belgium 6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
7 * 7 *
8 * This program is free software: you can redistribute it and/or 8 * This program is free software: you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation, either version 3 of the 10 * published by the Free Software Foundation, either version 3 of the
11 * License, or (at your option) any later version. 11 * License, or (at your option) any later version.
2034 operations.append("compressed-md5"); 2034 operations.append("compressed-md5");
2035 } 2035 }
2036 2036
2037 operations.append("compressed-size"); 2037 operations.append("compressed-size");
2038 operations.append("data"); 2038 operations.append("data");
2039 operations.append("info");
2039 operations.append("is-compressed"); 2040 operations.append("is-compressed");
2040 2041
2041 if (info.GetUncompressedMD5() != "") 2042 if (info.GetUncompressedMD5() != "")
2042 { 2043 {
2043 operations.append("md5"); 2044 operations.append("md5");
2049 if (info.GetCompressedMD5() != "" && 2050 if (info.GetCompressedMD5() != "" &&
2050 info.GetUncompressedMD5() != "") 2051 info.GetUncompressedMD5() != "")
2051 { 2052 {
2052 operations.append("verify-md5"); 2053 operations.append("verify-md5");
2053 } 2054 }
2055
2056 operations.append("uuid");
2054 2057
2055 call.GetOutput().AnswerJson(operations); 2058 call.GetOutput().AnswerJson(operations);
2056 } 2059 }
2057 } 2060 }
2058 2061
2137 { 2140 {
2138 call.GetOutput().AnswerBuffer(boost::lexical_cast<std::string>(info.GetUncompressedSize()), MimeType_PlainText); 2141 call.GetOutput().AnswerBuffer(boost::lexical_cast<std::string>(info.GetUncompressedSize()), MimeType_PlainText);
2139 } 2142 }
2140 } 2143 }
2141 2144
2145 static void GetAttachmentInfo(RestApiGetCall& call)
2146 {
2147 if (call.IsDocumentation())
2148 {
2149 ResourceType t = StringToResourceType(call.GetFullUri()[0].c_str());
2150 std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */);
2151 AddAttachmentDocumentation(call, r);
2152 call.GetDocumentation()
2153 .SetTag(GetResourceTypeText(t, true /* plural */, true /* upper case */))
2154 .SetSummary("Get info about the attachment")
2155 .SetDescription("Get all the information about the attachment associated with the given " + r)
2156 .AddAnswerType(MimeType_Json, "JSON object containing the information about the attachment")
2157 .SetHttpGetSample("https://demo.orthanc-server.com/instances/7c92ce8e-bbf67ed2-ffa3b8c1-a3b35d94-7ff3ae26/dicom/info", true);
2158 return;
2159 }
2160
2161 FileInfo info;
2162 if (GetAttachmentInfo(info, call))
2163 {
2164 Json::Value result = Json::objectValue;
2165 result["Uuid"] = info.GetUuid();
2166 result["ContentType"] = info.GetContentType();
2167 result["UncompressedSize"] = Json::Value::UInt64(info.GetUncompressedSize());
2168 result["CompressedSize"] = Json::Value::UInt64(info.GetCompressedSize());
2169 result["UncompressedMD5"] = info.GetUncompressedMD5();
2170 result["CompressedMD5"] = info.GetCompressedMD5();
2171
2172 call.GetOutput().AnswerJson(result);
2173 }
2174 }
2142 2175
2143 static void GetAttachmentCompressedSize(RestApiGetCall& call) 2176 static void GetAttachmentCompressedSize(RestApiGetCall& call)
2144 { 2177 {
2145 if (call.IsDocumentation()) 2178 if (call.IsDocumentation())
2146 { 2179 {
3380 { 3413 {
3381 OrthancRestApi::DocumentDicomFormat(call, DicomToJsonFormat_Human); 3414 OrthancRestApi::DocumentDicomFormat(call, DicomToJsonFormat_Human);
3382 3415
3383 call.GetDocumentation() 3416 call.GetDocumentation()
3384 .SetTag("System") 3417 .SetTag("System")
3385 .SetSummary("Describe a set of instances") 3418 .SetSummary("Describe a set of resources")
3386 .SetRequestField("Resources", RestApiCallDocumentation::Type_JsonListOfStrings, 3419 .SetRequestField("Resources", RestApiCallDocumentation::Type_JsonListOfStrings,
3387 "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", true) 3420 "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", true)
3388 .SetRequestField(LEVEL, RestApiCallDocumentation::Type_String, 3421 .SetRequestField(LEVEL, RestApiCallDocumentation::Type_String,
3389 "This optional argument specifies the level of interest (can be `Patient`, `Study`, `Series` or " 3422 "This optional argument specifies the level of interest (can be `Patient`, `Study`, `Series` or "
3390 "`Instance`). Orthanc will loop over the items inside `Resources`, and explorer upward or " 3423 "`Instance`). Orthanc will loop over the items inside `Resources`, and explorer upward or "
3556 { 3589 {
3557 if (call.IsDocumentation()) 3590 if (call.IsDocumentation())
3558 { 3591 {
3559 call.GetDocumentation() 3592 call.GetDocumentation()
3560 .SetTag("System") 3593 .SetTag("System")
3561 .SetSummary("Delete a set of instances") 3594 .SetSummary("Delete a set of resources")
3562 .SetRequestField("Resources", RestApiCallDocumentation::Type_JsonListOfStrings, 3595 .SetRequestField("Resources", RestApiCallDocumentation::Type_JsonListOfStrings,
3563 "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", true) 3596 "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", true)
3564 .SetDescription("Delete all the DICOM patients, studies, series or instances " 3597 .SetDescription("Delete all the DICOM patients, studies, series or instances "
3565 "whose identifiers are provided in the `Resources` field."); 3598 "whose identifiers are provided in the `Resources` field.");
3566 return; 3599 return;
3682 Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/data", GetAttachmentData<1>); 3715 Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/data", GetAttachmentData<1>);
3683 Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/is-compressed", IsAttachmentCompressed); 3716 Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/is-compressed", IsAttachmentCompressed);
3684 Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/md5", GetAttachmentMD5); 3717 Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/md5", GetAttachmentMD5);
3685 Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/size", GetAttachmentSize); 3718 Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/size", GetAttachmentSize);
3686 Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/uncompress", ChangeAttachmentCompression<CompressionType_None>); 3719 Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/uncompress", ChangeAttachmentCompression<CompressionType_None>);
3720 Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/info", GetAttachmentInfo);
3687 Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/verify-md5", VerifyAttachment); 3721 Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/verify-md5", VerifyAttachment);
3688 } 3722 }
3689 3723
3690 Register("/tools/invalidate-tags", InvalidateTags); 3724 Register("/tools/invalidate-tags", InvalidateTags);
3691 Register("/tools/lookup", Lookup); 3725 Register("/tools/lookup", Lookup);