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