annotate OrthancServer/Sources/OrthancRestApi/OrthancRestArchive.cpp @ 5604:c2a2fb8e868d

reformatting NEWS
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 08 May 2024 10:30:34 +0200
parents 3a6d6d35193c
children f7adfb22e20e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1847
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1121
diff changeset
4 * Department, University Hospital of Liege, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5447
diff changeset
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5447
diff changeset
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * General Public License for more details.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
23 #include "../PrecompiledHeadersServer.h"
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "OrthancRestApi.h"
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
26 #include "../../../OrthancFramework/Sources/Compression/ZipWriter.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
27 #include "../../../OrthancFramework/Sources/HttpServer/FilesystemHttpSender.h"
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
28 #include "../../../OrthancFramework/Sources/Logging.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
29 #include "../../../OrthancFramework/Sources/OrthancException.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
30 #include "../../../OrthancFramework/Sources/SerializationToolbox.h"
5447
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
31 #include "../../../OrthancFramework/Sources/Toolbox.h"
3181
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3161
diff changeset
32 #include "../OrthancConfiguration.h"
3095
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
33 #include "../ServerContext.h"
2632
2406ae891747 ArchiveJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2630
diff changeset
34 #include "../ServerJobs/ArchiveJob.h"
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
36 #include <boost/filesystem/fstream.hpp>
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
37
3095
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
38
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 namespace Orthanc
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
41 static const char* const KEY_RESOURCES = "Resources";
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
42 static const char* const KEY_EXTENDED = "Extended";
3913
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
43 static const char* const KEY_TRANSCODE = "Transcode";
4797
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
44
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
45 static const char* const CONFIG_LOADER_THREADS = "ZipLoaderThreads";
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
46
5447
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
47
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
48 static void AddResourcesOfInterestFromString(ArchiveJob& job,
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
49 const std::string& resourcesList)
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
50 {
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
51 std::set<std::string> resources;
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
52 Toolbox::SplitString(resources, resourcesList, ',');
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
53
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
54 for (std::set<std::string>::const_iterator it = resources.begin(); it != resources.end(); ++it)
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
55 {
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
56 job.AddResource(*it, false, ResourceType_Patient /* dummy value */);
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
57 }
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
58 }
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
59
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
60 static void AddResourcesOfInterestFromArray(ArchiveJob& job,
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
61 const Json::Value& resources)
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
62 {
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
63 if (resources.type() != Json::arrayValue)
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
64 {
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
65 throw OrthancException(ErrorCode_BadFileFormat,
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
66 "Expected a list of strings (Orthanc identifiers)");
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
67 }
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
68
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
69 for (Json::Value::ArrayIndex i = 0; i < resources.size(); i++)
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
70 {
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
71 if (resources[i].type() != Json::stringValue)
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
72 {
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
73 throw OrthancException(ErrorCode_BadFileFormat,
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
74 "Expected a list of strings (Orthanc identifiers)");
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
75 }
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
76 else
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
77 {
5169
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
78 job.AddResource(resources[i].asString(), false, ResourceType_Patient /* dummy value */);
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
79 }
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
80 }
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
81 }
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
82
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
83
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
84 static void AddResourcesOfInterest(ArchiveJob& job /* inout */,
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
85 const Json::Value& body /* in */)
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
86 {
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
87 if (body.type() == Json::arrayValue)
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
88 {
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
89 AddResourcesOfInterestFromArray(job, body);
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
90 }
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
91 else if (body.type() == Json::objectValue)
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
92 {
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
93 if (body.isMember(KEY_RESOURCES))
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
94 {
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
95 AddResourcesOfInterestFromArray(job, body[KEY_RESOURCES]);
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
96 }
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
97 else
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
98 {
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
99 throw OrthancException(ErrorCode_BadFileFormat,
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
100 "Missing field " + std::string(KEY_RESOURCES) +
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
101 " in the JSON body");
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
102 }
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
103 }
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
104 else
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
105 {
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
106 throw OrthancException(ErrorCode_BadFileFormat);
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
107 }
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
108 }
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
109
3913
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
110
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
111 static void GetJobParameters(bool& synchronous, /* out */
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
112 bool& extended, /* out */
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
113 bool& transcode, /* out */
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
114 DicomTransferSyntax& syntax, /* out */
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
115 int& priority, /* out */
4797
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
116 unsigned int& loaderThreads, /* out */
3913
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
117 const Json::Value& body, /* in */
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
118 const bool defaultExtended /* in */)
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
119 {
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
120 synchronous = OrthancRestApi::IsSynchronousJobRequest
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
121 (true /* synchronous by default */, body);
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
122
2970
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
123 priority = OrthancRestApi::GetJobRequestPriority(body);
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
124
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
125 if (body.type() == Json::objectValue &&
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
126 body.isMember(KEY_EXTENDED))
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
127 {
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
128 extended = SerializationToolbox::ReadBoolean(body, KEY_EXTENDED);
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
129 }
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
130 else
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
131 {
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
132 extended = defaultExtended;
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
133 }
3913
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
134
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
135 if (body.type() == Json::objectValue &&
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
136 body.isMember(KEY_TRANSCODE))
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
137 {
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
138 transcode = true;
5426
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5403
diff changeset
139 syntax = Orthanc::GetTransferSyntax(SerializationToolbox::ReadString(body, KEY_TRANSCODE));
3913
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
140 }
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
141 else
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
142 {
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
143 transcode = false;
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
144 }
4797
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
145
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
146 {
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
147 OrthancConfiguration::ReaderLock lock;
4902
df86d2505df8 Orthanc 1.9.8 is now known as Orthanc 1.10.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4892
diff changeset
148 loaderThreads = lock.GetConfiguration().GetUnsignedIntegerParameter(CONFIG_LOADER_THREADS, 0); // New in Orthanc 1.10.0
4797
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
149 }
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
150
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
151 }
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
152
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
153
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
154 namespace
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
155 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
156 class SynchronousZipChunk : public IDynamicObject
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
157 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
158 private:
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
159 std::string chunk_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
160 bool done_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
161
4690
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4674
diff changeset
162 explicit SynchronousZipChunk(bool done) :
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4674
diff changeset
163 done_(done)
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4674
diff changeset
164 {
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4674
diff changeset
165 }
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4674
diff changeset
166
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
167 public:
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
168 static SynchronousZipChunk* CreateDone()
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
169 {
4690
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4674
diff changeset
170 return new SynchronousZipChunk(true);
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
171 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
172
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
173 static SynchronousZipChunk* CreateChunk(const std::string& chunk)
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
174 {
4690
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4674
diff changeset
175 std::unique_ptr<SynchronousZipChunk> item(new SynchronousZipChunk(false));
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
176 item->chunk_ = chunk;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
177 return item.release();
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
178 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
179
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
180 bool IsDone() const
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
181 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
182 return done_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
183 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
184
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
185 void SwapString(std::string& target)
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
186 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
187 if (done_)
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
188 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
189 throw OrthancException(ErrorCode_BadSequenceOfCalls);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
190 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
191 else
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
192 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
193 target.swap(chunk_);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
194 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
195 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
196 };
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
197
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
198
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
199 class SynchronousZipStream : public ZipWriter::IOutputStream
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
200 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
201 private:
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
202 boost::shared_ptr<SharedMessageQueue> queue_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
203 uint64_t archiveSize_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
204
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
205 public:
4690
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4674
diff changeset
206 explicit SynchronousZipStream(const boost::shared_ptr<SharedMessageQueue>& queue) :
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
207 queue_(queue),
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
208 archiveSize_(0)
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
209 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
210 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
211
4690
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4674
diff changeset
212 virtual uint64_t GetArchiveSize() const ORTHANC_OVERRIDE
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
213 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
214 return archiveSize_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
215 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
216
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
217 virtual void Write(const std::string& chunk) ORTHANC_OVERRIDE
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
218 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
219 if (queue_.unique())
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
220 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
221 throw OrthancException(ErrorCode_NetworkProtocol,
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
222 "HTTP client has disconnected while creating an archive in synchronous mode");
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
223 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
224 else
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
225 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
226 queue_->Enqueue(SynchronousZipChunk::CreateChunk(chunk));
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
227 archiveSize_ += chunk.size();
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
228 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
229 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
230
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
231 virtual void Close() ORTHANC_OVERRIDE
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
232 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
233 queue_->Enqueue(SynchronousZipChunk::CreateDone());
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
234 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
235 };
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
236
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
237
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
238 class SynchronousZipSender : public IHttpStreamAnswer
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
239 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
240 private:
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
241 ServerContext& context_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
242 std::string jobId_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
243 boost::shared_ptr<SharedMessageQueue> queue_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
244 std::string filename_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
245 bool done_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
246 std::string chunk_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
247
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
248 public:
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
249 SynchronousZipSender(ServerContext& context,
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
250 const std::string& jobId,
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
251 const boost::shared_ptr<SharedMessageQueue>& queue,
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
252 const std::string& filename) :
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
253 context_(context),
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
254 jobId_(jobId),
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
255 queue_(queue),
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
256 filename_(filename),
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
257 done_(false)
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
258 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
259 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
260
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
261 virtual HttpCompression SetupHttpCompression(bool gzipAllowed,
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
262 bool deflateAllowed) ORTHANC_OVERRIDE
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
263 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
264 // This function is not called by HttpOutput::AnswerWithoutBuffering()
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
265 throw OrthancException(ErrorCode_InternalError);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
266 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
267
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
268 virtual bool HasContentFilename(std::string& filename) ORTHANC_OVERRIDE
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
269 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
270 filename = filename_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
271 return true;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
272 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
273
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
274 virtual std::string GetContentType() ORTHANC_OVERRIDE
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
275 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
276 return EnumerationToString(MimeType_Zip);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
277 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
278
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
279 virtual uint64_t GetContentLength() ORTHANC_OVERRIDE
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
280 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
281 throw OrthancException(ErrorCode_InternalError);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
282 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
283
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
284 virtual bool ReadNextChunk() ORTHANC_OVERRIDE
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
285 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
286 for (;;)
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
287 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
288 std::unique_ptr<IDynamicObject> obj(queue_->Dequeue(100));
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
289
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
290 if (obj.get() == NULL)
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
291 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
292 // Check that the job is still active, which indicates
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
293 // that more data might still be returned
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
294 JobState state;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
295 if (context_.GetJobsEngine().GetRegistry().GetState(state, jobId_) &&
4690
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4674
diff changeset
296 (state == JobState_Pending ||
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4674
diff changeset
297 state == JobState_Running ||
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4674
diff changeset
298 state == JobState_Success))
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
299 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
300 continue;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
301 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
302 else
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
303 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
304 return false;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
305 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
306 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
307 else
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
308 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
309 SynchronousZipChunk& item = dynamic_cast<SynchronousZipChunk&>(*obj);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
310 if (item.IsDone())
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
311 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
312 done_ = true;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
313 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
314 else
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
315 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
316 item.SwapString(chunk_);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
317 done_ = false;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
318 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
319
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
320 return !done_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
321 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
322 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
323 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
324
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
325 virtual const char* GetChunkContent() ORTHANC_OVERRIDE
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
326 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
327 if (done_)
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
328 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
329 throw OrthancException(ErrorCode_InternalError);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
330 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
331 else
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
332 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
333 return (chunk_.empty() ? NULL : chunk_.c_str());
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
334 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
335 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
336
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
337 virtual size_t GetChunkSize() ORTHANC_OVERRIDE
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
338 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
339 if (done_)
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
340 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
341 throw OrthancException(ErrorCode_InternalError);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
342 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
343 else
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
344 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
345 return chunk_.size();
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
346 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
347 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
348 };
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
349
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
350
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
351 class SynchronousTemporaryStream : public ZipWriter::IOutputStream
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
352 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
353 private:
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
354 boost::shared_ptr<TemporaryFile> temp_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
355 boost::filesystem::ofstream file_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
356 uint64_t archiveSize_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
357
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
358 public:
4690
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4674
diff changeset
359 explicit SynchronousTemporaryStream(const boost::shared_ptr<TemporaryFile>& temp) :
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
360 temp_(temp),
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
361 archiveSize_(0)
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
362 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
363 file_.open(temp_->GetPath(), std::ofstream::out | std::ofstream::binary);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
364 if (!file_.good())
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
365 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
366 throw OrthancException(ErrorCode_CannotWriteFile);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
367 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
368 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
369
4690
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4674
diff changeset
370 virtual uint64_t GetArchiveSize() const ORTHANC_OVERRIDE
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
371 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
372 return archiveSize_;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
373 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
374
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
375 virtual void Write(const std::string& chunk) ORTHANC_OVERRIDE
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
376 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
377 if (!chunk.empty())
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
378 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
379 try
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
380 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
381 file_.write(chunk.c_str(), chunk.size());
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
382
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
383 if (!file_.good())
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
384 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
385 file_.close();
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
386 throw OrthancException(ErrorCode_CannotWriteFile);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
387 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
388 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
389 catch (boost::filesystem::filesystem_error&)
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
390 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
391 throw OrthancException(ErrorCode_CannotWriteFile);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
392 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
393 catch (...) // To catch "std::system_error&" in C++11
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
394 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
395 throw OrthancException(ErrorCode_CannotWriteFile);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
396 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
397 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
398
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
399 archiveSize_ += chunk.size();
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
400 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
401
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
402 virtual void Close() ORTHANC_OVERRIDE
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
403 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
404 try
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
405 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
406 file_.close();
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
407 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
408 catch (boost::filesystem::filesystem_error&)
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
409 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
410 throw OrthancException(ErrorCode_CannotWriteFile);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
411 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
412 catch (...) // To catch "std::system_error&" in C++11
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
413 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
414 throw OrthancException(ErrorCode_CannotWriteFile);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
415 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
416 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
417 };
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
418 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
419
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
420
2969
2c16c29b287d preparing for asynchronous generation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
421 static void SubmitJob(RestApiOutput& output,
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
422 ServerContext& context,
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
423 std::unique_ptr<ArchiveJob>& job,
2970
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
424 int priority,
2969
2c16c29b287d preparing for asynchronous generation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
425 bool synchronous,
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
426 const std::string& filename)
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
427 {
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
428 if (job.get() == NULL)
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
429 {
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
430 throw OrthancException(ErrorCode_NullPointer);
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
431 }
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
432
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
433 job->SetDescription("REST API");
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
434
2969
2c16c29b287d preparing for asynchronous generation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
435 if (synchronous)
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
436 {
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
437 bool streaming;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
438
3181
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3161
diff changeset
439 {
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3161
diff changeset
440 OrthancConfiguration::ReaderLock lock;
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
441 streaming = lock.GetConfiguration().GetBooleanParameter("SynchronousZipStream", true); // New in Orthanc 1.9.4
3181
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3161
diff changeset
442 }
6fd38327e777 Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3161
diff changeset
443
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
444 if (streaming)
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
445 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
446 LOG(INFO) << "Streaming a ZIP archive";
5116
c9c052ba309c undo wrong commit
Alain Mazy <am@osimis.io>
parents: 5114
diff changeset
447 boost::shared_ptr<SharedMessageQueue> queue(new SharedMessageQueue);
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
448
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
449 job->AcquireSynchronousTarget(new SynchronousZipStream(queue));
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
450
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
451 std::string jobId;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
452 context.GetJobsEngine().GetRegistry().Submit(jobId, job.release(), priority);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
453
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
454 SynchronousZipSender sender(context, jobId, queue, filename);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
455 output.AnswerWithoutBuffering(sender);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
456
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
457 // If we reach this line, this means that
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
458 // "SynchronousZipSender::ReadNextChunk()" has returned "false"
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
459 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
460 else
2969
2c16c29b287d preparing for asynchronous generation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
461 {
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
462 // This was the only behavior in Orthanc <= 1.9.3
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
463 LOG(INFO) << "Not streaming a ZIP archive (use of a temporary file)";
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
464 boost::shared_ptr<TemporaryFile> tmp;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
465
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
466 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
467 OrthancConfiguration::ReaderLock lock;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
468 tmp.reset(lock.GetConfiguration().CreateTemporaryFile());
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
469 }
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
470
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
471 job->AcquireSynchronousTarget(new SynchronousTemporaryStream(tmp));
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
472
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
473 Json::Value publicContent;
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
474 context.GetJobsEngine().GetRegistry().SubmitAndWait
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
475 (publicContent, job.release(), priority);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
476
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
477 {
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
478 // The archive is now created: Prepare the sending of the ZIP file
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
479 FilesystemHttpSender sender(tmp->GetPath(), MimeType_Zip);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
480 sender.SetContentFilename(filename);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
481
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
482 // Send the ZIP
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
483 output.AnswerStream(sender);
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
484 }
2969
2c16c29b287d preparing for asynchronous generation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
485 }
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
486 }
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
487 else
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
488 {
2976
cb5d75143da0 Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2970
diff changeset
489 OrthancRestApi::SubmitGenericJob(output, context, job.release(), false, priority);
2969
2c16c29b287d preparing for asynchronous generation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
490 }
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
491 }
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
492
4416
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
493
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
494 static void DocumentPostArguments(RestApiPostCall& call,
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
495 bool isMedia,
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
496 bool defaultExtended)
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
497 {
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
498 call.GetDocumentation()
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
499 .SetRequestField("Synchronous", RestApiCallDocumentation::Type_Boolean,
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
500 "If `true`, create the archive in synchronous mode, which means that the HTTP answer will directly "
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
501 "contain the ZIP file. This is the default, easy behavior. However, if global configuration option "
4751
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
502 "\"SynchronousZipStream\" is set to \"false\", asynchronous transfers should be preferred for "
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
503 "large amount of data, as the creation of the temporary file might lead to network timeouts.", false)
4416
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
504 .SetRequestField("Asynchronous", RestApiCallDocumentation::Type_Boolean,
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
505 "If `true`, create the archive in asynchronous mode, which means that a job is submitted to create "
4674
cdab941fe17d ZIP archive/media generated in synchronous mode are now streamed by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
506 "the archive in background.", false)
4416
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
507 .SetRequestField(KEY_TRANSCODE, RestApiCallDocumentation::Type_String,
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
508 "If present, the DICOM files in the archive will be transcoded to the provided "
5432
59e3b6f8c5be migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5426
diff changeset
509 "transfer syntax: https://orthanc.uclouvain.be/book/faq/transcoding.html", false)
4416
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
510 .SetRequestField("Priority", RestApiCallDocumentation::Type_Number,
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
511 "In asynchronous mode, the priority of the job. The lower the value, the higher the priority.", false)
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
512 .AddAnswerType(MimeType_Zip, "In synchronous mode, the ZIP file containing the archive")
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
513 .AddAnswerType(MimeType_Json, "In asynchronous mode, information about the job that has been submitted to "
5432
59e3b6f8c5be migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5426
diff changeset
514 "generate the archive: https://orthanc.uclouvain.be/book/users/advanced-rest.html#jobs")
4417
a4518adede59 openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4416
diff changeset
515 .SetAnswerField("ID", RestApiCallDocumentation::Type_String, "Identifier of the job")
a4518adede59 openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4416
diff changeset
516 .SetAnswerField("Path", RestApiCallDocumentation::Type_String, "Path to access the job in the REST API");
4416
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
517
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
518 if (isMedia)
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
519 {
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
520 call.GetDocumentation().SetRequestField(
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
521 KEY_EXTENDED, RestApiCallDocumentation::Type_Boolean, "If `true`, will include additional "
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
522 "tags such as `SeriesDescription`, leading to a so-called *extended DICOMDIR*. Default value is " +
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
523 std::string(defaultExtended ? "`true`" : "`false`") + ".", false);
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
524 }
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
525 }
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
526
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
527
2970
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
528 template <bool IS_MEDIA,
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
529 bool DEFAULT_IS_EXTENDED /* only makes sense for media (i.e. not ZIP archives) */ >
5447
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
530 static void CreateBatchPost(RestApiPostCall& call)
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
531 {
4416
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
532 if (call.IsDocumentation())
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
533 {
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
534 DocumentPostArguments(call, IS_MEDIA, DEFAULT_IS_EXTENDED);
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
535 std::string m = (IS_MEDIA ? "DICOMDIR media" : "ZIP archive");
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
536 call.GetDocumentation()
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
537 .SetTag("System")
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
538 .SetSummary("Create " + m)
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
539 .SetDescription("Create a " + m + " containing the DICOM resources (patients, studies, series, or instances) "
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
540 "whose Orthanc identifiers are provided in the body")
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
541 .SetRequestField("Resources", RestApiCallDocumentation::Type_JsonListOfStrings,
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
542 "The list of Orthanc identifiers of interest.", false);
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
543 return;
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
544 }
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
545
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
546 ServerContext& context = OrthancRestApi::GetContext(call);
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
547
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
548 Json::Value body;
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
549 if (call.ParseJsonRequest(body))
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
550 {
3913
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
551 bool synchronous, extended, transcode;
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
552 DicomTransferSyntax transferSyntax;
2970
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
553 int priority;
4797
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
554 unsigned int loaderThreads;
3913
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
555 GetJobParameters(synchronous, extended, transcode, transferSyntax,
4797
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
556 priority, loaderThreads, body, DEFAULT_IS_EXTENDED);
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
557
5401
fc604681e6be When exporting a study archive, make sure to use the PatientName from the study and not from the patient in case of PatientID collision
Alain Mazy <am@osimis.io>
parents: 5185
diff changeset
558 std::unique_ptr<ArchiveJob> job(new ArchiveJob(context, IS_MEDIA, extended, ResourceType_Patient));
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
559 AddResourcesOfInterest(*job, body);
3913
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
560
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
561 if (transcode)
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
562 {
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
563 job->SetTranscode(transferSyntax);
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
564 }
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
565
4797
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
566 job->SetLoaderThreads(loaderThreads);
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
567
2970
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
568 SubmitJob(call.GetOutput(), context, job, priority, synchronous, "Archive.zip");
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
569 }
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
570 else
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
571 {
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
572 throw OrthancException(ErrorCode_BadFileFormat,
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
573 "Expected a list of resources to archive in the body");
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
574 }
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
575 }
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
576
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
577
5447
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
578 template <bool IS_MEDIA,
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
579 bool DEFAULT_IS_EXTENDED /* only makes sense for media (i.e. not ZIP archives) */ >
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
580 static void CreateBatchGet(RestApiGetCall& call)
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
581 {
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
582 static const char* const TRANSCODE = "transcode";
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
583 static const char* const RESOURCES = "resources";
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
584
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
585 if (call.IsDocumentation())
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
586 {
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
587 std::string m = (IS_MEDIA ? "DICOMDIR media" : "ZIP archive");
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
588 call.GetDocumentation()
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
589 .SetTag("System")
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
590 .SetSummary("Create " + m)
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
591 .SetDescription("Create a " + m + " containing the DICOM resources (patients, studies, series, or instances) "
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
592 "whose Orthanc identifiers are provided in the 'resources' argument")
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
593 .SetHttpGetArgument(TRANSCODE, RestApiCallDocumentation::Type_String,
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
594 "If present, the DICOM files will be transcoded to the provided "
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
595 "transfer syntax: https://orthanc.uclouvain.be/book/faq/transcoding.html", false)
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
596 .SetHttpGetArgument(RESOURCES, RestApiCallDocumentation::Type_String,
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
597 "A comma separated list of Orthanc resource identifiers to include in the " + m + ".", true);
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
598 return;
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
599 }
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
600
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
601 ServerContext& context = OrthancRestApi::GetContext(call);
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
602 bool transcode = false;
5576
3a6d6d35193c fix build of Housekeeper plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
603 DicomTransferSyntax transferSyntax = DicomTransferSyntax_LittleEndianImplicit; // Initialize variable to avoid warnings
5447
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
604
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
605 if (call.HasArgument(TRANSCODE))
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
606 {
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
607 transcode = true;
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
608 transferSyntax = GetTransferSyntax(call.GetArgument(TRANSCODE, ""));
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
609 }
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
610
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
611 if (!call.HasArgument(RESOURCES))
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
612 {
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
613 throw OrthancException(Orthanc::ErrorCode_BadRequest, std::string("Missing ") + RESOURCES + " argument");
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
614 }
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
615
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
616 std::unique_ptr<ArchiveJob> job(new ArchiveJob(context, IS_MEDIA, DEFAULT_IS_EXTENDED, ResourceType_Patient));
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
617 AddResourcesOfInterestFromString(*job, call.GetArgument(RESOURCES, ""));
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
618
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
619 if (transcode)
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
620 {
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
621 job->SetTranscode(transferSyntax);
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
622 }
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
623
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
624 SubmitJob(call.GetOutput(), context, job, 0, true, "Archive.zip");
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
625 }
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
626
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
627
5169
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
628 template <ResourceType LEVEL,
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
629 bool IS_MEDIA>
2970
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
630 static void CreateSingleGet(RestApiGetCall& call)
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
631 {
4797
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
632 static const char* const TRANSCODE = "transcode";
4987
48b53ac404d9 New option "filename" in "/.../{id}/archive" and "/.../{id}/media"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4902
diff changeset
633 static const char* const FILENAME = "filename";
4797
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
634
4416
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
635 if (call.IsDocumentation())
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
636 {
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
637 ResourceType t = StringToResourceType(call.GetFullUri()[0].c_str());
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
638 std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */);
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
639 std::string m = (IS_MEDIA ? "DICOMDIR media" : "ZIP archive");
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
640 call.GetDocumentation()
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
641 .SetTag(GetResourceTypeText(t, true /* plural */, true /* upper case */))
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
642 .SetSummary("Create " + m)
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
643 .SetDescription("Synchronously create a " + m + " containing the DICOM " + r +
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
644 " whose Orthanc identifier is provided in the URL. This flavor is synchronous, "
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
645 "which might *not* be desirable to archive large amount of data, as it might "
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
646 "lead to network timeouts. Prefer the asynchronous version using `POST` method.")
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
647 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest")
4987
48b53ac404d9 New option "filename" in "/.../{id}/archive" and "/.../{id}/media"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4902
diff changeset
648 .SetHttpGetArgument(FILENAME, RestApiCallDocumentation::Type_String,
48b53ac404d9 New option "filename" in "/.../{id}/archive" and "/.../{id}/media"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4902
diff changeset
649 "Filename to set in the \"Content-Disposition\" HTTP header "
48b53ac404d9 New option "filename" in "/.../{id}/archive" and "/.../{id}/media"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4902
diff changeset
650 "(including file extension)", false)
4797
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
651 .SetHttpGetArgument(TRANSCODE, RestApiCallDocumentation::Type_String,
4416
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
652 "If present, the DICOM files in the archive will be transcoded to the provided "
5432
59e3b6f8c5be migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5426
diff changeset
653 "transfer syntax: https://orthanc.uclouvain.be/book/faq/transcoding.html", false)
4416
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
654 .AddAnswerType(MimeType_Zip, "ZIP file containing the archive");
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
655 if (IS_MEDIA)
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
656 {
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
657 call.GetDocumentation().SetHttpGetArgument(
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
658 "extended", RestApiCallDocumentation::Type_String,
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
659 "If present, will include additional tags such as `SeriesDescription`, leading to a so-called *extended DICOMDIR*", false);
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
660 }
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
661 return;
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
662 }
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
663
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
664 ServerContext& context = OrthancRestApi::GetContext(call);
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
665
4987
48b53ac404d9 New option "filename" in "/.../{id}/archive" and "/.../{id}/media"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4902
diff changeset
666 const std::string id = call.GetUriComponent("id", "");
48b53ac404d9 New option "filename" in "/.../{id}/archive" and "/.../{id}/media"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4902
diff changeset
667 const std::string filename = call.GetArgument(FILENAME, id + ".zip"); // New in Orthanc 1.11.0
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
668
2970
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
669 bool extended;
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
670 if (IS_MEDIA)
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
671 {
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
672 extended = call.HasArgument("extended");
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
673 }
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
674 else
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
675 {
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
676 extended = false;
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
677 }
3913
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
678
5403
05cb668c5f3f fix to keep backward behaviour when exporting a series archive
Alain Mazy <am@osimis.io>
parents: 5401
diff changeset
679 std::unique_ptr<ArchiveJob> job(new ArchiveJob(context, IS_MEDIA, extended, (LEVEL == ResourceType_Patient ? ResourceType_Patient : ResourceType_Study))); // use patient info from study except when exporting a patient
5169
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
680 job->AddResource(id, true, LEVEL);
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
681
3913
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
682 if (call.HasArgument(TRANSCODE))
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
683 {
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
684 job->SetTranscode(GetTransferSyntax(call.GetArgument(TRANSCODE, "")));
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
685 }
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
686
4797
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
687 {
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
688 OrthancConfiguration::ReaderLock lock;
4902
df86d2505df8 Orthanc 1.9.8 is now known as Orthanc 1.10.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4892
diff changeset
689 unsigned int loaderThreads = lock.GetConfiguration().GetUnsignedIntegerParameter(CONFIG_LOADER_THREADS, 0); // New in Orthanc 1.10.0
4797
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
690 job->SetLoaderThreads(loaderThreads);
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
691 }
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
692
2970
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
693 SubmitJob(call.GetOutput(), context, job, 0 /* priority */,
4987
48b53ac404d9 New option "filename" in "/.../{id}/archive" and "/.../{id}/media"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4902
diff changeset
694 true /* synchronous */, filename);
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
695 }
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
696
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
697
5169
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
698 template <ResourceType LEVEL,
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
699 bool IS_MEDIA>
2978
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
700 static void CreateSinglePost(RestApiPostCall& call)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
701 {
4416
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
702 if (call.IsDocumentation())
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
703 {
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
704 DocumentPostArguments(call, IS_MEDIA, false /* not extended by default */);
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
705 ResourceType t = StringToResourceType(call.GetFullUri()[0].c_str());
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
706 std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */);
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
707 std::string m = (IS_MEDIA ? "DICOMDIR media" : "ZIP archive");
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
708 call.GetDocumentation()
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
709 .SetTag(GetResourceTypeText(t, true /* plural */, true /* upper case */))
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
710 .SetSummary("Create " + m)
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
711 .SetDescription("Create a " + m + " containing the DICOM " + r +
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
712 " whose Orthanc identifier is provided in the URL")
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
713 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest");
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
714 return;
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
715 }
0b27841950d5 openapi about creation of zip/media archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
716
2978
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
717 ServerContext& context = OrthancRestApi::GetContext(call);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
718
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
719 std::string id = call.GetUriComponent("id", "");
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
720
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
721 Json::Value body;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
722 if (call.ParseJsonRequest(body))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
723 {
3913
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
724 bool synchronous, extended, transcode;
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
725 DicomTransferSyntax transferSyntax;
2978
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
726 int priority;
4797
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
727 unsigned int loaderThreads;
3913
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
728 GetJobParameters(synchronous, extended, transcode, transferSyntax,
4797
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
729 priority, loaderThreads, body, false /* by default, not extented */);
2978
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
730
5401
fc604681e6be When exporting a study archive, make sure to use the PatientName from the study and not from the patient in case of PatientID collision
Alain Mazy <am@osimis.io>
parents: 5185
diff changeset
731 std::unique_ptr<ArchiveJob> job(new ArchiveJob(context, IS_MEDIA, extended, LEVEL));
5169
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
732 job->AddResource(id, true, LEVEL);
3913
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
733
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
734 if (transcode)
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
735 {
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
736 job->SetTranscode(transferSyntax);
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
737 }
6ddad3e0b569 transcoding ZIP archive and media
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
738
4797
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
739 job->SetLoaderThreads(loaderThreads);
4e765c18ace7 enable using multiple threads to load instances when generating zip archive/media
Alain Mazy <am@osimis.io>
parents: 4751
diff changeset
740
2978
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
741 SubmitJob(call.GetOutput(), context, job, priority, synchronous, id + ".zip");
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
742 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
743 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
744 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
745 throw OrthancException(ErrorCode_BadFileFormat);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
746 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
747 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
748
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
749
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
750 void OrthancRestApi::RegisterArchive()
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
751 {
5169
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
752 Register("/patients/{id}/archive", CreateSingleGet<ResourceType_Patient, false /* ZIP */>);
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
753 Register("/patients/{id}/archive", CreateSinglePost<ResourceType_Patient, false /* ZIP */>);
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
754 Register("/patients/{id}/media", CreateSingleGet<ResourceType_Patient, true /* media */>);
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
755 Register("/patients/{id}/media", CreateSinglePost<ResourceType_Patient, true /* media */>);
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
756 Register("/series/{id}/archive", CreateSingleGet<ResourceType_Series, false /* ZIP */>);
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
757 Register("/series/{id}/archive", CreateSinglePost<ResourceType_Series, false /* ZIP */>);
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
758 Register("/series/{id}/media", CreateSingleGet<ResourceType_Series, true /* media */>);
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
759 Register("/series/{id}/media", CreateSinglePost<ResourceType_Series, true /* media */>);
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
760 Register("/studies/{id}/archive", CreateSingleGet<ResourceType_Study, false /* ZIP */>);
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
761 Register("/studies/{id}/archive", CreateSinglePost<ResourceType_Study, false /* ZIP */>);
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
762 Register("/studies/{id}/media", CreateSingleGet<ResourceType_Study, true /* media */>);
8b74aa4f3515 enforce the existence of the patient/study/instance while creating its archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5116
diff changeset
763 Register("/studies/{id}/media", CreateSinglePost<ResourceType_Study, true /* media */>);
2978
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
764
2970
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
765 Register("/tools/create-archive",
5447
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
766 CreateBatchPost<false /* ZIP */, false /* extended makes no sense in ZIP */>);
2970
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
767 Register("/tools/create-media",
5447
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
768 CreateBatchPost<true /* media */, false /* not extended by default */>);
2970
eea66afed0db remove redundancies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2969
diff changeset
769 Register("/tools/create-media-extended",
5447
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
770 CreateBatchPost<true /* media */, true /* extended by default */>);
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
771
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
772 Register("/tools/create-archive",
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
773 CreateBatchGet<false /* ZIP */, false /* extended makes no sense in ZIP */>);
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
774 Register("/tools/create-media",
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
775 CreateBatchGet<true /* media */, false /* not extended by default */>);
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
776 Register("/tools/create-media-extended",
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
777 CreateBatchGet<true /* media */, true /* extended by default */>);
dacdce5e5c22 now accepting GET requests on the /tools/create-archive route and siblings
Alain Mazy <am@osimis.io>
parents: 5432
diff changeset
778
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
779 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
780 }