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