annotate OrthancServer/OrthancRestApi/OrthancRestArchive.cpp @ 2813:6d5b20af216f

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 06 Sep 2018 18:24:44 +0200
parents 2406ae891747
children 251614c2edac
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
2447
878b59270859 upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2446
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * 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
9 * published by the Free Software Foundation, either version 3 of the
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * 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
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * 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
30 * 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
31 **/
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
34 #include "../PrecompiledHeadersServer.h"
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "OrthancRestApi.h"
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../../Core/HttpServer/FilesystemHttpSender.h"
2632
2406ae891747 ArchiveJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2630
diff changeset
38 #include "../ServerJobs/ArchiveJob.h"
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 namespace Orthanc
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
2632
2406ae891747 ArchiveJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2630
diff changeset
42 static bool AddResourcesOfInterest(ArchiveJob& job,
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
43 RestApiPostCall& call)
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
44 {
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
45 Json::Value resources;
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
46 if (call.ParseJsonRequest(resources) &&
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
47 resources.type() == Json::arrayValue)
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
48 {
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
49 for (Json::Value::ArrayIndex i = 0; i < resources.size(); i++)
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
50 {
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
51 if (resources[i].type() != Json::stringValue)
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
52 {
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
53 return false; // Bad request
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
54 }
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
55
2632
2406ae891747 ArchiveJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2630
diff changeset
56 job.AddResource(resources[i].asString());
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
57 }
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
58
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
59 return true;
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
60 }
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
61 else
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
62 {
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
63 return false;
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
64 }
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
65 }
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
66
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
67
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
68 static void SubmitJob(RestApiCall& call,
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
69 boost::shared_ptr<TemporaryFile>& tmp,
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
70 ServerContext& context,
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
71 std::auto_ptr<ArchiveJob>& job,
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
72 const std::string& filename)
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
73 {
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
74 if (job.get() == NULL)
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
75 {
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
76 throw OrthancException(ErrorCode_NullPointer);
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
77 }
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
78
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
79 job->SetDescription("REST API");
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
80
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
81 if (context.GetJobsEngine().GetRegistry().SubmitAndWait(job.release(), 0 /* TODO priority */))
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
82 {
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
83 // The archive is now created: Prepare the sending of the ZIP file
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
84 FilesystemHttpSender sender(tmp->GetPath());
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
85 sender.SetContentType("application/zip");
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
86 sender.SetContentFilename(filename);
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
87
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
88 // Send the ZIP
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
89 call.GetOutput().AnswerStream(sender);
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
90 }
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
91 else
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
92 {
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
93 call.GetOutput().SignalError(HttpStatus_500_InternalServerError);
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
94 }
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
95 }
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
96
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
97
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
98 static void CreateBatchArchive(RestApiPostCall& call)
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
99 {
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
100 ServerContext& context = OrthancRestApi::GetContext(call);
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
101
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
102 boost::shared_ptr<TemporaryFile> tmp(new TemporaryFile);
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
103 std::auto_ptr<ArchiveJob> job(new ArchiveJob(tmp, context, false, false));
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
104
2632
2406ae891747 ArchiveJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2630
diff changeset
105 if (AddResourcesOfInterest(*job, call))
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
106 {
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
107 SubmitJob(call, tmp, context, job, "Archive.zip");
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
108 }
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
109 }
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
110
2446
a894adc8bb03 /tools/create-media-extended to include type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2422
diff changeset
111
a894adc8bb03 /tools/create-media-extended to include type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2422
diff changeset
112 template <bool Extended>
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
113 static void CreateBatchMedia(RestApiPostCall& call)
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
114 {
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
115 ServerContext& context = OrthancRestApi::GetContext(call);
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
116
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
117 boost::shared_ptr<TemporaryFile> tmp(new TemporaryFile);
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
118 std::auto_ptr<ArchiveJob> job(new ArchiveJob(tmp, context, true, Extended));
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
119
2632
2406ae891747 ArchiveJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2630
diff changeset
120 if (AddResourcesOfInterest(*job, call))
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
121 {
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
122 SubmitJob(call, tmp, context, job, "Archive.zip");
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
123 }
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
124 }
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
125
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
126
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
127 static void CreateArchive(RestApiGetCall& call)
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
128 {
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
129 ServerContext& context = OrthancRestApi::GetContext(call);
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
130
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
131 std::string id = call.GetUriComponent("id", "");
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
132
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
133 boost::shared_ptr<TemporaryFile> tmp(new TemporaryFile);
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
134 std::auto_ptr<ArchiveJob> job(new ArchiveJob(tmp, context, false, false));
2632
2406ae891747 ArchiveJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2630
diff changeset
135 job->AddResource(id);
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
136
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
137 SubmitJob(call, tmp, context, job, id + ".zip");
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
138 }
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
139
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
140
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
141 static void CreateMedia(RestApiGetCall& call)
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
142 {
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
143 ServerContext& context = OrthancRestApi::GetContext(call);
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
144
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
145 std::string id = call.GetUriComponent("id", "");
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
146
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
147 boost::shared_ptr<TemporaryFile> tmp(new TemporaryFile);
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
148 std::auto_ptr<ArchiveJob> job(new ArchiveJob(tmp, context, true, call.HasArgument("extended")));
2632
2406ae891747 ArchiveJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2630
diff changeset
149 job->AddResource(id);
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
150
2630
00327e989458 creating archives/medias is now a job
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2629
diff changeset
151 SubmitJob(call, tmp, context, job, id + ".zip");
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
152 }
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
153
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
154
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 void OrthancRestApi::RegisterArchive()
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 {
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
157 Register("/patients/{id}/archive", CreateArchive);
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
158 Register("/studies/{id}/archive", CreateArchive);
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
159 Register("/series/{id}/archive", CreateArchive);
1121
82567bac5e25 Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 976
diff changeset
160
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
161 Register("/patients/{id}/media", CreateMedia);
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
162 Register("/studies/{id}/media", CreateMedia);
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
163 Register("/series/{id}/media", CreateMedia);
1774
784a6b92d2f1 start of refactoring the creation of archives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1623
diff changeset
164
1778
776573e592da create media refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1777
diff changeset
165 Register("/tools/create-archive", CreateBatchArchive);
2446
a894adc8bb03 /tools/create-media-extended to include type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2422
diff changeset
166 Register("/tools/create-media", CreateBatchMedia<false>);
a894adc8bb03 /tools/create-media-extended to include type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2422
diff changeset
167 Register("/tools/create-media-extended", CreateBatchMedia<true>);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 }