Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestArchive.cpp @ 4819:70d2a97ca8cb openssl-3.x
integration mainline->openssl-3.x
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 25 Nov 2021 13:12:32 +0100 |
parents | b2417ac5055a 4e765c18ace7 |
children | 2e71a08eea15 |
comparison
equal
deleted
inserted
replaced
4785:61da49321754 | 4819:70d2a97ca8cb |
---|---|
37 namespace Orthanc | 37 namespace Orthanc |
38 { | 38 { |
39 static const char* const KEY_RESOURCES = "Resources"; | 39 static const char* const KEY_RESOURCES = "Resources"; |
40 static const char* const KEY_EXTENDED = "Extended"; | 40 static const char* const KEY_EXTENDED = "Extended"; |
41 static const char* const KEY_TRANSCODE = "Transcode"; | 41 static const char* const KEY_TRANSCODE = "Transcode"; |
42 | 42 |
43 static const char* const CONFIG_LOADER_THREADS = "ZipLoaderThreads"; | |
44 | |
43 static void AddResourcesOfInterestFromArray(ArchiveJob& job, | 45 static void AddResourcesOfInterestFromArray(ArchiveJob& job, |
44 const Json::Value& resources) | 46 const Json::Value& resources) |
45 { | 47 { |
46 if (resources.type() != Json::arrayValue) | 48 if (resources.type() != Json::arrayValue) |
47 { | 49 { |
109 static void GetJobParameters(bool& synchronous, /* out */ | 111 static void GetJobParameters(bool& synchronous, /* out */ |
110 bool& extended, /* out */ | 112 bool& extended, /* out */ |
111 bool& transcode, /* out */ | 113 bool& transcode, /* out */ |
112 DicomTransferSyntax& syntax, /* out */ | 114 DicomTransferSyntax& syntax, /* out */ |
113 int& priority, /* out */ | 115 int& priority, /* out */ |
116 unsigned int& loaderThreads, /* out */ | |
114 const Json::Value& body, /* in */ | 117 const Json::Value& body, /* in */ |
115 const bool defaultExtended /* in */) | 118 const bool defaultExtended /* in */) |
116 { | 119 { |
117 synchronous = OrthancRestApi::IsSynchronousJobRequest | 120 synchronous = OrthancRestApi::IsSynchronousJobRequest |
118 (true /* synchronous by default */, body); | 121 (true /* synchronous by default */, body); |
137 } | 140 } |
138 else | 141 else |
139 { | 142 { |
140 transcode = false; | 143 transcode = false; |
141 } | 144 } |
145 | |
146 { | |
147 OrthancConfiguration::ReaderLock lock; | |
148 loaderThreads = lock.GetConfiguration().GetUnsignedIntegerParameter(CONFIG_LOADER_THREADS, 0); // New in Orthanc 1.9.8 | |
149 } | |
150 | |
142 } | 151 } |
143 | 152 |
144 | 153 |
145 namespace | 154 namespace |
146 { | 155 { |
540 if (call.ParseJsonRequest(body)) | 549 if (call.ParseJsonRequest(body)) |
541 { | 550 { |
542 bool synchronous, extended, transcode; | 551 bool synchronous, extended, transcode; |
543 DicomTransferSyntax transferSyntax; | 552 DicomTransferSyntax transferSyntax; |
544 int priority; | 553 int priority; |
554 unsigned int loaderThreads; | |
545 GetJobParameters(synchronous, extended, transcode, transferSyntax, | 555 GetJobParameters(synchronous, extended, transcode, transferSyntax, |
546 priority, body, DEFAULT_IS_EXTENDED); | 556 priority, loaderThreads, body, DEFAULT_IS_EXTENDED); |
547 | 557 |
548 std::unique_ptr<ArchiveJob> job(new ArchiveJob(context, IS_MEDIA, extended)); | 558 std::unique_ptr<ArchiveJob> job(new ArchiveJob(context, IS_MEDIA, extended)); |
549 AddResourcesOfInterest(*job, body); | 559 AddResourcesOfInterest(*job, body); |
550 | 560 |
551 if (transcode) | 561 if (transcode) |
552 { | 562 { |
553 job->SetTranscode(transferSyntax); | 563 job->SetTranscode(transferSyntax); |
554 } | 564 } |
555 | 565 |
566 job->SetLoaderThreads(loaderThreads); | |
567 | |
556 SubmitJob(call.GetOutput(), context, job, priority, synchronous, "Archive.zip"); | 568 SubmitJob(call.GetOutput(), context, job, priority, synchronous, "Archive.zip"); |
557 } | 569 } |
558 else | 570 else |
559 { | 571 { |
560 throw OrthancException(ErrorCode_BadFileFormat, | 572 throw OrthancException(ErrorCode_BadFileFormat, |
564 | 576 |
565 | 577 |
566 template <bool IS_MEDIA> | 578 template <bool IS_MEDIA> |
567 static void CreateSingleGet(RestApiGetCall& call) | 579 static void CreateSingleGet(RestApiGetCall& call) |
568 { | 580 { |
581 static const char* const TRANSCODE = "transcode"; | |
582 | |
569 if (call.IsDocumentation()) | 583 if (call.IsDocumentation()) |
570 { | 584 { |
571 ResourceType t = StringToResourceType(call.GetFullUri()[0].c_str()); | 585 ResourceType t = StringToResourceType(call.GetFullUri()[0].c_str()); |
572 std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */); | 586 std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */); |
573 std::string m = (IS_MEDIA ? "DICOMDIR media" : "ZIP archive"); | 587 std::string m = (IS_MEDIA ? "DICOMDIR media" : "ZIP archive"); |
577 .SetDescription("Synchronously create a " + m + " containing the DICOM " + r + | 591 .SetDescription("Synchronously create a " + m + " containing the DICOM " + r + |
578 " whose Orthanc identifier is provided in the URL. This flavor is synchronous, " | 592 " whose Orthanc identifier is provided in the URL. This flavor is synchronous, " |
579 "which might *not* be desirable to archive large amount of data, as it might " | 593 "which might *not* be desirable to archive large amount of data, as it might " |
580 "lead to network timeouts. Prefer the asynchronous version using `POST` method.") | 594 "lead to network timeouts. Prefer the asynchronous version using `POST` method.") |
581 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest") | 595 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest") |
582 .SetHttpGetArgument("transcode", RestApiCallDocumentation::Type_String, | 596 .SetHttpGetArgument(TRANSCODE, RestApiCallDocumentation::Type_String, |
583 "If present, the DICOM files in the archive will be transcoded to the provided " | 597 "If present, the DICOM files in the archive will be transcoded to the provided " |
584 "transfer syntax: https://book.orthanc-server.com/faq/transcoding.html", false) | 598 "transfer syntax: https://book.orthanc-server.com/faq/transcoding.html", false) |
585 .AddAnswerType(MimeType_Zip, "ZIP file containing the archive"); | 599 .AddAnswerType(MimeType_Zip, "ZIP file containing the archive"); |
586 if (IS_MEDIA) | 600 if (IS_MEDIA) |
587 { | 601 { |
607 } | 621 } |
608 | 622 |
609 std::unique_ptr<ArchiveJob> job(new ArchiveJob(context, IS_MEDIA, extended)); | 623 std::unique_ptr<ArchiveJob> job(new ArchiveJob(context, IS_MEDIA, extended)); |
610 job->AddResource(id); | 624 job->AddResource(id); |
611 | 625 |
612 static const char* const TRANSCODE = "transcode"; | |
613 if (call.HasArgument(TRANSCODE)) | 626 if (call.HasArgument(TRANSCODE)) |
614 { | 627 { |
615 job->SetTranscode(GetTransferSyntax(call.GetArgument(TRANSCODE, ""))); | 628 job->SetTranscode(GetTransferSyntax(call.GetArgument(TRANSCODE, ""))); |
629 } | |
630 | |
631 { | |
632 OrthancConfiguration::ReaderLock lock; | |
633 unsigned int loaderThreads = lock.GetConfiguration().GetUnsignedIntegerParameter(CONFIG_LOADER_THREADS, 0); // New in Orthanc 1.9.8 | |
634 job->SetLoaderThreads(loaderThreads); | |
616 } | 635 } |
617 | 636 |
618 SubmitJob(call.GetOutput(), context, job, 0 /* priority */, | 637 SubmitJob(call.GetOutput(), context, job, 0 /* priority */, |
619 true /* synchronous */, id + ".zip"); | 638 true /* synchronous */, id + ".zip"); |
620 } | 639 } |
646 if (call.ParseJsonRequest(body)) | 665 if (call.ParseJsonRequest(body)) |
647 { | 666 { |
648 bool synchronous, extended, transcode; | 667 bool synchronous, extended, transcode; |
649 DicomTransferSyntax transferSyntax; | 668 DicomTransferSyntax transferSyntax; |
650 int priority; | 669 int priority; |
670 unsigned int loaderThreads; | |
651 GetJobParameters(synchronous, extended, transcode, transferSyntax, | 671 GetJobParameters(synchronous, extended, transcode, transferSyntax, |
652 priority, body, false /* by default, not extented */); | 672 priority, loaderThreads, body, false /* by default, not extented */); |
653 | 673 |
654 std::unique_ptr<ArchiveJob> job(new ArchiveJob(context, IS_MEDIA, extended)); | 674 std::unique_ptr<ArchiveJob> job(new ArchiveJob(context, IS_MEDIA, extended)); |
655 job->AddResource(id); | 675 job->AddResource(id); |
656 | 676 |
657 if (transcode) | 677 if (transcode) |
658 { | 678 { |
659 job->SetTranscode(transferSyntax); | 679 job->SetTranscode(transferSyntax); |
660 } | 680 } |
681 | |
682 job->SetLoaderThreads(loaderThreads); | |
661 | 683 |
662 SubmitJob(call.GetOutput(), context, job, priority, synchronous, id + ".zip"); | 684 SubmitJob(call.GetOutput(), context, job, priority, synchronous, id + ".zip"); |
663 } | 685 } |
664 else | 686 else |
665 { | 687 { |