Mercurial > hg > orthanc
annotate OrthancServer/Sources/ServerJobs/StorageCommitmentScpJob.cpp @ 4880:81dfdcf16e16
merge
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 19 Jan 2022 17:06:22 +0100 |
parents | 43e613a7756b |
children | 6eff25f70121 |
rev | line source |
---|---|
3636 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
3636 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU General Public License as | |
10 * published by the Free Software Foundation, either version 3 of the | |
11 * License, or (at your option) any later version. | |
12 * | |
13 * In addition, as a special exception, the copyright holders of this | |
14 * program give permission to link the code of its release with the | |
15 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
16 * that use the same license as the "OpenSSL" library), and distribute | |
17 * the linked executables. You must obey the GNU General Public License | |
18 * in all respects for all of the code used other than "OpenSSL". If you | |
19 * modify file(s) with this exception, you may extend this exception to | |
20 * your version of the file(s), but you are not obligated to do so. If | |
21 * you do not wish to do so, delete this exception statement from your | |
22 * version. If you delete this exception statement from all source files | |
23 * in the program, then also delete it here. | |
24 * | |
25 * This program is distributed in the hope that it will be useful, but | |
26 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
28 * General Public License for more details. | |
29 * | |
30 * You should have received a copy of the GNU General Public License | |
31 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
32 **/ | |
33 | |
34 | |
35 #include "../PrecompiledHeadersServer.h" | |
36 #include "StorageCommitmentScpJob.h" | |
37 | |
4045 | 38 #include "../../../OrthancFramework/Sources/DicomNetworking/DicomAssociation.h" |
39 #include "../../../OrthancFramework/Sources/Logging.h" | |
40 #include "../../../OrthancFramework/Sources/OrthancException.h" | |
41 #include "../../../OrthancFramework/Sources/SerializationToolbox.h" | |
3636 | 42 #include "../OrthancConfiguration.h" |
43 #include "../ServerContext.h" | |
44 | |
45 | |
3638
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
46 static const char* ANSWER = "Answer"; |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
47 static const char* CALLED_AET = "CalledAet"; |
3661 | 48 static const char* INDEX = "Index"; |
3638
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
49 static const char* LOOKUP = "Lookup"; |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
50 static const char* REMOTE_MODALITY = "RemoteModality"; |
3659
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
51 static const char* SETUP = "Setup"; |
3661 | 52 static const char* SOP_CLASS_UIDS = "SopClassUids"; |
53 static const char* SOP_INSTANCE_UIDS = "SopInstanceUids"; | |
3638
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
54 static const char* TRANSACTION_UID = "TransactionUid"; |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
55 static const char* TYPE = "Type"; |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
56 |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
57 |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
58 |
3636 | 59 namespace Orthanc |
60 { | |
3657
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
61 class StorageCommitmentScpJob::StorageCommitmentCommand : public SetOfCommandsJob::ICommand |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
62 { |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
63 public: |
3659
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
64 virtual CommandType GetType() const = 0; |
3657
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
65 }; |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
66 |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
67 |
3659
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
68 class StorageCommitmentScpJob::SetupCommand : public StorageCommitmentCommand |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
69 { |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
70 private: |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
71 StorageCommitmentScpJob& that_; |
3659
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
72 |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
73 public: |
4205 | 74 explicit SetupCommand(StorageCommitmentScpJob& that) : |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
75 that_(that) |
3659
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
76 { |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
77 } |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
78 |
3763
5ff5d5a0fd28
adding missing ORTHANC_OVERRIDE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3666
diff
changeset
|
79 virtual CommandType GetType() const ORTHANC_OVERRIDE |
3659
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
80 { |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
81 return CommandType_Setup; |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
82 } |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
83 |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
84 virtual bool Execute(const std::string& jobId) ORTHANC_OVERRIDE |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
85 { |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
86 that_.Setup(jobId); |
3659
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
87 return true; |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
88 } |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
89 |
3763
5ff5d5a0fd28
adding missing ORTHANC_OVERRIDE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3666
diff
changeset
|
90 virtual void Serialize(Json::Value& target) const ORTHANC_OVERRIDE |
3659
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
91 { |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
92 target = Json::objectValue; |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
93 target[TYPE] = SETUP; |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
94 } |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
95 }; |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
96 |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
97 |
3657
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
98 class StorageCommitmentScpJob::LookupCommand : public StorageCommitmentCommand |
3636 | 99 { |
100 private: | |
3661 | 101 StorageCommitmentScpJob& that_; |
102 size_t index_; | |
103 bool hasFailureReason_; | |
3657
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
104 StorageCommitmentFailureReason failureReason_; |
3636 | 105 |
106 public: | |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
107 LookupCommand(StorageCommitmentScpJob& that, |
3661 | 108 size_t index) : |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
109 that_(that), |
3661 | 110 index_(index), |
4206 | 111 hasFailureReason_(false), |
112 failureReason_(StorageCommitmentFailureReason_Success) | |
3636 | 113 { |
114 } | |
115 | |
3763
5ff5d5a0fd28
adding missing ORTHANC_OVERRIDE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3666
diff
changeset
|
116 virtual CommandType GetType() const ORTHANC_OVERRIDE |
3657
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
117 { |
3659
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
118 return CommandType_Lookup; |
3657
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
119 } |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
120 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3657
diff
changeset
|
121 virtual bool Execute(const std::string& jobId) ORTHANC_OVERRIDE |
3636 | 122 { |
3665
4c1d2ff7ddd0
handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3662
diff
changeset
|
123 failureReason_ = that_.Lookup(index_); |
4c1d2ff7ddd0
handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3662
diff
changeset
|
124 hasFailureReason_ = true; |
4c1d2ff7ddd0
handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3662
diff
changeset
|
125 return true; |
3636 | 126 } |
127 | |
3661 | 128 size_t GetIndex() const |
3657
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
129 { |
3661 | 130 return index_; |
3657
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
131 } |
3661 | 132 |
3657
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
133 StorageCommitmentFailureReason GetFailureReason() const |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
134 { |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
135 if (hasFailureReason_) |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
136 { |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
137 return failureReason_; |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
138 } |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
139 else |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
140 { |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
141 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
142 } |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
143 } |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
144 |
3763
5ff5d5a0fd28
adding missing ORTHANC_OVERRIDE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3666
diff
changeset
|
145 virtual void Serialize(Json::Value& target) const ORTHANC_OVERRIDE |
3636 | 146 { |
147 target = Json::objectValue; | |
3638
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
148 target[TYPE] = LOOKUP; |
3661 | 149 target[INDEX] = static_cast<unsigned int>(index_); |
3636 | 150 } |
151 }; | |
152 | |
153 | |
3657
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
154 class StorageCommitmentScpJob::AnswerCommand : public StorageCommitmentCommand |
3636 | 155 { |
156 private: | |
157 StorageCommitmentScpJob& that_; | |
158 | |
159 public: | |
4205 | 160 explicit AnswerCommand(StorageCommitmentScpJob& that) : |
3636 | 161 that_(that) |
162 { | |
3639
0c9a8f6d2349
better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3638
diff
changeset
|
163 if (that_.ready_) |
0c9a8f6d2349
better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3638
diff
changeset
|
164 { |
0c9a8f6d2349
better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3638
diff
changeset
|
165 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
0c9a8f6d2349
better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3638
diff
changeset
|
166 } |
0c9a8f6d2349
better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3638
diff
changeset
|
167 else |
0c9a8f6d2349
better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3638
diff
changeset
|
168 { |
0c9a8f6d2349
better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3638
diff
changeset
|
169 that_.ready_ = true; |
0c9a8f6d2349
better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3638
diff
changeset
|
170 } |
3636 | 171 } |
172 | |
3763
5ff5d5a0fd28
adding missing ORTHANC_OVERRIDE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3666
diff
changeset
|
173 virtual CommandType GetType() const ORTHANC_OVERRIDE |
3657
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
174 { |
3659
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
175 return CommandType_Answer; |
3657
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
176 } |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
177 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3657
diff
changeset
|
178 virtual bool Execute(const std::string& jobId) ORTHANC_OVERRIDE |
3636 | 179 { |
180 that_.Answer(); | |
181 return true; | |
182 } | |
183 | |
3763
5ff5d5a0fd28
adding missing ORTHANC_OVERRIDE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3666
diff
changeset
|
184 virtual void Serialize(Json::Value& target) const ORTHANC_OVERRIDE |
3636 | 185 { |
186 target = Json::objectValue; | |
3638
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
187 target[TYPE] = ANSWER; |
3636 | 188 } |
189 }; | |
190 | |
191 | |
192 class StorageCommitmentScpJob::Unserializer : public SetOfCommandsJob::ICommandUnserializer | |
193 { | |
194 private: | |
3657
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
195 StorageCommitmentScpJob& that_; |
3636 | 196 |
197 public: | |
4205 | 198 explicit Unserializer(StorageCommitmentScpJob& that) : |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
199 that_(that) |
3636 | 200 { |
3639
0c9a8f6d2349
better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3638
diff
changeset
|
201 that_.ready_ = false; |
3636 | 202 } |
203 | |
4205 | 204 virtual ICommand* Unserialize(const Json::Value& source) const ORTHANC_OVERRIDE |
3636 | 205 { |
3638
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
206 const std::string type = SerializationToolbox::ReadString(source, TYPE); |
3636 | 207 |
3659
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
208 if (type == SETUP) |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
209 { |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
210 return new SetupCommand(that_); |
3659
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
211 } |
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
212 else if (type == LOOKUP) |
3638
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
213 { |
3661 | 214 return new LookupCommand(that_, SerializationToolbox::ReadUnsignedInteger(source, INDEX)); |
3638
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
215 } |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
216 else if (type == ANSWER) |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
217 { |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
218 return new AnswerCommand(that_); |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
219 } |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
220 else |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
221 { |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
222 throw OrthancException(ErrorCode_BadFileFormat); |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
223 } |
3636 | 224 } |
225 }; | |
226 | |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
227 |
3661 | 228 void StorageCommitmentScpJob::CheckInvariants() |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
229 { |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
230 const size_t n = GetCommandsCount(); |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
231 |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
232 if (n <= 1) |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
233 { |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
234 throw OrthancException(ErrorCode_InternalError); |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
235 } |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
236 |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
237 for (size_t i = 0; i < n; i++) |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
238 { |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
239 const CommandType type = dynamic_cast<const StorageCommitmentCommand&>(GetCommand(i)).GetType(); |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
240 |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
241 if ((i == 0 && type != CommandType_Setup) || |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
242 (i >= 1 && i < n - 1 && type != CommandType_Lookup) || |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
243 (i == n - 1 && type != CommandType_Answer)) |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
244 { |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
245 throw OrthancException(ErrorCode_InternalError); |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
246 } |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
247 |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
248 if (type == CommandType_Lookup) |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
249 { |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
250 const LookupCommand& lookup = dynamic_cast<const LookupCommand&>(GetCommand(i)); |
3661 | 251 if (lookup.GetIndex() != i - 1) |
252 { | |
253 throw OrthancException(ErrorCode_InternalError); | |
254 } | |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
255 } |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
256 } |
3661 | 257 } |
258 | |
259 | |
260 void StorageCommitmentScpJob::Setup(const std::string& jobId) | |
261 { | |
262 CheckInvariants(); | |
3662
d8371b4302ff
OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3661
diff
changeset
|
263 |
d8371b4302ff
OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3661
diff
changeset
|
264 const std::string& remoteAet = remoteModality_.GetApplicationEntityTitle(); |
d8371b4302ff
OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3661
diff
changeset
|
265 lookupHandler_.reset(context_.CreateStorageCommitment(jobId, transactionUid_, sopClassUids_, |
d8371b4302ff
OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3661
diff
changeset
|
266 sopInstanceUids_, remoteAet, calledAet_)); |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
267 } |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
268 |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
269 |
3661 | 270 StorageCommitmentFailureReason StorageCommitmentScpJob::Lookup(size_t index) |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
271 { |
3661 | 272 #ifndef NDEBUG |
273 CheckInvariants(); | |
274 #endif | |
275 | |
276 if (index >= sopClassUids_.size()) | |
277 { | |
278 throw OrthancException(ErrorCode_InternalError); | |
279 } | |
3666
6e5b3ae8825c
handling of StorageCommitmentFailureReason_ClassInstanceConflict in the default SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3665
diff
changeset
|
280 else if (lookupHandler_.get() != NULL) |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
281 { |
3661 | 282 return lookupHandler_->Lookup(sopClassUids_[index], sopInstanceUids_[index]); |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
283 } |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
284 else |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
285 { |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
286 // This is the default implementation of Orthanc (if no storage |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
287 // commitment plugin is installed) |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
288 bool success = false; |
3666
6e5b3ae8825c
handling of StorageCommitmentFailureReason_ClassInstanceConflict in the default SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3665
diff
changeset
|
289 StorageCommitmentFailureReason reason = |
6e5b3ae8825c
handling of StorageCommitmentFailureReason_ClassInstanceConflict in the default SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3665
diff
changeset
|
290 StorageCommitmentFailureReason_NoSuchObjectInstance /* 0x0112 == 274 */; |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
291 |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
292 try |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
293 { |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
294 std::vector<std::string> orthancId; |
3661 | 295 context_.GetIndex().LookupIdentifierExact(orthancId, ResourceType_Instance, DICOM_TAG_SOP_INSTANCE_UID, sopInstanceUids_[index]); |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
296 |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
297 if (orthancId.size() == 1) |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
298 { |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
299 std::string a, b; |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
300 |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
301 // Make sure that the DICOM file can be re-read by DCMTK |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
302 // from the file storage, and that the actual SOP |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
303 // class/instance UIDs do match |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
304 ServerContext::DicomCacheLocker locker(context_, orthancId[0]); |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
305 if (locker.GetDicom().GetTagValue(a, DICOM_TAG_SOP_CLASS_UID) && |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
306 locker.GetDicom().GetTagValue(b, DICOM_TAG_SOP_INSTANCE_UID) && |
3661 | 307 b == sopInstanceUids_[index]) |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
308 { |
3666
6e5b3ae8825c
handling of StorageCommitmentFailureReason_ClassInstanceConflict in the default SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3665
diff
changeset
|
309 if (a == sopClassUids_[index]) |
6e5b3ae8825c
handling of StorageCommitmentFailureReason_ClassInstanceConflict in the default SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3665
diff
changeset
|
310 { |
6e5b3ae8825c
handling of StorageCommitmentFailureReason_ClassInstanceConflict in the default SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3665
diff
changeset
|
311 success = true; |
6e5b3ae8825c
handling of StorageCommitmentFailureReason_ClassInstanceConflict in the default SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3665
diff
changeset
|
312 reason = StorageCommitmentFailureReason_Success; |
6e5b3ae8825c
handling of StorageCommitmentFailureReason_ClassInstanceConflict in the default SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3665
diff
changeset
|
313 } |
6e5b3ae8825c
handling of StorageCommitmentFailureReason_ClassInstanceConflict in the default SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3665
diff
changeset
|
314 else |
6e5b3ae8825c
handling of StorageCommitmentFailureReason_ClassInstanceConflict in the default SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3665
diff
changeset
|
315 { |
6e5b3ae8825c
handling of StorageCommitmentFailureReason_ClassInstanceConflict in the default SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3665
diff
changeset
|
316 // Mismatch in the SOP class UID |
6e5b3ae8825c
handling of StorageCommitmentFailureReason_ClassInstanceConflict in the default SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3665
diff
changeset
|
317 reason = StorageCommitmentFailureReason_ClassInstanceConflict /* 0x0119 */; |
6e5b3ae8825c
handling of StorageCommitmentFailureReason_ClassInstanceConflict in the default SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3665
diff
changeset
|
318 } |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
319 } |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
320 } |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
321 } |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
322 catch (OrthancException&) |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
323 { |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
324 } |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
325 |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
326 LOG(INFO) << " Storage commitment SCP job: " << (success ? "Success" : "Failure") |
3661 | 327 << " while looking for " << sopClassUids_[index] << " / " << sopInstanceUids_[index]; |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
328 |
3666
6e5b3ae8825c
handling of StorageCommitmentFailureReason_ClassInstanceConflict in the default SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3665
diff
changeset
|
329 return reason; |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
330 } |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
331 } |
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
332 |
3636 | 333 |
3657
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
334 void StorageCommitmentScpJob::Answer() |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
335 { |
3661 | 336 CheckInvariants(); |
3657
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
337 LOG(INFO) << " Storage commitment SCP job: Sending answer"; |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
338 |
3661 | 339 std::vector<StorageCommitmentFailureReason> failureReasons; |
340 failureReasons.reserve(sopClassUids_.size()); | |
3657
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
341 |
3661 | 342 for (size_t i = 1; i < GetCommandsCount() - 1; i++) |
343 { | |
344 const LookupCommand& lookup = dynamic_cast<const LookupCommand&>(GetCommand(i)); | |
345 failureReasons.push_back(lookup.GetFailureReason()); | |
346 } | |
347 | |
348 if (failureReasons.size() != sopClassUids_.size()) | |
3636 | 349 { |
3657
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
350 throw OrthancException(ErrorCode_InternalError); |
115f82775c46
handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3642
diff
changeset
|
351 } |
3843
138d0dde41b5
end of replacements of DicomUserConnection by DicomControlUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3763
diff
changeset
|
352 |
138d0dde41b5
end of replacements of DicomUserConnection by DicomControlUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3763
diff
changeset
|
353 DicomAssociationParameters parameters(calledAet_, remoteModality_); |
138d0dde41b5
end of replacements of DicomUserConnection by DicomControlUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3763
diff
changeset
|
354 DicomAssociation::ReportStorageCommitment( |
138d0dde41b5
end of replacements of DicomUserConnection by DicomControlUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3763
diff
changeset
|
355 parameters, transactionUid_, sopClassUids_, sopInstanceUids_, failureReasons); |
3636 | 356 } |
357 | |
358 | |
359 StorageCommitmentScpJob::StorageCommitmentScpJob(ServerContext& context, | |
360 const std::string& transactionUid, | |
361 const std::string& remoteAet, | |
362 const std::string& calledAet) : | |
363 context_(context), | |
364 ready_(false), | |
365 transactionUid_(transactionUid), | |
366 calledAet_(calledAet) | |
367 { | |
368 { | |
369 OrthancConfiguration::ReaderLock lock; | |
370 if (!lock.GetConfiguration().LookupDicomModalityUsingAETitle(remoteModality_, remoteAet)) | |
371 { | |
372 throw OrthancException(ErrorCode_InexistentItem, | |
373 "Unknown remote modality for storage commitment SCP: " + remoteAet); | |
374 } | |
375 } | |
3659
08eb0f93c491
setup step in StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
376 |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
377 AddCommand(new SetupCommand(*this)); |
3636 | 378 } |
379 | |
380 | |
3661 | 381 void StorageCommitmentScpJob::Reserve(size_t size) |
382 { | |
383 if (ready_) | |
384 { | |
385 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
386 } | |
387 else | |
388 { | |
389 sopClassUids_.reserve(size); | |
390 sopInstanceUids_.reserve(size); | |
391 } | |
392 } | |
393 | |
394 | |
3636 | 395 void StorageCommitmentScpJob::AddInstance(const std::string& sopClassUid, |
396 const std::string& sopInstanceUid) | |
397 { | |
398 if (ready_) | |
399 { | |
400 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
401 } | |
402 else | |
403 { | |
3661 | 404 assert(sopClassUids_.size() == sopInstanceUids_.size()); |
405 AddCommand(new LookupCommand(*this, sopClassUids_.size())); | |
406 sopClassUids_.push_back(sopClassUid); | |
407 sopInstanceUids_.push_back(sopInstanceUid); | |
3636 | 408 } |
409 } | |
410 | |
411 | |
412 void StorageCommitmentScpJob::MarkAsReady() | |
413 { | |
3639
0c9a8f6d2349
better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3638
diff
changeset
|
414 AddCommand(new AnswerCommand(*this)); |
3636 | 415 } |
416 | |
417 | |
418 void StorageCommitmentScpJob::GetPublicContent(Json::Value& value) | |
419 { | |
420 SetOfCommandsJob::GetPublicContent(value); | |
421 | |
3638
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
422 value["CalledAet"] = calledAet_; |
3636 | 423 value["RemoteAet"] = remoteModality_.GetApplicationEntityTitle(); |
424 value["TransactionUid"] = transactionUid_; | |
425 } | |
3638
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
426 |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
427 |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
428 StorageCommitmentScpJob::StorageCommitmentScpJob(ServerContext& context, |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
429 const Json::Value& serialized) : |
3660
f159b731c47d
IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3659
diff
changeset
|
430 SetOfCommandsJob(new Unserializer(*this), serialized), |
4206 | 431 context_(context), |
432 transactionUid_(SerializationToolbox::ReadString(serialized, TRANSACTION_UID)), | |
433 calledAet_(SerializationToolbox::ReadString(serialized, CALLED_AET)) | |
434 // "ready_" is initialized by the unserializer | |
3638
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
435 { |
4206 | 436 if (serialized.type() != Json::objectValue || |
437 !serialized.isMember(REMOTE_MODALITY)) | |
438 { | |
439 throw OrthancException(ErrorCode_BadFileFormat); | |
440 } | |
441 | |
3638
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
442 remoteModality_ = RemoteModalityParameters(serialized[REMOTE_MODALITY]); |
3661 | 443 SerializationToolbox::ReadArrayOfStrings(sopClassUids_, serialized, SOP_CLASS_UIDS); |
444 SerializationToolbox::ReadArrayOfStrings(sopInstanceUids_, serialized, SOP_INSTANCE_UIDS); | |
3638
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
445 } |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
446 |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
447 |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
448 bool StorageCommitmentScpJob::Serialize(Json::Value& target) |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
449 { |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
450 if (!SetOfCommandsJob::Serialize(target)) |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
451 { |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
452 return false; |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
453 } |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
454 else |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
455 { |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
456 target[TRANSACTION_UID] = transactionUid_; |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
457 remoteModality_.Serialize(target[REMOTE_MODALITY], true /* force advanced format */); |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
458 target[CALLED_AET] = calledAet_; |
3661 | 459 SerializationToolbox::WriteArrayOfStrings(target, sopClassUids_, SOP_CLASS_UIDS); |
460 SerializationToolbox::WriteArrayOfStrings(target, sopInstanceUids_, SOP_INSTANCE_UIDS); | |
3638
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
461 return true; |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
462 } |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3636
diff
changeset
|
463 } |
3636 | 464 } |