annotate OrthancServer/Sources/ServerJobs/OrthancPeerStoreJob.cpp @ 4044:d25f4c0fa160 framework

splitting code into OrthancFramework and OrthancServer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jun 2020 20:30:34 +0200
parents OrthancServer/ServerJobs/OrthancPeerStoreJob.cpp@5fe8c6d3212e
children 05b8fd21089c
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
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
5 * Copyright (C) 2017-2020 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
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../../Core/Logging.h"
3949
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
38 #include "../../Core/SerializationToolbox.h"
3095
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
39 #include "../ServerContext.h"
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
3950
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
41 #include <dcmtk/dcmdata/dcfilefo.h>
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
42
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 namespace Orthanc
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 bool OrthancPeerStoreJob::HandleInstance(const std::string& instance)
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 //boost::this_thread::sleep(boost::posix_time::milliseconds(500));
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 if (client_.get() == NULL)
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 client_.reset(new HttpClient(peer_, "instances"));
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 client_->SetMethod(HttpMethod_Post);
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 LOG(INFO) << "Sending instance " << instance << " to peer \""
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 << peer_.GetUrl() << "\"";
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
2624
714dcddeb65f asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
59 try
714dcddeb65f asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
60 {
3950
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
61 if (transcode_)
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
62 {
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
63 std::string dicom;
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
64 context_.ReadDicom(dicom, instance);
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
65
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
66 std::set<DicomTransferSyntax> syntaxes;
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
67 syntaxes.insert(transferSyntax_);
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
68
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
69 IDicomTranscoder::DicomImage source, transcoded;
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
70 source.SetExternalBuffer(dicom);
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
71
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3950
diff changeset
72 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
73 {
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
74 client_->GetBody().assign(reinterpret_cast<const char*>(transcoded.GetBufferData()),
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
75 transcoded.GetBufferSize());
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
76 }
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
77 else
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 client_->GetBody().swap(dicom);
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
80 }
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
81 }
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
82 else
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
83 {
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
84 context_.ReadDicom(client_->GetBody(), instance);
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3949
diff changeset
85 }
2624
714dcddeb65f asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
86 }
714dcddeb65f asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
87 catch (OrthancException& e)
714dcddeb65f asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
88 {
714dcddeb65f asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
89 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
90 return false;
714dcddeb65f asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
91 }
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 std::string answer;
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 if (client_->Apply(answer))
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 return true;
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 else
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 throw OrthancException(ErrorCode_NetworkProtocol);
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
2842
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2812
diff changeset
105 bool OrthancPeerStoreJob::HandleTrailingStep()
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2812
diff changeset
106 {
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2812
diff changeset
107 throw OrthancException(ErrorCode_InternalError);
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2812
diff changeset
108 }
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2812
diff changeset
109
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2812
diff changeset
110
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 void OrthancPeerStoreJob::SetPeer(const WebServiceParameters& peer)
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 if (IsStarted())
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 throw OrthancException(ErrorCode_BadSequenceOfCalls);
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 else
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 peer_ = peer;
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123
3949
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
124 DicomTransferSyntax OrthancPeerStoreJob::GetTransferSyntax() const
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
125 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
126 if (transcode_)
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
127 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
128 return transferSyntax_;
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
129 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
130 else
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
131 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
132 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
133 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
134 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
135
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
136
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
137 void OrthancPeerStoreJob::SetTranscode(DicomTransferSyntax syntax)
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
138 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
139 if (IsStarted())
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
140 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
141 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
142 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
143 else
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
144 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
145 transcode_ = true;
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
146 transferSyntax_ = syntax;
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
147 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
148 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
149
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
150
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
151 void OrthancPeerStoreJob::SetTranscode(const std::string& transferSyntaxUid)
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
152 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
153 DicomTransferSyntax s;
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
154 if (LookupTransferSyntax(s, transferSyntaxUid))
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
155 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
156 SetTranscode(s);
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
157 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
158 else
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
159 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
160 throw OrthancException(ErrorCode_BadFileFormat,
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
161 "Unknown transfer syntax UID: " + transferSyntaxUid);
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 }
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
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
166 void OrthancPeerStoreJob::ClearTranscode()
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
167 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
168 if (IsStarted())
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 throw OrthancException(ErrorCode_BadSequenceOfCalls);
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 else
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 transcode_ = false;
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 }
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
2812
ea7aea6f6a95 improved naming of methods in IJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2811
diff changeset
179 void OrthancPeerStoreJob::Stop(JobStopReason reason) // For pausing jobs
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 client_.reset(NULL);
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 void OrthancPeerStoreJob::GetPublicContent(Json::Value& value)
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 {
2640
c691fcf66071 ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
187 SetOfInstancesJob::GetPublicContent(value);
c691fcf66071 ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
188
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 Json::Value v;
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2669
diff changeset
190 peer_.Serialize(v,
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2669
diff changeset
191 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
192 false /* don't include passwords */);
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 value["Peer"] = v;
3949
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 if (transcode_)
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
196 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
197 value["Transcode"] = GetTransferSyntaxUid(transferSyntax_);
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
198 }
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 }
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
200
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
201
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
202 static const char* PEER = "Peer";
3949
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
203 static const char* TRANSCODE = "Transcode";
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
204
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
205 OrthancPeerStoreJob::OrthancPeerStoreJob(ServerContext& context,
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
206 const Json::Value& serialized) :
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
207 SetOfInstancesJob(serialized),
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
208 context_(context)
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
209 {
3949
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
210 assert(serialized.type() == Json::objectValue);
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
211 peer_ = WebServiceParameters(serialized[PEER]);
3949
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 if (serialized.isMember(TRANSCODE))
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
214 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
215 SetTranscode(SerializationToolbox::ReadString(serialized, TRANSCODE));
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
216 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
217 else
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
218 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
219 transcode_ = false;
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
220 }
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
221 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
222
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
223
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
224 bool OrthancPeerStoreJob::Serialize(Json::Value& target)
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
225 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
226 if (!SetOfInstancesJob::Serialize(target))
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
227 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
228 return false;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
229 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
230 else
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
231 {
3949
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
232 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
233 peer_.Serialize(target[PEER],
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2669
diff changeset
234 true /* force advanced format */,
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2669
diff changeset
235 true /* include passwords */);
3949
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
236
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
237 if (transcode_)
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
238 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
239 target[TRANSCODE] = GetTransferSyntaxUid(transferSyntax_);
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
240 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
241
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
242 return true;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
243 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
244 }
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 }