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