annotate OrthancServer/Sources/ServerJobs/OrthancPeerStoreJob.cpp @ 4674:cdab941fe17d

ZIP archive/media generated in synchronous mode are now streamed by default
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 03 Jun 2021 17:40:15 +0200
parents 9804d6490872
children f0038043fb97 7053502fbf97
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4437
d9473bd5ed43 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4154
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
988936118354 reorganization
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
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "../PrecompiledHeadersServer.h"
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "OrthancPeerStoreJob.h"
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
37 #include "../../../OrthancFramework/Sources/Compression/GzipCompressor.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
38 #include "../../../OrthancFramework/Sources/Logging.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
39 #include "../../../OrthancFramework/Sources/SerializationToolbox.h"
3095
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
40 #include "../ServerContext.h"
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
3950
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
42 #include <dcmtk/dcmdata/dcfilefo.h>
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
43
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 namespace Orthanc
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 bool OrthancPeerStoreJob::HandleInstance(const std::string& instance)
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 //boost::this_thread::sleep(boost::posix_time::milliseconds(500));
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 if (client_.get() == NULL)
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 client_.reset(new HttpClient(peer_, "instances"));
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 client_->SetMethod(HttpMethod_Post);
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
55
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
56 if (compress_)
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
57 {
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
58 client_->AddHeader("Expect", "");
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
59 client_->AddHeader("Content-Encoding", "gzip");
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
60 }
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 LOG(INFO) << "Sending instance " << instance << " to peer \""
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 << peer_.GetUrl() << "\"";
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
4650
9804d6490872 Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
66 // Lifetime of "body" must exceed the call to "client_->Apply()" because of "SetExternalBody()"
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
67 std::string body;
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
68
2624
714dcddeb65f asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
69 try
714dcddeb65f asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
70 {
3950
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
71 if (transcode_)
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
72 {
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
73 std::string dicom;
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
74 context_.ReadDicom(dicom, instance);
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
75
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
76 std::set<DicomTransferSyntax> syntaxes;
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
77 syntaxes.insert(transferSyntax_);
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
78
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
79 IDicomTranscoder::DicomImage source, transcoded;
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
80 source.SetExternalBuffer(dicom);
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
81
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3950
diff changeset
82 if (context_.Transcode(transcoded, source, syntaxes, true))
3950
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
83 {
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
84 body.assign(reinterpret_cast<const char*>(transcoded.GetBufferData()),
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
85 transcoded.GetBufferSize());
3950
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
86 }
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
87 else
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
88 {
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
89 body.swap(dicom);
3950
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
90 }
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
91 }
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
92 else
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
93 {
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
94 context_.ReadDicom(body, instance);
3950
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
95 }
2624
714dcddeb65f asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
96 }
714dcddeb65f asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
97 catch (OrthancException& e)
714dcddeb65f asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
98 {
714dcddeb65f asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
99 LOG(WARNING) << "An instance was removed after the job was issued: " << instance;
714dcddeb65f asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
100 return false;
714dcddeb65f asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
101 }
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
4650
9804d6490872 Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
103 // Lifetime of "compressedBody" must exceed the call to "client_->Apply()" because of "SetExternalBody()"
9804d6490872 Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
104 std::string compressedBody;
9804d6490872 Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
105
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
106 if (compress_)
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
107 {
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
108 GzipCompressor compressor;
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
109 compressor.SetCompressionLevel(9); // Max compression level
4650
9804d6490872 Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
110 IBufferCompressor::Compress(compressedBody, compressor, body);
9804d6490872 Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
111
9804d6490872 Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
112 client_->SetExternalBody(compressedBody);
9804d6490872 Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
113 size_ += compressedBody.size();
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
114 }
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
115 else
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
116 {
4650
9804d6490872 Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
117 client_->SetExternalBody(body);
9804d6490872 Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
118 size_ += body.size();
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
119 }
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
120
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 std::string answer;
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 if (client_->Apply(answer))
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 return true;
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 else
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 {
4154
6e7c842679ec improved log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4153
diff changeset
128 if (compress_)
6e7c842679ec improved log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4153
diff changeset
129 {
6e7c842679ec improved log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4153
diff changeset
130 LOG(ERROR) << "Cannot send DICOM over HTTP using \"gzip\" as "
6e7c842679ec improved log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4153
diff changeset
131 << "\"Content-Encoding\": Make sure that the version "
6e7c842679ec improved log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4153
diff changeset
132 << "of the remote Orthanc server is >= 1.6.0";
6e7c842679ec improved log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4153
diff changeset
133 }
6e7c842679ec improved log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4153
diff changeset
134
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 throw OrthancException(ErrorCode_NetworkProtocol);
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139
2842
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2812
diff changeset
140 bool OrthancPeerStoreJob::HandleTrailingStep()
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2812
diff changeset
141 {
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2812
diff changeset
142 throw OrthancException(ErrorCode_InternalError);
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2812
diff changeset
143 }
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2812
diff changeset
144
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2812
diff changeset
145
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 void OrthancPeerStoreJob::SetPeer(const WebServiceParameters& peer)
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 if (IsStarted())
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 throw OrthancException(ErrorCode_BadSequenceOfCalls);
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 else
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 peer_ = peer;
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158
3949
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
159 DicomTransferSyntax OrthancPeerStoreJob::GetTransferSyntax() const
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
160 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
161 if (transcode_)
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
162 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
163 return transferSyntax_;
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
164 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
165 else
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
166 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
167 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
168 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
169 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
170
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
171
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
172 void OrthancPeerStoreJob::SetTranscode(DicomTransferSyntax syntax)
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
173 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
174 if (IsStarted())
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
175 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
176 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
177 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
178 else
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
179 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
180 transcode_ = true;
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
181 transferSyntax_ = syntax;
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
182 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
183 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
184
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
185
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
186 void OrthancPeerStoreJob::SetTranscode(const std::string& transferSyntaxUid)
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
187 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
188 DicomTransferSyntax s;
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
189 if (LookupTransferSyntax(s, transferSyntaxUid))
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
190 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
191 SetTranscode(s);
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
192 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
193 else
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
194 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
195 throw OrthancException(ErrorCode_BadFileFormat,
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
196 "Unknown transfer syntax UID: " + transferSyntaxUid);
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
197 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
198 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
199
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
200
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
201 void OrthancPeerStoreJob::ClearTranscode()
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
202 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
203 if (IsStarted())
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
204 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
205 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
206 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
207 else
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
208 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
209 transcode_ = false;
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
210 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
211 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
212
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
213
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
214 void OrthancPeerStoreJob::SetCompress(bool compress)
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
215 {
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
216 if (IsStarted())
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
217 {
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
218 throw OrthancException(ErrorCode_BadSequenceOfCalls);
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
219 }
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
220 else
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
221 {
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
222 compress_ = compress;
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
223 }
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
224 }
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
225
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
226
2812
ea7aea6f6a95 improved naming of methods in IJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2811
diff changeset
227 void OrthancPeerStoreJob::Stop(JobStopReason reason) // For pausing jobs
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 client_.reset(NULL);
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 void OrthancPeerStoreJob::GetPublicContent(Json::Value& value)
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 {
2640
c691fcf66071 ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
235 SetOfInstancesJob::GetPublicContent(value);
c691fcf66071 ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
236
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 Json::Value v;
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2669
diff changeset
238 peer_.Serialize(v,
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2669
diff changeset
239 false /* allow simple format if possible */,
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2669
diff changeset
240 false /* don't include passwords */);
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 value["Peer"] = v;
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
242 value["Compress"] = compress_;
3949
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
243
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
244 if (transcode_)
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
245 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
246 value["Transcode"] = GetTransferSyntaxUid(transferSyntax_);
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
247 }
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
248
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
249 static const uint64_t MEGA_BYTES = 1024 * 1024;
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
250 value["Size"] = boost::lexical_cast<std::string>(size_);
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
251 value["SizeMB"] = static_cast<unsigned int>(size_ / MEGA_BYTES);
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 }
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
253
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
254
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
255 static const char* PEER = "Peer";
3949
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
256 static const char* TRANSCODE = "Transcode";
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
257 static const char* COMPRESS = "Compress";
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
258 static const char* SIZE = "Size";
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
259
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
260 OrthancPeerStoreJob::OrthancPeerStoreJob(ServerContext& context,
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
261 const Json::Value& serialized) :
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
262 SetOfInstancesJob(serialized),
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
263 context_(context)
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
264 {
3949
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
265 assert(serialized.type() == Json::objectValue);
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
266 peer_ = WebServiceParameters(serialized[PEER]);
3949
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
267
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
268 if (serialized.isMember(TRANSCODE))
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
269 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
270 SetTranscode(SerializationToolbox::ReadString(serialized, TRANSCODE));
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
271 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
272 else
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
273 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
274 transcode_ = false;
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
275 transferSyntax_ = DicomTransferSyntax_LittleEndianExplicit; // Dummy value
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
276 }
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
277
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
278 if (serialized.isMember(COMPRESS))
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
279 {
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
280 SetCompress(SerializationToolbox::ReadBoolean(serialized, COMPRESS));
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
281 }
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
282 else
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
283 {
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
284 compress_ = false;
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
285 }
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
286
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
287 if (serialized.isMember(SIZE))
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
288 {
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
289 size_ = boost::lexical_cast<uint64_t>(SerializationToolbox::ReadString(serialized, SIZE));
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
290 }
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
291 else
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
292 {
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
293 size_ = 0;
3949
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
294 }
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
295 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
296
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
297
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
298 bool OrthancPeerStoreJob::Serialize(Json::Value& target)
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
299 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
300 if (!SetOfInstancesJob::Serialize(target))
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
301 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
302 return false;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
303 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
304 else
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
305 {
3949
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
306 assert(target.type() == Json::objectValue);
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2669
diff changeset
307 peer_.Serialize(target[PEER],
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2669
diff changeset
308 true /* force advanced format */,
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2669
diff changeset
309 true /* include passwords */);
3949
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
310
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
311 if (transcode_)
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
312 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
313 target[TRANSCODE] = GetTransferSyntaxUid(transferSyntax_);
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
314 }
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
315
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
316 target[COMPRESS] = compress_;
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
317 target[SIZE] = boost::lexical_cast<std::string>(size_);
3949
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
318
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
319 return true;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
320 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
321 }
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 }