annotate OrthancServer/Sources/ServerJobs/StorageCommitmentScpJob.cpp @ 4796:94616af363ec filter-store-instance

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